static Option *Exp P((int n, int x, int y));
void MenuCallback P((int n));
void SizeKludge P((int n));
+static Option *LogoW P((int n, int x, int y));
+static Option *LogoB P((int n, int x, int y));
static int pmFromX = -1, pmFromY = -1;
+void *userLogo;
+
+void
+DisplayLogos (void *w1, void *w2)
+{
+ void *whiteLogo = first.programLogo, *blackLogo = second.programLogo;
+ if(appData.autoLogo) {
+
+ switch(gameMode) { // pick logos based on game mode
+ case IcsObserving:
+ whiteLogo = second.programLogo; // ICS logo
+ blackLogo = second.programLogo;
+ default:
+ break;
+ case IcsPlayingWhite:
+ if(!appData.zippyPlay) whiteLogo = userLogo;
+ blackLogo = second.programLogo; // ICS logo
+ break;
+ case IcsPlayingBlack:
+ whiteLogo = second.programLogo; // ICS logo
+ blackLogo = appData.zippyPlay ? first.programLogo : userLogo;
+ break;
+ case TwoMachinesPlay:
+ if(first.twoMachinesColor[0] == 'b') {
+ whiteLogo = second.programLogo;
+ blackLogo = first.programLogo;
+ }
+ break;
+ case MachinePlaysWhite:
+ blackLogo = userLogo;
+ break;
+ case MachinePlaysBlack:
+ whiteLogo = userLogo;
+ blackLogo = first.programLogo;
+ }
+ }
+ DrawLogo(w1, whiteLogo);
+ DrawLogo(w2, blackLogo);
+}
static void
PMSelect (int n)
{ 0, COMBO_CALLBACK, 0, NULL, (void*)&MenuCallback, NULL, NULL, DropDown, N_("Help") },
{ 0, 0, 0, NULL, (void*)&SizeKludge, "", NULL, BoxEnd, "" },
{ 0, LR|T2T|BORDER|SAME_ROW, 0, NULL, NULL, "", NULL, Label, "1" }, // optional title in window
-{ 0, L2L|T2T, 200, NULL, (void*) &CCB, NULL, NULL, Label, "White" }, // white clock
-{ 0, R2R|T2T|SAME_ROW, 200, NULL, (void*) &CCB, NULL, NULL, Label, "Black" }, // black clock
+{ 50, LL|TT, 100, NULL, (void*) &LogoW, NULL, NULL, -1, "LogoW" }, // white logo
+{ 0, L2L|T2T, 200, NULL, (void*) &CCB, NULL, NULL, Label, "White" }, // white clock
+{ 0, R2R|T2T|SAME_ROW, 200, NULL, (void*) &CCB, NULL, NULL, Label, "Black" }, // black clock
+{ 50, RR|TT|SAME_ROW, 100, NULL, (void*) &LogoB, NULL, NULL, -1, "LogoB" }, // black logo
{ 0, LR|T2T|BORDER, 401, NULL, NULL, "", NULL, -1, "2" }, // backup for title in window (if no room for other)
{ 0, LR|T2T|BORDER, 270, NULL, NULL, "", NULL, Label, "message" }, // message field
{ 0, RR|TT|SAME_ROW, 125, NULL, NULL, "", NULL, BoxBegin, "" }, // (optional) button bar
{ 0, SAME_ROW, 0, NULL, (void*) &ForwardEvent, NULL, NULL, Button, N_(">") },
{ 0, SAME_ROW, 0, NULL, (void*) &ToEndEvent, NULL, NULL, Button, N_(">>") },
{ 0, 0, 0, NULL, NULL, "", NULL, BoxEnd, "" },
-{ 401, LR|TT, 401, NULL, (char*) &Exp, NULL, NULL, Graph, "shadow board" }, // board
+{ 401, LR|TB, 401, NULL, (char*) &Exp, NULL, NULL, Graph, "shadow board" }, // board
{ 2, COMBO_CALLBACK, 0, NULL, (void*) &PMSelect, NULL, pieceMenuStrings[0], PopUp, "menuW" },
{ 2, COMBO_CALLBACK, 0, NULL, (void*) &PMSelect, NULL, pieceMenuStrings[1], PopUp, "menuB" },
{ -1, COMBO_CALLBACK, 0, NULL, (void*) &PMSelect, NULL, dropMenuStrings, PopUp, "menuD" },
{ 0, NO_OK, 0, NULL, NULL, "", NULL, EndMark , "" }
};
+Option *
+LogoW (int n, int x, int y)
+{
+ if(n == 10) DisplayLogos(mainOptions[W_WHITE-1].handle, NULL);
+ return NULL;
+}
+
+Option *
+LogoB (int n, int x, int y)
+{
+ if(n == 10) DisplayLogos(NULL, mainOptions[W_BLACK+1].handle);
+ return NULL;
+}
+
void
SizeKludge (int n)
{ // callback called by GenericPopUp immediately after sizing the menu bar
Option *
BoardPopUp (int squareSize, int lineGap, void *clockFontThingy)
{
- int i, size = BOARD_WIDTH*(squareSize + lineGap) + lineGap;
+ int i, size = BOARD_WIDTH*(squareSize + lineGap) + lineGap, logo = appData.logoSize;
mainOptions[W_WHITE].choice = (char**) clockFontThingy;
mainOptions[W_BLACK].choice = (char**) clockFontThingy;
mainOptions[W_BOARD].value = BOARD_HEIGHT*(squareSize + lineGap) + lineGap;
mainOptions[W_MESSG].max = appData.showButtonBar ? size-130 : size-2; // message
mainOptions[W_MENU].max = size-40; // menu bar
mainOptions[W_TITLE].type = appData.titleInWindow ? Label : -1 ;
+ if(logo && logo <= size/4) { // Activate logos
+ mainOptions[W_WHITE-1].type = mainOptions[W_BLACK+1].type = Graph;
+ mainOptions[W_WHITE-1].max = mainOptions[W_BLACK+1].max = logo;
+ mainOptions[W_WHITE-1].value= mainOptions[W_BLACK+1].value= logo/2;
+ mainOptions[W_WHITE].min |= SAME_ROW;
+ mainOptions[W_WHITE].max = mainOptions[W_BLACK].max -= logo + 4;
+ mainOptions[W_WHITE].name = mainOptions[W_BLACK].name = "Double\nHeight";
+ }
if(!appData.showButtonBar) for(i=W_BUTTON; i<W_BOARD; i++) mainOptions[i].type = -1;
for(i=0; i<8; i++) mainOptions[i+1].choice = (char**) menuBar[i].mi;
GenericPopUp(mainOptions, "XBoard", BoardWindow, BoardWindow, NONMODAL, 1);
CreateGrid();
CreateAnyPieces();
+ if(appData.logoSize)
+ { // locate and read user logo
+ char buf[MSG_SIZ];
+ snprintf(buf, MSG_SIZ, "%s/%s.xpm", appData.logoDir, UserName());
+ XpmReadFileToPixmap(xDisplay, xBoardWindow, buf, (Pixmap *) &userLogo, NULL, NULL);
+ }
+
if (appData.animate || appData.animateDragging)
CreateAnimVars();
gameInfo.boardWidth = 0; // [HGM] pieces: kludge to ensure InitPosition() calls InitDrawingSizes()
InitPosition(TRUE);
+ UpdateLogos(TRUE);
// XtSetKeyboardFocus(shellWidget, formWidget);
XSetInputFocus(xDisplay, XtWindow(formWidget), RevertToPointerRoot, CurrentTime);
return 1;
}
+void
+DrawLogo (void *handle, void *logo)
+{
+ if(!logo || !handle) return;
+ XCopyArea(xDisplay, (Pixmap) logo, XtWindow((Widget) handle), wlPieceGC,
+ 0, 0, appData.logoSize, appData.logoSize/2, 0, 0);
+}
+
static void
BlankSquare (int x, int y, int color, ChessSquare piece, Drawable dest, int fac)
{ // [HGM] extra param 'fac' for forcing destination to (0,0) for copying to animation buffer
/* Maybe all the enables should be handled here, not just this one */
EnableNamedMenuItem("Mode.Training", gameMode == Training || gameMode == PlayFromGameFile);
+
+ DisplayLogos(optList[W_WHITE-1].handle, optList[W_BLACK+1].handle);
}
foregroundOrWarningColor = lowTimeWarningColor;
if (appData.clockMode) {
- snprintf(buf, MSG_SIZ, "%s: %s", color, TimeString(timer));
+ snprintf(buf, MSG_SIZ, "%s:%s%s", color, appData.logoSize && !partnerUp ? "\n" : " ", TimeString(timer));
XtSetArg(args[0], XtNlabel, buf);
} else {
snprintf(buf, MSG_SIZ, "%s ", color);
if(appData.monoMode) arrow[nr] = arrow[0], XDrawLines(xDisplay, xBoardWindow, darkSquareGC, pts, nr+1, CoordModeOrigin);
}
+static void
+LoadLogo (ChessProgramState *cps, int n, Boolean ics)
+{
+ char buf[MSG_SIZ], *logoName = buf;
+ if(appData.logo[n][0]) {
+ logoName = appData.logo[n];
+ } else if(appData.autoLogo) {
+ if(ics) { // [HGM] logo: in ICS mode second can be used for ICS
+ sprintf(buf, "%s/%s.xpm", appData.logoDir, appData.icsHost);
+ } else if(appData.directory[n] && appData.directory[n][0]) {
+ sprintf(buf, "%s/%s.xpm", appData.logoDir, cps->tidy);
+ }
+ }
+ if(logoName[0])
+ XpmReadFileToPixmap(xDisplay, xBoardWindow, logoName, (Pixmap *) &(cps->programLogo), NULL, NULL);
+}
+
void
UpdateLogos (int displ)
{
- return; // no logos in XBoard yet
+ if(optList[W_WHITE-1].handle == NULL) return;
+ LoadLogo(&first, 0, 0);
+ LoadLogo(&second, 1, appData.icsActive);
+ if(displ) DisplayLogos(optList[W_WHITE-1].handle, optList[W_BLACK+1].handle);
+ return;
}