X-Git-Url: http://winboard.nl/cgi-bin?a=blobdiff_plain;f=winboard%2Fwinboard.c;h=9ce542829252fe6b7a57f07d96383218d8178e78;hb=f4cc69edd466fda83f84629f40c086dd2a249616;hp=6f26f2b7376d4bf6a370c583d592fab472f044ea;hpb=222c259543a8125e7391106f8a6c0f9d9720efc9;p=xboard.git diff --git a/winboard/winboard.c b/winboard/winboard.c index 6f26f2b..9ce5428 100644 --- a/winboard/winboard.c +++ b/winboard/winboard.c @@ -435,7 +435,7 @@ TranslateOneMenu(int i, HMENU subMenu) info.dwTypeData = buf; info.cch = sizeof(buf); GetMenuItemInfo(subMenu, j, TRUE, &info); - if(i < 10) { + if(i < 10) { if(menuText[i][j]) safeStrCpy(buf, menuText[i][j], sizeof(buf)/sizeof(buf[0]) ); else menuText[i][j] = strdup(buf); // remember original on first change } @@ -492,6 +492,29 @@ TranslateMenus(int addLanguage) #endif +#define IDM_RecentEngines 3000 + +void +RecentEngineMenu (char *s) +{ + if(appData.recentEngines > 0 && *s) { // feature is on, and list non-empty + HMENU mainMenu = GetMenu(hwndMain); + HMENU subMenu = GetSubMenu(mainMenu, 5); // Engine menu + int i=IDM_RecentEngines; + recentEngines = strdup(appData.recentEngineList); // remember them as they are in menu + AppendMenu(subMenu, MF_SEPARATOR, (UINT_PTR) 0, NULL); + while(*s) { + char *p = strchr(s, '\n'); + if(p == NULL) return; // malformed! + *p = NULLCHAR; + AppendMenu(subMenu, MF_ENABLED|MF_STRING|MF_UNCHECKED, (UINT_PTR) i++, (LPCTSTR) s); + *p = '\n'; + s = p+1; + } + } +} + + typedef struct { char *name; int squareSize; @@ -1095,6 +1118,7 @@ InitInstance(HINSTANCE hInstance, int nCmdShow, LPSTR lpCmdLine) } InitDrawingSizes(boardSize, 0); + RecentEngineMenu(appData.recentEngineList); InitMenuChecks(); buttonCount = GetSystemMetrics(SM_CMOUSEBUTTONS); @@ -4247,7 +4271,7 @@ MouseEvent(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) } break; case 2: - SetCapture(hwndMain); + SetCapture(hwndMain); break; case 1: hmenu = LoadMenu(hInst, "DropPieceMenu"); @@ -5443,6 +5467,9 @@ WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) break; default: + if(wmId >= IDM_RecentEngines && wmId < IDM_RecentEngines + appData.recentEngines) + RecentEngineEvent(wmId - 3000); + else if(wmId > IDM_English && wmId < IDM_English+20) { LoadLanguageFile(languageFile[wmId - IDM_English - 1]); TranslateMenus(0); @@ -6157,7 +6184,7 @@ StartupDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) ParseArgs(StringGet, &p); 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' @@ -6467,10 +6494,10 @@ TypeInMoveDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) case WM_COMMAND: switch (LOWORD(wParam)) { - case IDOK: + case IDOK: shiftKey = GetKeyState(VK_SHIFT) < 0; // [HGM] remember last shift status - GetDlgItemText(hDlg, OPT_Move, move, sizeof(move)); + GetDlgItemText(hDlg, OPT_Move, move, sizeof(move)); TypeInDoneEvent(move); EndDialog(hDlg, TRUE); return TRUE; @@ -7433,7 +7460,7 @@ DisplayHoldingsCount(HDC hdc, int x, int y, int rightAlign, int copyNumber) HFONT oldFont; RECT rect; - if(copyNumber > 1) + if(copyNumber > 1) snprintf(buf, sizeof(buf)/sizeof(buf[0]),"%d", copyNumber); else buf[0] = 0; oldFg = SetTextColor(hdc, RGB(255, 255, 255)); /* white */ @@ -8183,8 +8210,8 @@ DisplayMessage(char *str1, char *str2) if (len > remain) len = remain; strncat(messageText, str2, len); } - messageText[MESSAGE_TEXT_MAX - 1] = NULLCHAR; - safeStrCpy(lastMsg, messageText, MSG_SIZ); + messageText[MESSAGE_TEXT_MAX - 1] = NULLCHAR; + safeStrCpy(lastMsg, messageText, MSG_SIZ); if (hwndMain == NULL || IsIconic(hwndMain)) return;