if(appData.dualBoard && !twoBoards) { twoBoards = 1; InitDrawingSizes(-2,0); }
if(twoBoards) { partnerUp = 1; flipView = !flipView; } // [HGM] dual
if(partnerUp) DrawPosition(FALSE, partnerBoard);
- if(twoBoards) { partnerUp = 0; flipView = !flipView; } // [HGM] dual
+ if(twoBoards) {
+ DisplayWhiteClock(white_time, to_play == 'W');
+ DisplayBlackClock(black_time, to_play != 'W');
+ partnerUp = 0; flipView = !flipView; } // [HGM] dual
snprintf(partnerStatus, MSG_SIZ,"W: %d:%02d B: %d:%02d (%d-%d) %c", white_time/60000, (white_time%60000)/1000,
(black_time/60000), (black_time%60000)/1000, white_stren, black_stren, to_play);
DisplayMessage(partnerStatus, "");
#endif
-int squareSize, lineGap, hOffset;
+int squareSize, lineGap;
int damage[2][BOARD_RANKS][BOARD_FILES];
(squareSize + lineGap);
}
- if(twoBoards && partnerUp) x += hOffset; // [HGM] dual: draw second board
-
square_color = SquareColor(row, column);
string[1] = NULLCHAR;
MarkMenuItem("View.Flip View", flipView);
}
+ if(nr) { SlavePopUp(); SwitchWindow(); } // [HGM] popup board if not yet popped up, and switch drawing to it.
+
/*
* It would be simpler to clear the window with XClearWindow()
* but this causes a very distracting flicker.
if (!repaint && lastBoardValid[nr] && (nr == 1 || lastFlipView == flipView)) {
if ( lineGap && IsDrawArrowEnabled())
- DrawGrid(0);
+ DrawGrid();
/* If too much changes (begin observing new game, etc.), don't
do flashing */
}
} else {
if (lineGap > 0)
- DrawGrid(twoBoards & partnerUp);
+ DrawGrid();
for (i = 0; i < BOARD_HEIGHT; i++)
for (j = 0; j < BOARD_WIDTH; j++) {
}
DrawArrowHighlight(hi1X, hi1Y, hi2X, hi2Y);
}
+ else DrawArrowHighlight (board[EP_STATUS-3], board[EP_STATUS-4], board[EP_STATUS-1], board[EP_STATUS-2]);
+
/* If piece being dragged around board, must redraw that too */
DrawDragPiece();
FlashDelay(0); // this flushes drawing queue;
+ if(nr) SwitchWindow();
}
/* [AS] Arrow highlighting support */
void
ArrowDamage (int s_col, int s_row, int d_col, int d_row)
{
- int hor, vert, i;
+ int hor, vert, i, n = partnerUp * twoBoards;
hor = 64*s_col + 32; vert = 64*s_row + 32;
for(i=0; i<= 64; i++) {
- damage[0][vert+6>>6][hor+6>>6] = True;
- damage[0][vert-6>>6][hor+6>>6] = True;
- damage[0][vert+6>>6][hor-6>>6] = True;
- damage[0][vert-6>>6][hor-6>>6] = True;
+ damage[n][vert+6>>6][hor+6>>6] = True;
+ damage[n][vert-6>>6][hor+6>>6] = True;
+ damage[n][vert+6>>6][hor-6>>6] = True;
+ damage[n][vert-6>>6][hor-6>>6] = True;
hor += d_col - s_col; vert += d_row - s_row;
}
}
Boolean
IsDrawArrowEnabled ()
{
- return appData.highlightMoveWithArrow && squareSize >= 32;
+ return (appData.highlightMoveWithArrow || twoBoards && partnerUp) && squareSize >= 32;
}
void
void DrawPolygon P((Pnt arrow[], int nr));
void DrawOneSquare P((int x, int y, ChessSquare piece, int square_color, int marker, char *string, int align));
void DrawDot P((int marker, int x, int y, int r));
-void DrawGrid P((int second));
+void DrawGrid P((void));
int SquareColor P((int row, int column));
void ScreenSquare P((int column, int row, Pnt *pt, int *color));
void BoardSquare P((int x, int y, int *column, int *row));
void DrawArrowHighlight P((int fromX, int fromY, int toX,int toY));
Boolean IsDrawArrowEnabled P((void));
-extern int hOffset; // [HGM] dual
extern int damage[2][BOARD_RANKS][BOARD_FILES];
SetWindowTitle(text, title, icon);
}
-void
-DisplayWhiteClock (long timeRemaining, int highlight)
-{
- if(appData.noGUI) return;
- DisplayTimerLabel(11, _("White"), timeRemaining, highlight);
- if(highlight) SetClockIcon(0);
-}
-
-void
-DisplayBlackClock (long timeRemaining, int highlight)
-{
- if(appData.noGUI) return;
- DisplayTimerLabel(12, _("Black"), timeRemaining, highlight);
- if(highlight) SetClockIcon(1);
-}
-
#define PAUSE_BUTTON "P"
#define PIECE_MENU_SIZE 18
static String pieceMenuStrings[2][PIECE_MENU_SIZE+1] = {
case -3: menuNr = RightClick(Release, x, y, &pmFromX, &pmFromY), but3 = 0; break;
case 10:
DrawPosition(True, NULL);
- if(twoBoards) { // [HGM] dual: draw other board in other orientation
- flipView = !flipView; partnerUp = !partnerUp;
- DrawPosition(True, NULL);
- flipView = !flipView; partnerUp = !partnerUp;
- }
default:
return NULL;
}
return mainOptions;
}
+static Option *
+SlaveExp (int n, int x, int y)
+{
+ if(n == 10) { // expose event
+ flipView = !flipView; partnerUp = !partnerUp;
+ DrawPosition(True, NULL); // [HGM] dual: draw other board in other orientation
+ flipView = !flipView; partnerUp = !partnerUp;
+ }
+ return NULL;
+}
+
+Option dualOptions[] = { // auxiliary board window
+{ 0, L2L|T2T, 198, NULL, NULL, NULL, NULL, Label, "White" }, // white clock
+{ 0, R2R|T2T|SAME_ROW, 198, NULL, NULL, NULL, NULL, Label, "Black" }, // black clock
+{ 0, LR|T2T|BORDER, 401, NULL, NULL, NULL, NULL, Label, "message" }, // message field
+{ 401, LR|TT, 401, NULL, (char*) &SlaveExp, NULL, NULL, Graph, "shadow board" }, // board
+{ 0, NO_OK, 0, NULL, NULL, "", NULL, EndMark , "" }
+};
+
+void
+SlavePopUp ()
+{
+ // copy params from main board
+ dualOptions[0].choice = mainOptions[11].choice;
+ dualOptions[1].choice = mainOptions[12].choice;
+ dualOptions[3].value = mainOptions[22].value;
+ dualOptions[3].max = dualOptions[2].max = mainOptions[22].max; // board size
+ dualOptions[0].max = dualOptions[1].max = mainOptions[11].max; // clock width
+ GenericPopUp(dualOptions, "XBoard", DummyDlg, BoardWindow, NONMODAL, 1);
+}
+
+void
+DisplayWhiteClock (long timeRemaining, int highlight)
+{
+ if(appData.noGUI) return;
+ if(twoBoards && partnerUp) {
+ DisplayTimerLabel(&dualOptions[0], _("White"), timeRemaining, highlight);
+ return;
+ }
+ DisplayTimerLabel(&mainOptions[11], _("White"), timeRemaining, highlight);
+ if(highlight) SetClockIcon(0);
+}
+
+void
+DisplayBlackClock (long timeRemaining, int highlight)
+{
+ if(appData.noGUI) return;
+ if(twoBoards && partnerUp) {
+ DisplayTimerLabel(&dualOptions[1], _("Black"), timeRemaining, highlight);
+ return;
+ }
+ DisplayTimerLabel(&mainOptions[12], _("Black"), timeRemaining, highlight);
+ if(highlight) SetClockIcon(1);
+}
+
+
+//---------------------------------------------
+
void
DisplayMessage (char *message, char *extMessage)
{
int ShiftKeys P((void));
void SetClockIcon P((int color));
void DelayedLoad P((void));
-void DisplayTimerLabel P((int optNr, char *color, long timer, int highlight));
+void DisplayTimerLabel P((Option *opt, char *color, long timer, int highlight));
Option *BoardPopUp P((int squareSize, int lineGap, void *clockFontThingy));
int SetCurrentComboSelection P((Option *opt));
COLORREF oldFg, oldBg;\r
HFONT oldFont;\r
\r
+ if (twoBoards && partnerUp) return;\r
if (appData.clockMode) {\r
if (tinyLayout)\r
snprintf(buf, sizeof(buf)/sizeof(buf[0]), "%c %s %s", color[0], TimeString(timeRemaining), flagFell);\r
ChildProc *cp;\r
int err;\r
SOCKET s;\r
+\r
struct sockaddr_in sa, mysa;\r
struct hostent FAR *hp;\r
unsigned short uport;\r
Pixmap iconPixmap, wIconPixmap, bIconPixmap, xMarkPixmap;
Widget shellWidget, formWidget, boardWidget, titleWidget, dropMenu, menuBarWidget;
Option *optList; // contains all widgets of main window
-XSegment secondSegments[BOARD_RANKS + BOARD_FILES + 2];
XSegment gridSegments[BOARD_RANKS + BOARD_FILES + 2];
#if ENABLE_NLS
XFontSet fontSet, clockFontSet;
return xBoardWindow != 0;
}
+void SwitchWindow()
+{
+ extern Option dualOptions[];
+ static Window dual;
+ Window tmp = xBoardWindow;
+ if(!dual) dual = XtWindow(dualOptions[3].handle); // must be first call
+ xBoardWindow = dual; // swap them
+ dual = tmp;
+}
+
void
PopUpStartupDialog ()
{ // start menu not implemented in XBoard
int i;
static Dimension oldWidth, oldHeight;
static VariantClass oldVariant;
- static int oldDual = -1, oldMono = -1;
+ static int oldMono = -1;
if(!formWidget) return;
boardWidth = lineGap + BOARD_WIDTH * (squareSize + lineGap);
boardHeight = lineGap + BOARD_HEIGHT * (squareSize + lineGap);
- if(boardWidth != oldWidth || boardHeight != oldHeight || oldDual != twoBoards) { // do resizing stuff only if size actually changed
+ if(boardWidth != oldWidth || boardHeight != oldHeight) { // do resizing stuff only if size actually changed
- oldWidth = boardWidth; oldHeight = boardHeight; oldDual = twoBoards;
+ oldWidth = boardWidth; oldHeight = boardHeight;
CreateGrid();
- hOffset = boardWidth + 10;
- for(i=0; i<BOARD_WIDTH+BOARD_HEIGHT+2; i++) { // [HGM] dual: grid for second board
- secondSegments[i] = gridSegments[i];
- secondSegments[i].x1 += hOffset;
- secondSegments[i].x2 += hOffset;
- }
/*
* Inhibit shell resizing.
*/
- shellArgs[0].value = w = (XtArgVal) boardWidth + marginW + twoBoards*hOffset; // [HGM] dual
+ shellArgs[0].value = w = (XtArgVal) boardWidth + marginW ;
shellArgs[1].value = h = (XtArgVal) boardHeight + marginH;
shellArgs[4].value = shellArgs[2].value = w;
shellArgs[5].value = shellArgs[3].value = h;
}
void
-DrawGrid (int second)
+DrawGrid ()
{
XDrawSegments(xDisplay, xBoardWindow, lineGC,
- second ? secondSegments : // [HGM] dual
gridSegments, BOARD_HEIGHT + BOARD_WIDTH + 2);
}
}
void
-DisplayTimerLabel (int optNr, char *color, long timer, int highlight)
+DisplayTimerLabel (Option *opt, char *color, long timer, int highlight)
{
char buf[MSG_SIZ];
Arg args[16];
- Widget w = optList[optNr].handle;
+ Widget w = (Widget) opt->handle;
/* check for low time warning */
Pixel foregroundOrWarningColor = timerForegroundPixel;