updated year in copyright info
[xboard.git] / winboard / woptions.c
index b2bbf0a..461ce73 100644 (file)
@@ -1,25 +1,27 @@
 /*\r
  * woptions.c -- Options dialog box routines for WinBoard\r
- * $Id: woptions.c,v 2.1 2003/10/27 19:21:02 mann Exp $\r
  *\r
- * Copyright 2000 Free Software Foundation, Inc.\r
+ * Copyright 2000, 2009, 2010 Free Software Foundation, Inc.\r
+ *\r
+ * Enhancements Copyright 2005 Alessandro Scotti\r
  *\r
  * ------------------------------------------------------------------------\r
- * This program is free software; you can redistribute it and/or modify\r
+ *\r
+ * GNU XBoard is free software: you can redistribute it and/or modify\r
  * it under the terms of the GNU General Public License as published by\r
- * the Free Software Foundation; either version 2 of the License, or\r
- * (at your option) any later version.\r
+ * the Free Software Foundation, either version 3 of the License, or (at\r
+ * your option) any later version.\r
  *\r
- * This program is distributed in the hope that it will be useful,\r
- * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
- * GNU General Public License for more details.\r
+ * GNU XBoard is distributed in the hope that it will be useful, but\r
+ * WITHOUT ANY WARRANTY; without even the implied warranty of\r
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\r
+ * General Public License for more details.\r
  *\r
  * You should have received a copy of the GNU General Public License\r
- * along with this program; if not, write to the Free Software\r
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.\r
- * ------------------------------------------------------------------------\r
- */\r
+ * along with this program. If not, see http://www.gnu.org/licenses/.  *\r
+ *\r
+ *------------------------------------------------------------------------\r
+ ** See the file ChangeLog for a revision history.  */\r
 \r
 #include "config.h"\r
 \r
 #include <stdio.h>\r
 #include <stdlib.h>\r
 #include <shlobj.h>    /* [AS] Requires NT 4.0 or Win95 */\r
+#include <ctype.h>\r
 \r
 #include "common.h"\r
+#include "frontend.h"\r
 #include "winboard.h"\r
 #include "backend.h"\r
 #include "woptions.h"\r
 #include "defaults.h"\r
-#include "wedittags.h"\r
 #include <richedit.h>\r
 \r
 #if __GNUC__\r
@@ -61,11 +64,13 @@ extern HWND hwndConsole;
 extern char *defaultTextAttribs[];\r
 extern HWND commentDialog;\r
 extern HWND moveHistoryDialog;\r
+extern HWND engineOutputDialog;\r
 extern char installDir[];\r
 extern HWND hCommPort;    /* currently open comm port */\r
 extern DCB dcb;\r
 extern BOOLEAN chessProgram;\r
-extern startedFromPositionFile; /* [HGM] loadPos */\r
+extern int startedFromPositionFile; /* [HGM] loadPos */\r
+extern int searchTime;\r
 \r
 /* types */\r
 \r
@@ -126,6 +131,7 @@ 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
@@ -214,11 +220,13 @@ 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
+      appData.showThinking         = IS_CHECKED(OPT_ShowThinking);\r
+      ShowThinkingEvent(); // [HGM] thinking: tests four options\r
+      appData.testLegality         = IS_CHECKED(OPT_TestLegality);\r
       appData.highlightMoveWithArrow=IS_CHECKED(OPT_HighlightMoveArrow);\r
 \r
 #undef IS_CHECKED\r
@@ -304,7 +312,7 @@ PaintSampleSquare(
   HBRUSH  brushSquareOutline;\r
   HBRUSH  brushPiece;\r
   HBRUSH  brushPieceDetail;\r
-  HBRUSH  oldBrushPiece;\r
+  HBRUSH  oldBrushPiece = NULL;\r
   HBRUSH  oldBrushSquare;\r
   HBITMAP oldBitmapMem;\r
   HBITMAP oldBitmapTemp;\r
@@ -362,38 +370,16 @@ PaintSampleSquare(
       oldBrushPiece = SelectObject(hdcMem, brushPiece);\r
       BitBlt(hdcMem, x, y, SAMPLE_SQ_SIZE, SAMPLE_SQ_SIZE, \r
             hdcTemp, 0, 0, 0x00B8074A);\r
-#if 0\r
-      /* Use pieceDetailColor for outline of white pieces */\r
-      SelectObject(hdcTemp, pieces[OUTLINE]);\r
-      SelectObject(hdcMem, brushPieceDetail);\r
-      BitBlt(hdcMem, x, y, SAMPLE_SQ_SIZE, SAMPLE_SQ_SIZE, \r
-            hdcTemp, 0, 0, 0x00B8074A);\r
-#else\r
       /* Use black for outline of white pieces */\r
       SelectObject(hdcTemp, pieces[OUTLINE]);\r
       BitBlt(hdcMem, x, y, SAMPLE_SQ_SIZE, SAMPLE_SQ_SIZE, \r
             hdcTemp, 0, 0, SRCAND);\r
-#endif\r
     } else {\r
-#if 0\r
-      /* Use pieceDetailColor for details of black pieces */\r
-      /* Requires filled-in solid bitmaps (BLACK_PIECE class); the\r
-        WHITE_PIECE ones aren't always the right shape. */\r
-      oldBitmapTemp = SelectObject(hdcTemp, pieces[BLACK]);\r
-      oldBrushPiece = SelectObject(hdcMem, brushPieceDetail);\r
-      BitBlt(hdcMem, x, y, SAMPLE_SQ_SIZE, SAMPLE_SQ_SIZE, \r
-            hdcTemp, 0, 0, 0x00B8074A);\r
-      SelectObject(hdcTemp, pieces[SOLID]);\r
-      SelectObject(hdcMem, brushPiece);\r
-      BitBlt(hdcMem, x, y, SAMPLE_SQ_SIZE, SAMPLE_SQ_SIZE, \r
-            hdcTemp, 0, 0, 0x00B8074A);\r
-#else\r
       /* Use square color for details of black pieces */\r
       oldBitmapTemp = SelectObject(hdcTemp, pieces[SOLID]);\r
       oldBrushPiece = SelectObject(hdcMem, brushPiece);\r
       BitBlt(hdcMem, x, y, SAMPLE_SQ_SIZE, SAMPLE_SQ_SIZE, \r
             hdcTemp, 0, 0, 0x00B8074A);\r
-#endif\r
     }\r
     SelectObject(hdcMem, oldBrushPiece);\r
     SelectObject(hdcTemp, oldBitmapTemp);\r
@@ -560,6 +546,7 @@ BoardOptionsDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
       break;\r
     case SizeTitanic:\r
       CheckDlgButton(hDlg, OPT_SizeTitanic, TRUE);\r
+    default: ; // should not happen, but suppresses warning on pedantic compilers\r
     }\r
 \r
     if (appData.monoMode)\r
@@ -778,21 +765,23 @@ 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
          (IsDlgButtonChecked(hDlg, OPT_VariantNocastle) ? VariantNoCastle :\r
-          VariantNormal ))))))))))))))))))))))));\r
+         (IsDlgButtonChecked(hDlg, OPT_Variant3Check) ? Variant3Check :\r
+         (IsDlgButtonChecked(hDlg, OPT_VariantGreat) ? VariantGreat :\r
+         (IsDlgButtonChecked(hDlg, OPT_VariantGiveaway) ? VariantGiveaway :\r
+         (IsDlgButtonChecked(hDlg, OPT_VariantTwilight) ? VariantTwilight :\r
+         (IsDlgButtonChecked(hDlg, OPT_VariantMakruk) ? VariantMakruk :\r
+          VariantNormal )))))))))))))))))))))))))))));\r
 }\r
 \r
 LRESULT CALLBACK\r
 NewVariantDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)\r
 {\r
-  static Boolean  mono;\r
   static VariantClass v;\r
-  static COLORREF lsc, dsc, wpc, bpc, hsc, phc;\r
-  static HBITMAP pieces[3];\r
   static int n1_ok, n2_ok, n3_ok;\r
 \r
   switch (message) {\r
@@ -859,7 +848,10 @@ 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
+      CheckDlgButton(hDlg, OPT_Variant3Check, TRUE);\r
+      break;\r
+    case VariantSuper:\r
+      CheckDlgButton(hDlg, OPT_VariantSuper, TRUE);\r
       break;\r
     case VariantBerolina:\r
       CheckDlgButton(hDlg, OPT_VariantBerolina, TRUE);\r
@@ -873,6 +865,19 @@ NewVariantDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
     case VariantNoCastle:\r
       CheckDlgButton(hDlg, OPT_VariantNocastle, TRUE);\r
       break;\r
+    case VariantGreat:\r
+      CheckDlgButton(hDlg, OPT_VariantGreat, TRUE);\r
+      break;\r
+    case VariantGiveaway:\r
+      CheckDlgButton(hDlg, OPT_VariantGiveaway, TRUE);\r
+      break;\r
+    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
     SetDlgItemInt( hDlg, IDC_Files, -1, TRUE );\r
@@ -899,6 +904,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
@@ -998,6 +1015,7 @@ MyCreateFont(HWND hwnd, MyFont *font)
   font->mfp.italic = font->lf.lfItalic;\r
   font->mfp.underline = font->lf.lfUnderline;\r
   font->mfp.strikeout = font->lf.lfStrikeOut;\r
+  font->mfp.charset = font->lf.lfCharSet;\r
   strcpy(font->mfp.faceName, font->lf.lfFaceName);\r
   return TRUE;\r
 }\r
@@ -1009,7 +1027,7 @@ UpdateSampleText(HWND hDlg, int id, MyColorizeAttribs *mca)
   CHARFORMAT cf;\r
   cf.cbSize = sizeof(CHARFORMAT);\r
   cf.dwMask = \r
-    CFM_COLOR|CFM_BOLD|CFM_ITALIC|CFM_UNDERLINE|CFM_STRIKEOUT|CFM_FACE|CFM_SIZE;\r
+    CFM_COLOR|CFM_CHARSET|CFM_BOLD|CFM_ITALIC|CFM_UNDERLINE|CFM_STRIKEOUT|CFM_FACE|CFM_SIZE;\r
   cf.crTextColor = mca->color;\r
   cf.dwEffects = mca->effects;\r
   strcpy(cf.szFaceName, font[boardSize][CONSOLE_FONT]->mfp.faceName);\r
@@ -1253,7 +1271,9 @@ IcsOptionsDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
       appData.colorize =\r
        (Boolean)!IsDlgButtonChecked(hDlg, OPT_DontColorize);\r
 \r
-      if (!appData.colorize) {\r
+    ChangedConsoleFont();\r
+\r
+    if (!appData.colorize) {\r
        CHARFORMAT cf;\r
        COLORREF background = ParseColorName(COLOR_BKGD);\r
        /*\r
@@ -1452,21 +1472,6 @@ SetSampleFontText(HWND hwnd, int id, const MyFont *mf)
   rectFormat.left   = center.x - (size.cx / 2) - 1;\r
   rectFormat.right  = center.x + (size.cx / 2) + 1;\r
 \r
-#if 0\r
-  fprintf(debugFP, "\nfont: %s\n"\r
-                   "center.x   %d, centerY %d\n"\r
-                  "size.cx    %d, size.cy %d\n"\r
-                  "client.top %d, bottom %d, left %d, right %d\n"\r
-                  "format.top %d, bottom %d, left %d, right %d\n",\r
-                  buf,\r
-                  center.x, center.y,\r
-                  size.cx, size.cy,\r
-                  rectClient.top, rectClient.bottom, rectClient.left,\r
-                  rectClient.right,\r
-                  rectFormat.top, rectFormat.bottom, rectFormat.left,\r
-                  rectFormat.right);\r
-#endif\r
-\r
   cf.cbSize = sizeof(CHARFORMAT);\r
   cf.dwMask = CFM_FACE|CFM_SIZE|CFM_CHARSET|CFM_BOLD|CFM_ITALIC;\r
   cf.dwEffects = 0;\r
@@ -1498,6 +1503,7 @@ CopyFont(MyFont *dest, const MyFont *src)
   dest->mfp.italic    = src->mfp.italic;\r
   dest->mfp.underline = src->mfp.underline;\r
   dest->mfp.strikeout = src->mfp.strikeout;\r
+  dest->mfp.charset   = src->mfp.charset;\r
   lstrcpy(dest->mfp.faceName, src->mfp.faceName);\r
   CreateFontInMF(dest);\r
 }\r
@@ -1598,7 +1604,17 @@ FontOptionsDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
        SendDlgItemMessage(moveHistoryDialog, IDC_MoveHistory,\r
          WM_SETFONT, (WPARAM)font[boardSize][MOVEHISTORY_FONT]->hf, \r
          MAKELPARAM(TRUE, 0));\r
-       InvalidateRect(editTagsDialog, NULL, TRUE);\r
+        SendMessage( moveHistoryDialog, WM_INITDIALOG, 0, 0 );\r
+//     InvalidateRect(editTagsDialog, NULL, TRUE); // [HGM] this ws improperly cloned?\r
+      }\r
+\r
+      if( engineOutputDialog != NULL ) {\r
+       SendDlgItemMessage(engineOutputDialog, IDC_EngineMemo1,\r
+         WM_SETFONT, (WPARAM)font[boardSize][MOVEHISTORY_FONT]->hf, \r
+         MAKELPARAM(TRUE, 0));\r
+       SendDlgItemMessage(engineOutputDialog, IDC_EngineMemo2,\r
+         WM_SETFONT, (WPARAM)font[boardSize][MOVEHISTORY_FONT]->hf, \r
+         MAKELPARAM(TRUE, 0));\r
       }\r
 \r
       if (hwndConsole) {\r
@@ -1751,7 +1767,7 @@ InitSoundCombo(HWND hwndCombo, SoundComboData *scd)
     err = SendMessage(hwndCombo, CB_ADDSTRING, 0, (LPARAM) scd->label);\r
     if (err != cnt++) {\r
       sprintf(buf, "InitSoundCombo(): err '%d', cnt '%d'\n",\r
-         err, cnt);\r
+         (int)err, (int)cnt);\r
       MessageBox(NULL, buf, NULL, MB_OK);\r
     }\r
     scd++;\r
@@ -1870,6 +1886,7 @@ SoundOptionsDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
   SoundClass sc;\r
   ColorClass cc;\r
   SoundComboData *scd;\r
+  int oldMute;\r
 \r
   switch (message) {\r
   case WM_INITDIALOG:\r
@@ -1950,6 +1967,8 @@ SoundOptionsDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
        }\r
       }\r
 \r
+       mute = FALSE; // [HGM] mute: switch sounds automatically on if we select one\r
+      CheckMenuItem(GetMenu(hwndMain),IDM_MuteSounds,MF_BYCOMMAND|MF_UNCHECKED);\r
       ResetSoundComboData(soundComboData);\r
       EndDialog(hDlg, TRUE);\r
       return TRUE;\r
@@ -1979,8 +1998,10 @@ SoundOptionsDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
       tmp.name = strdup(SoundDialogGetName(hDlg, radio));\r
       tmp.data = NULL;\r
       MyLoadSound(&tmp);\r
+       oldMute = mute; mute = FALSE; // [HGM] mute: always sound when user presses play, ignorig mute setting\r
       MyPlaySound(&tmp);\r
-      if (tmp.data  != NULL) free(tmp.data);\r
+       mute = oldMute;\r
+      if (tmp.data  != NULL) FreeResource(tmp.data); // technically obsolete fn, but tmp.data is NOT malloc'd mem\r
       if (tmp.name != NULL) free(tmp.name);\r
       return TRUE;\r
 \r
@@ -2146,7 +2167,7 @@ VOID PrintCommSettings(FILE *f, char *name, DCB *dcb)
     flow = cdFlow[FLOW_NONE].label;\r
   }\r
   fprintf(f, "/%s=%d,%d,%s,%s,%s\n", name,\r
-    dcb->BaudRate, dcb->ByteSize, parity, stopBits, flow);\r
+    (int)dcb->BaudRate, dcb->ByteSize, parity, stopBits, flow);\r
 }\r
 \r
 \r
@@ -2208,7 +2229,7 @@ CommPortOptionsDialog(HWND hDlg, UINT message, WPARAM wParam,     LPARAM lParam)
 \r
     hwndCombo = GetDlgItem(hDlg, OPT_DataRate);\r
     InitCombo(hwndCombo, cdDataRate);\r
-    sprintf(buf, "%u", dcb.BaudRate);\r
+    sprintf(buf, "%u", (int)dcb.BaudRate);\r
     if (SendMessage(hwndCombo, CB_SELECTSTRING, (WPARAM) -1, (LPARAM) buf) == CB_ERR) {\r
       SendMessage(hwndCombo, CB_SETCURSEL, (WPARAM) -1, (LPARAM) 0);\r
       SendMessage(hwndCombo, WM_SETTEXT, (WPARAM) 0, (LPARAM) buf);\r
@@ -2567,25 +2588,28 @@ SetTimeControlEnables(HWND hDlg)
 {\r
   UINT state;\r
 \r
-  state = IsDlgButtonChecked(hDlg, OPT_TCUseMoves);\r
-  EnableWindow(GetDlgItem(hDlg, OPT_TCTime), state);\r
-  EnableWindow(GetDlgItem(hDlg, OPT_TCMoves), state);\r
-  EnableWindow(GetDlgItem(hDlg, OPT_TCtext1), state);\r
-  EnableWindow(GetDlgItem(hDlg, OPT_TCtext2), state);\r
+  state = IsDlgButtonChecked(hDlg, OPT_TCUseMoves)\r
+       + 2*IsDlgButtonChecked(hDlg, OPT_TCUseFixed);\r
+  EnableWindow(GetDlgItem(hDlg, OPT_TCTime), state == 1);\r
+  EnableWindow(GetDlgItem(hDlg, OPT_TCMoves), state == 1);\r
+  EnableWindow(GetDlgItem(hDlg, OPT_TCtext1), state == 1);\r
+  EnableWindow(GetDlgItem(hDlg, OPT_TCtext2), state == 1);\r
   EnableWindow(GetDlgItem(hDlg, OPT_TCTime2), !state);\r
   EnableWindow(GetDlgItem(hDlg, OPT_TCInc), !state);\r
   EnableWindow(GetDlgItem(hDlg, OPT_TCitext1), !state);\r
   EnableWindow(GetDlgItem(hDlg, OPT_TCitext2), !state);\r
   EnableWindow(GetDlgItem(hDlg, OPT_TCitext3), !state);\r
+  EnableWindow(GetDlgItem(hDlg, OPT_TCFixed), state == 2);\r
+  EnableWindow(GetDlgItem(hDlg, OPT_TCftext), state == 2);\r
 }\r
 \r
 \r
 LRESULT CALLBACK\r
 TimeControl(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)\r
 {\r
-  char buf[MSG_SIZ];\r
-  int mps, increment;\r
-  BOOL ok;\r
+  char buf[MSG_SIZ], *tc;\r
+  int mps, increment, odds1, odds2, st;\r
+  BOOL ok, ok2;\r
 \r
   switch (message) {\r
   case WM_INITDIALOG: /* message: initialize dialog box */\r
@@ -2593,8 +2617,13 @@ TimeControl(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
     CenterWindow (hDlg, GetWindow (hDlg, GW_OWNER));\r
     /* Initialize the dialog items */\r
     if (appData.clockMode && !appData.icsActive) {\r
+      if (searchTime) {\r
+       CheckRadioButton(hDlg, OPT_TCUseMoves, OPT_TCUseFixed,\r
+                        OPT_TCUseFixed);\r
+       SetDlgItemInt(hDlg, OPT_TCFixed, searchTime, FALSE);\r
+      } else\r
       if (appData.timeIncrement == -1) {\r
-       CheckRadioButton(hDlg, OPT_TCUseMoves, OPT_TCUseInc,\r
+       CheckRadioButton(hDlg, OPT_TCUseMoves, OPT_TCUseFixed,\r
                         OPT_TCUseMoves);\r
        SetDlgItemText(hDlg, OPT_TCTime, appData.timeControl);\r
        SetDlgItemInt(hDlg, OPT_TCMoves, appData.movesPerSession,\r
@@ -2602,13 +2631,15 @@ TimeControl(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
        SetDlgItemText(hDlg, OPT_TCTime2, "");\r
        SetDlgItemText(hDlg, OPT_TCInc, "");\r
       } else {\r
-       CheckRadioButton(hDlg, OPT_TCUseMoves, OPT_TCUseInc,\r
+       CheckRadioButton(hDlg, OPT_TCUseMoves, OPT_TCUseFixed,\r
                         OPT_TCUseInc);\r
        SetDlgItemText(hDlg, OPT_TCTime, "");\r
        SetDlgItemText(hDlg, OPT_TCMoves, "");\r
        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
@@ -2616,7 +2647,19 @@ TimeControl(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
   case WM_COMMAND: /* message: received a command */\r
     switch (LOWORD(wParam)) {\r
     case IDOK:\r
+      mps = appData.movesPerSession;\r
+      increment = appData.timeIncrement;\r
+      tc = appData.timeControl;\r
+      st = 0;\r
       /* Read changed options from the dialog box */\r
+      if (IsDlgButtonChecked(hDlg, OPT_TCUseFixed)) {\r
+       st = GetDlgItemInt(hDlg, OPT_TCFixed, &ok, FALSE);\r
+       if (!ok || st <= 0) {\r
+         MessageBox(hDlg, "Invalid max time per move",\r
+                    "Option Error", MB_OK|MB_ICONEXCLAMATION);\r
+         return FALSE;\r
+       }\r
+      } else\r
       if (IsDlgButtonChecked(hDlg, OPT_TCUseMoves)) {\r
        increment = -1;\r
        mps = GetDlgItemInt(hDlg, OPT_TCMoves, &ok, FALSE);\r
@@ -2631,9 +2674,9 @@ TimeControl(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
                     "Option Error", MB_OK|MB_ICONEXCLAMATION);\r
          return FALSE;\r
        }\r
+      tc = buf;\r
       } else {\r
        increment = GetDlgItemInt(hDlg, OPT_TCInc, &ok, FALSE);\r
-       mps = appData.movesPerSession;\r
        if (!ok || increment < 0) {\r
          MessageBox(hDlg, "Invalid increment",\r
                     "Option Error", MB_OK|MB_ICONEXCLAMATION);\r
@@ -2645,10 +2688,21 @@ TimeControl(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
                     "Option Error", MB_OK|MB_ICONEXCLAMATION);\r
          return FALSE;\r
        }\r
+      tc = buf;\r
       }\r
-      appData.timeControl = strdup(buf);\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
+      searchTime = st;\r
+      appData.timeControl = strdup(tc);\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 +2761,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 +2784,9 @@ 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
-      ShowThinkingEvent(             IS_CHECKED(IDC_EpShowThinking));\r
-      appData.hideThinkingFromHuman= IS_CHECKED(IDC_EpHideThinkingHuman);\r
+      appData.hideThinkingFromHuman= IS_CHECKED(IDC_EpHideThinkingHuman); // [HGM] thinking: moved up\r
+      appData.showThinking   = IS_CHECKED(IDC_EpShowThinking);\r
+      ShowThinkingEvent(); // [HGM] thinking: tests all options that need thinking output\r
       appData.testClaims    = IS_CHECKED(IDC_TestClaims);\r
       appData.checkMates    = IS_CHECKED(IDC_DetectMates);\r
       appData.materialDraws = IS_CHECKED(IDC_MaterialDraws);\r
@@ -2739,6 +2797,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
+      first.scoreIsAbsolute  = appData.firstScoreIsAbsolute  = IS_CHECKED(IDC_ScoreAbs1);\r
+      second.scoreIsAbsolute = appData.secondScoreIsAbsolute = IS_CHECKED(IDC_ScoreAbs2);\r
+\r
       EndDialog(hDlg, TRUE);\r
       return TRUE;\r
 \r
@@ -2816,6 +2877,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 +2892,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 +2914,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