Implement engine-requested settings-popup WB
authorH.G.Muller <hgm@hgm-xboard.(none)>
Mon, 1 Feb 2016 19:45:14 +0000 (20:45 +0100)
committerH.G.Muller <hgm@hgm-xboard.(none)>
Mon, 1 Feb 2016 20:50:39 +0000 (21:50 +0100)
winboard/wsettings.c

index eb04e41..8790bcc 100644 (file)
@@ -455,6 +455,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
@@ -467,7 +468,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
@@ -477,12 +478,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
@@ -691,6 +692,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