X-Git-Url: http://winboard.nl/cgi-bin?a=blobdiff_plain;f=winboard%2Fwinboard.c;h=43dfeeda52bbb061b40d399347458a5c22b1e8c6;hb=f0fa0b3b5570ba67f4a83101fe24f5504fb21012;hp=ccebf786576fb6c7f2ebc303b828595c2e73cf5b;hpb=8bec087a08da8b78d787fa6844cda66dfa1fb576;p=xboard.git diff --git a/winboard/winboard.c b/winboard/winboard.c index ccebf78..43dfeed 100644 --- a/winboard/winboard.c +++ b/winboard/winboard.c @@ -248,7 +248,7 @@ Boolean barbaric; // flag indicating if translation is needed #define ABOUTBOX2 -1 int dialogItems[][40] = { -{ ABOUTBOX, IDOK, 400 }, +{ ABOUTBOX, IDOK, OPT_MESS, 400 }, { DLG_TimeControl, IDC_Babble, OPT_TCUseMoves, OPT_TCUseInc, OPT_TCUseFixed, OPT_TCtext1, OPT_TCtext2, OPT_TCitext1, OPT_TCitext2, OPT_TCftext, GPB_Factors, IDC_Factor1, IDC_Factor2, IDOK, IDCANCEL }, { DLG_LoadOptions, OPT_Autostep, OPT_AStext1, IDOK, IDCANCEL }, @@ -282,7 +282,7 @@ int dialogItems[][40] = { OPT_AutoFlipView, OPT_ShowButtonBar, OPT_AutoRaiseBoard, OPT_ShowCoordinates, OPT_Blindfold, OPT_ShowThinking, OPT_HighlightDragging, OPT_TestLegality, OPT_SaveExtPGN, OPT_HideThinkFromHuman, OPT_ExtraInfoInMoveHistory, - OPT_HighlightMoveArrow, OPT_AutoLogo }, + OPT_HighlightMoveArrow, OPT_AutoLogo ,OPT_SmartMove }, { DLG_IcsOptions, IDOK, IDCANCEL, OPT_AutoComment, OPT_AutoKibitz, OPT_AutoObserve, OPT_GetMoveList, OPT_LocalLineEditing, OPT_QuietPlay, OPT_SeekGraph, OPT_AutoRefresh, OPT_BgObserve, OPT_DualBoard, OPT_Premove, OPT_PremoveWhite, OPT_PremoveBlack, @@ -398,13 +398,11 @@ Translate(HWND hDlg, int dialogID) { // translate all text items in the given dialog int i=0, j, k; char buf[MSG_SIZ], *s; -//if(appData.debugMode) fprintf(debugFP, "Translate(%d)\n", dialogID); if(!barbaric) return; while(dialogItems[i][0] && dialogItems[i][0] != dialogID) i++; // find the dialog description if(dialogItems[i][0] != dialogID) return; // unknown dialog, should not happen GetWindowText( hDlg, buf, MSG_SIZ ); s = T_(buf); -//if(appData.debugMode) fprintf(debugFP, "WindowText '%s' -> '%s'\n", buf, s); if(strcmp(buf, s)) SetWindowText(hDlg, s); // replace by translated string (if different) for(j=1; k=dialogItems[i][j]; j++) { // translate all listed dialog items GetDlgItemText(hDlg, k, buf, MSG_SIZ); @@ -414,10 +412,35 @@ Translate(HWND hDlg, int dialogID) } } +HMENU +TranslateOneMenu(int i, HMENU subMenu) +{ + int j; + static MENUITEMINFO info; + + info.cbSize = sizeof(MENUITEMINFO); + info.fMask = MIIM_STATE | MIIM_TYPE; + for(j=GetMenuItemCount(subMenu)-1; j>=0; j--){ + char buf[MSG_SIZ]; + info.dwTypeData = buf; + info.cch = sizeof(buf); + GetMenuItemInfo(subMenu, j, TRUE, &info); + 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 + } + if(buf[0] == NULLCHAR) continue; + info.dwTypeData = T_(buf); + info.cch = strlen(buf)+1; + SetMenuItemInfo(subMenu, j, TRUE, &info); + } + return subMenu; +} + void TranslateMenus(int addLanguage) { - int i, j; + int i; WIN32_FIND_DATA fileData; HANDLE hFind; #define IDM_English 1895 @@ -427,20 +450,7 @@ TranslateMenus(int addLanguage) HMENU subMenu = GetSubMenu(mainMenu, i); ModifyMenu(mainMenu, i, MF_STRING|MF_BYPOSITION|MF_POPUP|EnableMenuItem(mainMenu, i, MF_BYPOSITION), (UINT) subMenu, T_(menuBarText[tinyLayout][i])); - for(j=GetMenuItemCount(subMenu)-1; j>=0; j--){ - char buf[MSG_SIZ]; - UINT k = GetMenuItemID(subMenu, j); - if(menuText[i][j]) - safeStrCpy(buf, menuText[i][j], sizeof(buf)/sizeof(buf[0]) ); else { - GetMenuString(subMenu, j, buf, MSG_SIZ, MF_BYPOSITION); - menuText[i][j] = strdup(buf); // remember original on first change - } - if(buf[0] == NULLCHAR) continue; -//fprintf(debugFP, "menu(%d,%d) = %s (%08x, %08x) %d\n", i, j, buf, mainMenu, subMenu, k); - ModifyMenu(subMenu, j, MF_STRING|MF_BYPOSITION - |CheckMenuItem(subMenu, j, MF_BYPOSITION) - |EnableMenuItem(subMenu, j, MF_BYPOSITION), k, T_(buf)); - } + TranslateOneMenu(i, subMenu); } DrawMenuBar(hwndMain); } @@ -756,6 +766,7 @@ WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, } JAWS_INIT + TranslateMenus(1); // InitCommonControlsEx(&ex); InitCommonControls(); @@ -884,6 +895,8 @@ SetUserLogo() 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 ); } } } @@ -1048,7 +1061,6 @@ InitInstance(HINSTANCE hInstance, int nCmdShow, LPSTR lpCmdLine) } InitDrawingSizes(boardSize, 0); - TranslateMenus(1); InitMenuChecks(); buttonCount = GetSystemMetrics(SM_CMOUSEBUTTONS); @@ -4287,19 +4299,20 @@ Promotion(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) Translate(hDlg, DLG_PromotionKing); ShowWindow(GetDlgItem(hDlg, PB_King), (!appData.testLegality || gameInfo.variant == VariantSuicide || + gameInfo.variant == VariantSpartan && !WhiteOnMove(currentMove) || gameInfo.variant == VariantGiveaway || gameInfo.variant == VariantSuper ) ? SW_SHOW : SW_HIDE); /* [HGM] Only allow C & A promotions if these pieces are defined */ ShowWindow(GetDlgItem(hDlg, PB_Archbishop), - ((PieceToChar(WhiteAngel) >= 'A' && + ((PieceToChar(WhiteAngel) >= 'A' && WhiteOnMove(currentMove) && PieceToChar(WhiteAngel) != '~') || - (PieceToChar(BlackAngel) >= 'A' && + (PieceToChar(BlackAngel) >= 'A' && !WhiteOnMove(currentMove) && PieceToChar(BlackAngel) != '~') ) ? SW_SHOW : SW_HIDE); ShowWindow(GetDlgItem(hDlg, PB_Chancellor), - ((PieceToChar(WhiteMarshall) >= 'A' && + ((PieceToChar(WhiteMarshall) >= 'A' && WhiteOnMove(currentMove) && PieceToChar(WhiteMarshall) != '~') || - (PieceToChar(BlackMarshall) >= 'A' && + (PieceToChar(BlackMarshall) >= 'A' && !WhiteOnMove(currentMove) && PieceToChar(BlackMarshall) != '~') ) ? SW_SHOW : SW_HIDE); /* [HGM] Hide B & R button in Shogi, use Q as promote, N as defer */ @@ -4330,31 +4343,30 @@ Promotion(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) promoChar = gameInfo.variant == VariantSuper ? PieceToChar(BlackSilver) : PieceToChar(BlackKing); break; case PB_Queen: - promoChar = gameInfo.variant == VariantShogi ? '+' : PieceToChar(BlackQueen); + promoChar = gameInfo.variant == VariantShogi ? '+' : ToLower(PieceToChar(WhiteOnMove(currentMove) ? WhiteQueen : BlackQueen)); break; case PB_Rook: - promoChar = PieceToChar(BlackRook); + promoChar = ToLower(PieceToChar(WhiteOnMove(currentMove) ? WhiteRook : BlackRook)); + if(gameInfo.variant == VariantSpartan && !WhiteOnMove(currentMove)) promoChar = PieceToChar(BlackDragon); break; case PB_Bishop: - promoChar = PieceToChar(BlackBishop); + promoChar = ToLower(PieceToChar(WhiteOnMove(currentMove) ? WhiteBishop : BlackBishop)); + if(gameInfo.variant == VariantSpartan && !WhiteOnMove(currentMove)) promoChar = PieceToChar(BlackAlfil); break; case PB_Chancellor: - promoChar = PieceToChar(BlackMarshall); + promoChar = ToLower(PieceToChar(WhiteOnMove(currentMove) ? WhiteMarshall : BlackMarshall)); break; case PB_Archbishop: - promoChar = PieceToChar(BlackAngel); + promoChar = ToLower(PieceToChar(WhiteOnMove(currentMove) ? WhiteAngel : BlackAngel)); break; case PB_Knight: - promoChar = gameInfo.variant == VariantShogi ? '=' : PieceToChar(BlackKnight); + promoChar = gameInfo.variant == VariantShogi ? '=' : PieceToChar(WhiteOnMove(currentMove) ? WhiteKnight : BlackKnight); break; default: return FALSE; } + if(promoChar == '.') return FALSE; // invalid piece chosen EndDialog(hDlg, TRUE); /* Exit the dialog */ - /* [HGM] Call FinishMove rather than UserMoveEvent, as we - only show the popup when we are already sure the move is valid or - legal. We pass a faulty move type, but the kludge is that FinishMove - will figure out it is a promotion from the promoChar. */ UserMoveEvent(fromX, fromY, toX, toY, promoChar); fromX = fromY = -1; if (!appData.highlightLastMove) { @@ -4904,11 +4916,13 @@ WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) break; case IDM_EditGame: + case IDM_EditGame2: EditGameEvent(); SAY("edit game"); break; case IDM_EditPosition: + case IDM_EditPosition2: EditPositionEvent(); SAY("enter a FEN string or setup a position on the board using the control R pop up menu"); break; @@ -4921,6 +4935,18 @@ WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) ShowGameListProc(); break; + case IDM_EditProgs1: + EditTagsPopUp(firstChessProgramNames, &firstChessProgramNames); + break; + + case IDM_EditProgs2: + EditTagsPopUp(secondChessProgramNames, &secondChessProgramNames); + break; + + case IDM_EditServers: + EditTagsPopUp(icsNames, &icsNames); + break; + case IDM_EditTags: case IDM_Tags: EditTagsProc(); @@ -5790,6 +5816,7 @@ MenuPopup(HWND hwnd, POINT pt, HMENU hmenu, UINT def) * menu that TrackPopupMenu displays. */ hmenuTrackPopup = GetSubMenu(hmenu, 0); + TranslateOneMenu(10, hmenuTrackPopup); SetMenuDefaultItem(hmenuTrackPopup, def, FALSE); @@ -6228,7 +6255,7 @@ CommentDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) sizeY = newSizeY; } } - SendDlgItemMessage( hDlg, OPT_CommentText, EM_SETEVENTMASK, 0, ENM_MOUSEEVENTS ); + SendDlgItemMessage( hDlg, OPT_CommentText, EM_SETEVENTMASK, 0, ENM_MOUSEEVENTS | ENM_KEYEVENTS ); return FALSE; case WM_COMMAND: /* message: received a command */ @@ -6277,13 +6304,19 @@ CommentDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) if( wParam == OPT_CommentText ) { MSGFILTER * lpMF = (MSGFILTER *) lParam; - if( lpMF->msg == WM_RBUTTONDOWN && (lpMF->wParam & (MK_CONTROL | MK_SHIFT)) == 0 ) { + if( lpMF->msg == WM_RBUTTONDOWN && (lpMF->wParam & (MK_CONTROL | MK_SHIFT)) == 0 || + lpMF->msg == WM_CHAR && lpMF->wParam == '\022' ) { POINTL pt; LRESULT index; pt.x = LOWORD( lpMF->lParam ); pt.y = HIWORD( lpMF->lParam ); + if(lpMF->msg == WM_CHAR) { + CHARRANGE sel; + SendDlgItemMessage( hDlg, OPT_CommentText, EM_EXGETSEL, 0, (LPARAM) &sel ); + index = sel.cpMin; + } else index = SendDlgItemMessage( hDlg, OPT_CommentText, EM_CHARFROMPOS, 0, (LPARAM) &pt ); hwndText = GetDlgItem(hDlg, OPT_CommentText); // cloned from above @@ -6387,6 +6420,7 @@ TypeInMoveDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) case WM_COMMAND: switch (LOWORD(wParam)) { case IDOK: + shiftKey = GetKeyState(VK_SHIFT) < 0; // [HGM] remember last shift status GetDlgItemText(hDlg, OPT_Move, move, sizeof(move)); { int n; Board board; @@ -6841,6 +6875,7 @@ ConsoleTextSubclass(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) switch (message) { case WM_KEYDOWN: if (!(GetKeyState(VK_CONTROL) & ~1)) break; + if(wParam=='R') return 0; switch (wParam) { case VK_PRIOR: SendMessage(hwnd, EM_LINESCROLL, 0, -999999); @@ -6874,7 +6909,8 @@ ConsoleTextSubclass(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) SendMessage(hInput, message, wParam, lParam); } return 0; - } // [HGM] navigate: for Ctrl+R, flow into nex case (moved up here) to summon up menu + } // [HGM] navigate: for Ctrl+R, flow into next case (moved up here) to summon up menu + lParam = -1; case WM_RBUTTONDOWN: if (!(GetKeyState(VK_SHIFT) & ~1)) { /* Move selection here if it was empty */ @@ -6883,7 +6919,7 @@ ConsoleTextSubclass(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) pt.y = HIWORD(lParam); SendMessage(hwnd, EM_EXGETSEL, 0, (LPARAM)&sel); if (sel.cpMin == sel.cpMax) { - sel.cpMin = SendMessage(hwnd, EM_CHARFROMPOS, 0, (LPARAM)&pt); /*doc is wrong*/ + if(lParam != -1) sel.cpMin = SendMessage(hwnd, EM_CHARFROMPOS, 0, (LPARAM)&pt); /*doc is wrong*/ sel.cpMax = sel.cpMin; SendMessage(hwnd, EM_EXSETSEL, 0, (LPARAM)&sel); } @@ -7447,7 +7483,7 @@ DisplayAClock(HDC hdc, int timeRemaining, int highlight, rect, str, strlen(str), NULL); if(logoHeight > 0 && appData.clockMode) { RECT r; - snprintf(buf, sizeof(buf)/sizeof(buf[0]), "%s %s", buf+7, flagFell); + str += strlen(color)+2; r.top = rect->top + logoHeight/2; r.left = rect->left; r.right = rect->right;