X-Git-Url: http://winboard.nl/cgi-bin?a=blobdiff_plain;f=winboard%2Fwinboard.c;h=87b1830023f6cdc4cc66b1d4bdedeb43225ad472;hb=56310c5b198bc521e0a715377c68378b7bcf10a5;hp=ae9d56165adc1e76c715511c5e76cc1fdc86cf41;hpb=7454f494554a3406c6a382d6feba2f9040eb3121;p=xboard.git diff --git a/winboard/winboard.c b/winboard/winboard.c index ae9d561..87b1830 100644 --- a/winboard/winboard.c +++ b/winboard/winboard.c @@ -889,16 +889,19 @@ WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, void SetUserLogo() { // update user logo if necessary - static char oldUserName[MSG_SIZ], *curName; + static char oldUserName[MSG_SIZ], dir[MSG_SIZ], *curName; if(appData.autoLogo) { curName = UserName(); if(strcmp(curName, oldUserName)) { - snprintf(oldUserName, MSG_SIZ, "logos\\%s.bmp", curName); + GetCurrentDirectory(MSG_SIZ, dir); + SetCurrentDirectory(installDir); + snprintf(oldUserName, MSG_SIZ, "logos\\%s.bmp", curName); userLogo = LoadImage( 0, oldUserName, IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE ); safeStrCpy(oldUserName, curName, sizeof(oldUserName)/sizeof(oldUserName[0]) ); if(userLogo == NULL) userLogo = LoadImage( 0, "logos\\dummy.bmp", IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE ); + SetCurrentDirectory(dir); /* return to prev directory */ } } } @@ -955,6 +958,31 @@ EnsureOnScreen(int *x, int *y, int minX, int minY) if (*y < minY) *y = minY; } +VOID +LoadLogo(ChessProgramState *cps, int n, Boolean ics) +{ + char buf[MSG_SIZ], dir[MSG_SIZ]; + GetCurrentDirectory(MSG_SIZ, dir); + SetCurrentDirectory(installDir); + if( appData.logo[n] && appData.logo[n][0] != NULLCHAR) { + cps->programLogo = LoadImage( 0, appData.logo[n], IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE ); + + if (cps->programLogo == NULL && appData.debugMode) { + fprintf( debugFP, "Unable to load logo bitmap '%s'\n", appData.logo[n] ); + } + } else if(appData.autoLogo) { + if(ics) { // [HGM] logo: in ICS mode second can be used for ICS + sprintf(buf, "logos\\%s.bmp", appData.icsHost); + cps->programLogo = LoadImage( 0, buf, IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE ); + } else + if(appData.directory[n] && appData.directory[n][0]) { + SetCurrentDirectory(appData.directory[n]); + cps->programLogo = LoadImage( 0, "logo.bmp", IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE ); + } + } + SetCurrentDirectory(dir); /* return to prev directory */ +} + BOOL InitInstance(HINSTANCE hInstance, int nCmdShow, LPSTR lpCmdLine) { @@ -1010,37 +1038,8 @@ InitInstance(HINSTANCE hInstance, int nCmdShow, LPSTR lpCmdLine) } /* [HGM] logo: Load logos if specified (must be done before InitDrawingSizes) */ - if( appData.firstLogo && appData.firstLogo[0] != NULLCHAR) { - first.programLogo = LoadImage( 0, appData.firstLogo, IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE ); - - if (first.programLogo == NULL && appData.debugMode) { - fprintf( debugFP, "Unable to load logo bitmap '%s'\n", appData.firstLogo ); - } - } else if(appData.autoLogo) { - if(appData.firstDirectory && appData.firstDirectory[0]) { - char buf[MSG_SIZ]; - snprintf(buf, MSG_SIZ, "%s/logo.bmp", appData.firstDirectory); - first.programLogo = LoadImage( 0, buf, IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE ); - } - } - - if( appData.secondLogo && appData.secondLogo[0] != NULLCHAR) { - second.programLogo = LoadImage( 0, appData.secondLogo, IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE ); - - if (second.programLogo == NULL && appData.debugMode) { - 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 - snprintf(buf, MSG_SIZ, "logos\\%s.bmp", appData.icsHost); - second.programLogo = LoadImage( 0, buf, IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE ); - } else - if(appData.secondDirectory && appData.secondDirectory[0]) { - snprintf(buf, MSG_SIZ, "%s\\logo.bmp", appData.secondDirectory); - second.programLogo = LoadImage( 0, buf, IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE ); - } - } + LoadLogo(&first, 0, FALSE); + LoadLogo(&second, 1, appData.icsActive); SetUserLogo(); @@ -1232,7 +1231,7 @@ ParseFontName(char *name, MyFontParams *mfp) q = strchr(p, ':'); if (q) { if (q - p >= sizeof(mfp->faceName)) - ExitArgError(_("Font name too long:"), name); + ExitArgError(_("Font name too long:"), name, TRUE); memcpy(mfp->faceName, p, q - p); mfp->faceName[q - p] = NULLCHAR; p = q + 1; @@ -1241,12 +1240,12 @@ ParseFontName(char *name, MyFontParams *mfp) while (*p && !isdigit(*p)) { *q++ = *p++; if (q - mfp->faceName >= sizeof(mfp->faceName)) - ExitArgError(_("Font name too long:"), name); + ExitArgError(_("Font name too long:"), name, TRUE); } while (q > mfp->faceName && q[-1] == ' ') q--; *q = NULLCHAR; } - if (!*p) ExitArgError(_("Font point size missing:"), name); + if (!*p) ExitArgError(_("Font point size missing:"), name, TRUE); mfp->pointSize = (float) atof(p); mfp->bold = (strchr(p, 'b') != NULL); mfp->italic = (strchr(p, 'i') != NULL); @@ -1352,7 +1351,7 @@ ParseBoardSize(void *addr, char *name) } bs++; } - ExitArgError(_("Unrecognized board size value"), name); + ExitArgError(_("Unrecognized board size value"), name, TRUE); } void @@ -2693,8 +2692,8 @@ SquareToPos(int row, int column, int * x, int * y) VOID DrawCoordsOnDC(HDC hdc) { - static char files[24] = {'0', '1','2','3','4','5','6','7','8','9','0','1','1','0','9','8','7','6','5','4','3','2','1','0'}; - static char ranks[24] = {'l', 'k','j','i','h','g','f','e','d','c','b','a','a','b','c','d','e','f','g','h','i','j','k','l'}; + static char files[] = "0123456789012345678901221098765432109876543210"; + static char ranks[] = "wvutsrqponmlkjihgfedcbaabcdefghijklmnopqrstuvw"; char str[2] = { NULLCHAR, NULLCHAR }; int oldMode, oldAlign, x, y, start, i; HFONT oldFont; @@ -2703,7 +2702,7 @@ DrawCoordsOnDC(HDC hdc) if (!appData.showCoords) return; - start = flipView ? 1-(ONE!='1') : 23+(ONE!='1')-BOARD_HEIGHT; + start = flipView ? 1-(ONE!='1') : 45+(ONE!='1')-BOARD_HEIGHT; oldBrush = SelectObject(hdc, GetStockObject(BLACK_BRUSH)); oldMode = SetBkMode(hdc, (appData.monoMode ? OPAQUE : TRANSPARENT)); @@ -2720,7 +2719,7 @@ DrawCoordsOnDC(HDC hdc) y += squareSize + lineGap; } - start = flipView ? 12-(BOARD_RGHT-BOARD_LEFT) : 12; + start = flipView ? 23-(BOARD_RGHT-BOARD_LEFT) : 23; SetTextAlign(hdc, TA_RIGHT|TA_BOTTOM); for (i = 0; i < BOARD_RGHT - BOARD_LEFT; i++) { @@ -3380,7 +3379,10 @@ DrawLogoOnDC(HDC hdc, RECT logoRect, HBITMAP logo) HBITMAP hbm; int w = 100, h = 50; - if(logo == NULL) return; + if(logo == NULL) { + if(!logoHeight) return; + FillRect( hdc, &logoRect, whitePieceBrush ); + } // GetClientRect(hwndMain, &Rect); // bufferBitmap = CreateCompatibleBitmap(hdc, Rect.right-Rect.left+1, // Rect.bottom-Rect.top+1); @@ -3438,6 +3440,15 @@ DisplayLogos() } } +void +UpdateLogos(int display) +{ // called after loading new engine(s), in tourney or from menu + LoadLogo(&first, 0, FALSE); + LoadLogo(&second, 1, appData.icsActive); + InitDrawingSizes(-2, 0); // adapt layout of board window to presence/absence of logos + if(display) DisplayLogos(); +} + static HDC hdcSeek; // [HGM] seekgraph @@ -4056,10 +4067,11 @@ SetupDropMenu(HMENU hmenu) } } -void DragPieceBegin(int x, int y) +void DragPieceBegin(int x, int y, Boolean instantly) { dragInfo.lastpos.x = boardRect.left + x; dragInfo.lastpos.y = boardRect.top + y; + if(instantly) dragInfo.pos = dragInfo.lastpos; dragInfo.from.x = fromX; dragInfo.from.y = fromY; dragInfo.piece = boards[currentMove][fromY][fromX]; @@ -4937,7 +4949,8 @@ WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) break; case IDM_EditProgs2: - EditTagsPopUp(secondChessProgramNames, &secondChessProgramNames); + LoadEnginePopUp(hwndMain); +// EditTagsPopUp(secondChessProgramNames, &secondChessProgramNames); break; case IDM_EditServers: @@ -4949,6 +4962,10 @@ WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) EditTagsProc(); break; + case IDM_EditBook: + EditBookEvent(); + break; + case IDM_EditComment: case IDM_Comment: if (commentUp && editComment) { @@ -5100,6 +5117,10 @@ WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) UciOptionsPopup(hwnd); break; + case IDM_Tourney: + TourneyPopup(hwnd); + break; + case IDM_IcsOptions: IcsOptionsPopup(hwnd); break; @@ -5601,7 +5622,7 @@ MyLoadSound(MySound *ms) struct stat st; FILE *f; - if (ms->data) free(ms->data); + if (ms->data && ms->flag) free(ms->data); ms->data = NULL; switch (ms->name[0]) { @@ -5622,6 +5643,7 @@ MyLoadSound(MySound *ms) HANDLE h = FindResource(hInst, ms->name + 1, "WAVE"); if (h == NULL) break; ms->data = (void *)LoadResource(hInst, h); + ms->flag = 0; // not maloced, so cannot be freed! if (h == NULL) break; ok = TRUE; } @@ -5632,6 +5654,7 @@ MyLoadSound(MySound *ms) if (f == NULL) break; if (fstat(fileno(f), &st) < 0) break; ms->data = malloc(st.st_size); + ms->flag = 1; if (fread(ms->data, st.st_size, 1, f) < 1) break; fclose(f); ok = TRUE; @@ -6065,8 +6088,8 @@ StartupDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) appData.firstChessProgram, "fd", appData.firstDirectory, firstChessProgramNames); InitEngineBox(hDlg, GetDlgItem(hDlg, OPT_SecondChessEngineName), - appData.secondChessProgram, "sd", appData.secondDirectory, - secondChessProgramNames); + appData.secondChessProgram, singleList ? "fd" : "sd", appData.secondDirectory, + singleList ? firstChessProgramNames : secondChessProgramNames); //[HGM] single: use first list in second combo hwndCombo = GetDlgItem(hDlg, OPT_ChessServerName); InitComboStringsFromOption(hwndCombo, icsNames); snprintf(buf, MSG_SIZ, "%s /icsport=%s", appData.icsHost, appData.icsPort); @@ -6103,10 +6126,12 @@ StartupDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) GetDlgItemText(hDlg, OPT_ChessEngineName, buf + strlen(buf), sizeof(buf) - strlen(buf)); p = buf; ParseArgs(StringGet, &p); - safeStrCpy(buf, "/scp=", sizeof(buf)/sizeof(buf[0]) ); + safeStrCpy(buf, singleList ? "/fcp=" : "/scp=", sizeof(buf)/sizeof(buf[0]) ); GetDlgItemText(hDlg, OPT_SecondChessEngineName, buf + strlen(buf), sizeof(buf) - strlen(buf)); - p = buf; + p = buf; + SwapEngines(singleList); // temporarily swap first and second, to load a second 'first', ... ParseArgs(StringGet, &p); + SwapEngines(singleList); // ... and then make it 'second' appData.noChessProgram = FALSE; appData.icsActive = FALSE; } else if (IsDlgButtonChecked(hDlg, OPT_ChessServer)) { @@ -7742,6 +7767,22 @@ Enables gnuEnables[] = { { IDM_Revert, MF_BYCOMMAND|MF_GRAYED }, { IDM_Annotate, MF_BYCOMMAND|MF_GRAYED }, { IDM_NewChat, MF_BYCOMMAND|MF_GRAYED }, + + // Needed to switch from ncp to GNU mode on Engine Load + { ACTION_POS, MF_BYPOSITION|MF_ENABLED }, + { IDM_MachineWhite, MF_BYCOMMAND|MF_ENABLED }, + { IDM_MachineBlack, MF_BYCOMMAND|MF_ENABLED }, + { IDM_TwoMachines, MF_BYCOMMAND|MF_ENABLED }, + { IDM_Match, MF_BYCOMMAND|MF_ENABLED }, + { IDM_AnalysisMode, MF_BYCOMMAND|MF_ENABLED }, + { IDM_AnalyzeFile, MF_BYCOMMAND|MF_ENABLED }, + { IDM_Engine1Options, MF_BYCOMMAND|MF_ENABLED }, + { IDM_Engine2Options, MF_BYCOMMAND|MF_ENABLED }, + { IDM_TimeControl, MF_BYCOMMAND|MF_ENABLED }, + { IDM_RetractMove, MF_BYCOMMAND|MF_ENABLED }, + { IDM_MoveNow, MF_BYCOMMAND|MF_ENABLED }, + { IDM_Hint, MF_BYCOMMAND|MF_ENABLED }, + { IDM_Book, MF_BYCOMMAND|MF_ENABLED }, { -1, -1 } }; @@ -7759,10 +7800,12 @@ Enables icsEnables[] = { { IDM_MoveNow, MF_BYCOMMAND|MF_GRAYED }, { IDM_Hint, MF_BYCOMMAND|MF_GRAYED }, { IDM_Book, MF_BYCOMMAND|MF_GRAYED }, + { IDM_EditProgs2, MF_BYCOMMAND|MF_GRAYED }, { IDM_IcsOptions, MF_BYCOMMAND|MF_ENABLED }, { IDM_Engine1Options, MF_BYCOMMAND|MF_GRAYED }, { IDM_Engine2Options, MF_BYCOMMAND|MF_GRAYED }, { IDM_Annotate, MF_BYCOMMAND|MF_GRAYED }, + { IDM_Tourney, MF_BYCOMMAND|MF_GRAYED }, { -1, -1 } }; @@ -8562,6 +8605,12 @@ PlayAlarmSound() MyPlaySound(&sounds[(int)SoundAlarm]); } +VOID +PlayTellSound() +{ + MyPlaySound(&textAttribs[ColorTell].sound); +} + VOID EchoOn() @@ -9775,6 +9824,8 @@ HistorySet( char movelist[][2*MOVE_LEN], int first, int last, int current ) MoveHistorySet( movelist, first, last, current, pvInfoList ); EvalGraphSet( first, last, current, pvInfoList ); + + MakeEngineOutputTitle(); } void