changes from H.G. Muller; version 4.3.14
[xboard.git] / winboard / woptions.c
index 1d92129..b2bbf0a 100644 (file)
@@ -65,6 +65,7 @@ extern char installDir[];
 extern HWND hCommPort;    /* currently open comm port */\r
 extern DCB dcb;\r
 extern BOOLEAN chessProgram;\r
+extern startedFromPositionFile; /* [HGM] loadPos */\r
 \r
 /* types */\r
 \r
@@ -495,7 +496,7 @@ BoardOptionsWhichRadio(HWND hDlg)
 LRESULT CALLBACK\r
 BoardOptionsDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)\r
 {\r
-  static Boolean  mono;\r
+  static Boolean  mono, white, flip;\r
   static BoardSize size;\r
   static COLORREF lsc, dsc, wpc, bpc, hsc, phc;\r
   static HBITMAP pieces[3];\r
@@ -564,6 +565,12 @@ BoardOptionsDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
     if (appData.monoMode)\r
       CheckDlgButton(hDlg, OPT_Monochrome, TRUE);\r
 \r
+    if (appData.allWhite)\r
+      CheckDlgButton(hDlg, OPT_AllWhite, TRUE);\r
+\r
+    if (appData.upsideDown)\r
+      CheckDlgButton(hDlg, OPT_UpsideDown, 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
@@ -575,6 +582,8 @@ BoardOptionsDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
     hsc = highlightSquareColor;\r
     phc = premoveHighlightColor;\r
     mono = appData.monoMode;\r
+    white= appData.allWhite;\r
+    flip = appData.upsideDown;\r
     size = boardSize;\r
 \r
     SetBoardOptionEnables(hDlg);\r
@@ -619,6 +628,8 @@ BoardOptionsDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
          (wpc  != whitePieceColor) ||\r
          (bpc  != blackPieceColor) ||\r
          (hsc  != highlightSquareColor) ||\r
+          (flip != appData.upsideDown) ||\r
+          (white != appData.allWhite) ||\r
          (phc  != premoveHighlightColor)) {\r
 \r
          lightSquareColor = lsc;\r
@@ -628,6 +639,8 @@ BoardOptionsDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
          highlightSquareColor = hsc;\r
          premoveHighlightColor = phc;\r
          appData.monoMode = mono;\r
+          appData.allWhite = white;\r
+          appData.upsideDown = flip;\r
 \r
          InitDrawingColors();\r
          InitDrawingSizes(boardSize, 0);\r
@@ -695,7 +708,11 @@ BoardOptionsDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
       hsc = ParseColorName(HIGHLIGHT_SQUARE_COLOR);\r
       phc = ParseColorName(PREMOVE_HIGHLIGHT_COLOR);\r
       mono = FALSE;\r
+      white= FALSE;\r
+      flip = FALSE;\r
       CheckDlgButton(hDlg, OPT_Monochrome, FALSE);\r
+      CheckDlgButton(hDlg, OPT_AllWhite,   FALSE);\r
+      CheckDlgButton(hDlg, OPT_UpsideDown, FALSE);\r
       PaintColorBlock(hDlg, OPT_LightSquareColor, lsc);\r
       PaintColorBlock(hDlg, OPT_DarkSquareColor,  dsc);\r
       PaintColorBlock(hDlg, OPT_WhitePieceColor,  wpc);\r
@@ -713,6 +730,16 @@ BoardOptionsDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
       mono = !mono;\r
       SetBoardOptionEnables(hDlg);\r
       break;\r
+\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
     break;\r
   }\r
@@ -747,7 +774,16 @@ VariantWhichRadio(HWND hDlg)
          (IsDlgButtonChecked(hDlg, OPT_VariantSuicide) ? VariantSuicide :\r
          (IsDlgButtonChecked(hDlg, OPT_VariantAtomic) ? VariantAtomic :\r
          (IsDlgButtonChecked(hDlg, OPT_VariantShatranj) ? VariantShatranj :\r
-          VariantNormal )))))))))))))));\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_Variant3Checks) ? Variant3Check :\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
 }\r
 \r
 LRESULT CALLBACK\r
@@ -810,6 +846,33 @@ NewVariantDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
     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_Variant3Checks, 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
     }\r
 \r
     SetDlgItemInt( hDlg, IDC_Files, -1, TRUE );\r
@@ -848,6 +911,9 @@ NewVariantDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
       if(!n2_ok) appData.NrRanks = -1;\r
       if(!n3_ok) appData.holdingsSize = -1;\r
 \r
+      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
       Reset(TRUE, TRUE);\r
 \r
       return TRUE;\r
@@ -1919,7 +1985,7 @@ SoundOptionsDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
       return TRUE;\r
 \r
     case OPT_BrowseSound:\r
-      f = OpenFileDialog(hDlg, FALSE, NULL, "wav", SOUND_FILT,\r
+      f = OpenFileDialog(hDlg, "rb", NULL, "wav", SOUND_FILT,\r
        "Browse for Sound File", NULL, NULL, buf);\r
       if (f != NULL) {\r
        fclose(f);\r
@@ -2463,7 +2529,7 @@ SaveOptionsDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
       return TRUE;\r
 \r
     case OPT_AVBrowse:\r
-      f = OpenFileDialog(hDlg, TRUE, NULL, \r
+      f = OpenFileDialog(hDlg, "a", NULL, \r
                         appData.oldSaveStyle ? "gam" : "pgn", \r
                         GAME_FILT, "Browse for Auto Save File", \r
                         NULL, NULL, buf);\r