Merge branch 'v4.8.x'
[xboard.git] / winboard / wsettings.c
index bbf9003..c825d24 100644 (file)
@@ -456,6 +456,7 @@ GetOptionValues(HWND hDlg, ChessProgramState *cps, Option *optionList)
 }\r
 \r
 char *defaultExt[] = { NULL, "pgn", "fen", "exe", "trn", "bin", "log", "ini" };\r
+HWND settingsDlg;\r
 \r
 LRESULT CALLBACK SettingsProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)\r
 {\r
@@ -468,7 +469,7 @@ LRESULT CALLBACK SettingsProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lPa
 \r
 //        CenterWindow(hDlg, GetWindow(hDlg, GW_OWNER));\r
        SetOptionValues(hDlg, activeCps, activeList);\r
-\r
+       settingsDlg = hDlg;\r
         SetFocus(GetDlgItem(hDlg, IDCANCEL));\r
 \r
         break;\r
@@ -478,12 +479,12 @@ LRESULT CALLBACK SettingsProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lPa
         case IDOK:\r
            if(!GetOptionValues(hDlg, activeCps, activeList)) return FALSE;\r
             EndDialog( hDlg, 0 );\r
-           comboCallback = NULL; activeCps = NULL;\r
+           comboCallback = NULL; activeCps = NULL; settingsDlg = NULL;\r
             return TRUE;\r
 \r
         case IDCANCEL:\r
             EndDialog( hDlg, 1 );\r
-           comboCallback = NULL; activeCps = NULL;\r
+           comboCallback = NULL; activeCps = NULL; settingsDlg = NULL;\r
             return TRUE;\r
 \r
        default:\r
@@ -692,6 +693,19 @@ EngineOptionsPopup(HWND hwnd, ChessProgramState *cps)
     return;\r
 }\r
 \r
+void\r
+RefreshSettingsDialog (ChessProgramState *cps, int val)\r
+{\r
+    int isUp = (settingsDlg != NULL);\r
+    if(val == 1) {\r
+       if(activeCps == cps && isUp) SetOptionValues(settingsDlg, cps, activeList);\r
+       return;\r
+    }\r
+    if(settingsDlg) EndDialog(settingsDlg, 1);\r
+    comboCallback = NULL; activeCps = NULL; settingsDlg = NULL;\r
+    if(val == 3 || isUp) EngineOptionsPopup(hwndMain, cps);\r
+}\r
+\r
 int EnterGroup P((HWND hDlg));\r
 \r
 static int engineNr, selected;\r
@@ -887,6 +901,7 @@ int MatchOK()
 \r
 void PseudoOK(HWND hDlg)\r
 {\r
+    if(matchMode) return;\r
     okFunc = 0;\r
     GetOptionValues(hDlg, activeCps, activeList);\r
     EndDialog( hDlg, 0 );\r
@@ -894,7 +909,12 @@ void PseudoOK(HWND hDlg)
 \r
     if(autoinc) appData.loadGameIndex = appData.loadPositionIndex = -(twice + 1); else\r
     if(!appData.loadGameFile[0]) appData.loadGameIndex = -2*twice; // kludge to pass value of "twice" for use in GUI book\r
+    if(!autoinc && !twice) { // prevent auto-inc being remembered in index value if checkboxes not ticked\r
+       if(appData.loadGameIndex < 0) appData.loadGameIndex = 0;\r
+       if(appData.loadPositionIndex < 0) appData.loadPositionIndex = 0;\r
+    }\r
     if(swiss) { appData.defaultMatchGames = 1; appData.tourneyType = -1; }\r
+    ASSIGN(appData.tourneyFile, tfName);\r
 }\r
 \r
 char *GetParticipants(HWND hDlg)\r