Allow match to be started from WB menu
[xboard.git] / winboard / woptions.c
index 09739e5..0f035b9 100644 (file)
@@ -1,7 +1,7 @@
 /*\r
  * woptions.c -- Options dialog box routines for WinBoard\r
  *\r
- * Copyright 2000,2009 Free Software Foundation, Inc.\r
+ * Copyright 2000, 2009, 2010 Free Software Foundation, Inc.\r
  *\r
  * Enhancements Copyright 2005 Alessandro Scotti\r
  *\r
@@ -131,7 +131,6 @@ void SelectComboValue(HANDLE hwndCombo, ComboData *cd, unsigned value);
 VOID SetLoadOptionEnables(HWND hDlg);\r
 VOID SetSaveOptionEnables(HWND hDlg);\r
 VOID SetTimeControlEnables(HWND hDlg);\r
-void NewSettingEvent(int option, char *command, int value);\r
 \r
 /*---------------------------------------------------------------------------*\\r
  *\r
@@ -146,12 +145,14 @@ GeneralOptionsDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
   static Boolean oldShowCoords;\r
   static Boolean oldBlindfold;\r
   static Boolean oldShowButtonBar;\r
+  static Boolean oldAutoLogo;\r
 \r
   switch (message) {\r
   case WM_INITDIALOG: /* message: initialize dialog box */\r
     oldShowCoords = appData.showCoords;\r
     oldBlindfold  = appData.blindfold;\r
     oldShowButtonBar = appData.showButtonBar;\r
+    oldAutoLogo  = appData.autoLogo;\r
 \r
     /* Center the dialog over the application window */\r
     CenterWindow (hDlg, GetWindow (hDlg, GW_OWNER));\r
@@ -181,6 +182,7 @@ GeneralOptionsDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
     CHECK_BOX(OPT_SaveExtPGN, appData.saveExtendedInfoInPGN);\r
     CHECK_BOX(OPT_ExtraInfoInMoveHistory, appData.showEvalInMoveHistory);\r
     CHECK_BOX(OPT_HighlightMoveArrow, appData.highlightMoveWithArrow);\r
+    CHECK_BOX(OPT_AutoLogo, appData.autoLogo); // [HGM] logo\r
 \r
 #undef CHECK_BOX\r
 \r
@@ -228,6 +230,7 @@ GeneralOptionsDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
       ShowThinkingEvent(); // [HGM] thinking: tests four options\r
       appData.testLegality         = IS_CHECKED(OPT_TestLegality);\r
       appData.highlightMoveWithArrow=IS_CHECKED(OPT_HighlightMoveArrow);\r
+      appData.autoLogo             =IS_CHECKED(OPT_AutoLogo); // [HGM] logo\r
 \r
 #undef IS_CHECKED\r
 \r
@@ -249,7 +252,10 @@ GeneralOptionsDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
        */\r
       EndDialog(hDlg, TRUE);\r
 \r
-      if (oldShowButtonBar != appData.showButtonBar) {\r
+      if (oldAutoLogo != appData.autoLogo) { // [HGM] logo: remove any logos when we switch autologo off\r
+       if(oldAutoLogo) first.programLogo = second.programLogo = NULL;\r
+       InitDrawingSizes(boardSize, 0);\r
+      } else if (oldShowButtonBar != appData.showButtonBar) {\r
        InitDrawingSizes(boardSize, 0);\r
       } else if ((oldShowCoords != appData.showCoords) || \r
                 (oldBlindfold != appData.blindfold)) {\r
@@ -774,7 +780,8 @@ VariantWhichRadio(HWND hDlg)
          (IsDlgButtonChecked(hDlg, OPT_VariantGreat) ? VariantGreat :\r
          (IsDlgButtonChecked(hDlg, OPT_VariantGiveaway) ? VariantGiveaway :\r
          (IsDlgButtonChecked(hDlg, OPT_VariantTwilight) ? VariantTwilight :\r
-          VariantNormal ))))))))))))))))))))))))))));\r
+         (IsDlgButtonChecked(hDlg, OPT_VariantMakruk) ? VariantMakruk :\r
+          VariantNormal )))))))))))))))))))))))))))));\r
 }\r
 \r
 LRESULT CALLBACK\r
@@ -873,6 +880,9 @@ NewVariantDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
     case VariantTwilight:\r
       CheckDlgButton(hDlg, OPT_VariantTwilight, TRUE);\r
       break;\r
+    case VariantMakruk:\r
+      CheckDlgButton(hDlg, OPT_VariantMakruk, TRUE);\r
+      break;\r
     default: ;\r
     }\r
 \r
@@ -1166,11 +1176,17 @@ IcsOptionsDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
     /* Initialize the dialog items */\r
 #define CHECK_BOX(x,y) CheckDlgButton(hDlg, (x), (BOOL)(y))\r
 \r
+    CHECK_BOX(OPT_AutoKibitz, appData.autoKibitz);\r
     CHECK_BOX(OPT_AutoComment, appData.autoComment);\r
     CHECK_BOX(OPT_AutoObserve, appData.autoObserve);\r
     CHECK_BOX(OPT_GetMoveList, appData.getMoveList);\r
     CHECK_BOX(OPT_LocalLineEditing, appData.localLineEditing);\r
     CHECK_BOX(OPT_QuietPlay, appData.quietPlay);\r
+    CHECK_BOX(OPT_SeekGraph, appData.seekGraph);\r
+    CHECK_BOX(OPT_AutoRefresh, appData.autoRefresh);\r
+    CHECK_BOX(OPT_BgObserve, appData.bgObserve);\r
+    CHECK_BOX(OPT_DualBoard, appData.dualBoard);\r
+    CHECK_BOX(OPT_SmartMove, appData.oneClick);\r
     CHECK_BOX(OPT_Premove, appData.premove);\r
     CHECK_BOX(OPT_PremoveWhite, appData.premoveWhite);\r
     CHECK_BOX(OPT_PremoveBlack, appData.premoveBlack);\r
@@ -1183,6 +1199,7 @@ IcsOptionsDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
     SetDlgItemText(hDlg, OPT_IcsAlarmTime, buf);\r
     SetDlgItemText(hDlg, OPT_PremoveWhiteText, appData.premoveWhiteText);\r
     SetDlgItemText(hDlg, OPT_PremoveBlackText, appData.premoveBlackText);\r
+    SetDlgItemText(hDlg, OPT_StartupChatBoxes, appData.chatBoxes);\r
 \r
     SendDlgItemMessage(hDlg, OPT_SampleShout,     EM_SETBKGNDCOLOR, 0, cbc);\r
     SendDlgItemMessage(hDlg, OPT_SampleSShout,    EM_SETBKGNDCOLOR, 0, cbc);\r
@@ -1244,17 +1261,25 @@ IcsOptionsDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
       appData.premove          = IS_CHECKED(OPT_Premove);\r
       appData.premoveWhite     = IS_CHECKED(OPT_PremoveWhite);\r
       appData.premoveBlack     = IS_CHECKED(OPT_PremoveBlack);\r
+      appData.autoKibitz       = IS_CHECKED(OPT_AutoKibitz);\r
       appData.autoComment      = IS_CHECKED(OPT_AutoComment);\r
       appData.autoObserve      = IS_CHECKED(OPT_AutoObserve);\r
       appData.getMoveList      = IS_CHECKED(OPT_GetMoveList);\r
       appData.localLineEditing = IS_CHECKED(OPT_LocalLineEditing);\r
       appData.quietPlay        = IS_CHECKED(OPT_QuietPlay);\r
+      appData.seekGraph        = IS_CHECKED(OPT_SeekGraph);\r
+      appData.autoRefresh      = IS_CHECKED(OPT_AutoRefresh);\r
+      appData.bgObserve        = IS_CHECKED(OPT_BgObserve);\r
+      appData.dualBoard        = IS_CHECKED(OPT_DualBoard);\r
+      appData.oneClick         = IS_CHECKED(OPT_SmartMove);\r
 \r
 #undef IS_CHECKED\r
 \r
       appData.icsAlarmTime = number * 1000;\r
       GetDlgItemText(hDlg, OPT_PremoveWhiteText, appData.premoveWhiteText, 5);\r
       GetDlgItemText(hDlg, OPT_PremoveBlackText, appData.premoveBlackText, 5);\r
+      GetDlgItemText(hDlg, OPT_StartupChatBoxes, buf, sizeof(buf));\r
+      buf[sizeof(buf)-1] = NULLCHAR; appData.chatBoxes = StrSave(buf); // memory leak\r
 \r
       if (appData.localLineEditing) {\r
        DontEcho();\r
@@ -2893,6 +2918,9 @@ LRESULT CALLBACK UciOptionsDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM
     // [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
+    SetDlgItemInt( hDlg, IDC_BookDep, appData.bookDepth, TRUE );\r
+    SetDlgItemInt( hDlg, IDC_BookStr, appData.bookStrength, TRUE );\r
+    SetDlgItemInt( hDlg, IDC_Games, appData.defaultMatchGames, TRUE );\r
 \r
     SendDlgItemMessage( hDlg, IDC_PolyglotDir, EM_SETSEL, 0, -1 );\r
 \r
@@ -2913,10 +2941,13 @@ LRESULT CALLBACK UciOptionsDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM
       // [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
+      if(appData.smpCores != oldCores) NewSettingEvent(FALSE, &(first.maxCores), "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
+      appData.bookDepth = GetDlgItemInt(hDlg, IDC_BookDep, NULL, FALSE );\r
+      appData.bookStrength = GetDlgItemInt(hDlg, IDC_BookStr, NULL, FALSE );\r
+      appData.defaultMatchGames = GetDlgItemInt(hDlg, IDC_Games, NULL, FALSE );\r
 \r
       if(gameMode == BeginningOfGame) Reset(TRUE, TRUE);\r
       EndDialog(hDlg, TRUE);\r