Fix multi-leg promotions
[xboard.git] / winboard / woptions.c
index fd0ac4c..34e3800 100644 (file)
@@ -1,7 +1,8 @@
 /*\r
  * woptions.c -- Options dialog box routines for WinBoard\r
  *\r
- * Copyright 2000, 2009, 2010 Free Software Foundation, Inc.\r
+ * Copyright 2000, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016 Free\r
+ * Software Foundation, Inc.\r
  *\r
  * Enhancements Copyright 2005 Alessandro Scotti\r
  *\r
@@ -44,6 +45,9 @@
 #include <string.h>\r
 #endif\r
 \r
+#define _(s) T_(s)\r
+#define N_(s) s\r
+\r
 /* Imports from winboard.c */\r
 \r
 extern MyFont *font[NUM_SIZES][NUM_FONTS];\r
@@ -51,7 +55,7 @@ extern HINSTANCE hInst;          /* current instance */
 extern HWND hwndMain;            /* root window*/\r
 extern BOOLEAN alwaysOnTop;\r
 extern RECT boardRect;\r
-extern COLORREF lightSquareColor, darkSquareColor, whitePieceColor, \r
+extern COLORREF lightSquareColor, darkSquareColor, whitePieceColor,\r
   blackPieceColor, highlightSquareColor, premoveHighlightColor;\r
 extern HPALETTE hPal;\r
 extern BoardSize boardSize;\r
@@ -97,15 +101,15 @@ LRESULT CALLBACK SaveOptions(HWND, UINT, WPARAM, LPARAM);
 LRESULT CALLBACK TimeControl(HWND, UINT, WPARAM, LPARAM);\r
 VOID ChangeBoardSize(BoardSize newSize);\r
 VOID PaintSampleSquare(\r
-    HWND     hwnd, \r
-    int      ctrlid, \r
-    COLORREF squareColor, \r
+    HWND     hwnd,\r
+    int      ctrlid,\r
+    COLORREF squareColor,\r
     COLORREF pieceColor,\r
     COLORREF squareOutlineColor,\r
     COLORREF pieceDetailColor,\r
     BOOL     isWhitePiece,\r
     BOOL     isMono,\r
-    HBITMAP  pieces[3] \r
+    HBITMAP  pieces[3]\r
     );\r
 VOID PaintColorBlock(HWND hwnd, int ctrlid, COLORREF color);\r
 VOID SetBoardOptionEnables(HWND hDlg);\r
@@ -131,7 +135,28 @@ 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
+char *\r
+InterpretFileName(char *buf, char *homeDir)\r
+{ // [HGM] file name relative to homeDir. (Taken out of SafeOptionsDialog, because it is generally useful)\r
+  char *result = NULL;\r
+  if ((isalpha(buf[0]) && buf[1] == ':') ||\r
+    (buf[0] == '\\' && buf[1] == '\\')) {\r
+    return strdup(buf);\r
+  } else {\r
+    char buf2[MSG_SIZ], buf3[MSG_SIZ];\r
+    char *dummy;\r
+    GetCurrentDirectory(MSG_SIZ, buf3);\r
+    SetCurrentDirectory(homeDir);\r
+    if (GetFullPathName(buf, MSG_SIZ, buf2, &dummy)) {\r
+      result = strdup(buf2);\r
+    } else {\r
+      result = strdup(buf);\r
+    }\r
+    SetCurrentDirectory(buf3);\r
+  }\r
+  return result;\r
+}\r
 \r
 /*---------------------------------------------------------------------------*\\r
  *\r
@@ -146,15 +171,18 @@ 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
+    Translate(hDlg, DLG_GeneralOptions);\r
 \r
     /* Initialize the dialog items */\r
 #define CHECK_BOX(x,y) CheckDlgButton(hDlg, (x), (BOOL)(y))\r
@@ -181,6 +209,13 @@ 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
+    CHECK_BOX(OPT_SmartMove, appData.oneClick); // [HGM] one-click\r
+    CHECK_BOX(OPT_AutoTags, appData.autoDisplayTags); // [HGM]\r
+    CHECK_BOX(OPT_AutoComment, appData.autoDisplayComment); // [HGM]\r
+    CHECK_BOX(OPT_Headers, appData.headers); // [HGM]\r
+    CHECK_BOX(OPT_Variations, appData.variations); // [HGM]\r
+    CHECK_BOX(OPT_AutoExtend, appData.autoExtend); // [HGM]\r
 \r
 #undef CHECK_BOX\r
 \r
@@ -190,9 +225,9 @@ GeneralOptionsDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
                 appData.icsActive || !appData.noChessProgram);\r
     EnableWindow(GetDlgItem(hDlg, OPT_PonderNextMove),\r
                 !appData.noChessProgram);\r
-    EnableWindow(GetDlgItem(hDlg, OPT_PeriodicUpdates), \r
+    EnableWindow(GetDlgItem(hDlg, OPT_PeriodicUpdates),\r
                 !appData.noChessProgram && !appData.icsActive);\r
-    EnableWindow(GetDlgItem(hDlg, OPT_ShowThinking), \r
+    EnableWindow(GetDlgItem(hDlg, OPT_ShowThinking),\r
                 !appData.noChessProgram);\r
     return TRUE;\r
 \r
@@ -201,7 +236,7 @@ GeneralOptionsDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
     switch (LOWORD(wParam)) {\r
     case IDOK:\r
       /* Read changed options from the dialog box */\r
-      \r
+\r
 #define IS_CHECKED(x) (Boolean)IsDlgButtonChecked(hDlg, (x))\r
 \r
       alwaysOnTop                  = IS_CHECKED(OPT_AlwaysOnTop);\r
@@ -228,6 +263,13 @@ 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
+      appData.oneClick             =IS_CHECKED(OPT_SmartMove); // [HGM] one-click\r
+      appData.autoDisplayTags      =IS_CHECKED(OPT_AutoTags); // [HGM]\r
+      appData.autoDisplayComment   =IS_CHECKED(OPT_AutoComment); // [HGM]\r
+      appData.headers              =IS_CHECKED(OPT_Headers); // [HGM]\r
+      appData.variations           =IS_CHECKED(OPT_Variations); // [HGM]\r
+      appData.autoExtend           =IS_CHECKED(OPT_AutoExtend); // [HGM]\r
 \r
 #undef IS_CHECKED\r
 \r
@@ -243,15 +285,18 @@ GeneralOptionsDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
        ClearHighlights();\r
        DrawPosition(FALSE, NULL);\r
       }\r
-      /* \r
+      /*\r
        * for some reason the redraw seems smoother when we invalidate\r
        * the board rect after the call to EndDialog()\r
        */\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
+      } else if ((oldShowCoords != appData.showCoords) ||\r
                 (oldBlindfold != appData.blindfold)) {\r
        InvalidateRect(hwndMain, &boardRect, FALSE);\r
       }\r
@@ -268,7 +313,7 @@ GeneralOptionsDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
   return FALSE;\r
 }\r
 \r
-VOID \r
+VOID\r
 GeneralOptionsPopup(HWND hwnd)\r
 {\r
   FARPROC lpProc;\r
@@ -297,15 +342,15 @@ ChangeBoardSize(BoardSize newSize)
 \r
 VOID\r
 PaintSampleSquare(\r
-    HWND     hwnd, \r
-    int      ctrlid, \r
-    COLORREF squareColor, \r
+    HWND     hwnd,\r
+    int      ctrlid,\r
+    COLORREF squareColor,\r
     COLORREF pieceColor,\r
     COLORREF squareOutlineColor,\r
     COLORREF pieceDetailColor,\r
     BOOL     isWhitePiece,\r
     BOOL     isMono,\r
-    HBITMAP  pieces[3] \r
+    HBITMAP  pieces[3]\r
     )\r
 {\r
   HBRUSH  brushSquare;\r
@@ -348,15 +393,15 @@ PaintSampleSquare(
   brushPiece          = CreateSolidBrush(pieceColor);\r
   brushPieceDetail    = CreateSolidBrush(pieceDetailColor);\r
 \r
-  /* \r
-   * first draw the rectangle \r
+  /*\r
+   * first draw the rectangle\r
    */\r
   pen      = CreatePen(PS_SOLID, BORDER, squareOutlineColor);\r
   oldPen   = (HPEN)  SelectObject(hdcMem, pen);\r
   oldBrushSquare = (HBRUSH)SelectObject(hdcMem, brushSquare);\r
   Rectangle(hdcMem, rect.left, rect.top, rect.right, rect.bottom);\r
 \r
-  /* \r
+  /*\r
    * now draw the piece\r
    */\r
   if (isMono) {\r
@@ -368,23 +413,23 @@ PaintSampleSquare(
     if (isWhitePiece) {\r
       oldBitmapTemp = SelectObject(hdcTemp, pieces[WHITE]);\r
       oldBrushPiece = SelectObject(hdcMem, brushPiece);\r
-      BitBlt(hdcMem, x, y, SAMPLE_SQ_SIZE, SAMPLE_SQ_SIZE, \r
+      BitBlt(hdcMem, x, y, SAMPLE_SQ_SIZE, SAMPLE_SQ_SIZE,\r
             hdcTemp, 0, 0, 0x00B8074A);\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
+      BitBlt(hdcMem, x, y, SAMPLE_SQ_SIZE, SAMPLE_SQ_SIZE,\r
             hdcTemp, 0, 0, SRCAND);\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
+      BitBlt(hdcMem, x, y, SAMPLE_SQ_SIZE, SAMPLE_SQ_SIZE,\r
             hdcTemp, 0, 0, 0x00B8074A);\r
     }\r
     SelectObject(hdcMem, oldBrushPiece);\r
     SelectObject(hdcTemp, oldBitmapTemp);\r
   }\r
-  /* \r
+  /*\r
    * copy the memory dc to the screen\r
    */\r
   SelectObject(hdcMem, bufferBitmap);\r
@@ -393,10 +438,10 @@ PaintSampleSquare(
         rect.bottom - rect.top,\r
         hdcMem, rect.left, rect.top, SRCCOPY);\r
   SelectObject(hdcMem, oldBitmapMem);\r
-  /* \r
+  /*\r
    * clean up\r
    */\r
-  SelectObject(hdcMem, oldBrushPiece);\r
+  SelectObject(hdcMem, oldBrushSquare);\r
   SelectObject(hdcMem, oldPen);\r
   DeleteObject(brushPiece);\r
   DeleteObject(brushPieceDetail);\r
@@ -456,7 +501,7 @@ SetBoardOptionEnables(HWND hDlg)
   }\r
 }\r
 \r
-BoardSize \r
+BoardSize\r
 BoardOptionsWhichRadio(HWND hDlg)\r
 {\r
   return (IsDlgButtonChecked(hDlg, OPT_SizeTiny) ? SizeTiny :\r
@@ -482,7 +527,7 @@ BoardOptionsWhichRadio(HWND hDlg)
 LRESULT CALLBACK\r
 BoardOptionsDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)\r
 {\r
-  static Boolean  mono, white, flip;\r
+  static Boolean  mono, white, flip, fonts, bitmaps, grid;\r
   static BoardSize size;\r
   static COLORREF lsc, dsc, wpc, bpc, hsc, phc;\r
   static HBITMAP pieces[3];\r
@@ -491,6 +536,7 @@ BoardOptionsDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
   case WM_INITDIALOG: /* message: initialize dialog box */\r
     /* Center the dialog over the application window */\r
     CenterWindow (hDlg, GetWindow (hDlg, GW_OWNER));\r
+    Translate(hDlg, DLG_BoardOptions);\r
     /* Initialize the dialog items */\r
     switch (boardSize) {\r
     case SizeTiny:\r
@@ -558,20 +604,32 @@ BoardOptionsDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
     if (appData.upsideDown)\r
       CheckDlgButton(hDlg, OPT_UpsideDown, TRUE);\r
 \r
+    if (appData.useBitmaps)\r
+      CheckDlgButton(hDlg, OPT_Bitmaps, TRUE);\r
+\r
+    if (appData.useFont)\r
+      CheckDlgButton(hDlg, OPT_PieceFont, TRUE);\r
+\r
+    if (appData.overrideLineGap >= 0)\r
+      CheckDlgButton(hDlg, OPT_Grid, TRUE);\r
+\r
     pieces[0] = DoLoadBitmap(hInst, "n", SAMPLE_SQ_SIZE, "s");\r
     pieces[1] = DoLoadBitmap(hInst, "n", SAMPLE_SQ_SIZE, "w");\r
     pieces[2] = DoLoadBitmap(hInst, "n", SAMPLE_SQ_SIZE, "o");\r
-       \r
+\r
     lsc = lightSquareColor;\r
     dsc = darkSquareColor;\r
-    wpc = whitePieceColor;\r
-    bpc = blackPieceColor;\r
+    fonts = appData.useFont;\r
+    wpc = fonts ? appData.fontBackColorWhite : whitePieceColor;\r
+    bpc = fonts ? appData.fontForeColorBlack : blackPieceColor;\r
     hsc = highlightSquareColor;\r
     phc = premoveHighlightColor;\r
     mono = appData.monoMode;\r
     white= appData.allWhite;\r
     flip = appData.upsideDown;\r
     size = boardSize;\r
+    bitmaps = appData.useBitmaps;\r
+    grid = appData.overrideLineGap >= 0;\r
 \r
     SetBoardOptionEnables(hDlg);\r
     return TRUE;\r
@@ -593,7 +651,7 @@ BoardOptionsDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
   case WM_COMMAND: /* message: received a command */\r
     switch (LOWORD(wParam)) {\r
     case IDOK:\r
-      /* \r
+      /*\r
        * if we call EndDialog() after the call to ChangeBoardSize(),\r
        * then ChangeBoardSize() does not take effect, although the new\r
        * boardSize is saved. Go figure...\r
@@ -609,25 +667,38 @@ BoardOptionsDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
        ChangeBoardSize(size);\r
       }\r
 \r
+      if (bitmaps && !appData.useBitmaps) InitTextures();\r
+\r
       if ((mono != appData.monoMode) ||\r
          (lsc  != lightSquareColor) ||\r
          (dsc  != darkSquareColor) ||\r
-         (wpc  != whitePieceColor) ||\r
-         (bpc  != blackPieceColor) ||\r
+         (wpc  != fonts ? appData.fontBackColorWhite : whitePieceColor) ||\r
+         (bpc  != fonts ? appData.fontForeColorBlack : blackPieceColor) ||\r
          (hsc  != highlightSquareColor) ||\r
           (flip != appData.upsideDown) ||\r
           (white != appData.allWhite) ||\r
+          (fonts != appData.useFont) ||\r
+          (bitmaps != appData.useBitmaps) ||\r
+          (grid != appData.overrideLineGap >= 0) ||\r
          (phc  != premoveHighlightColor)) {\r
 \r
          lightSquareColor = lsc;\r
          darkSquareColor = dsc;\r
-         whitePieceColor = wpc;\r
-         blackPieceColor = bpc;\r
+         if(fonts) {\r
+           appData.fontBackColorWhite = wpc;\r
+           appData.fontForeColorBlack = bpc;\r
+         } else {\r
+           whitePieceColor = wpc;\r
+           blackPieceColor = bpc;\r
+         }\r
          highlightSquareColor = hsc;\r
          premoveHighlightColor = phc;\r
          appData.monoMode = mono;\r
           appData.allWhite = white;\r
           appData.upsideDown = flip;\r
+          appData.useFont = fonts;\r
+          appData.useBitmaps = bitmaps;\r
+          if(grid != appData.overrideLineGap >= 0) appData.overrideLineGap = grid - 1;\r
 \r
          InitDrawingColors();\r
          InitDrawingSizes(boardSize, 0);\r
@@ -635,6 +706,7 @@ BoardOptionsDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
       }\r
       DeleteObject(pieces[0]);\r
       DeleteObject(pieces[1]);\r
+\r
       DeleteObject(pieces[2]);\r
       return TRUE;\r
 \r
@@ -646,42 +718,42 @@ BoardOptionsDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
       return TRUE;\r
 \r
     case OPT_ChooseLightSquareColor:\r
-      if (ChangeColor(hDlg, &lsc)) \r
+      if (ChangeColor(hDlg, &lsc))\r
        PaintColorBlock(hDlg, OPT_LightSquareColor, lsc);\r
        PaintSampleSquare(hDlg, OPT_SampleLightSquare, lsc, wpc, hsc, bpc,\r
            TRUE, mono, pieces);\r
       break;\r
 \r
     case OPT_ChooseDarkSquareColor:\r
-      if (ChangeColor(hDlg, &dsc)) \r
+      if (ChangeColor(hDlg, &dsc))\r
        PaintColorBlock(hDlg, OPT_DarkSquareColor, dsc);\r
        PaintSampleSquare(hDlg, OPT_SampleDarkSquare, dsc, bpc, phc, wpc,\r
            FALSE, mono, pieces);\r
       break;\r
 \r
     case OPT_ChooseWhitePieceColor:\r
-      if (ChangeColor(hDlg, &wpc)) \r
+      if (ChangeColor(hDlg, &wpc))\r
        PaintColorBlock(hDlg, OPT_WhitePieceColor, wpc);\r
        PaintSampleSquare(hDlg, OPT_SampleLightSquare, lsc, wpc, hsc, bpc,\r
            TRUE, mono, pieces);\r
       break;\r
 \r
     case OPT_ChooseBlackPieceColor:\r
-      if (ChangeColor(hDlg, &bpc)) \r
+      if (ChangeColor(hDlg, &bpc))\r
        PaintColorBlock(hDlg, OPT_BlackPieceColor, bpc);\r
        PaintSampleSquare(hDlg, OPT_SampleDarkSquare, dsc, bpc, phc, wpc,\r
            FALSE, mono, pieces);\r
       break;\r
 \r
     case OPT_ChooseHighlightSquareColor:\r
-      if (ChangeColor(hDlg, &hsc)) \r
+      if (ChangeColor(hDlg, &hsc))\r
        PaintColorBlock(hDlg, OPT_HighlightSquareColor, hsc);\r
        PaintSampleSquare(hDlg, OPT_SampleLightSquare, lsc, wpc, hsc, bpc,\r
            TRUE, mono, pieces);\r
       break;\r
 \r
     case OPT_ChoosePremoveHighlightColor:\r
-      if (ChangeColor(hDlg, &phc)) \r
+      if (ChangeColor(hDlg, &phc))\r
        PaintColorBlock(hDlg, OPT_PremoveHighlightColor, phc);\r
        PaintSampleSquare(hDlg, OPT_SampleDarkSquare, dsc, bpc, phc, wpc,\r
            FALSE, mono, pieces);\r
@@ -720,12 +792,22 @@ BoardOptionsDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
 \r
     case OPT_AllWhite:\r
       white = !white;\r
-      SetBoardOptionEnables(hDlg);\r
       break;\r
 \r
     case OPT_UpsideDown:\r
       flip = !flip;\r
-      SetBoardOptionEnables(hDlg);\r
+      break;\r
+\r
+    case OPT_Bitmaps:\r
+      bitmaps = !bitmaps;\r
+      break;\r
+\r
+    case OPT_PieceFont:\r
+      fonts = !fonts;\r
+      break;\r
+\r
+    case OPT_Grid:\r
+      grid = !grid;\r
       break;\r
     }\r
     break;\r
@@ -743,39 +825,94 @@ BoardOptionsPopup(HWND hwnd)
   FreeProcInstance(lpProc);\r
 }\r
 \r
+int radioButton[] = {\r
+    OPT_VariantNormal,\r
+    -1, // Loadable\r
+    OPT_VariantWildcastle,\r
+    OPT_VariantNocastle,\r
+    OPT_VariantFRC,\r
+    OPT_VariantBughouse,\r
+    OPT_VariantCrazyhouse,\r
+    OPT_VariantLosers,\r
+    OPT_VariantSuicide,\r
+    OPT_VariantGiveaway,\r
+    OPT_VariantTwoKings,\r
+    -1, //Kriegspiel\r
+    OPT_VariantAtomic,\r
+    OPT_Variant3Check,\r
+    OPT_VariantShatranj,\r
+    -1,\r
+    -1,\r
+    -1,\r
+    -1,\r
+    -1,\r
+    -1,\r
+    -1,\r
+    -1,\r
+    OPT_VariantShogi,\r
+    -1, // Chu\r
+    OPT_VariantCourier,\r
+    OPT_VariantGothic,\r
+    OPT_VariantCapablanca,\r
+    OPT_VariantKnightmate,\r
+    OPT_VariantFairy,        \r
+    OPT_VariantCylinder,\r
+    OPT_VariantFalcon,\r
+    OPT_VariantCRC,\r
+    OPT_VariantBerolina,\r
+    OPT_VariantJanus,\r
+    OPT_VariantSuper,\r
+    OPT_VariantGreat,\r
+    -1, // Twilight,\r
+    OPT_VariantMakruk,\r
+    OPT_VariantSChess,\r
+    OPT_VariantGrand,\r
+    OPT_VariantSpartan, // Spartan\r
+    OPT_VariantXiangqi,\r
+    OPT_VariantASEAN,\r
+    OPT_VariantLion,\r
+    -2 // sentinel\r
+};\r
+\r
 VariantClass\r
 VariantWhichRadio(HWND hDlg)\r
 {\r
-  return (IsDlgButtonChecked(hDlg, OPT_VariantFairy) ? VariantFairy :\r
-         (IsDlgButtonChecked(hDlg, OPT_VariantGothic) ? VariantGothic :\r
-         (IsDlgButtonChecked(hDlg, OPT_VariantCrazyhouse) ? VariantCrazyhouse :\r
-         (IsDlgButtonChecked(hDlg, OPT_VariantBughouse) ? VariantBughouse :\r
-         (IsDlgButtonChecked(hDlg, OPT_VariantCourier) ? VariantCourier :\r
-         (IsDlgButtonChecked(hDlg, OPT_VariantShatranj) ? VariantShatranj :\r
-         (IsDlgButtonChecked(hDlg, OPT_VariantShogi) ? VariantShogi :\r
-         (IsDlgButtonChecked(hDlg, OPT_VariantXiangqi) ? VariantXiangqi :\r
-         (IsDlgButtonChecked(hDlg, OPT_VariantCapablanca) ? VariantCapablanca :\r
-         (IsDlgButtonChecked(hDlg, OPT_VariantTwoKings) ? VariantTwoKings :\r
-         (IsDlgButtonChecked(hDlg, OPT_VariantKnightmate) ? VariantKnightmate :\r
-         (IsDlgButtonChecked(hDlg, OPT_VariantLosers) ? VariantLosers :\r
-         (IsDlgButtonChecked(hDlg, OPT_VariantSuicide) ? VariantSuicide :\r
-         (IsDlgButtonChecked(hDlg, OPT_VariantAtomic) ? VariantAtomic :\r
-         (IsDlgButtonChecked(hDlg, OPT_VariantShatranj) ? VariantShatranj :\r
-         (IsDlgButtonChecked(hDlg, OPT_VariantFRC) ? VariantFischeRandom :\r
-         (IsDlgButtonChecked(hDlg, OPT_VariantCylinder) ? VariantCylinder :\r
-         (IsDlgButtonChecked(hDlg, OPT_VariantFalcon) ? VariantFalcon :\r
-         (IsDlgButtonChecked(hDlg, OPT_VariantCRC) ? VariantCapaRandom :\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
-         (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
+  int i=0, j;\r
+  *engineVariant = NULLCHAR;\r
+  while((j = radioButton[i++]) != -2) {\r
+       if(j == -1) continue; // no menu button\r
+       if(IsDlgButtonChecked(hDlg, j) &&\r
+          (appData.noChessProgram || strstr(first.variants, VariantName(i-1)))) return (VariantClass) i-1;\r
+  }\r
+  for(i=0; i<15; i++) { // check for engine-defined variants\r
+    if(IsDlgButtonChecked(hDlg, OPT_EngineVariant+i) ) {\r
+       GetDlgItemText(hDlg, OPT_EngineVariant+i, engineVariant, MSG_SIZ); // remember name, so we can resolve it later\r
+       return VariantUnknown;\r
+    }\r
+  }\r
+  return gameInfo.variant; // If no button checked, keep old\r
+}\r
+\r
+void\r
+VariantShowRadio(HWND hDlg)\r
+{\r
+  char c = *engineVariant, *v, *p;\r
+  int i=0, j;\r
+  CheckDlgButton(hDlg, radioButton[gameInfo.variant], TRUE);\r
+  *engineVariant = NULLCHAR; // [HGM] kludge to prevent VariantName will always return engineVariant\r
+  while((j = radioButton[i++]) != -2) {\r
+       if(j == -1) continue; // no menu button\r
+       v = VariantName(i-1); p = strstr(first.variants, v);\r
+       EnableWindow(GetDlgItem(hDlg, j), appData.noChessProgram || p && (!*v || strlen(v) == strlen(p) || p[strlen(v)] == ','));\r
+  }\r
+  *engineVariant = c;\r
+  for(i=0; i<15; i++) { // initialize engine-defined variants\r
+    char *v = EngineDefinedVariant(&first, i); // get name of #i\r
+    if(v) { // there is such a variant\r
+       EnableWindow(GetDlgItem(hDlg, OPT_EngineVariant+i), TRUE);     // and enable the button\r
+       SetDlgItemText(hDlg, OPT_EngineVariant+i, v);                  // put its name on button\r
+    } else EnableWindow(GetDlgItem(hDlg, OPT_EngineVariant+i), FALSE); // no such variant; disable button\r
+  }\r
 }\r
 \r
 LRESULT CALLBACK\r
@@ -788,97 +925,10 @@ NewVariantDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
   case WM_INITDIALOG: /* message: initialize dialog box */\r
     /* Center the dialog over the application window */\r
     CenterWindow (hDlg, GetWindow (hDlg, GW_OWNER));\r
+    Translate(hDlg, DLG_NewVariant);\r
+\r
     /* Initialize the dialog items */\r
-    switch (gameInfo.variant) {\r
-    case VariantNormal:\r
-      CheckDlgButton(hDlg, OPT_VariantNormal, TRUE);\r
-      break;\r
-    case VariantCrazyhouse:\r
-      CheckDlgButton(hDlg, OPT_VariantCrazyhouse, TRUE);\r
-      break;\r
-    case VariantBughouse:\r
-      CheckDlgButton(hDlg, OPT_VariantBughouse, TRUE);\r
-      break;\r
-    case VariantShogi:\r
-      CheckDlgButton(hDlg, OPT_VariantShogi, TRUE);\r
-      break;\r
-    case VariantXiangqi:\r
-      CheckDlgButton(hDlg, OPT_VariantXiangqi, TRUE);\r
-      break;\r
-    case VariantCapablanca:\r
-      CheckDlgButton(hDlg, OPT_VariantCapablanca, TRUE);\r
-      break;\r
-    case VariantGothic:\r
-      CheckDlgButton(hDlg, OPT_VariantGothic, TRUE);\r
-      break;\r
-    case VariantCourier:\r
-      CheckDlgButton(hDlg, OPT_VariantCourier, TRUE);\r
-      break;\r
-    case VariantKnightmate:\r
-      CheckDlgButton(hDlg, OPT_VariantKnightmate, TRUE);\r
-      break;\r
-    case VariantTwoKings:\r
-      CheckDlgButton(hDlg, OPT_VariantTwoKings, TRUE);\r
-      break;\r
-    case VariantFairy:\r
-      CheckDlgButton(hDlg, OPT_VariantFairy, TRUE);\r
-      break;\r
-    case VariantAtomic:\r
-      CheckDlgButton(hDlg, OPT_VariantAtomic, TRUE);\r
-      break;\r
-    case VariantSuicide:\r
-      CheckDlgButton(hDlg, OPT_VariantSuicide, TRUE);\r
-      break;\r
-    case VariantLosers:\r
-      CheckDlgButton(hDlg, OPT_VariantLosers, TRUE);\r
-      break;\r
-    case VariantShatranj:\r
-      CheckDlgButton(hDlg, OPT_VariantShatranj, TRUE);\r
-      break;\r
-    case VariantFischeRandom:\r
-      CheckDlgButton(hDlg, OPT_VariantFRC, TRUE);\r
-      break;\r
-    case VariantCapaRandom:\r
-      CheckDlgButton(hDlg, OPT_VariantCRC, TRUE);\r
-      break;\r
-    case VariantFalcon:\r
-      CheckDlgButton(hDlg, OPT_VariantFalcon, TRUE);\r
-      break;\r
-    case VariantCylinder:\r
-      CheckDlgButton(hDlg, OPT_VariantCylinder, TRUE);\r
-      break;\r
-    case Variant3Check:\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
-      break;\r
-    case VariantJanus:\r
-      CheckDlgButton(hDlg, OPT_VariantJanus, TRUE);\r
-      break;\r
-    case VariantWildCastle:\r
-      CheckDlgButton(hDlg, OPT_VariantWildcastle, TRUE);\r
-      break;\r
-    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
+    VariantShowRadio(hDlg);\r
 \r
     SetDlgItemInt( hDlg, IDC_Files, -1, TRUE );\r
     SendDlgItemMessage( hDlg, IDC_Files, EM_SETSEL, 0, -1 );\r
@@ -896,7 +946,7 @@ NewVariantDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
   case WM_COMMAND: /* message: received a command */\r
     switch (LOWORD(wParam)) {\r
     case IDOK:\r
-      /* \r
+      /*\r
        * if we call EndDialog() after the call to ChangeBoardSize(),\r
        * then ChangeBoardSize() does not take effect, although the new\r
        * boardSize is saved. Go figure...\r
@@ -904,21 +954,22 @@ 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(!appData.noChessProgram) {\r
+       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
+         /* [HGM] in protocol 2 we check if variant is suported by engine */\r
+         snprintf(buf, MSG_SIZ, _("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
+         snprintf(buf, MSG_SIZ, _("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
+      ASSIGN(appData.variant, VariantName(v));\r
 \r
       appData.NrFiles = (int) GetDlgItemInt(hDlg, IDC_Files, NULL, FALSE );\r
       appData.NrRanks = (int) GetDlgItemInt(hDlg, IDC_Ranks, NULL, FALSE );\r
@@ -931,6 +982,9 @@ NewVariantDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
       shuffleOpenings = FALSE; /* [HGM] shuffle: possible shuffle reset when we switch */\r
       startedFromPositionFile = FALSE; /* [HGM] loadPos: no longer valid in new variant */\r
       appData.pieceToCharTable = NULL;\r
+      ASSIGN(appData.pieceNickNames, "");\r
+      ASSIGN(appData.colorNickNames, "");\r
+      ASSIGN(appData.men, "");\r
       Reset(TRUE, TRUE);\r
 \r
       return TRUE;\r
@@ -1016,7 +1070,7 @@ MyCreateFont(HWND hwnd, MyFont *font)
   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
+  safeStrCpy(font->mfp.faceName, font->lf.lfFaceName, sizeof(font->mfp.faceName)/sizeof(font->mfp.faceName[0]) );\r
   return TRUE;\r
 }\r
 \r
@@ -1026,12 +1080,12 @@ UpdateSampleText(HWND hDlg, int id, MyColorizeAttribs *mca)
 {\r
   CHARFORMAT cf;\r
   cf.cbSize = sizeof(CHARFORMAT);\r
-  cf.dwMask = \r
+  cf.dwMask =\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
-  /* \r
+  safeStrCpy(cf.szFaceName, font[boardSize][CONSOLE_FONT]->mfp.faceName, sizeof(cf.szFaceName)/sizeof(cf.szFaceName[0]) );\r
+  /*\r
    * The 20.0 below is in fact documented. yHeight is expressed in twips.\r
    * A twip is 1/20 of a font's point size. See documentation of CHARFORMAT.\r
    * --msw\r
@@ -1055,6 +1109,7 @@ ColorizeTextDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
     mca = colorizeAttribs[cc];\r
     /* Center the dialog over the application window */\r
     CenterWindow (hDlg, GetWindow (hDlg, GW_OWNER));\r
+    Translate(hDlg, DLG_Colorize);\r
     /* Initialize the dialog items */\r
     CheckDlgButton(hDlg, OPT_Bold, (mca.effects & CFE_BOLD) != 0);\r
     CheckDlgButton(hDlg, OPT_Italic, (mca.effects & CFE_ITALIC) != 0);\r
@@ -1062,14 +1117,14 @@ ColorizeTextDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
     CheckDlgButton(hDlg, OPT_Strikeout, (mca.effects & CFE_STRIKEOUT) != 0);\r
 \r
     /* get the current background color from the parent window */\r
-    SendMessage(GetWindow(hDlg, GW_OWNER),WM_COMMAND, \r
-               (WPARAM)WM_USER_GetConsoleBackground, \r
+    SendMessage(GetWindow(hDlg, GW_OWNER),WM_COMMAND,\r
+               (WPARAM)WM_USER_GetConsoleBackground,\r
                (LPARAM)&background);\r
 \r
     /* set the background color */\r
     SendDlgItemMessage(hDlg, OPT_Sample, EM_SETBKGNDCOLOR, FALSE, background);\r
 \r
-    SetDlgItemText(hDlg, OPT_Sample, mca.name);\r
+    SetDlgItemText(hDlg, OPT_Sample, T_(mca.name));\r
     UpdateSampleText(hDlg, OPT_Sample, &mca);\r
     return TRUE;\r
 \r
@@ -1086,7 +1141,7 @@ ColorizeTextDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
        cf.cbSize = sizeof(CHARFORMAT);\r
        cf.dwMask = CFM_COLOR;\r
        cf.crTextColor = mca.color;\r
-       SendDlgItemMessage(hwndConsole, OPT_ConsoleInput, \r
+       SendDlgItemMessage(hwndConsole, OPT_ConsoleInput,\r
          EM_SETCHARFORMAT, SCF_ALL, (LPARAM)&cf);\r
       }\r
       EndDialog(hDlg, TRUE);\r
@@ -1166,12 +1221,15 @@ IcsOptionsDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
 \r
     /* Center the dialog over the application window */\r
     CenterWindow (hDlg, GetWindow (hDlg, GW_OWNER));\r
+    Translate(hDlg, DLG_IcsOptions);\r
 \r
     /* 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_AutoCreate, appData.autoCreateLogon);\r
     CHECK_BOX(OPT_GetMoveList, appData.getMoveList);\r
     CHECK_BOX(OPT_LocalLineEditing, appData.localLineEditing);\r
     CHECK_BOX(OPT_QuietPlay, appData.quietPlay);\r
@@ -1188,7 +1246,7 @@ IcsOptionsDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
 \r
 #undef CHECK_BOX\r
 \r
-    sprintf(buf, "%d", appData.icsAlarmTime / 1000);\r
+    snprintf(buf, MSG_SIZ, "%d", appData.icsAlarmTime / 1000);\r
     SetDlgItemText(hDlg, OPT_IcsAlarmTime, buf);\r
     SetDlgItemText(hDlg, OPT_PremoveWhiteText, appData.premoveWhiteText);\r
     SetDlgItemText(hDlg, OPT_PremoveBlackText, appData.premoveBlackText);\r
@@ -1205,16 +1263,16 @@ IcsOptionsDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
     SendDlgItemMessage(hDlg, OPT_SampleSeek,      EM_SETBKGNDCOLOR, 0, cbc);\r
     SendDlgItemMessage(hDlg, OPT_SampleNormal,    EM_SETBKGNDCOLOR, 0, cbc);\r
 \r
-    SetDlgItemText(hDlg, OPT_SampleShout,     mca[ColorShout].name);\r
-    SetDlgItemText(hDlg, OPT_SampleSShout,    mca[ColorSShout].name);\r
-    SetDlgItemText(hDlg, OPT_SampleChannel1,  mca[ColorChannel1].name);\r
-    SetDlgItemText(hDlg, OPT_SampleChannel,   mca[ColorChannel].name);\r
-    SetDlgItemText(hDlg, OPT_SampleKibitz,    mca[ColorKibitz].name);\r
-    SetDlgItemText(hDlg, OPT_SampleTell,      mca[ColorTell].name);\r
-    SetDlgItemText(hDlg, OPT_SampleChallenge, mca[ColorChallenge].name);\r
-    SetDlgItemText(hDlg, OPT_SampleRequest,   mca[ColorRequest].name);\r
-    SetDlgItemText(hDlg, OPT_SampleSeek,      mca[ColorSeek].name);\r
-    SetDlgItemText(hDlg, OPT_SampleNormal,    mca[ColorNormal].name);\r
+    SetDlgItemText(hDlg, OPT_SampleShout,     T_(mca[ColorShout].name));\r
+    SetDlgItemText(hDlg, OPT_SampleSShout,    T_(mca[ColorSShout].name));\r
+    SetDlgItemText(hDlg, OPT_SampleChannel1,  T_(mca[ColorChannel1].name));\r
+    SetDlgItemText(hDlg, OPT_SampleChannel,   T_(mca[ColorChannel].name));\r
+    SetDlgItemText(hDlg, OPT_SampleKibitz,    T_(mca[ColorKibitz].name));\r
+    SetDlgItemText(hDlg, OPT_SampleTell,      T_(mca[ColorTell].name));\r
+    SetDlgItemText(hDlg, OPT_SampleChallenge, T_(mca[ColorChallenge].name));\r
+    SetDlgItemText(hDlg, OPT_SampleRequest,   T_(mca[ColorRequest].name));\r
+    SetDlgItemText(hDlg, OPT_SampleSeek,      T_(mca[ColorSeek].name));\r
+    SetDlgItemText(hDlg, OPT_SampleNormal,    T_(mca[ColorNormal].name));\r
 \r
     UpdateSampleText(hDlg, OPT_SampleShout,     &mca[ColorShout]);\r
     UpdateSampleText(hDlg, OPT_SampleSShout,    &mca[ColorSShout]);\r
@@ -1233,7 +1291,7 @@ IcsOptionsDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
   case WM_COMMAND: /* message: received a command */\r
     switch (LOWORD(wParam)) {\r
 \r
-    case WM_USER_GetConsoleBackground: \r
+    case WM_USER_GetConsoleBackground:\r
       /* the ColorizeTextDialog needs the current background color */\r
       colorref = (COLORREF *)lParam;\r
       *colorref = cbc;\r
@@ -1243,8 +1301,8 @@ IcsOptionsDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
       /* Read changed options from the dialog box */\r
       GetDlgItemText(hDlg, OPT_IcsAlarmTime, buf, MSG_SIZ);\r
       if (sscanf(buf, "%d", &number) != 1 || (number < 0)){\r
-         MessageBox(hDlg, "Invalid ICS Alarm Time",\r
-                    "Option Error", MB_OK|MB_ICONEXCLAMATION);\r
+         MessageBox(hDlg, _("Invalid ICS Alarm Time"),\r
+                    _("Option Error"), MB_OK|MB_ICONEXCLAMATION);\r
          return FALSE;\r
       }\r
 \r
@@ -1254,8 +1312,10 @@ 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.autoCreateLogon  = IS_CHECKED(OPT_AutoCreate);\r
       appData.getMoveList      = IS_CHECKED(OPT_GetMoveList);\r
       appData.localLineEditing = IS_CHECKED(OPT_LocalLineEditing);\r
       appData.quietPlay        = IS_CHECKED(OPT_QuietPlay);\r
@@ -1297,20 +1357,20 @@ IcsOptionsDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
        cf.dwMask = CFM_COLOR;\r
        cf.crTextColor = ParseColorName(COLOR_NORMAL);\r
 \r
-       SendDlgItemMessage(hwndConsole, OPT_ConsoleInput, \r
+       SendDlgItemMessage(hwndConsole, OPT_ConsoleInput,\r
          EM_SETCHARFORMAT, SCF_ALL, (LPARAM)&cf);\r
-        SendDlgItemMessage(hwndConsole, OPT_ConsoleText, \r
+        SendDlgItemMessage(hwndConsole, OPT_ConsoleText,\r
          EM_SETBKGNDCOLOR, FALSE, background);\r
-       SendDlgItemMessage(hwndConsole, OPT_ConsoleInput, \r
+       SendDlgItemMessage(hwndConsole, OPT_ConsoleInput,\r
          EM_SETBKGNDCOLOR, FALSE, background);\r
       }\r
 \r
       if (cbc != consoleBackgroundColor) {\r
        consoleBackgroundColor = cbc;\r
        if (appData.colorize) {\r
-         SendDlgItemMessage(hwndConsole, OPT_ConsoleText, \r
+         SendDlgItemMessage(hwndConsole, OPT_ConsoleText,\r
            EM_SETBKGNDCOLOR, FALSE, consoleBackgroundColor);\r
-         SendDlgItemMessage(hwndConsole, OPT_ConsoleInput, \r
+         SendDlgItemMessage(hwndConsole, OPT_ConsoleInput,\r
            EM_SETBKGNDCOLOR, FALSE, consoleBackgroundColor);\r
        }\r
       }\r
@@ -1339,7 +1399,7 @@ IcsOptionsDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
 \r
     case OPT_ChooseChannel1Color:\r
       ColorizeTextPopup(hDlg, ColorChannel1);\r
-      UpdateSampleText(hDlg, OPT_SampleChannel1, \r
+      UpdateSampleText(hDlg, OPT_SampleChannel1,\r
                       &colorizeAttribs[ColorChannel1]);\r
       break;\r
 \r
@@ -1373,6 +1433,9 @@ IcsOptionsDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
       UpdateSampleText(hDlg, OPT_SampleSeek, &mca[ColorSeek]);\r
       break;\r
 \r
+\r
+\r
+\r
     case OPT_ChooseNormalColor:\r
       ColorizeTextPopup(hDlg, ColorNormal);\r
       UpdateSampleText(hDlg, OPT_SampleNormal, &mca[ColorNormal]);\r
@@ -1395,7 +1458,7 @@ IcsOptionsDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
 \r
     case OPT_DefaultColors:\r
       for (i=0; i < NColorClasses - 1; i++)\r
-       ParseAttribs(&mca[i].color, \r
+       ParseAttribs(&mca[i].color,\r
                     &mca[i].effects,\r
                     defaultTextAttribs[i]);\r
 \r
@@ -1447,6 +1510,8 @@ IcsOptionsPopup(HWND hwnd)
  *\r
 \*---------------------------------------------------------------------------*/\r
 \r
+char *string; // sorry\r
+\r
 VOID\r
 SetSampleFontText(HWND hwnd, int id, const MyFont *mf)\r
 {\r
@@ -1460,21 +1525,23 @@ SetSampleFontText(HWND hwnd, int id, const MyFont *mf)
   POINT center;\r
   int len;\r
 \r
-  len = sprintf(buf, "%.0f pt. %s%s%s\n",\r
-               mf->mfp.pointSize, mf->mfp.faceName,\r
-               mf->mfp.bold ? " bold" : "",\r
-               mf->mfp.italic ? " italic" : "");\r
+  len = snprintf(buf, MSG_SIZ, "%.0f pt. %s%s%s\n",\r
+                mf->mfp.pointSize, mf->mfp.faceName,\r
+                mf->mfp.bold ? " bold" : "",\r
+                mf->mfp.italic ? " italic" : "");\r
+ if(id != OPT_SamplePieceFont)\r
   SetDlgItemText(hwnd, id, buf);\r
+ else SetDlgItemText(hwnd, id, string);\r
 \r
   hControl = GetDlgItem(hwnd, id);\r
   hdc = GetDC(hControl);\r
   SetMapMode(hdc, MM_TEXT);    /* 1 pixel == 1 logical unit */\r
   oldFont = SelectObject(hdc, mf->hf);\r
-  \r
+\r
   /* get number of logical units necessary to display font name */\r
   GetTextExtentPoint32(hdc, buf, len, &size);\r
 \r
-  /* calculate formatting rectangle in the rich edit control.  \r
+  /* calculate formatting rectangle in the rich edit control.\r
    * May be larger or smaller than the actual control.\r
    */\r
   GetClientRect(hControl, &rectClient);\r
@@ -1490,7 +1557,7 @@ SetSampleFontText(HWND hwnd, int id, const MyFont *mf)
   cf.dwEffects = 0;\r
   if (mf->lf.lfWeight == FW_BOLD) cf.dwEffects |= CFE_BOLD;\r
   if (mf->lf.lfItalic) cf.dwEffects |= CFE_ITALIC;\r
-  strcpy(cf.szFaceName, mf->mfp.faceName);\r
+  safeStrCpy(cf.szFaceName, mf->mfp.faceName, sizeof(cf.szFaceName)/sizeof(cf.szFaceName[0]) );\r
   /*\r
    * yHeight is expressed in twips.  A twip is 1/20 of a font's point\r
    * size. See documentation of CHARFORMAT.  --msw\r
@@ -1501,6 +1568,7 @@ SetSampleFontText(HWND hwnd, int id, const MyFont *mf)
 \r
   /* format the text in the rich edit control */\r
   SendMessage(hControl, EM_SETCHARFORMAT, SCF_ALL, (LPARAM) &cf);\r
+ if(id != OPT_SamplePieceFont)\r
   SendMessage(hControl, EM_SETRECT, (WPARAM)0, (LPARAM) &rectFormat);\r
 \r
   /* clean up */\r
@@ -1517,7 +1585,7 @@ CopyFont(MyFont *dest, const MyFont *src)
   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
+  safeStrCpy(dest->mfp.faceName, src->mfp.faceName, sizeof(dest->mfp.faceName)/sizeof(dest->mfp.faceName[0]) );\r
   CreateFontInMF(dest);\r
 }\r
 \r
@@ -1525,8 +1593,9 @@ CopyFont(MyFont *dest, const MyFont *src)
 LRESULT CALLBACK\r
 FontOptionsDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)\r
 {\r
-  static MyFont workFont[NUM_FONTS];\r
+  static MyFont workFont[NUM_FONTS+1];\r
   static BOOL firstPaint;\r
+  static char pieceText[] = "ABCDEFGHIJKLMNOPQRSTUVWXZabcdefghijklmnopqrstuvwxyz";\r
   int i;\r
   RECT rect;\r
 \r
@@ -1536,7 +1605,11 @@ FontOptionsDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
     /* copy the current font settings into a working copy */\r
     for (i=0; i < NUM_FONTS; i++)\r
       CopyFont(&workFont[i], font[boardSize][i]);\r
+    strncpy(workFont[NUM_FONTS].mfp.faceName, appData.renderPiecesWithFont, sizeof(workFont[NUM_FONTS].mfp.faceName));\r
+    workFont[NUM_FONTS].mfp.pointSize = 16.;\r
+    workFont[NUM_FONTS].mfp.charset = DEFAULT_CHARSET;\r
 \r
+    Translate(hDlg, DLG_Fonts);\r
     if (!appData.icsActive)\r
       EnableWindow(GetDlgItem(hDlg, OPT_ChooseConsoleFont), FALSE);\r
 \r
@@ -1563,6 +1636,9 @@ FontOptionsDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
       SetSampleFontText(hDlg, OPT_SampleCommentsFont, &workFont[COMMENT_FONT]);\r
       SetSampleFontText(hDlg, OPT_SampleConsoleFont, &workFont[CONSOLE_FONT]);\r
       SetSampleFontText(hDlg, OPT_SampleMoveHistoryFont, &workFont[MOVEHISTORY_FONT]);\r
+      SetSampleFontText(hDlg, OPT_SampleGameListFont, &workFont[GAMELIST_FONT]);\r
+      string = appData.fontToPieceTable;\r
+      SetSampleFontText(hDlg, OPT_SamplePieceFont, &workFont[NUM_FONTS]);\r
       firstPaint = FALSE;\r
     }\r
     break;\r
@@ -1578,6 +1654,13 @@ FontOptionsDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
       for (i=0; i < NUM_FONTS; i++)\r
        CopyFont(font[boardSize][i], &workFont[i]);\r
 \r
+      { // Make new piece-to-char table\r
+       char buf[MSG_SIZ];\r
+       GetDlgItemText(hDlg, OPT_SamplePieceFont, buf, MSG_SIZ);\r
+       ASSIGN(appData.fontToPieceTable, buf);\r
+      }\r
+      ASSIGN(appData.renderPiecesWithFont, workFont[NUM_FONTS].mfp.faceName); // piece font\r
+\r
       /* a sad necessity due to the original design of having a separate\r
        * console font, tags font, and comment font for each board size.  IMHO\r
        * these fonts should not be dependent on the current board size.  I'm\r
@@ -1591,6 +1674,7 @@ FontOptionsDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
        CopyFont(font[i][CONSOLE_FONT],  &workFont[CONSOLE_FONT]);\r
        CopyFont(font[i][COMMENT_FONT],  &workFont[COMMENT_FONT]);\r
        CopyFont(font[i][MOVEHISTORY_FONT],  &workFont[MOVEHISTORY_FONT]);\r
+       CopyFont(font[i][GAMELIST_FONT],  &workFont[GAMELIST_FONT]);\r
       }\r
       /* end sad necessity */\r
 \r
@@ -1599,7 +1683,7 @@ FontOptionsDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
 \r
       if (commentDialog) {\r
        SendDlgItemMessage(commentDialog, OPT_CommentText,\r
-         WM_SETFONT, (WPARAM)font[boardSize][COMMENT_FONT]->hf, \r
+         WM_SETFONT, (WPARAM)font[boardSize][COMMENT_FONT]->hf,\r
          MAKELPARAM(TRUE, 0));\r
        GetClientRect(GetDlgItem(commentDialog, OPT_CommentText), &rect);\r
        InvalidateRect(commentDialog, &rect, TRUE);\r
@@ -1607,7 +1691,7 @@ FontOptionsDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
 \r
       if (editTagsDialog) {\r
        SendDlgItemMessage(editTagsDialog, OPT_TagsText,\r
-         WM_SETFONT, (WPARAM)font[boardSize][EDITTAGS_FONT]->hf, \r
+         WM_SETFONT, (WPARAM)font[boardSize][EDITTAGS_FONT]->hf,\r
          MAKELPARAM(TRUE, 0));\r
        GetClientRect(GetDlgItem(editTagsDialog, OPT_TagsText), &rect);\r
        InvalidateRect(editTagsDialog, &rect, TRUE);\r
@@ -1615,7 +1699,7 @@ FontOptionsDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
 \r
       if( moveHistoryDialog != NULL ) {\r
        SendDlgItemMessage(moveHistoryDialog, IDC_MoveHistory,\r
-         WM_SETFONT, (WPARAM)font[boardSize][MOVEHISTORY_FONT]->hf, \r
+         WM_SETFONT, (WPARAM)font[boardSize][MOVEHISTORY_FONT]->hf,\r
          MAKELPARAM(TRUE, 0));\r
         SendMessage( moveHistoryDialog, WM_INITDIALOG, 0, 0 );\r
 //     InvalidateRect(editTagsDialog, NULL, TRUE); // [HGM] this ws improperly cloned?\r
@@ -1623,10 +1707,10 @@ FontOptionsDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
 \r
       if( engineOutputDialog != NULL ) {\r
        SendDlgItemMessage(engineOutputDialog, IDC_EngineMemo1,\r
-         WM_SETFONT, (WPARAM)font[boardSize][MOVEHISTORY_FONT]->hf, \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
+         WM_SETFONT, (WPARAM)font[boardSize][MOVEHISTORY_FONT]->hf,\r
          MAKELPARAM(TRUE, 0));\r
       }\r
 \r
@@ -1680,6 +1764,17 @@ FontOptionsDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
       SetSampleFontText(hDlg, OPT_SampleMoveHistoryFont, &workFont[MOVEHISTORY_FONT]);\r
       break;\r
 \r
+    case OPT_ChooseGameListFont:\r
+      MyCreateFont(hDlg, &workFont[GAMELIST_FONT]);\r
+      SetSampleFontText(hDlg, OPT_SampleGameListFont, &workFont[GAMELIST_FONT]);\r
+      break;\r
+\r
+    case OPT_ChoosePieceFont:\r
+      MyCreateFont(hDlg, &workFont[NUM_FONTS]);\r
+      string = pieceText;\r
+      SetSampleFontText(hDlg, OPT_SamplePieceFont, &workFont[NUM_FONTS]);\r
+      break;\r
+\r
     case OPT_DefaultFonts:\r
       for (i=0; i<NUM_FONTS; i++) {\r
        DeleteObject(&workFont[i].hf);\r
@@ -1693,6 +1788,7 @@ FontOptionsDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
       SetSampleFontText(hDlg, OPT_SampleCommentsFont, &workFont[COMMENT_FONT]);\r
       SetSampleFontText(hDlg, OPT_SampleConsoleFont, &workFont[CONSOLE_FONT]);\r
       SetSampleFontText(hDlg, OPT_SampleMoveHistoryFont, &workFont[MOVEHISTORY_FONT]);\r
+      SetSampleFontText(hDlg, OPT_SampleGameListFont, &workFont[GAMELIST_FONT]);\r
       break;\r
     }\r
   }\r
@@ -1716,22 +1812,23 @@ FontsOptionsPopup(HWND hwnd)
 \r
 \r
 SoundComboData soundComboData[] = {\r
-  {"Move", NULL},\r
-  {"Bell", NULL},\r
-  {"ICS Alarm", NULL},\r
-  {"ICS Win", NULL},\r
-  {"ICS Loss", NULL},\r
-  {"ICS Draw", NULL},\r
-  {"ICS Unfinished", NULL},\r
-  {"Shout", NULL},\r
-  {"SShout/CShout", NULL},\r
-  {"Channel 1", NULL},\r
-  {"Channel", NULL},\r
-  {"Kibitz", NULL},\r
-  {"Tell", NULL},\r
-  {"Challenge", NULL},\r
-  {"Request", NULL},\r
-  {"Seek", NULL},\r
+  {N_("Move"), NULL},\r
+  {N_("Bell"), NULL},\r
+  {N_("Roar"), NULL},\r
+  {N_("ICS Alarm"), NULL},\r
+  {N_("ICS Win"), NULL},\r
+  {N_("ICS Loss"), NULL},\r
+  {N_("ICS Draw"), NULL},\r
+  {N_("ICS Unfinished"), NULL},\r
+  {N_("Shout"), NULL},\r
+  {N_("SShout/CShout"), NULL},\r
+  {N_("Channel 1"), NULL},\r
+  {N_("Channel"), NULL},\r
+  {N_("Kibitz"), NULL},\r
+  {N_("Tell"), NULL},\r
+  {N_("Challenge"), NULL},\r
+  {N_("Request"), NULL},\r
+  {N_("Seek"), NULL},\r
   {NULL, NULL},\r
 };\r
 \r
@@ -1777,9 +1874,9 @@ InitSoundCombo(HWND hwndCombo, SoundComboData *scd)
 \r
   /* send the labels to the combo box */\r
   while (scd->label) {\r
-    err = SendMessage(hwndCombo, CB_ADDSTRING, 0, (LPARAM) scd->label);\r
+    err = SendMessage(hwndCombo, CB_ADDSTRING, 0, (LPARAM) T_(scd->label));\r
     if (err != cnt++) {\r
-      sprintf(buf, "InitSoundCombo(): err '%d', cnt '%d'\n",\r
+      snprintf(buf, MSG_SIZ,  "InitSoundCombo(): err '%d', cnt '%d'\n",\r
          (int)err, (int)cnt);\r
       MessageBox(NULL, buf, NULL, MB_OK);\r
     }\r
@@ -1840,7 +1937,7 @@ void
 DisplaySelectedSound(HWND hDlg, HWND hCombo, const char *name)\r
 {\r
   int radio;\r
-  /* \r
+  /*\r
    * I think it's best to clear the combo and edit boxes. It looks stupid\r
    * to have a value from another sound event sitting there grayed out.\r
    */\r
@@ -1866,7 +1963,7 @@ DisplaySelectedSound(HWND hDlg, HWND hCombo, const char *name)
       radio = OPT_NoSound;\r
     } else {\r
       radio = OPT_BuiltInSound;\r
-      if (SendMessage(hCombo, CB_SELECTSTRING, (WPARAM) -1, \r
+      if (SendMessage(hCombo, CB_SELECTSTRING, (WPARAM) -1,\r
                      (LPARAM) (name + 1)) == CB_ERR) {\r
        SendMessage(hCombo, CB_SETCURSEL, (WPARAM) -1, (LPARAM) 0);\r
        SendMessage(hCombo, WM_SETTEXT, (WPARAM) 0, (LPARAM) (name + 1));\r
@@ -1881,7 +1978,7 @@ DisplaySelectedSound(HWND hDlg, HWND hCombo, const char *name)
   SoundDialogSetEnables(hDlg, radio);\r
   CheckRadioButton(hDlg, OPT_NoSound, OPT_WavFile, radio);\r
 }\r
-    \r
+\r
 \r
 char *builtInSoundNames[] = BUILT_IN_SOUND_NAMES;\r
 \r
@@ -1905,6 +2002,7 @@ SoundOptionsDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
   case WM_INITDIALOG:\r
     /* Center the dialog over the application window */\r
     CenterWindow (hDlg, GetWindow (hDlg, GW_OWNER));\r
+    Translate(hDlg, DLG_Sound);\r
 \r
     /* Initialize the built-in sounds combo */\r
     hBISN = GetDlgItem(hDlg, OPT_BuiltInSoundName);\r
@@ -1922,16 +2020,16 @@ SoundOptionsDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
 \r
   case WM_COMMAND: /* message: received a command */\r
 \r
-    if (((HWND)lParam == hSoundCombo) && \r
+    if (((HWND)lParam == hSoundCombo) &&\r
        (HIWORD(wParam) == CBN_SELCHANGE)) {\r
-      /* \r
+      /*\r
        * the user has selected a new sound event. We must store the name for\r
        * the previously selected event, then retrieve the name for the\r
-       * newly selected event and update the dialog. \r
+       * newly selected event and update the dialog.\r
        */\r
       radio = SoundDialogWhichRadio(hDlg);\r
       newName = strdup(SoundDialogGetName(hDlg, radio));\r
-      \r
+\r
       if (strcmp(newName, soundComboData[index].name) != 0) {\r
        free(soundComboData[index].name);\r
        soundComboData[index].name = newName;\r
@@ -1942,13 +2040,13 @@ SoundOptionsDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
       /* now get the settings for the newly selected event */\r
       index = SendMessage(hSoundCombo, CB_GETCURSEL, (WPARAM)0, (LPARAM)0);\r
       DisplaySelectedSound(hDlg, hBISN, soundComboData[index].name);\r
-      \r
+\r
       return TRUE;\r
     }\r
     switch (LOWORD(wParam)) {\r
     case IDOK:\r
-      /* \r
-       * save the name for the currently selected sound event \r
+      /*\r
+       * save the name for the currently selected sound event\r
        */\r
       radio = SoundDialogWhichRadio(hDlg);\r
       newName = strdup(SoundDialogGetName(hDlg, radio));\r
@@ -1972,7 +2070,7 @@ SoundOptionsDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
       }\r
       for ( cc = (ColorClass)0; cc < NColorClasses - 2; cc++) {\r
        index = (int)cc + (int)NSoundClasses;\r
-       if (strcmp(soundComboData[index].name, \r
+       if (strcmp(soundComboData[index].name,\r
                   textAttribs[cc].sound.name) != 0) {\r
          free(textAttribs[cc].sound.name);\r
          textAttribs[cc].sound.name = strdup(soundComboData[index].name);\r
@@ -2020,7 +2118,7 @@ SoundOptionsDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
 \r
     case OPT_BrowseSound:\r
       f = OpenFileDialog(hDlg, "rb", NULL, "wav", SOUND_FILT,\r
-       "Browse for Sound File", NULL, NULL, buf);\r
+       _("Browse for Sound File"), NULL, NULL, buf);\r
       if (f != NULL) {\r
        fclose(f);\r
        SetDlgItemText(hDlg, OPT_WavFileName, buf);\r
@@ -2145,7 +2243,7 @@ ParseCommSettings(char *arg, DCB *dcb)
   if (cd->label == NULL) goto cant_parse;\r
   return;\r
 cant_parse:\r
-    ExitArgError("Can't parse com port settings", arg);\r
+    ExitArgError(_("Can't parse com port settings"), arg, TRUE);\r
 }\r
 \r
 \r
@@ -2153,7 +2251,7 @@ VOID PrintCommSettings(FILE *f, char *name, DCB *dcb)
 {\r
   char *flow = "??", *parity = "??", *stopBits = "??";\r
   ComboData *cd;\r
-  \r
+\r
   cd = cdParity;\r
   while (cd->label != NULL) {\r
     if (dcb->Parity == cd->value) {\r
@@ -2225,6 +2323,7 @@ CommPortOptionsDialog(HWND hDlg, UINT message, WPARAM wParam,     LPARAM lParam)
   case WM_INITDIALOG: /* message: initialize dialog box */\r
     /* Center the dialog over the application window */\r
     CenterWindow (hDlg, GetWindow(hDlg, GW_OWNER));\r
+    Translate(hDlg, DLG_CommPort);\r
     /* Initialize the dialog items */\r
     /* !! There should probably be some synchronization\r
        in accessing hCommPort and dcb.  Or does modal nature\r
@@ -2242,7 +2341,7 @@ CommPortOptionsDialog(HWND hDlg, UINT message, WPARAM wParam,     LPARAM lParam)
 \r
     hwndCombo = GetDlgItem(hDlg, OPT_DataRate);\r
     InitCombo(hwndCombo, cdDataRate);\r
-    sprintf(buf, "%u", (int)dcb.BaudRate);\r
+    snprintf(buf, MSG_SIZ, "%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
@@ -2304,8 +2403,8 @@ CommPortOptionsDialog(HWND hDlg, UINT message, WPARAM wParam,     LPARAM lParam)
       hwndCombo = GetDlgItem(hDlg, OPT_DataRate);\r
       SendMessage(hwndCombo, WM_GETTEXT, (WPARAM) MSG_SIZ, (LPARAM) buf);\r
       if (sscanf(buf, "%u", &value) != 1) {\r
-       MessageBox(hDlg, "Invalid data rate",\r
-                  "Option Error", MB_OK|MB_ICONEXCLAMATION);\r
+       MessageBox(hDlg, _("Invalid data rate"),\r
+                  _("Option Error"), MB_OK|MB_ICONEXCLAMATION);\r
        return TRUE;\r
       }\r
       dcb.BaudRate = value;\r
@@ -2348,11 +2447,11 @@ CommPortOptionsDialog(HWND hDlg, UINT message, WPARAM wParam,   LPARAM lParam)
       }\r
       if (!SetCommState(hCommPort, (LPDCB) &dcb)) {\r
        err = GetLastError();\r
-       switch(MessageBox(hDlg, \r
+       switch(MessageBox(hDlg,\r
                         "Failed to set comm port state;\r\ninvalid options?",\r
-                        "Option Error", MB_ABORTRETRYIGNORE|MB_ICONQUESTION)) {\r
+                        _("Option Error"), MB_ABORTRETRYIGNORE|MB_ICONQUESTION)) {\r
        case IDABORT:\r
-         DisplayFatalError("Failed to set comm port state", err, 1);\r
+         DisplayFatalError(_("Failed to set comm port state"), err, 1);\r
          exit(1);  /*is it ok to do this from here?*/\r
 \r
        case IDRETRY:\r
@@ -2393,6 +2492,17 @@ CommPortOptionsPopup(HWND hwnd)
  *\r
 \*---------------------------------------------------------------------------*/\r
 \r
+int\r
+LoadOptionsWhichRadio(HWND hDlg)\r
+{\r
+  return (IsDlgButtonChecked(hDlg, OPT_Exact) ? 1 :\r
+         (IsDlgButtonChecked(hDlg, OPT_Subset) ? 2 :\r
+         (IsDlgButtonChecked(hDlg, OPT_Struct) ? 3 :\r
+         (IsDlgButtonChecked(hDlg, OPT_Material) ? 4 :\r
+         (IsDlgButtonChecked(hDlg, OPT_Range) ? 5 :\r
+         (IsDlgButtonChecked(hDlg, OPT_Difference) ? 6 : -1))))));\r
+}\r
+\r
 VOID\r
 SetLoadOptionEnables(HWND hDlg)\r
 {\r
@@ -2408,20 +2518,49 @@ LoadOptions(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
 {\r
   char buf[MSG_SIZ];\r
   float fnumber;\r
+  int ok;\r
 \r
   switch (message) {\r
   case WM_INITDIALOG: /* message: initialize dialog box */\r
     /* Center the dialog over the application window */\r
     CenterWindow (hDlg, GetWindow (hDlg, GW_OWNER));\r
+    Translate(hDlg, DLG_LoadOptions);\r
     /* Initialize the dialog items */\r
     if (appData.timeDelay >= 0.0) {\r
       CheckDlgButton(hDlg, OPT_Autostep, TRUE);\r
-      sprintf(buf, "%.2g", appData.timeDelay);\r
+      snprintf(buf, MSG_SIZ, "%.2g", appData.timeDelay);\r
       SetDlgItemText(hDlg, OPT_ASTimeDelay, buf);\r
     } else {\r
       CheckDlgButton(hDlg, OPT_Autostep, FALSE);\r
     }\r
     SetLoadOptionEnables(hDlg);\r
+    SetDlgItemInt(hDlg, OPT_elo1, appData.eloThreshold1, FALSE);\r
+    SetDlgItemInt(hDlg, OPT_elo2, appData.eloThreshold2, FALSE);\r
+    SetDlgItemInt(hDlg, OPT_date, appData.dateThreshold, FALSE);\r
+    SetDlgItemInt(hDlg, OPT_Stretch, appData.stretch, FALSE);\r
+    CheckDlgButton(hDlg, OPT_Reversed, appData.ignoreColors);\r
+    CheckDlgButton(hDlg, OPT_Mirror, appData.findMirror);\r
+    SetDlgItemText(hDlg, OPT_Counts,  "");\r
+    switch (appData.searchMode) {\r
+    case 1:\r
+      CheckDlgButton(hDlg, OPT_Exact, TRUE);\r
+      break;\r
+    case 2:\r
+      CheckDlgButton(hDlg, OPT_Subset, TRUE);\r
+      break;\r
+    case 3:\r
+      CheckDlgButton(hDlg, OPT_Struct, TRUE);\r
+      break;\r
+    case 4:\r
+      CheckDlgButton(hDlg, OPT_Material, TRUE);\r
+      break;\r
+    case 5:\r
+      CheckDlgButton(hDlg, OPT_Range, TRUE);\r
+      break;\r
+    case 6:\r
+      CheckDlgButton(hDlg, OPT_Difference, TRUE);\r
+      break;\r
+    }\r
     return TRUE;\r
 \r
   case WM_COMMAND: /* message: received a command */\r
@@ -2431,14 +2570,25 @@ LoadOptions(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
       if (IsDlgButtonChecked(hDlg, OPT_Autostep)) {\r
        GetDlgItemText(hDlg, OPT_ASTimeDelay, buf, MSG_SIZ);\r
        if (sscanf(buf, "%f", &fnumber) != 1) {\r
-         MessageBox(hDlg, "Invalid load game step rate",\r
-                    "Option Error", MB_OK|MB_ICONEXCLAMATION);\r
+         MessageBox(hDlg, _("Invalid load game step rate"),\r
+                    _("Option Error"), MB_OK|MB_ICONEXCLAMATION);\r
          return FALSE;\r
        }\r
        appData.timeDelay = fnumber;\r
       } else {\r
        appData.timeDelay = (float) -1.0;\r
       }\r
+      appData.eloThreshold1 = GetDlgItemInt(hDlg, OPT_elo1, &ok, FALSE);\r
+      appData.eloThreshold2 = GetDlgItemInt(hDlg, OPT_elo2, &ok, FALSE);\r
+      appData.dateThreshold = GetDlgItemInt(hDlg, OPT_date, &ok, FALSE);\r
+      appData.stretch = GetDlgItemInt(hDlg, OPT_Stretch, &ok, FALSE);\r
+      appData.searchMode = LoadOptionsWhichRadio(hDlg);\r
+      appData.ignoreColors = IsDlgButtonChecked(hDlg, OPT_Reversed);\r
+      appData.findMirror   = IsDlgButtonChecked(hDlg, OPT_Mirror);\r
+      GetDlgItemText(hDlg, OPT_Counts, buf, MSG_SIZ);\r
+      appData.minPieces = appData.maxPieces = 0;\r
+      sscanf(buf, "%d-%d", &appData.minPieces, &appData.maxPieces);\r
+      if(appData.maxPieces < appData.minPieces) appData.maxPieces = appData.minPieces;\r
       EndDialog(hDlg, TRUE);\r
       return TRUE;\r
 \r
@@ -2456,7 +2606,7 @@ LoadOptions(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
 }\r
 \r
 \r
-VOID \r
+VOID\r
 LoadOptionsPopup(HWND hwnd)\r
 {\r
   FARPROC lpProc = MakeProcInstance((FARPROC)LoadOptions, hInst);\r
@@ -2498,6 +2648,7 @@ SaveOptionsDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
   case WM_INITDIALOG: /* message: initialize dialog box */\r
     /* Center the dialog over the application window */\r
     CenterWindow (hDlg, GetWindow (hDlg, GW_OWNER));\r
+    Translate(hDlg, DLG_SaveOptions);\r
     /* Initialize the dialog items */\r
     if (*appData.saveGameFile != NULLCHAR) {\r
       CheckDlgButton(hDlg, OPT_Autosave, (UINT) TRUE);\r
@@ -2525,33 +2676,20 @@ SaveOptionsDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
       if (IsDlgButtonChecked(hDlg, OPT_Autosave)) {\r
        appData.autoSaveGames = TRUE;\r
        if (IsDlgButtonChecked(hDlg, OPT_AVPrompt)) {\r
-         appData.saveGameFile = "";\r
+         ASSIGN(appData.saveGameFile, ""); // [HGM] make sure value is ALWAYS in allocated memory\r
        } else /*if (IsDlgButtonChecked(hDlg, OPT_AVToFile))*/ {\r
          GetDlgItemText(hDlg, OPT_AVFilename, buf, MSG_SIZ);\r
          if (*buf == NULLCHAR) {\r
-           MessageBox(hDlg, "Invalid save game file name",\r
-                      "Option Error", MB_OK|MB_ICONEXCLAMATION);\r
+           MessageBox(hDlg, _("Invalid save game file name"),\r
+                      _("Option Error"), MB_OK|MB_ICONEXCLAMATION);\r
            return FALSE;\r
          }\r
-         if ((isalpha(buf[0]) && buf[1] == ':') ||\r
-           (buf[0] == '\\' && buf[1] == '\\')) {\r
-           appData.saveGameFile = strdup(buf);\r
-         } else {\r
-           char buf2[MSG_SIZ], buf3[MSG_SIZ];\r
-           char *dummy;\r
-           GetCurrentDirectory(MSG_SIZ, buf3);\r
-           SetCurrentDirectory(installDir);\r
-           if (GetFullPathName(buf, MSG_SIZ, buf2, &dummy)) {\r
-             appData.saveGameFile = strdup(buf2);\r
-           } else {\r
-             appData.saveGameFile = strdup(buf);\r
-           }\r
-           SetCurrentDirectory(buf3);\r
-         }\r
+         FREE(appData.saveGameFile);\r
+         appData.saveGameFile = InterpretFileName(buf, homeDir);\r
        }\r
       } else {\r
        appData.autoSaveGames = FALSE;\r
-       appData.saveGameFile = "";\r
+       ASSIGN(appData.saveGameFile, "");\r
       }\r
       appData.oldSaveStyle = IsDlgButtonChecked(hDlg, OPT_Old);\r
       appData.saveOutOfBookInfo = IsDlgButtonChecked( hDlg, OPT_OutOfBookInfo );\r
@@ -2563,9 +2701,9 @@ SaveOptionsDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
       return TRUE;\r
 \r
     case OPT_AVBrowse:\r
-      f = OpenFileDialog(hDlg, "a", NULL, \r
-                        appData.oldSaveStyle ? "gam" : "pgn", \r
-                        GAME_FILT, "Browse for Auto Save File", \r
+      f = OpenFileDialog(hDlg, "a", NULL,\r
+                        appData.oldSaveStyle ? "gam" : "pgn",\r
+                        GAME_FILT, _("Browse for Auto Save File"),\r
                         NULL, NULL, buf);\r
       if (f != NULL) {\r
        fclose(f);\r
@@ -2621,15 +2759,17 @@ LRESULT CALLBACK
 TimeControl(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)\r
 {\r
   char buf[MSG_SIZ], *tc;\r
-  int mps, increment, odds1, odds2, st;\r
+  int mps, odds1, odds2, st;\r
+  float increment;\r
   BOOL ok, ok2;\r
 \r
   switch (message) {\r
   case WM_INITDIALOG: /* message: initialize dialog box */\r
     /* Center the dialog over the application window */\r
     CenterWindow (hDlg, GetWindow (hDlg, GW_OWNER));\r
+    Translate(hDlg, DLG_TimeControl);\r
     /* Initialize the dialog items */\r
-    if (appData.clockMode && !appData.icsActive) {\r
+    if (/*appData.clockMode &&*/ !appData.icsActive) { // [HGM] even if !clockMode, we could want to set it in tournament dialog\r
       if (searchTime) {\r
        CheckRadioButton(hDlg, OPT_TCUseMoves, OPT_TCUseFixed,\r
                         OPT_TCUseFixed);\r
@@ -2644,12 +2784,15 @@ TimeControl(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
        SetDlgItemText(hDlg, OPT_TCTime2, "");\r
        SetDlgItemText(hDlg, OPT_TCInc, "");\r
       } else {\r
+       int i = appData.timeIncrement;\r
+       if(i == appData.timeIncrement) snprintf(buf, MSG_SIZ, "%d", i);\r
+       else snprintf(buf, MSG_SIZ, "%4.2f", appData.timeIncrement);\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
+       SetDlgItemText(hDlg, OPT_TCInc, buf);\r
       }\r
       SetDlgItemInt(hDlg, OPT_TCOdds1, 1, FALSE);\r
       SetDlgItemInt(hDlg, OPT_TCOdds2, 1, FALSE);\r
@@ -2668,8 +2811,8 @@ TimeControl(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
       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
+         MessageBox(hDlg, _("Invalid max time per move"),\r
+                    _("Option Error"), MB_OK|MB_ICONEXCLAMATION);\r
          return FALSE;\r
        }\r
       } else\r
@@ -2677,28 +2820,29 @@ TimeControl(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
        increment = -1;\r
        mps = GetDlgItemInt(hDlg, OPT_TCMoves, &ok, FALSE);\r
        if (!ok || mps <= 0) {\r
-         MessageBox(hDlg, "Invalid moves per time control",\r
-                    "Option Error", MB_OK|MB_ICONEXCLAMATION);\r
+         MessageBox(hDlg, _("Invalid moves per time control"),\r
+                    _("Option Error"), MB_OK|MB_ICONEXCLAMATION);\r
          return FALSE;\r
        }\r
        GetDlgItemText(hDlg, OPT_TCTime, buf, MSG_SIZ);\r
        if (!ParseTimeControl(buf, increment, mps)) {\r
-         MessageBox(hDlg, "Invalid minutes per time control",\r
-                    "Option Error", MB_OK|MB_ICONEXCLAMATION);\r
+         MessageBox(hDlg, _("Invalid minutes per time control"),\r
+                    _("Option Error"), MB_OK|MB_ICONEXCLAMATION);\r
          return FALSE;\r
        }\r
       tc = buf;\r
       } else {\r
-       increment = GetDlgItemInt(hDlg, OPT_TCInc, &ok, FALSE);\r
+       GetDlgItemText(hDlg, OPT_TCInc, buf, MSG_SIZ);\r
+       ok = (sscanf(buf, "%f%c", &increment, buf) == 1);\r
        if (!ok || increment < 0) {\r
-         MessageBox(hDlg, "Invalid increment",\r
-                    "Option Error", MB_OK|MB_ICONEXCLAMATION);\r
+         MessageBox(hDlg, _("Invalid increment"),\r
+                    _("Option Error"), MB_OK|MB_ICONEXCLAMATION);\r
          return FALSE;\r
        }\r
        GetDlgItemText(hDlg, OPT_TCTime2, buf, MSG_SIZ);\r
        if (!ParseTimeControl(buf, increment, mps)) {\r
-         MessageBox(hDlg, "Invalid initial time",\r
-                    "Option Error", MB_OK|MB_ICONEXCLAMATION);\r
+         MessageBox(hDlg, _("Invalid initial time"),\r
+                    _("Option Error"), MB_OK|MB_ICONEXCLAMATION);\r
          return FALSE;\r
        }\r
       tc = buf;\r
@@ -2706,8 +2850,8 @@ TimeControl(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
       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
+         MessageBox(hDlg, _("Invalid time-odds factor"),\r
+                    _("Option Error"), MB_OK|MB_ICONEXCLAMATION);\r
          return FALSE;\r
       }\r
       searchTime = st;\r
@@ -2737,7 +2881,7 @@ VOID
 TimeControlOptionsPopup(HWND hwnd)\r
 {\r
   if (gameMode != BeginningOfGame) {\r
-    DisplayError("Changing time control during a game is not implemented", 0);\r
+    DisplayError(_("Changing time control during a game is not implemented"), 0);\r
   } else {\r
     FARPROC lpProc = MakeProcInstance((FARPROC)TimeControl, hInst);\r
     DialogBox(hInst, MAKEINTRESOURCE(DLG_TimeControl), hwnd, (DLGPROC) lpProc);\r
@@ -2762,6 +2906,7 @@ LRESULT CALLBACK EnginePlayOptionsDialog(HWND hDlg, UINT message, WPARAM wParam,
 \r
     /* Center the dialog over the application window */\r
     CenterWindow (hDlg, GetWindow (hDlg, GW_OWNER));\r
+    Translate(hDlg, DLG_EnginePlayOptions);\r
 \r
     /* Initialize the dialog items */\r
     CHECK_BOX(IDC_EpPeriodicUpdates, appData.periodicUpdates);\r
@@ -2858,7 +3003,21 @@ VOID EnginePlayOptionsPopup(HWND hwnd)
  * UCI Options Dialog functions\r
  *\r
 \*---------------------------------------------------------------------------*/\r
-static BOOL BrowseForFolder( const char * title, char * path )\r
+INT CALLBACK BrowseCallbackProc(HWND hwnd, \r
+                                UINT uMsg,\r
+                                LPARAM lp, \r
+                                LPARAM pData) \r
+{\r
+    switch(uMsg) \r
+    {\r
+      case BFFM_INITIALIZED: \r
+        SendMessage(hwnd, BFFM_SETSELECTION, TRUE, (LPARAM)pData);\r
+        break;\r
+    }\r
+    return 0;\r
+}\r
+\r
+BOOL BrowseForFolder( const char * title, char * path )\r
 {\r
     BOOL result = FALSE;\r
     BROWSEINFO bi;\r
@@ -2866,8 +3025,10 @@ static BOOL BrowseForFolder( const char * title, char * path )
 \r
     ZeroMemory( &bi, sizeof(bi) );\r
 \r
-    bi.lpszTitle = title == 0 ? "Choose Folder" : title;\r
+    bi.lpszTitle = title == 0 ? _("Choose Folder") : title;\r
     bi.ulFlags = BIF_RETURNONLYFSDIRS;\r
+    bi.lpfn = BrowseCallbackProc;\r
+    bi.lParam = (LPARAM) path;\r
 \r
     pidl = SHBrowseForFolder( &bi );\r
 \r
@@ -2887,6 +3048,13 @@ static BOOL BrowseForFolder( const char * title, char * path )
     return result;\r
 }\r
 \r
+int\r
+IsMultiFormat(char *s)\r
+{\r
+  char *p = strchr(s, ':');\r
+  return p && p != s+1;\r
+}\r
+\r
 LRESULT CALLBACK UciOptionsDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)\r
 {\r
   char buf[MAX_PATH];\r
@@ -2897,11 +3065,15 @@ LRESULT CALLBACK UciOptionsDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM
 \r
     /* Center the dialog over the application window */\r
     CenterWindow (hDlg, GetWindow (hDlg, GW_OWNER));\r
+    Translate(hDlg, DLG_OptionsUCI);\r
 \r
     /* Initialize the dialog items */\r
     SetDlgItemText( hDlg, IDC_PolyglotDir, appData.polyglotDir );\r
     SetDlgItemInt( hDlg, IDC_HashSize, appData.defaultHashSize, TRUE );\r
+    if(appData.defaultPathEGTB[0])\r
     SetDlgItemText( hDlg, IDC_PathToEGTB, appData.defaultPathEGTB );\r
+    else\r
+    SetDlgItemText( hDlg, IDC_PathToEGTB, appData.egtFormats );\r
     SetDlgItemInt( hDlg, IDC_SizeOfEGTB, appData.defaultCacheSizeEGTB, TRUE );\r
     CheckDlgButton( hDlg, IDC_UseBook, (BOOL) appData.usePolyglotBook );\r
     SetDlgItemText( hDlg, IDC_BookFile, appData.polyglotBook );\r
@@ -2910,8 +3082,13 @@ 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
+    // [HGM] Yet another ponder duplicate\r
+    CheckDlgButton( hDlg, OPT_PonderNextMove, (BOOL) appData.ponderNextMove );\r
 \r
     return TRUE;\r
 \r
@@ -2923,17 +3100,25 @@ LRESULT CALLBACK UciOptionsDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM
       appData.defaultHashSize = GetDlgItemInt(hDlg, IDC_HashSize, NULL, FALSE );\r
       appData.defaultCacheSizeEGTB = GetDlgItemInt(hDlg, IDC_SizeOfEGTB, NULL, FALSE );\r
       GetDlgItemText( hDlg, IDC_PathToEGTB, buf, sizeof(buf) );\r
-      appData.defaultPathEGTB = strdup(buf);\r
+      if(IsMultiFormat(buf)) {\r
+        ASSIGN(appData.egtFormats, buf);\r
+      } else {\r
+        ASSIGN(appData.defaultPathEGTB, buf);\r
+      }\r
       GetDlgItemText( hDlg, IDC_BookFile, buf, sizeof(buf) );\r
       appData.polyglotBook = strdup(buf);\r
       appData.usePolyglotBook = (Boolean) IsDlgButtonChecked( hDlg, IDC_UseBook );\r
-      // [HGM] smp: get nr of cores:\r
+      // [HGM] smp: get nr of cores and ponder:\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
+      PonderNextMoveEvent((Boolean) IsDlgButtonChecked( hDlg, OPT_PonderNextMove ));\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
@@ -2945,7 +3130,7 @@ LRESULT CALLBACK UciOptionsDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM
 \r
     case IDC_BrowseForBook:\r
       {\r
-          char filter[] = { \r
+          char filter[] = {\r
               'A','l','l',' ','F','i','l','e','s', 0,\r
               '*','.','*', 0,\r
               'B','I','N',' ','F','i','l','e','s', 0,\r
@@ -2954,7 +3139,7 @@ LRESULT CALLBACK UciOptionsDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM
 \r
           OPENFILENAME ofn;\r
 \r
-          strcpy( buf, "" );\r
+          safeStrCpy( buf, "" , sizeof( buf)/sizeof( buf[0]) );\r
 \r
           ZeroMemory( &ofn, sizeof(ofn) );\r
 \r
@@ -2962,9 +3147,10 @@ LRESULT CALLBACK UciOptionsDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM
           ofn.hwndOwner = hDlg;\r
           ofn.hInstance = hInst;\r
           ofn.lpstrFilter = filter;\r
+\r
           ofn.lpstrFile = buf;\r
           ofn.nMaxFile = sizeof(buf);\r
-          ofn.lpstrTitle = "Choose Book";\r
+          ofn.lpstrTitle = _("Choose Book");\r
           ofn.Flags = OFN_FILEMUSTEXIST | OFN_LONGNAMES | OFN_HIDEREADONLY;\r
 \r
           if( GetOpenFileName( &ofn ) ) {\r
@@ -2974,19 +3160,19 @@ LRESULT CALLBACK UciOptionsDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM
       return TRUE;\r
 \r
     case IDC_BrowseForPolyglotDir:\r
-      if( BrowseForFolder( "Choose Polyglot Directory", buf ) ) {\r
+      if( BrowseForFolder( _("Choose Polyglot Directory"), buf ) ) {\r
         SetDlgItemText( hDlg, IDC_PolyglotDir, buf );\r
 \r
         strcat( buf, "\\polyglot.exe" );\r
 \r
         if( GetFileAttributes(buf) == 0xFFFFFFFF ) {\r
-            MessageBox( hDlg, "Polyglot was not found in the specified folder!", "Warning", MB_OK | MB_ICONWARNING );\r
+            MessageBox( hDlg, _("Polyglot was not found in the specified folder!"), "Warning", MB_OK | MB_ICONWARNING );\r
         }\r
       }\r
       return TRUE;\r
 \r
     case IDC_BrowseForEGTB:\r
-      if( BrowseForFolder( "Choose EGTB Directory:", buf ) ) {\r
+      if( BrowseForFolder( _("Choose EGTB Directory:"), buf ) ) {\r
         SetDlgItemText( hDlg, IDC_PathToEGTB, buf );\r
       }\r
       return TRUE;\r