changes from H.G. Muller; version 4.3.15
[xboard.git] / winboard / woptions.c
index b2bbf0a..0941cce 100644 (file)
@@ -214,11 +214,17 @@ GeneralOptionsDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
       appData.popupMoveErrors      = IS_CHECKED(OPT_PopupMoveErrors);\r
       appData.showButtonBar        = IS_CHECKED(OPT_ShowButtonBar);\r
       appData.showCoords           = IS_CHECKED(OPT_ShowCoordinates);\r
-      ShowThinkingEvent(             IS_CHECKED(OPT_ShowThinking));\r
-      appData.testLegality         = IS_CHECKED(OPT_TestLegality);\r
-      appData.hideThinkingFromHuman= IS_CHECKED(OPT_HideThinkFromHuman);\r
+      // [HGM] thinking: next three moved up\r
       appData.saveExtendedInfoInPGN= IS_CHECKED(OPT_SaveExtPGN);\r
+      appData.hideThinkingFromHuman= IS_CHECKED(OPT_HideThinkFromHuman);\r
       appData.showEvalInMoveHistory= IS_CHECKED(OPT_ExtraInfoInMoveHistory);\r
+#if 0\r
+      ShowThinkingEvent(             IS_CHECKED(OPT_ShowThinking));\r
+#else\r
+      appData.showThinking         = IS_CHECKED(OPT_ShowThinking);\r
+      ShowThinkingEvent(); // [HGM] thinking: tests four options\r
+#endif\r
+      appData.testLegality         = IS_CHECKED(OPT_TestLegality);\r
       appData.highlightMoveWithArrow=IS_CHECKED(OPT_HighlightMoveArrow);\r
 \r
 #undef IS_CHECKED\r
@@ -778,7 +784,7 @@ VariantWhichRadio(HWND hDlg)
          (IsDlgButtonChecked(hDlg, OPT_VariantCylinder) ? VariantCylinder :\r
          (IsDlgButtonChecked(hDlg, OPT_VariantFalcon) ? VariantFalcon :\r
          (IsDlgButtonChecked(hDlg, OPT_VariantCRC) ? VariantCapaRandom :\r
-         (IsDlgButtonChecked(hDlg, OPT_Variant3Checks) ? Variant3Check :\r
+         (IsDlgButtonChecked(hDlg, OPT_VariantSuper) ? VariantSuper :\r
          (IsDlgButtonChecked(hDlg, OPT_VariantBerolina) ? VariantBerolina :\r
          (IsDlgButtonChecked(hDlg, OPT_VariantJanus) ? VariantJanus :\r
          (IsDlgButtonChecked(hDlg, OPT_VariantWildcastle) ? VariantWildCastle :\r
@@ -859,7 +865,8 @@ NewVariantDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
       CheckDlgButton(hDlg, OPT_VariantCylinder, TRUE);\r
       break;\r
     case Variant3Check:\r
-      CheckDlgButton(hDlg, OPT_Variant3Checks, TRUE);\r
+    case VariantSuper:\r
+      CheckDlgButton(hDlg, OPT_VariantSuper, TRUE);\r
       break;\r
     case VariantBerolina:\r
       CheckDlgButton(hDlg, OPT_VariantBerolina, TRUE);\r
@@ -899,6 +906,18 @@ NewVariantDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
       EndDialog(hDlg, TRUE);\r
 \r
       v = VariantWhichRadio(hDlg);\r
+      if(!appData.noChessProgram) { char *name = VariantName(v), buf[MSG_SIZ];\r
+       if (first.protocolVersion > 1 && StrStr(first.variants, name) == NULL) {\r
+           /* [HGM] in protocol 2 we check if variant is suported by engine */\r
+           sprintf(buf, "Variant %s not supported by %s", name, first.tidy);\r
+           DisplayError(buf, 0);\r
+           return TRUE; /* treat as "Cancel" if first engine does not support it */\r
+       } else\r
+       if (second.initDone && second.protocolVersion > 1 && StrStr(second.variants, name) == NULL) {\r
+           sprintf(buf, "Warning: second engine (%s) does not support this!", second.tidy);\r
+           DisplayError(buf, 0);   /* use of second engine is optional; only warn user */\r
+       }\r
+      }\r
 \r
       gameInfo.variant = v;\r
       appData.variant = VariantName(v);\r
@@ -2584,8 +2603,8 @@ LRESULT CALLBACK
 TimeControl(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)\r
 {\r
   char buf[MSG_SIZ];\r
-  int mps, increment;\r
-  BOOL ok;\r
+  int mps, increment, odds1, odds2;\r
+  BOOL ok, ok2;\r
 \r
   switch (message) {\r
   case WM_INITDIALOG: /* message: initialize dialog box */\r
@@ -2609,6 +2628,8 @@ TimeControl(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
        SetDlgItemText(hDlg, OPT_TCTime2, appData.timeControl);\r
        SetDlgItemInt(hDlg, OPT_TCInc, appData.timeIncrement, FALSE);\r
       }\r
+      SetDlgItemInt(hDlg, OPT_TCOdds1, 1, FALSE);\r
+      SetDlgItemInt(hDlg, OPT_TCOdds2, 1, FALSE);\r
       SetTimeControlEnables(hDlg);\r
     }\r
     return TRUE;\r
@@ -2646,9 +2667,18 @@ TimeControl(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
          return FALSE;\r
        }\r
       }\r
+      odds1 = GetDlgItemInt(hDlg, OPT_TCOdds1, &ok, FALSE);\r
+      odds2 = GetDlgItemInt(hDlg, OPT_TCOdds2, &ok2, FALSE);\r
+      if (!ok || !ok2 || odds1 <= 0 || odds2 <= 0) {\r
+         MessageBox(hDlg, "Invalid time-odds factor",\r
+                    "Option Error", MB_OK|MB_ICONEXCLAMATION);\r
+         return FALSE;\r
+      }\r
       appData.timeControl = strdup(buf);\r
       appData.movesPerSession = mps;\r
       appData.timeIncrement = increment;\r
+      appData.firstTimeOdds  = first.timeOdds  = odds1;\r
+      appData.secondTimeOdds = second.timeOdds = odds2;\r
       Reset(TRUE, TRUE);\r
       EndDialog(hDlg, TRUE);\r
       return TRUE;\r
@@ -2707,6 +2737,9 @@ LRESULT CALLBACK EnginePlayOptionsDialog(HWND hDlg, UINT message, WPARAM wParam,
     CHECK_BOX(IDC_MaterialDraws, appData.materialDraws);\r
     CHECK_BOX(IDC_TrivialDraws, appData.trivialDraws);\r
 \r
+    CHECK_BOX(IDC_ScoreAbs1, appData.firstScoreIsAbsolute);\r
+    CHECK_BOX(IDC_ScoreAbs2, appData.secondScoreIsAbsolute);\r
+\r
     SetDlgItemInt( hDlg, IDC_EpDrawMoveCount, appData.adjudicateDrawMoves, TRUE );\r
     SendDlgItemMessage( hDlg, IDC_EpDrawMoveCount, EM_SETSEL, 0, -1 );\r
 \r
@@ -2727,8 +2760,13 @@ LRESULT CALLBACK EnginePlayOptionsDialog(HWND hDlg, UINT message, WPARAM wParam,
       /* Read changed options from the dialog box */\r
       PeriodicUpdatesEvent(          IS_CHECKED(IDC_EpPeriodicUpdates));\r
       PonderNextMoveEvent(           IS_CHECKED(IDC_EpPonder));\r
+      appData.hideThinkingFromHuman= IS_CHECKED(IDC_EpHideThinkingHuman); // [HGM] thinking: moved up\r
+#if 0\r
       ShowThinkingEvent(             IS_CHECKED(IDC_EpShowThinking));\r
-      appData.hideThinkingFromHuman= IS_CHECKED(IDC_EpHideThinkingHuman);\r
+#else\r
+      appData.showThinking   = IS_CHECKED(IDC_EpShowThinking);\r
+      ShowThinkingEvent(); // [HGM] thinking: tests all options that need thinking output\r
+#endif\r
       appData.testClaims    = IS_CHECKED(IDC_TestClaims);\r
       appData.checkMates    = IS_CHECKED(IDC_DetectMates);\r
       appData.materialDraws = IS_CHECKED(IDC_MaterialDraws);\r
@@ -2739,6 +2777,9 @@ LRESULT CALLBACK EnginePlayOptionsDialog(HWND hDlg, UINT message, WPARAM wParam,
       appData.ruleMoves = GetDlgItemInt(hDlg, IDC_RuleMoves, NULL, FALSE );\r
       appData.drawRepeats = (int) GetDlgItemInt(hDlg, IDC_DrawRepeats, NULL, FALSE );\r
 \r
+      appData.firstScoreIsAbsolute  = IS_CHECKED(IDC_ScoreAbs1);\r
+      appData.secondScoreIsAbsolute = IS_CHECKED(IDC_ScoreAbs2);\r
+\r
       EndDialog(hDlg, TRUE);\r
       return TRUE;\r
 \r
@@ -2816,6 +2857,7 @@ static BOOL BrowseForFolder( const char * title, char * path )
 LRESULT CALLBACK UciOptionsDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)\r
 {\r
   char buf[MAX_PATH];\r
+  int oldCores;\r
 \r
   switch (message) {\r
   case WM_INITDIALOG: /* message: initialize dialog box */\r
@@ -2830,6 +2872,11 @@ LRESULT CALLBACK UciOptionsDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM
     SetDlgItemInt( hDlg, IDC_SizeOfEGTB, appData.defaultCacheSizeEGTB, TRUE );\r
     CheckDlgButton( hDlg, IDC_UseBook, (BOOL) appData.usePolyglotBook );\r
     SetDlgItemText( hDlg, IDC_BookFile, appData.polyglotBook );\r
+    // [HGM] smp: input field for nr of cores:\r
+    SetDlgItemInt( hDlg, IDC_Cores, appData.smpCores, TRUE );\r
+    // [HGM] book: tick boxes for own book use\r
+    CheckDlgButton( hDlg, IDC_OwnBook1, (BOOL) appData.firstHasOwnBookUCI );\r
+    CheckDlgButton( hDlg, IDC_OwnBook2, (BOOL) appData.secondHasOwnBookUCI );\r
 \r
     SendDlgItemMessage( hDlg, IDC_PolyglotDir, EM_SETSEL, 0, -1 );\r
 \r
@@ -2847,7 +2894,15 @@ LRESULT CALLBACK UciOptionsDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM
       GetDlgItemText( hDlg, IDC_BookFile, buf, sizeof(buf) );\r
       appData.polyglotBook = strdup(buf);\r
       appData.usePolyglotBook = (Boolean) IsDlgButtonChecked( hDlg, IDC_UseBook );\r
-\r
+      // [HGM] smp: get nr of cores:\r
+      oldCores = appData.smpCores;\r
+      appData.smpCores = GetDlgItemInt(hDlg, IDC_Cores, NULL, FALSE );\r
+      if(appData.smpCores != oldCores) NewSettingEvent(FALSE, "cores", appData.smpCores);\r
+      // [HGM] book: read tick boxes for own book use\r
+      appData.firstHasOwnBookUCI  = (Boolean) IsDlgButtonChecked( hDlg, IDC_OwnBook1 );\r
+      appData.secondHasOwnBookUCI = (Boolean) IsDlgButtonChecked( hDlg, IDC_OwnBook2 );\r
+\r
+      if(gameMode == BeginningOfGame) Reset(TRUE, TRUE);\r
       EndDialog(hDlg, TRUE);\r
       return TRUE;\r
 \r