X-Git-Url: http://winboard.nl/cgi-bin?a=blobdiff_plain;f=winboard%2Fwinboard.c;h=ad14f7e94f6bbcc559b6bc00ce70f21e10cd2fb3;hb=d413d3ed517beac460ae9ed147e6200a57125bb5;hp=f08ddb620260e98b486fc0d10736cfa311d91069;hpb=668bf3e7edd72719c0ad749cdad314fe517ae377;p=xboard.git diff --git a/winboard/winboard.c b/winboard/winboard.c index f08ddb6..ad14f7e 100644 --- a/winboard/winboard.c +++ b/winboard/winboard.c @@ -152,7 +152,8 @@ char installDir[MSG_SIZ]; BoardSize boardSize; BOOLEAN chessProgram; -static int boardX, boardY, consoleX, consoleY, consoleW, consoleH; +static int boardX, boardY; +int minX, minY; // [HGM] placement: volatile limits on upper-left corner static int squareSize, lineGap, minorSize; static int winWidth, winHeight; static RECT messageRect, whiteRect, blackRect, leftLogoRect, rightLogoRect; // [HGM] logo @@ -201,6 +202,7 @@ static HICON iconWhite, iconBlack, iconCurrent; static int doingSizing = FALSE; static int lastSizing = 0; static int prevStderrPort; +static HBITMAP userLogo; /* [AS] Support for background textures */ #define BACK_TEXTURE_MODE_DISABLED 0 @@ -426,6 +428,8 @@ HWND engineOutputDialog = NULL; BOOLEAN engineOutputDialogUp = FALSE; WindowPlacement wpEngineOutput; +WindowPlacement wpGameList; +WindowPlacement wpConsole; VOID MoveHistoryPopUp(); VOID MoveHistoryPopDown(); @@ -543,6 +547,21 @@ WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, * \*---------------------------------------------------------------------------*/ +void +SetUserLogo() +{ // update user logo if necessary + static char oldUserName[MSG_SIZ], *curName; + + if(appData.autoLogo) { + curName = UserName(); + if(strcmp(curName, oldUserName)) { + sprintf(oldUserName, "logos\\%s.bmp", curName); + userLogo = LoadImage( 0, oldUserName, IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE ); + strcpy(oldUserName, curName); + } + } +} + BOOL InitApplication(HINSTANCE hInstance) { @@ -585,16 +604,14 @@ InitApplication(HINSTANCE hInstance) int screenHeight, screenWidth; void -EnsureOnScreen(int *x, int *y) +EnsureOnScreen(int *x, int *y, int minX, int minY) { // int gap = GetSystemMetrics(SM_CYFRAME) + GetSystemMetrics(SM_CYCAPTION); /* Be sure window at (x,y) is not off screen (or even mostly off screen) */ if (*x > screenWidth - 32) *x = 0; if (*y > screenHeight - 32) *y = 0; - if (*x < 0) *x = 0; - if (*y < 0) *y = 0; -// if (*x < 10) *x = 10; -// if (*y < gap) *y = gap; + if (*x < minX) *x = minX; + if (*y < minY) *y = minY; } BOOL @@ -613,6 +630,7 @@ InitInstance(HINSTANCE hInstance, int nCmdShow, LPSTR lpCmdLine) GetCurrentDirectory(MSG_SIZ, installDir); } gameInfo.boardWidth = gameInfo.boardHeight = 8; // [HGM] won't have open window otherwise + screenWidth = screenHeight = 1000; // [HGM] placement: kludge to allow calling EnsureOnScreen from InitAppData InitAppData(lpCmdLine); /* Get run-time parameters */ if (appData.debugMode) { debugFP = fopen(appData.nameOfDebugFile, "w"); @@ -658,13 +676,19 @@ InitInstance(HINSTANCE hInstance, int nCmdShow, LPSTR lpCmdLine) fprintf( debugFP, "Unable to load logo bitmap '%s'\n", appData.secondLogo ); } } else if(appData.autoLogo) { + char buf[MSG_SIZ]; + if(appData.icsActive) { // [HGM] logo: in ICS mode second can be used for ICS + sprintf(buf, "logos\\%s.bmp", appData.icsHost); + second.programLogo = LoadImage( 0, buf, IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE ); + } else if(appData.secondDirectory && appData.secondDirectory[0]) { - char buf[MSG_SIZ]; sprintf(buf, "%s\\logo.bmp", appData.secondDirectory); second.programLogo = LoadImage( 0, buf, IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE ); } } + SetUserLogo(); + iconWhite = LoadIcon(hInstance, "icon_white"); iconBlack = LoadIcon(hInstance, "icon_black"); iconCurrent = iconWhite; @@ -674,7 +698,7 @@ InitInstance(HINSTANCE hInstance, int nCmdShow, LPSTR lpCmdLine) for (ibs = (int) NUM_SIZES - 1; ibs >= 0; ibs--) { /* Compute window size for each board size, and use the largest size that fits on this screen as the default. */ - InitDrawingSizes((BoardSize)ibs, 0); + InitDrawingSizes((BoardSize)(ibs+1000), 0); if (boardSize == (BoardSize)-1 && winHeight <= screenHeight - GetSystemMetrics(SM_CYFRAME) - GetSystemMetrics(SM_CYCAPTION) - 10 @@ -726,7 +750,7 @@ InitInstance(HINSTANCE hInstance, int nCmdShow, LPSTR lpCmdLine) InitBackEnd2(); /* Make the window visible; update its client area; and return "success" */ - EnsureOnScreen(&boardX, &boardY); + EnsureOnScreen(&boardX, &boardY, minX, minY); wp.length = sizeof(WINDOWPLACEMENT); wp.flags = 0; wp.showCmd = nCmdShow; @@ -740,12 +764,6 @@ InitInstance(HINSTANCE hInstance, int nCmdShow, LPSTR lpCmdLine) SetWindowPos(hwndMain, alwaysOnTop ? HWND_TOPMOST : HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOMOVE|SWP_NOSIZE); -#if 0 - /* [AS] Disable the FRC stuff if not playing the proper variant */ - if( gameInfo.variant != VariantFischeRandom ) { - EnableMenuItem( GetMenu(hwndMain), IDM_NewGameFRC, MF_GRAYED ); - } -#endif if (hwndConsole) { #if AOT_CONSOLE SetWindowPos(hwndConsole, alwaysOnTop ? HWND_TOPMOST : HWND_NOTOPMOST, @@ -763,7 +781,8 @@ InitInstance(HINSTANCE hInstance, int nCmdShow, LPSTR lpCmdLine) typedef enum { ArgString, ArgInt, ArgFloat, ArgBoolean, ArgTrue, ArgFalse, ArgNone, ArgColor, ArgAttribs, ArgFilename, ArgBoardSize, ArgFont, ArgCommSettings, - ArgSettingsFilename + ArgSettingsFilename, + ArgX, ArgY, ArgZ // [HGM] placement: for window-placement options stored relative to main window } ArgType; typedef struct { @@ -1099,28 +1118,6 @@ ArgDescriptor argDescriptors[] = { { "xreuse2", ArgFalse, (LPVOID) &appData.reuseSecond, FALSE }, { "-reuse2", ArgFalse, (LPVOID) &appData.reuseSecond, FALSE }, { "comPortSettings", ArgCommSettings, (LPVOID) &dcb, TRUE }, - { "x", ArgInt, (LPVOID) &boardX, TRUE }, - { "y", ArgInt, (LPVOID) &boardY, TRUE }, - { "icsX", ArgInt, (LPVOID) &consoleX, TRUE }, - { "icsY", ArgInt, (LPVOID) &consoleY, TRUE }, - { "icsW", ArgInt, (LPVOID) &consoleW, TRUE }, - { "icsH", ArgInt, (LPVOID) &consoleH, TRUE }, - { "analysisX", ArgInt, (LPVOID) &analysisX, TRUE }, - { "analysisY", ArgInt, (LPVOID) &analysisY, TRUE }, - { "analysisW", ArgInt, (LPVOID) &analysisW, TRUE }, - { "analysisH", ArgInt, (LPVOID) &analysisH, TRUE }, - { "commentX", ArgInt, (LPVOID) &commentX, TRUE }, - { "commentY", ArgInt, (LPVOID) &commentY, TRUE }, - { "commentW", ArgInt, (LPVOID) &commentW, TRUE }, - { "commentH", ArgInt, (LPVOID) &commentH, TRUE }, - { "tagsX", ArgInt, (LPVOID) &editTagsX, TRUE }, - { "tagsY", ArgInt, (LPVOID) &editTagsY, TRUE }, - { "tagsW", ArgInt, (LPVOID) &editTagsW, TRUE }, - { "tagsH", ArgInt, (LPVOID) &editTagsH, TRUE }, - { "gameListX", ArgInt, (LPVOID) &gameListX, TRUE }, - { "gameListY", ArgInt, (LPVOID) &gameListY, TRUE }, - { "gameListW", ArgInt, (LPVOID) &gameListW, TRUE }, - { "gameListH", ArgInt, (LPVOID) &gameListH, TRUE }, { "settingsFile", ArgSettingsFilename, (LPVOID) &settingsFileName, FALSE }, { "ini", ArgSettingsFilename, (LPVOID) &settingsFileName, FALSE }, { "saveSettingsOnExit", ArgBoolean, (LPVOID) &saveSettingsOnExit, TRUE }, @@ -1195,25 +1192,6 @@ ArgDescriptor argDescriptors[] = { { "defaultCacheSizeEGTB", ArgInt, (LPVOID) &appData.defaultCacheSizeEGTB, TRUE }, { "defaultPathEGTB", ArgFilename, (LPVOID) &appData.defaultPathEGTB, TRUE }, - /* [AS] Layout stuff */ - { "moveHistoryUp", ArgBoolean, (LPVOID) &wpMoveHistory.visible, TRUE }, - { "moveHistoryX", ArgInt, (LPVOID) &wpMoveHistory.x, TRUE }, - { "moveHistoryY", ArgInt, (LPVOID) &wpMoveHistory.y, TRUE }, - { "moveHistoryW", ArgInt, (LPVOID) &wpMoveHistory.width, TRUE }, - { "moveHistoryH", ArgInt, (LPVOID) &wpMoveHistory.height, TRUE }, - - { "evalGraphUp", ArgBoolean, (LPVOID) &wpEvalGraph.visible, TRUE }, - { "evalGraphX", ArgInt, (LPVOID) &wpEvalGraph.x, TRUE }, - { "evalGraphY", ArgInt, (LPVOID) &wpEvalGraph.y, TRUE }, - { "evalGraphW", ArgInt, (LPVOID) &wpEvalGraph.width, TRUE }, - { "evalGraphH", ArgInt, (LPVOID) &wpEvalGraph.height, TRUE }, - - { "engineOutputUp", ArgBoolean, (LPVOID) &wpEngineOutput.visible, TRUE }, - { "engineOutputX", ArgInt, (LPVOID) &wpEngineOutput.x, TRUE }, - { "engineOutputY", ArgInt, (LPVOID) &wpEngineOutput.y, TRUE }, - { "engineOutputW", ArgInt, (LPVOID) &wpEngineOutput.width, TRUE }, - { "engineOutputH", ArgInt, (LPVOID) &wpEngineOutput.height, TRUE }, - /* [HGM] board-size, adjudication and misc. options */ { "boardWidth", ArgInt, (LPVOID) &appData.NrFiles, TRUE }, { "boardHeight", ArgInt, (LPVOID) &appData.NrRanks, TRUE }, @@ -1302,6 +1280,53 @@ ArgDescriptor argDescriptors[] = { { "firstNPS", ArgInt, (LPVOID) &appData.firstNPS, FALSE }, { "secondNPS", ArgInt, (LPVOID) &appData.secondNPS, FALSE }, { "noGUI", ArgTrue, (LPVOID) &appData.noGUI, FALSE }, + + // [HGM] placement: put all window layouts last in ini file, but man X,Y before all others + { "minX", ArgZ, (LPVOID) &minX, FALSE }, // [HGM] placement: to make suer auxialary windows can be placed + { "minY", ArgZ, (LPVOID) &minY, FALSE }, + { "winWidth", ArgInt, (LPVOID) &winWidth, TRUE }, // [HGM] placement: dummies to remember right & bottom + { "winHeight", ArgInt, (LPVOID) &winHeight, TRUE }, // for attaching auxiliary windows to them + { "x", ArgInt, (LPVOID) &boardX, TRUE }, + { "y", ArgInt, (LPVOID) &boardY, TRUE }, + { "icsX", ArgX, (LPVOID) &wpConsole.x, TRUE }, + { "icsY", ArgY, (LPVOID) &wpConsole.y, TRUE }, + { "icsW", ArgInt, (LPVOID) &wpConsole.width, TRUE }, + { "icsH", ArgInt, (LPVOID) &wpConsole.height, TRUE }, + { "analysisX", ArgX, (LPVOID) &analysisX, FALSE }, // [HGM] placement: analysis window no longer exists + { "analysisY", ArgY, (LPVOID) &analysisY, FALSE }, // provided for compatibility with old ini files + { "analysisW", ArgInt, (LPVOID) &analysisW, FALSE }, + { "analysisH", ArgInt, (LPVOID) &analysisH, FALSE }, + { "commentX", ArgX, (LPVOID) &commentX, TRUE }, + { "commentY", ArgY, (LPVOID) &commentY, TRUE }, + { "commentW", ArgInt, (LPVOID) &commentW, TRUE }, + { "commentH", ArgInt, (LPVOID) &commentH, TRUE }, + { "tagsX", ArgX, (LPVOID) &editTagsX, TRUE }, + { "tagsY", ArgY, (LPVOID) &editTagsY, TRUE }, + { "tagsW", ArgInt, (LPVOID) &editTagsW, TRUE }, + { "tagsH", ArgInt, (LPVOID) &editTagsH, TRUE }, + { "gameListX", ArgX, (LPVOID) &wpGameList.x, TRUE }, + { "gameListY", ArgY, (LPVOID) &wpGameList.y, TRUE }, + { "gameListW", ArgInt, (LPVOID) &wpGameList.width, TRUE }, + { "gameListH", ArgInt, (LPVOID) &wpGameList.height, TRUE }, + /* [AS] Layout stuff */ + { "moveHistoryUp", ArgBoolean, (LPVOID) &wpMoveHistory.visible, TRUE }, + { "moveHistoryX", ArgX, (LPVOID) &wpMoveHistory.x, TRUE }, + { "moveHistoryY", ArgY, (LPVOID) &wpMoveHistory.y, TRUE }, + { "moveHistoryW", ArgInt, (LPVOID) &wpMoveHistory.width, TRUE }, + { "moveHistoryH", ArgInt, (LPVOID) &wpMoveHistory.height, TRUE }, + + { "evalGraphUp", ArgBoolean, (LPVOID) &wpEvalGraph.visible, TRUE }, + { "evalGraphX", ArgX, (LPVOID) &wpEvalGraph.x, TRUE }, + { "evalGraphY", ArgY, (LPVOID) &wpEvalGraph.y, TRUE }, + { "evalGraphW", ArgInt, (LPVOID) &wpEvalGraph.width, TRUE }, + { "evalGraphH", ArgInt, (LPVOID) &wpEvalGraph.height, TRUE }, + + { "engineOutputUp", ArgBoolean, (LPVOID) &wpEngineOutput.visible, TRUE }, + { "engineOutputX", ArgX, (LPVOID) &wpEngineOutput.x, TRUE }, + { "engineOutputY", ArgY, (LPVOID) &wpEngineOutput.y, TRUE }, + { "engineOutputW", ArgInt, (LPVOID) &wpEngineOutput.width, TRUE }, + { "engineOutputH", ArgInt, (LPVOID) &wpEngineOutput.height, TRUE }, + { NULL, ArgNone, NULL, FALSE } }; @@ -1632,6 +1657,19 @@ ParseArgs(GetFunc get, void *cl) *(int *) ad->argLoc = atoi(argValue); break; + case ArgX: + *(int *) ad->argLoc = atoi(argValue) + boardX; // [HGM] placement: translate stored relative to absolute + break; + + case ArgY: + *(int *) ad->argLoc = atoi(argValue) + boardY; // (this is really kludgey, it should be done where used...) + break; + + case ArgZ: + *(int *) ad->argLoc = atoi(argValue); + EnsureOnScreen(&boardX, &boardY, minX, minY); + break; + case ArgFloat: *(float *) ad->argLoc = (float) atof(argValue); break; @@ -1895,10 +1933,6 @@ InitAppData(LPSTR lpCmdLine) saveSettingsOnExit = TRUE; boardX = CW_USEDEFAULT; boardY = CW_USEDEFAULT; - consoleX = CW_USEDEFAULT; - consoleY = CW_USEDEFAULT; - consoleW = CW_USEDEFAULT; - consoleH = CW_USEDEFAULT; analysisX = CW_USEDEFAULT; analysisY = CW_USEDEFAULT; analysisW = CW_USEDEFAULT; @@ -1911,10 +1945,6 @@ InitAppData(LPSTR lpCmdLine) editTagsY = CW_USEDEFAULT; editTagsW = CW_USEDEFAULT; editTagsH = CW_USEDEFAULT; - gameListX = CW_USEDEFAULT; - gameListY = CW_USEDEFAULT; - gameListW = CW_USEDEFAULT; - gameListH = CW_USEDEFAULT; icsTextMenuString = ICS_TEXT_MENU_DEFAULT; icsNames = ICS_NAMES; firstChessProgramNames = FCP_NAMES; @@ -1972,9 +2002,11 @@ InitAppData(LPSTR lpCmdLine) appData.firstOptions = ""; appData.secondOptions = ""; + InitWindowPlacement( &wpGameList ); InitWindowPlacement( &wpMoveHistory ); InitWindowPlacement( &wpEvalGraph ); InitWindowPlacement( &wpEngineOutput ); + InitWindowPlacement( &wpConsole ); /* [HGM] User-selectable board size, adjudication control, miscellaneous */ appData.NrFiles = -1; @@ -2187,10 +2219,10 @@ SaveSettings(char* name) if (hwndConsole) { GetWindowPlacement(hwndConsole, &wp); - consoleX = wp.rcNormalPosition.left; - consoleY = wp.rcNormalPosition.top; - consoleW = wp.rcNormalPosition.right - wp.rcNormalPosition.left; - consoleH = wp.rcNormalPosition.bottom - wp.rcNormalPosition.top; + wpConsole.x = wp.rcNormalPosition.left; + wpConsole.y = wp.rcNormalPosition.top; + wpConsole.width = wp.rcNormalPosition.right - wp.rcNormalPosition.left; + wpConsole.height = wp.rcNormalPosition.bottom - wp.rcNormalPosition.top; } if (analysisDialog) { @@ -2219,10 +2251,10 @@ SaveSettings(char* name) if (gameListDialog) { GetWindowPlacement(gameListDialog, &wp); - gameListX = wp.rcNormalPosition.left; - gameListY = wp.rcNormalPosition.top; - gameListW = wp.rcNormalPosition.right - wp.rcNormalPosition.left; - gameListH = wp.rcNormalPosition.bottom - wp.rcNormalPosition.top; + wpGameList.x = wp.rcNormalPosition.left; + wpGameList.y = wp.rcNormalPosition.top; + wpGameList.width = wp.rcNormalPosition.right - wp.rcNormalPosition.left; + wpGameList.height = wp.rcNormalPosition.bottom - wp.rcNormalPosition.top; } /* [AS] Move history */ @@ -2288,8 +2320,15 @@ SaveSettings(char* name) } break; case ArgInt: + case ArgZ: fprintf(f, "/%s=%d\n", ad->argName, *(int *)ad->argLoc); break; + case ArgX: + fprintf(f, "/%s=%d\n", ad->argName, *(int *)ad->argLoc - boardX); // [HGM] placement: stor relative value + break; + case ArgY: + fprintf(f, "/%s=%d\n", ad->argName, *(int *)ad->argLoc - boardY); + break; case ArgFloat: fprintf(f, "/%s=%g\n", ad->argName, *(float *)ad->argLoc); break; @@ -3078,7 +3117,7 @@ InitDrawingSizes(BoardSize boardSize, int flags) char buf[MSG_SIZ]; char *str; HMENU hmenu = GetMenu(hwndMain); - RECT crect, wrect; + RECT crect, wrect, oldRect; int offby; LOGBRUSH logbrush; @@ -3088,6 +3127,11 @@ InitDrawingSizes(BoardSize boardSize, int flags) /* [HGM] call with -2 uses old size (for if nr of files, ranks changes) */ if(boardSize == (BoardSize)(-2) ) boardSize = oldBoardSize; + oldRect.left = boardX; //[HGM] placement: remember previous window params + oldRect.top = boardY; + oldRect.right = boardX + winWidth; + oldRect.bottom = boardY + winHeight; + tinyLayout = sizeInfo[boardSize].tinyLayout; smallLayout = sizeInfo[boardSize].smallLayout; squareSize = sizeInfo[boardSize].squareSize; @@ -3188,6 +3232,8 @@ InitDrawingSizes(BoardSize boardSize, int flags) sizeInfo[boardSize].cliWidth = boardRect.right + OUTER_MARGIN; sizeInfo[boardSize].cliHeight = boardRect.bottom + OUTER_MARGIN; + oldBoardSize = boardSize; + oldTinyLayout = tinyLayout; if(suppressVisibleEffects) return; // [HGM] when called for filling sizeInfo only winWidth = 2 * GetSystemMetrics(SM_CXFRAME) + boardRect.right + OUTER_MARGIN; winHeight = 2 * GetSystemMetrics(SM_CYFRAME) + GetSystemMetrics(SM_CYMENU) + @@ -3195,6 +3241,14 @@ InitDrawingSizes(BoardSize boardSize, int flags) GetWindowRect(hwndMain, &wrect); SetWindowPos(hwndMain, NULL, 0, 0, winWidth, winHeight, SWP_NOCOPYBITS|SWP_NOZORDER|SWP_NOMOVE); + + // [HGM] placement: let attached windows follow size change. + ReattachAfterSize( &oldRect, winWidth, winHeight, moveHistoryDialog, &wpMoveHistory ); + ReattachAfterSize( &oldRect, winWidth, winHeight, evalGraphDialog, &wpEvalGraph ); + ReattachAfterSize( &oldRect, winWidth, winHeight, engineOutputDialog, &wpEngineOutput ); + ReattachAfterSize( &oldRect, winWidth, winHeight, gameListDialog, &wpGameList ); + ReattachAfterSize( &oldRect, winWidth, winHeight, hwndConsole, &wpConsole ); + /* compensate if menu bar wrapped */ GetClientRect(hwndMain, &crect); offby = boardRect.bottom + OUTER_MARGIN - crect.bottom; @@ -3304,8 +3358,6 @@ InitDrawingSizes(BoardSize boardSize, int flags) /* if (boardSize == oldBoardSize) return; [HGM] variant might have changed */ - oldBoardSize = boardSize; - oldTinyLayout = tinyLayout; /* Load piece bitmaps for this board size */ for (i=0; i<=2; i++) { @@ -4234,7 +4286,7 @@ void fputDW(FILE *f, int x) #define MAX_CLIPS 200 /* more than enough */ VOID -DrawLogoOnDC(HDC hdc, RECT logoRect, ChessProgramState *cps) +DrawLogoOnDC(HDC hdc, RECT logoRect, HBITMAP logo) { // HBITMAP bufferBitmap; BITMAP bi; @@ -4243,13 +4295,13 @@ DrawLogoOnDC(HDC hdc, RECT logoRect, ChessProgramState *cps) HBITMAP hbm; int w = 100, h = 50; - if(cps->programLogo == NULL) return; + if(logo == NULL) return; // GetClientRect(hwndMain, &Rect); // bufferBitmap = CreateCompatibleBitmap(hdc, Rect.right-Rect.left+1, // Rect.bottom-Rect.top+1); tmphdc = CreateCompatibleDC(hdc); - hbm = SelectObject(tmphdc, (HBITMAP) cps->programLogo); - if( GetObject( cps->programLogo, sizeof(bi), &bi ) > 0 ) { + hbm = SelectObject(tmphdc, logo); + if( GetObject( logo, sizeof(bi), &bi ) > 0 ) { w = bi.bmWidth; h = bi.bmHeight; } @@ -4532,8 +4584,39 @@ HDCDrawPosition(HDC hdc, BOOLEAN repaint, Board board) DrawBoardOnDC(hdcmem, board, tmphdc); } if(logoHeight) { - DrawLogoOnDC(hdc, leftLogoRect, flipClock ? &second : &first); - DrawLogoOnDC(hdc, rightLogoRect, flipClock ? &first : &second); + HBITMAP whiteLogo = (HBITMAP) first.programLogo, blackLogo = (HBITMAP) 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; + } + } + DrawLogoOnDC(hdc, leftLogoRect, flipClock ? blackLogo : whiteLogo); + DrawLogoOnDC(hdc, rightLogoRect, flipClock ? whiteLogo : blackLogo); } if( appData.highlightMoveWithArrow ) { @@ -6300,6 +6383,8 @@ WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) ReattachAfterMove( &rcMain, lpwp->x, lpwp->y, moveHistoryDialog, &wpMoveHistory ); ReattachAfterMove( &rcMain, lpwp->x, lpwp->y, evalGraphDialog, &wpEvalGraph ); ReattachAfterMove( &rcMain, lpwp->x, lpwp->y, engineOutputDialog, &wpEngineOutput ); + ReattachAfterMove( &rcMain, lpwp->x, lpwp->y, gameListDialog, &wpGameList ); + ReattachAfterMove( &rcMain, lpwp->x, lpwp->y, hwndConsole, &wpConsole ); boardX = lpwp->x; boardY = lpwp->y; } @@ -7070,7 +7155,7 @@ CommentDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) if (commentX != CW_USEDEFAULT && commentY != CW_USEDEFAULT && commentW != CW_USEDEFAULT && commentH != CW_USEDEFAULT) { WINDOWPLACEMENT wp; - EnsureOnScreen(&commentX, &commentY); + EnsureOnScreen(&commentX, &commentY, 0, 0); wp.length = sizeof(WINDOWPLACEMENT); wp.flags = 0; wp.showCmd = SW_SHOW; @@ -7290,6 +7375,7 @@ TypeInNameDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) case IDOK: GetDlgItemText(hDlg, OPT_Name, move, sizeof(move)); appData.userName = strdup(move); + SetUserLogo(); EndDialog(hDlg, TRUE); return TRUE; @@ -8013,37 +8099,37 @@ ConsoleWndProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) GetClientRect(hDlg, &rect); sizeX = rect.right; sizeY = rect.bottom; - if (consoleX != CW_USEDEFAULT && consoleY != CW_USEDEFAULT && - consoleW != CW_USEDEFAULT && consoleH != CW_USEDEFAULT) { + if (wpConsole.x != CW_USEDEFAULT && wpConsole.y != CW_USEDEFAULT && + wpConsole.width != CW_USEDEFAULT && wpConsole.height != CW_USEDEFAULT) { WINDOWPLACEMENT wp; - EnsureOnScreen(&consoleX, &consoleY); + EnsureOnScreen(&wpConsole.x, &wpConsole.y, 0, 0); wp.length = sizeof(WINDOWPLACEMENT); wp.flags = 0; wp.showCmd = SW_SHOW; wp.ptMaxPosition.x = wp.ptMaxPosition.y = 0; - wp.rcNormalPosition.left = consoleX; - wp.rcNormalPosition.right = consoleX + consoleW; - wp.rcNormalPosition.top = consoleY; - wp.rcNormalPosition.bottom = consoleY + consoleH; + wp.rcNormalPosition.left = wpConsole.x; + wp.rcNormalPosition.right = wpConsole.x + wpConsole.width; + wp.rcNormalPosition.top = wpConsole.y; + wp.rcNormalPosition.bottom = wpConsole.y + wpConsole.height; SetWindowPlacement(hDlg, &wp); } #if 0 // [HGM] Chessknight's change 2004-07-13 else { /* Determine Defaults */ WINDOWPLACEMENT wp; - consoleX = winWidth + 1; - consoleY = boardY; - consoleW = screenWidth - winWidth; - consoleH = winHeight; - EnsureOnScreen(&consoleX, &consoleY); + wpConsole.x = winWidth + 1; + wpConsole.y = boardY; + wpConsoleW = screenWidth - winWidth; + wpConsoleH = winHeight; + EnsureOnScreen(&wpConsole.x, &wpConsole.y, 0, 0); wp.length = sizeof(WINDOWPLACEMENT); wp.flags = 0; wp.showCmd = SW_SHOW; wp.ptMaxPosition.x = wp.ptMaxPosition.y = 0; - wp.rcNormalPosition.left = consoleX; - wp.rcNormalPosition.right = consoleX + consoleW; - wp.rcNormalPosition.top = consoleY; - wp.rcNormalPosition.bottom = consoleY + consoleH; + wp.rcNormalPosition.left = wpConsole.x; + wp.rcNormalPosition.right = wpConsole.x + wpConsole.width; + wp.rcNormalPosition.top = wpConsole.y; + wp.rcNormalPosition.bottom = wpConsole.y + wpConsole.height; SetWindowPlacement(hDlg, &wp); } #endif @@ -10454,7 +10540,7 @@ AnalysisDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) if (analysisX != CW_USEDEFAULT && analysisY != CW_USEDEFAULT && analysisW != CW_USEDEFAULT && analysisH != CW_USEDEFAULT) { WINDOWPLACEMENT wp; - EnsureOnScreen(&analysisX, &analysisY); + EnsureOnScreen(&analysisX, &analysisY, 0, 0); wp.length = sizeof(WINDOWPLACEMENT); wp.flags = 0; wp.showCmd = SW_SHOW;