Boolean chessProgram;\r
//static int boardX, boardY;\r
int minX, minY; // [HGM] placement: volatile limits on upper-left corner\r
-int squareSize, lineGap, minorSize, border;\r
+int squareSize, lineGap, minorSize;\r
static int winW, winH;\r
static RECT messageRect, whiteRect, blackRect, leftLogoRect, rightLogoRect; // [HGM] logo\r
static int logoHeight = 0;\r
{ DLG_TimeControl, IDC_Babble, OPT_TCUseMoves, OPT_TCUseInc, OPT_TCUseFixed, \r
OPT_TCtext1, OPT_TCtext2, OPT_TCitext1, OPT_TCitext2, OPT_TCftext, GPB_Factors, IDC_Factor1, IDC_Factor2, IDOK, IDCANCEL }, \r
{ DLG_LoadOptions, OPT_Autostep, OPT_AStext1, OPT_Exact, OPT_Subset, OPT_Struct, OPT_Material, OPT_Range, OPT_Difference,\r
- OPT_elo1t, OPT_elo2t, OPT_datet, OPT_Stretch, OPT_Stretcht, OPT_Reversed, OPT_SearchMode, OPT_Mirror, OPT_thresholds, IDOK, IDCANCEL }, \r
+ OPT_elo1t, OPT_elo2t, OPT_datet, OPT_Stretch, OPT_Stretcht, OPT_Reversed, OPT_SearchMode, OPT_Mirror, OPT_thresholds,\r
+ OPT_Ranget, IDOK, IDCANCEL }, \r
{ DLG_SaveOptions, OPT_Autosave, OPT_AVPrompt, OPT_AVToFile, OPT_AVBrowse,\r
801, OPT_PGN, OPT_Old, OPT_OutOfBookInfo, IDOK, IDCANCEL }, \r
{ 1536, 1090, IDC_Directories, 1089, 1091, IDOK, IDCANCEL, 1038, IDC_IndexNr, 1037 }, \r
*\r
\*---------------------------------------------------------------------------*/\r
\r
+static void HandleMessage P((MSG *message));\r
+static HANDLE hAccelMain, hAccelNoAlt, hAccelNoICS;\r
+\r
int APIENTRY\r
WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,\r
LPSTR lpCmdLine, int nCmdShow)\r
{\r
MSG msg;\r
- HANDLE hAccelMain, hAccelNoAlt, hAccelNoICS;\r
// INITCOMMONCONTROLSEX ex;\r
\r
debugFP = stderr;\r
0, /* lowest message to examine */\r
0)) /* highest message to examine */\r
{\r
+ HandleMessage(&msg);\r
+ }\r
+\r
+\r
+ return (msg.wParam); /* Returns the value from PostQuitMessage */\r
+}\r
+\r
+static void\r
+HandleMessage (MSG *message)\r
+{\r
+ MSG msg = *message;\r
\r
if(msg.message == WM_CHAR && msg.wParam == '\t') {\r
// [HGM] navigate: switch between all windows with tab\r
if(currentElement < 5 && IsIconic(hwndMain)) ShowWindow(hwndMain, SW_RESTORE); // all open together\r
SetFocus(h);\r
\r
- continue; // this message now has been processed\r
+ return; // this message now has been processed\r
}\r
}\r
\r
if(chatHandle[i] && IsDialogMessage(chatHandle[i], &msg)) {\r
done = 1; break;\r
}\r
- if(done) continue; // [HGM] chat: end patch\r
+ if(done) return; // [HGM] chat: end patch\r
TranslateMessage(&msg); /* Translates virtual key codes */\r
DispatchMessage(&msg); /* Dispatches message to window */\r
}\r
- }\r
-\r
+}\r
\r
- return (msg.wParam); /* Returns the value from PostQuitMessage */\r
+void\r
+DoEvents ()\r
+{ /* Dispatch pending messages */\r
+ MSG msg;\r
+ while (PeekMessage(&msg, /* message structure */\r
+ NULL, /* handle of window receiving the message */\r
+ 0, /* lowest message to examine */\r
+ 0, /* highest message to examine */\r
+ PM_REMOVE))\r
+ {\r
+ HandleMessage(&msg);\r
+ }\r
}\r
\r
/*---------------------------------------------------------------------------*\\r
(void) CheckMenuItem(hmenu, IDM_SaveSettingsOnExit,\r
MF_BYCOMMAND|(saveSettingsOnExit ?\r
MF_CHECKED : MF_UNCHECKED));\r
+ EnableMenuItem(hmenu, IDM_SaveSelected, MF_GRAYED);\r
}\r
\r
//---------------------------------------------------------------------------------------------------------\r
lf->lfStrikeOut = mfp->strikeout;\r
lf->lfCharSet = mfp->charset;\r
lf->lfOutPrecision = OUT_DEFAULT_PRECIS;\r
+\r
lf->lfClipPrecision = CLIP_DEFAULT_PRECIS;\r
lf->lfQuality = DEFAULT_QUALITY;\r
lf->lfPitchAndFamily = DEFAULT_PITCH|FF_DONTCARE;\r
COLORREF chroma = RGB(0xFF,0x00,0xFF);\r
RECT rc;\r
SIZE sz;\r
+\r
+\r
POINT pt;\r
int backColor = whitePieceColor; \r
int foreColor = blackPieceColor;\r
{ // correct board size to one where built-in pieces exist\r
if((v == VariantCapablanca || v == VariantGothic || v == VariantGrand || v == VariantCapaRandom || v == VariantJanus || v == VariantSuper)\r
&& (boardSize < SizePetite || boardSize > SizeBulky) // Archbishop and Chancellor available in entire middle range\r
+\r
|| (v == VariantShogi && boardSize != SizeModerate) // Japanese-style Shogi\r
|| v == VariantKnightmate || v == VariantSChess || v == VariantXiangqi || v == VariantSpartan\r
|| v == VariantShatranj || v == VariantMakruk || v == VariantGreat || v == VariantFairy || v == VariantLion ) {\r
pieceBitmap[1][WhiteLion] = DoLoadBitmap(hInst, "ln", squareSize, "o");\r
pieceBitmap[2][WhiteLion] = DoLoadBitmap(hInst, "ln", squareSize, "w");\r
\r
- if(gameInfo.variant == VariantShogi) { /* promoted Gold represemtations */\r
+ if(gameInfo.variant == VariantShogi && BOARD_HEIGHT != 7) { /* promoted Gold representations (but not in Tori!)*/\r
pieceBitmap[0][WhiteCannon] = DoLoadBitmap(hInst, "wp", squareSize, "s");\r
pieceBitmap[1][WhiteCannon] = DoLoadBitmap(hInst, "wp", squareSize, "o");\r
pieceBitmap[2][WhiteCannon] = DoLoadBitmap(hInst, "w", squareSize, "w");\r
else\r
if(dragInfo.from.x == BOARD_RGHT+1 )\r
board[dragInfo.from.y][dragInfo.from.x-1]++;\r
+\r
board[dragInfo.from.y][dragInfo.from.x] = dragged_piece;\r
x = dragInfo.pos.x - squareSize / 2;\r
y = dragInfo.pos.y - squareSize / 2;\r
char promoChar;\r
\r
switch (message) {\r
+\r
case WM_INITDIALOG: /* message: initialize dialog box */\r
/* Center the dialog over the application window */\r
CenterWindow(hDlg, GetWindow(hDlg, GW_OWNER));\r
WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)\r
{\r
FARPROC lpProc;\r
- int wmId, wmEvent;\r
+ int wmId;\r
char *defName;\r
FILE *f;\r
UINT number;\r
\r
case WM_COMMAND: /* message: command from application menu */\r
wmId = LOWORD(wParam);\r
- wmEvent = HIWORD(wParam);\r
\r
switch (wmId) {\r
case IDM_NewGame:\r
}\r
break;\r
\r
+ case IDM_SaveSelected:\r
+ f = OpenFileDialog(hwnd, "a", "",\r
+ "pgn",\r
+ GAME_FILT,\r
+ _("Save Game to File"), NULL, fileTitle, NULL);\r
+ if (f != NULL) {\r
+ SaveSelected(f, 0, "");\r
+ }\r
+ break;\r
+\r
case IDM_CreateBook:\r
CreateBookEvent();\r
break;\r
if( hwnd == hwndMain && appData.useStickyWindows ) {\r
LPWINDOWPOS lpwp = (LPWINDOWPOS) lParam;\r
\r
- if( ((lpwp->flags & SWP_NOMOVE) == 0) && ((lpwp->flags & SWP_NOSIZE) != 0) ) {\r
+ if( ((lpwp->flags & SWP_NOMOVE) == 0) /*&& ((lpwp->flags & SWP_NOSIZE) != 0)*/ ) { // [HGM] in Win8 size always accompanies move?\r
/* Window is moving */\r
RECT rcMain;\r
\r
default: /* Passes it on if unprocessed */\r
return (DefWindowProc(hwnd, message, wParam, lParam));\r
}\r
+\r
+\r
return 0;\r
}\r
\r
CommentDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)\r
{\r
static HANDLE hwndText = NULL;\r
- int len, newSizeX, newSizeY, flags;\r
+ int len, newSizeX, newSizeY;\r
static int sizeX, sizeY;\r
char *str;\r
RECT rect;\r
/* Size and position the dialog */\r
if (!commentDialog) {\r
commentDialog = hDlg;\r
- flags = SWP_NOZORDER;\r
GetClientRect(hDlg, &rect);\r
sizeX = rect.right;\r
sizeY = rect.bottom;\r
LRESULT CALLBACK\r
ErrorDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)\r
{\r
- HANDLE hwndText;\r
RECT rChild;\r
\r
switch (message) {\r
\r
errorDialog = hDlg;\r
SetWindowText(hDlg, errorTitle);\r
- hwndText = GetDlgItem(hDlg, OPT_ErrorText);\r
SetDlgItemText(hDlg, OPT_ErrorText, errorMessage);\r
return FALSE;\r
\r
LRESULT CALLBACK\r
GothicDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)\r
{\r
- HANDLE hwndText;\r
RECT rChild;\r
int height = GetSystemMetrics(SM_CYCAPTION)+GetSystemMetrics(SM_CYFRAME);\r
\r
*/\r
gothicDialog = hDlg;\r
SetWindowText(hDlg, errorTitle);\r
- hwndText = GetDlgItem(hDlg, OPT_ErrorText);\r
SetDlgItemText(hDlg, OPT_ErrorText, errorMessage);\r
return FALSE;\r
\r
result = DialogBoxParam( hInst, MAKEINTRESOURCE(DLG_GameListOptions), hwndMain, (DLGPROC)lpProc, (LPARAM)lpUserGLT );\r
\r
if( result == 0 ) {\r
+ char *oldTags = appData.gameListTags;\r
/* [AS] Memory leak here! */\r
appData.gameListTags = strdup( lpUserGLT ); \r
+ if(strcmp(oldTags, appData.gameListTags)) // [HGM] redo Game List when we changed something\r
+ GameListToListBox(NULL, TRUE, ".", NULL, FALSE, FALSE); // "." as filter is kludge to select all\r
}\r
\r
return result;\r
int outCount = SOCKET_ERROR;\r
ChildProc *cp = (ChildProc *) pr;\r
static OVERLAPPED ovl;\r
+\r
static int line = 0;\r
\r
if (pr == NoProc)\r
ov.OffsetHigh = 0;\r
switch(code) {\r
case 1: LockFileEx(hFile, LOCKFILE_EXCLUSIVE_LOCK, 0, 1024, 0, &ov); break; // LOCK_SH\r
+\r
case 2: LockFileEx(hFile, LOCKFILE_EXCLUSIVE_LOCK, 0, 1024, 0, &ov); break; // LOCK_EX\r
case 3: UnlockFileEx(hFile, 0, 1024, 0, &ov); break; // LOCK_UN\r
default: return -1;\r