Subversion Repositories Games.Chess Giants

Rev

Rev 26 | Rev 39 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed

  1. // dialog_options.cpp
  2.  
  3. #include "../common.h"
  4.  
  5.  
  6. // dialog template
  7. #define THIS_DIALOG DIALOG_OPTIONS
  8.  
  9.  
  10. // global variables used in this module only
  11. static void *tab_control;
  12. static wchar_t server_string[MAX_PATH];
  13. static COLORREF custom_colors[16];
  14. static CHOOSECOLOR cc;
  15. static unsigned long selectedcolor_clock;
  16. static unsigned long selectedcolor_history;
  17.  
  18.  
  19. // prototypes of local functions
  20. static void StartThread_ThisDialog (void *thread_parms);
  21. static int CALLBACK DialogProc_ThisDialog (HWND hWnd, unsigned int message, WPARAM wParam, LPARAM lParam);
  22. static void StartThread_DialogBoxLoad (void *thread_parms);
  23.  
  24.  
  25. void DialogBox_Options (void)
  26. {
  27.    // helper function to fire up the modeless dialog box
  28.  
  29.    _beginthread (StartThread_ThisDialog, 0, NULL); // fire up a new one
  30.  
  31.    return; // return as soon as the thread is fired up
  32. }
  33.  
  34.  
  35. void DialogBox_Options_Validated (void)
  36. {
  37.    // callback function called by the main game thread when the dialog box is validated
  38.  
  39.    // remember this callback is no longer to be called
  40.    is_dialogbox_options_validated = false;
  41.  
  42.    return; // finished
  43. }
  44.  
  45.  
  46. static void StartThread_ThisDialog (void *thread_parms)
  47. {
  48.    // this function runs in a separate thread, for that's the only way (seemingly)
  49.    // to implement a non-modal message box using the Common Controls library.
  50.  
  51.    // display the dialog box
  52.    if (DialogBox (hAppInstance, MAKEINTRESOURCE (THIS_DIALOG), hMainWnd, DialogProc_ThisDialog) == 1)
  53.       is_dialogbox_options_validated = true;
  54.  
  55.    TabControl_Destroy (tab_control);
  56.  
  57.    return; // _endthread() implied
  58. }
  59.  
  60.  
  61. static int CALLBACK DialogProc_ThisDialog (HWND hWnd, unsigned int message, WPARAM wParam, LPARAM lParam)
  62. {
  63.    // message handler for the dialog box
  64.  
  65.    static wchar_t temp_string[MAX_PATH];
  66.    static wchar_t value_string[32];
  67.  
  68.    unsigned short wParam_hiword;
  69.    unsigned short wParam_loword;
  70.    wchar_t *port_string;
  71.    int is_checked;
  72.  
  73.    // filter out the commonly used message values
  74.    wParam_hiword = HIWORD (wParam);
  75.    wParam_loword = LOWORD (wParam);
  76.  
  77.    // have we just fired up this window ?
  78.    if (message == WM_INITDIALOG)
  79.    {
  80.       // center the window
  81.       CenterWindow (hWnd, hMainWnd);
  82.  
  83.       // set dialog icons (small one for title bar & big one for task manager)
  84.       SendMessage (hWnd, WM_SETICON, ICON_SMALL, (LPARAM) LoadIcon (hAppInstance, MAKEINTRESOURCE (ICON_MAIN)));
  85.       SendMessage (hWnd, WM_SETICON, ICON_BIG, (LPARAM) LoadIcon (hAppInstance, MAKEINTRESOURCE (ICON_MAIN)));
  86.  
  87.       // set window title and control texts
  88.       SetWindowText (hWnd, LOCALIZE (L"Options_Title"));
  89.       SetWindowText (GetDlgItem (hWnd, BUTTON_OK), LOCALIZE (L"Button_OK"));
  90.       SetWindowText (GetDlgItem (hWnd, BUTTON_CANCEL), LOCALIZE (L"Button_Cancel"));
  91.  
  92.       // create the tab control and populate it
  93.       tab_control = TabControl_New (GetDlgItem (hWnd, TABBOX_OPTIONS), (WNDPROC) DialogProc_ThisDialog);
  94.       TabControl_AddPage (tab_control, LOCALIZE (L"Options_OfflineGameParameters"), DIALOG_OPTIONS_ENGINE);
  95.       TabControl_AddPage (tab_control, LOCALIZE (L"Options_OnlineGameParameters"), DIALOG_OPTIONS_INTERNET);
  96.       TabControl_AddPage (tab_control, LOCALIZE (L"Options_DisplayParameters"), DIALOG_OPTIONS_DISPLAY);
  97.       TabControl_AddPage (tab_control, LOCALIZE (L"Options_GameplayParameters"), DIALOG_OPTIONS_GAMEPLAY);
  98.  
  99.       // setup page 1 (computer play)
  100.       SetWindowText (TabControl_GetItem (tab_control, STATICTEXT_ENGINESEARCHDEPTH), LOCALIZE (L"Options_EnginePredictionLevel"));
  101.       SetWindowText (TabControl_GetItem (tab_control, STATICTEXT_EASY), LOCALIZE (L"Options_Easy"));
  102.       SetWindowText (TabControl_GetItem (tab_control, STATICTEXT_HARD), LOCALIZE (L"Options_Hard"));
  103.       swprintf_s (value_string, WCHAR_SIZEOF (value_string), L"%d", options.engine.depth);
  104.       SetWindowText (TabControl_GetItem (tab_control, STATICTEXT_ENGINESEARCHDEPTHVALUE), value_string);
  105.  
  106.       SetWindowText (TabControl_GetItem (tab_control, CHECKBOX_OPTIONS_ALLOWENGINEBLUNDERS), LOCALIZE (L"Options_AllowEngineBlunders"));
  107.       SetWindowText (TabControl_GetItem (tab_control, STATICTEXT_1PCCHANCE), LOCALIZE (L"Options_1PercentChance"));
  108.       SetWindowText (TabControl_GetItem (tab_control, STATICTEXT_100PCCHANCE), LOCALIZE (L"Options_100PercentChance"));
  109.       if (options.engine.blunder_chances != 0)
  110.          swprintf_s (value_string, WCHAR_SIZEOF (value_string), L"%d %%", options.engine.blunder_chances);
  111.       else
  112.          value_string[0] = 0;
  113.       SetWindowText (TabControl_GetItem (tab_control, STATICTEXT_ENGINEBLUNDERSVALUE), value_string);
  114.  
  115.       SetWindowText (TabControl_GetItem (tab_control, CHECKBOX_OPTIONS_ALLOWENGINERESIGNS), LOCALIZE (L"Options_AllowEngineResigns"));
  116.       SetWindowText (TabControl_GetItem (tab_control, STATICTEXT_YIELDING), LOCALIZE (L"Options_Yielding"));
  117.       SetWindowText (TabControl_GetItem (tab_control, STATICTEXT_OBSTINATE), LOCALIZE (L"Options_Obstinate"));
  118.       if (options.engine.obstinacy_level != -1)
  119.          swprintf_s (value_string, WCHAR_SIZEOF (value_string), L"%d", 1 + options.engine.obstinacy_level);
  120.       else
  121.          value_string[0] = 0;
  122.       SetWindowText (TabControl_GetItem (tab_control, STATICTEXT_ENGINERESIGNVALUE), value_string);
  123.       SetWindowText (TabControl_GetItem (tab_control, STATICTEXT_EXPERTSETTINGS), LOCALIZE (L"Options_ExpertSettingsHelpText"));
  124.       SetWindowText (TabControl_GetItem (tab_control, CHECKBOX_OPTIONS_IAMANEXPERT), LOCALIZE (L"Options_IAmAnExpert"));
  125.       SetWindowText (TabControl_GetItem (tab_control, BUTTON_EXPERTSETTINGS), LOCALIZE (L"Options_ExpertSettings"));
  126.  
  127.       Button_SetCheck (TabControl_GetItem (tab_control, CHECKBOX_OPTIONS_ALLOWENGINEBLUNDERS), (options.engine.blunder_chances > 0 ? BST_CHECKED : BST_UNCHECKED));
  128.       EnableWindow (TabControl_GetItem (tab_control, SLIDER_ENGINE_BLUNDERCHANCE), (options.engine.blunder_chances > 0));
  129.       EnableWindow (TabControl_GetItem (tab_control, STATICTEXT_1PCCHANCE), (options.engine.blunder_chances > 0));
  130.       EnableWindow (TabControl_GetItem (tab_control, STATICTEXT_100PCCHANCE), (options.engine.blunder_chances > 0));
  131.       EnableWindow (TabControl_GetItem (tab_control, SLIDER_ENGINE_BLUNDERCHANCE), (options.engine.blunder_chances > 0));
  132.       Button_SetCheck (TabControl_GetItem (tab_control, CHECKBOX_OPTIONS_ALLOWENGINERESIGNS), (options.engine.obstinacy_level >= 0 ? BST_CHECKED : BST_UNCHECKED));
  133.       EnableWindow (TabControl_GetItem (tab_control, SLIDER_ENGINE_OBSTINACY), (options.engine.obstinacy_level >= 0));
  134.       EnableWindow (TabControl_GetItem (tab_control, STATICTEXT_YIELDING), (options.engine.obstinacy_level >= 0));
  135.       EnableWindow (TabControl_GetItem (tab_control, STATICTEXT_OBSTINATE), (options.engine.obstinacy_level >= 0));
  136.       Button_SetCheck (TabControl_GetItem (tab_control, CHECKBOX_OPTIONS_IAMANEXPERT), (options.engine.is_expert_mode ? BST_CHECKED : BST_UNCHECKED));
  137.       EnableWindow (TabControl_GetItem (tab_control, BUTTON_EXPERTSETTINGS), options.engine.is_expert_mode);
  138.       SendMessage (TabControl_GetItem (tab_control, SLIDER_ENGINE_DIFFICULTYLEVEL), TBM_SETRANGE, true, MAKELONG (1, options.engine.max_depth * (options.engine.is_expert_mode ? 3 : 1)));
  139.       SendMessage (TabControl_GetItem (tab_control, SLIDER_ENGINE_DIFFICULTYLEVEL), TBM_SETPOS, true, options.engine.depth);
  140.       SendMessage (TabControl_GetItem (tab_control, SLIDER_ENGINE_BLUNDERCHANCE), TBM_SETRANGE, true, MAKELONG (1, 100));
  141.       SendMessage (TabControl_GetItem (tab_control, SLIDER_ENGINE_BLUNDERCHANCE), TBM_SETPOS, true, (options.engine.blunder_chances > 0 ? options.engine.blunder_chances : 1));
  142.       SendMessage (TabControl_GetItem (tab_control, SLIDER_ENGINE_OBSTINACY), TBM_SETRANGE, true, MAKELONG (0, 9));
  143.       SendMessage (TabControl_GetItem (tab_control, SLIDER_ENGINE_OBSTINACY), TBM_SETPOS, true, (options.engine.obstinacy_level >= 0 ? options.engine.obstinacy_level : 9));
  144.  
  145.       // setup page 2 (Internet play)
  146.       SetWindowText (TabControl_GetItem (tab_control, STATICTEXT_OPTIONS_SERVERADDRESS), LOCALIZE (L"Options_ServerAddress"));
  147.       SetWindowText (TabControl_GetItem (tab_control, STATICTEXT_OPTIONS_SERVERLOGIN), LOCALIZE (L"Options_ServerLogin"));
  148.       SetWindowText (TabControl_GetItem (tab_control, STATICTEXT_OPTIONS_SERVERPASSWORD), LOCALIZE (L"Options_ServerPassword"));
  149.       SetWindowText (TabControl_GetItem (tab_control, CHECKBOX_OPTIONS_SHOWSERVERMESSAGES), LOCALIZE (L"Options_ShowServerMessages"));
  150.       SetWindowText (TabControl_GetItem (tab_control, CHECKBOX_OPTIONS_SHOWPUBLICCHAT), LOCALIZE (L"Options_ShowPublicChat"));
  151.       SetWindowText (TabControl_GetItem (tab_control, STATICTEXT_OPTIONS_SERVERURL), LOCALIZE (L"Options_CreateAccount"));
  152.       ConvertStaticToHyperlink (TabControl_GetItem (tab_control, STATICTEXT_OPTIONS_SERVERURL));
  153.       SetWindowText (TabControl_GetItem (tab_control, STATICTEXT_OPTIONS_SERVERWARNING), LOCALIZE (L"Options_ServerWarning"));
  154.  
  155.       swprintf_s (server_string, WCHAR_SIZEOF (server_string), L"%s:%d", options.network.server_address, options.network.server_port);
  156.       SetWindowText (TabControl_GetItem (tab_control, EDITBOX_SERVERADDRESS), server_string);
  157.       EnableWindow (TabControl_GetItem (tab_control, EDITBOX_SERVERADDRESS), false); // FIXME: as long as we don't support ICC, don't allow users to change server address
  158.       SetWindowText (TabControl_GetItem (tab_control, EDITBOX_LOGIN), options.network.login);
  159.       SetWindowText (TabControl_GetItem (tab_control, EDITBOX_PASSWORD), options.network.password);
  160.       Button_SetCheck (TabControl_GetItem (tab_control, CHECKBOX_OPTIONS_SHOWPUBLICCHAT), (options.network.want_publicchat ? BST_CHECKED : BST_UNCHECKED));
  161.       Button_SetCheck (TabControl_GetItem (tab_control, CHECKBOX_OPTIONS_SHOWSERVERMESSAGES), (options.network.want_servermessages ? BST_CHECKED : BST_UNCHECKED));
  162.  
  163.       // setup page 3 (display)
  164.       SetWindowText (TabControl_GetItem (tab_control, CHECKBOX_OPTIONS_FULLSCREEN), LOCALIZE (L"Options_Fullscreen"));
  165.       SetWindowText (TabControl_GetItem (tab_control, CHECKBOX_OPTIONS_TEXTUREFILTERING), LOCALIZE (L"Options_TextureFiltering"));
  166.       SetWindowText (TabControl_GetItem (tab_control, CHECKBOX_OPTIONS_HIGHQUALITYFILTERING), LOCALIZE (L"Options_HiQualityFiltering"));
  167.       SetWindowText (TabControl_GetItem (tab_control, CHECKBOX_OPTIONS_SPECULARLIGHTING), LOCALIZE (L"Options_SpecularLighting"));
  168.       SetWindowText (TabControl_GetItem (tab_control, CHECKBOX_OPTIONS_SHOWREFLECTIONS), LOCALIZE (L"Options_ShowReflections"));
  169.  
  170.       Button_SetCheck (TabControl_GetItem (tab_control, CHECKBOX_OPTIONS_FULLSCREEN), (options.want_fullscreen ? BST_CHECKED : BST_UNCHECKED));
  171.       Button_SetCheck (TabControl_GetItem (tab_control, CHECKBOX_OPTIONS_TEXTUREFILTERING), (options.want_filtering ? BST_CHECKED : BST_UNCHECKED));
  172.       EnableWindow (TabControl_GetItem (tab_control, CHECKBOX_OPTIONS_HIGHQUALITYFILTERING), options.want_filtering);
  173.       Button_SetCheck (TabControl_GetItem (tab_control, CHECKBOX_OPTIONS_HIGHQUALITYFILTERING), (options.want_hiquality ? BST_CHECKED : BST_UNCHECKED));
  174.       Button_SetCheck (TabControl_GetItem (tab_control, CHECKBOX_OPTIONS_SPECULARLIGHTING), (options.want_specularlighting ? BST_CHECKED : BST_UNCHECKED));
  175.       Button_SetCheck (TabControl_GetItem (tab_control, CHECKBOX_OPTIONS_SHOWREFLECTIONS), (options.want_reflections ? BST_CHECKED : BST_UNCHECKED));
  176.  
  177.       // setup page 4 (gameplay)
  178.       SetWindowText (TabControl_GetItem (tab_control, CHECKBOX_OPTIONS_SHOWLASTMOVE), LOCALIZE (L"Options_ShowLastMove"));
  179.       SetWindowText (TabControl_GetItem (tab_control, CHECKBOX_OPTIONS_SHOWPOSSIBLEMOVES), LOCALIZE (L"Options_ShowPossibleMoves"));
  180.       SetWindowText (TabControl_GetItem (tab_control, CHECKBOX_OPTIONS_SHOWTHREATS), LOCALIZE (L"Options_ShowThreats"));
  181.       SetWindowText (TabControl_GetItem (tab_control, CHECKBOX_OPTIONS_SHOWANIMATIONS), LOCALIZE (L"Options_ShowAnimations"));
  182.       SetWindowText (TabControl_GetItem (tab_control, CHECKBOX_OPTIONS_SHOWTAKENPARTS), LOCALIZE (L"Options_ShowTakenParts"));
  183.       SetWindowText (TabControl_GetItem (tab_control, CHECKBOX_OPTIONS_SHOWTURN), LOCALIZE (L"Options_ShowTurn"));
  184.       SetWindowText (TabControl_GetItem (tab_control, CHECKBOX_OPTIONS_SHOWCLOCK), LOCALIZE (L"Options_ShowClock"));
  185.       SetWindowText (TabControl_GetItem (tab_control, BUTTON_COLORCLOCK), LOCALIZE (L"Button_Color"));
  186.       SetWindowText (TabControl_GetItem (tab_control, CHECKBOX_OPTIONS_SHOWHISTORY), LOCALIZE (L"Options_ShowHistory"));
  187.       SetWindowText (TabControl_GetItem (tab_control, BUTTON_COLORHISTORY), LOCALIZE (L"Button_Color"));
  188.       SetWindowText (TabControl_GetItem (tab_control, CHECKBOX_OPTIONS_USESEPIAFORHISTORY), LOCALIZE (L"Options_UseSepiaForHistory"));
  189.       SetWindowText (TabControl_GetItem (tab_control, CHECKBOX_OPTIONS_ROTATEBOARD), LOCALIZE (L"Options_RotateBoard"));
  190.       SetWindowText (TabControl_GetItem (tab_control, STATICTEXT_OPTIONS_ROTATESPEED), LOCALIZE (L"Options_RotateSpeed"));
  191.       SetWindowText (TabControl_GetItem (tab_control, CHECKBOX_OPTIONS_PLAYSOUNDS), LOCALIZE (L"Options_PlaySounds"));
  192.  
  193.       Button_SetCheck (TabControl_GetItem (tab_control, CHECKBOX_OPTIONS_SHOWLASTMOVE), (options.want_lastmove ? BST_CHECKED : BST_UNCHECKED));
  194.       Button_SetCheck (TabControl_GetItem (tab_control, CHECKBOX_OPTIONS_SHOWPOSSIBLEMOVES), (options.want_possiblemoves ? BST_CHECKED : BST_UNCHECKED));
  195.       Button_SetCheck (TabControl_GetItem (tab_control, CHECKBOX_OPTIONS_SHOWTHREATS), (options.want_threats ? BST_CHECKED : BST_UNCHECKED));
  196.       Button_SetCheck (TabControl_GetItem (tab_control, CHECKBOX_OPTIONS_SHOWANIMATIONS), (options.want_animations ? BST_CHECKED : BST_UNCHECKED));
  197.       Button_SetCheck (TabControl_GetItem (tab_control, CHECKBOX_OPTIONS_SHOWTAKENPARTS), (options.want_takenparts ? BST_CHECKED : BST_UNCHECKED));
  198.       Button_SetCheck (TabControl_GetItem (tab_control, CHECKBOX_OPTIONS_SHOWTURN), (options.want_turn ? BST_CHECKED : BST_UNCHECKED));
  199.       Button_SetCheck (TabControl_GetItem (tab_control, CHECKBOX_OPTIONS_SHOWCLOCK), (options.want_clock ? BST_CHECKED : BST_UNCHECKED));
  200.       Button_SetCheck (TabControl_GetItem (tab_control, CHECKBOX_OPTIONS_SHOWHISTORY), (options.want_history ? BST_CHECKED : BST_UNCHECKED));
  201.       Button_SetCheck (TabControl_GetItem (tab_control, CHECKBOX_OPTIONS_USESEPIAFORHISTORY), (options.want_sepiafilter ? BST_CHECKED : BST_UNCHECKED));
  202.       Button_SetCheck (TabControl_GetItem (tab_control, CHECKBOX_OPTIONS_ROTATEBOARD), (options.want_autorotateon1vs1 ? BST_CHECKED : BST_UNCHECKED));
  203.       Button_SetCheck (TabControl_GetItem (tab_control, CHECKBOX_OPTIONS_PLAYSOUNDS), (options.want_sounds ? BST_CHECKED : BST_UNCHECKED));
  204.       SendMessage (TabControl_GetItem (tab_control, SLIDER_OPTIONS_ROTATESPEED), TBM_SETRANGE, true, MAKELONG (5, 80));
  205.       SendMessage (TabControl_GetItem (tab_control, SLIDER_OPTIONS_ROTATESPEED), TBM_SETPOS, true, options.rotate_speed);
  206.  
  207.       // set the selected color to the current game clock color (convert from RGBA to GDI BGR)
  208.       selectedcolor_clock = ((options.clock_color & 0x0000ff00) << 8)
  209.                             | ((options.clock_color & 0x00ff0000) >> 8)
  210.                             | ((options.clock_color & 0xff000000) >> 24);
  211.  
  212.       // set the selected color to the current game history color (convert from RGBA to GDI BGR)
  213.       selectedcolor_history = ((options.history_color & 0x0000ff00) << 8)
  214.                               | ((options.history_color & 0x00ff0000) >> 8)
  215.                               | ((options.history_color & 0xff000000) >> 24);
  216.  
  217.       // set focus on the first settable item
  218.       SendMessage (TabControl_GetItem (tab_control, EDITBOX_LOGIN), EM_SETSEL, 0, -1); // select all text
  219.       SetFocus (TabControl_GetItem (tab_control, EDITBOX_LOGIN));
  220.    }
  221.  
  222.    // else did we click the close button on the title bar ?
  223.    else if (message == WM_CLOSE)
  224.       EndDialog (hWnd, 0); // close the dialog box
  225.  
  226.    // else did we take action on one of the controls ?
  227.    else if (message == WM_COMMAND)
  228.    {
  229.       // did we cancel the dialog box ? (IDCANCEL is a system-wide dialog box handler value, that catches the ESC key)
  230.       if (wParam_loword == IDCANCEL)
  231.          EndDialog (hWnd, 0); // close the dialog box
  232.  
  233.       // else was it the OK button ?
  234.       else if (wParam_loword == BUTTON_OK)
  235.       {
  236.          // grab the new parameters and close the dialog box
  237.  
  238.          // set the server address, login and password
  239.          GetWindowText (TabControl_GetItem (tab_control, EDITBOX_SERVERADDRESS), server_string, WCHAR_SIZEOF (server_string));
  240.          options.network.server_address[0] = 0; // default values
  241.          options.network.server_port = 0;
  242.          port_string = wcschr (server_string, L':'); // find the address:port separator
  243.          if (port_string != NULL)
  244.          {
  245.             port_string[0] = 0; // split the string
  246.             options.network.server_port = _wtoi (&port_string[1]); // and read the port
  247.          }
  248.          wcscpy_s (options.network.server_address, WCHAR_SIZEOF (options.network.server_address), server_string); // now read the address
  249.          GetWindowText (TabControl_GetItem (tab_control, EDITBOX_LOGIN), options.network.login, WCHAR_SIZEOF (options.network.login));
  250.          GetWindowText (TabControl_GetItem (tab_control, EDITBOX_PASSWORD), options.network.password, WCHAR_SIZEOF (options.network.password));
  251.  
  252.          options.network.want_servermessages = (Button_GetCheck (TabControl_GetItem (tab_control, CHECKBOX_OPTIONS_SHOWSERVERMESSAGES)) != 0);
  253.          options.network.want_publicchat = (Button_GetCheck (TabControl_GetItem (tab_control, CHECKBOX_OPTIONS_SHOWPUBLICCHAT)) != 0);
  254.          options.want_fullscreen = (Button_GetCheck (TabControl_GetItem (tab_control, CHECKBOX_OPTIONS_FULLSCREEN)) != 0);
  255.          options.want_filtering = (Button_GetCheck (TabControl_GetItem (tab_control, CHECKBOX_OPTIONS_TEXTUREFILTERING)) != 0);
  256.          options.want_specularlighting = (Button_GetCheck (TabControl_GetItem (tab_control, CHECKBOX_OPTIONS_SPECULARLIGHTING)) != 0);
  257.          options.want_reflections = (Button_GetCheck (TabControl_GetItem (tab_control, CHECKBOX_OPTIONS_SHOWREFLECTIONS)) != 0);
  258.          options.want_lastmove = (Button_GetCheck (TabControl_GetItem (tab_control, CHECKBOX_OPTIONS_SHOWLASTMOVE)) != 0);
  259.          options.want_possiblemoves = (Button_GetCheck (TabControl_GetItem (tab_control, CHECKBOX_OPTIONS_SHOWPOSSIBLEMOVES)) != 0);
  260.          options.want_threats = (Button_GetCheck (TabControl_GetItem (tab_control, CHECKBOX_OPTIONS_SHOWTHREATS)) != 0);
  261.          options.want_animations = (Button_GetCheck (TabControl_GetItem (tab_control, CHECKBOX_OPTIONS_SHOWANIMATIONS)) != 0);
  262.          options.want_takenparts = (Button_GetCheck (TabControl_GetItem (tab_control, CHECKBOX_OPTIONS_SHOWTAKENPARTS)) != 0);
  263.          options.want_turn = (Button_GetCheck (TabControl_GetItem (tab_control, CHECKBOX_OPTIONS_SHOWTURN)) != 0);
  264.          options.want_clock = (Button_GetCheck (TabControl_GetItem (tab_control, CHECKBOX_OPTIONS_SHOWCLOCK)) != 0);
  265.          options.clock_color = 0 | ((selectedcolor_clock & 0x000000ff) << 24)
  266.                                  | ((selectedcolor_clock & 0x0000ff00) << 8)
  267.                                  | ((selectedcolor_clock & 0x00ff0000) >> 8); // convert from GDI BGR to RGBA
  268.          options.want_history = (Button_GetCheck (TabControl_GetItem (tab_control, CHECKBOX_OPTIONS_SHOWHISTORY)) != 0);
  269.          options.history_color = 0 | ((selectedcolor_history & 0x000000ff) << 24)
  270.                                    | ((selectedcolor_history & 0x0000ff00) << 8)
  271.                                    | ((selectedcolor_history & 0x00ff0000) >> 8); // convert from GDI BGR to RGBA
  272.          options.want_sepiafilter = (Button_GetCheck (TabControl_GetItem (tab_control, CHECKBOX_OPTIONS_USESEPIAFORHISTORY)) != 0);
  273.          options.want_autorotateon1vs1 = (Button_GetCheck (TabControl_GetItem (tab_control, CHECKBOX_OPTIONS_ROTATEBOARD)) != 0);
  274.          options.want_sounds = (Button_GetCheck (TabControl_GetItem (tab_control, CHECKBOX_OPTIONS_PLAYSOUNDS)) != 0);
  275.  
  276.          options.engine.depth = SendMessage (TabControl_GetItem (tab_control, SLIDER_ENGINE_DIFFICULTYLEVEL), TBM_GETPOS, 0, 0);
  277.          options.rotate_speed = SendMessage (TabControl_GetItem (tab_control, SLIDER_OPTIONS_ROTATESPEED), TBM_GETPOS, 0, 0);
  278.  
  279.          EndDialog (hWnd, 0); // close the dialog box
  280.       }
  281.  
  282.       // else was it the cancel button ?
  283.       else if (wParam_loword == BUTTON_CANCEL)
  284.          EndDialog (hWnd, 0); // close the dialog box
  285.  
  286.       // else was it the expert settings button ?
  287.       else if (wParam_loword == BUTTON_EXPERTSETTINGS)
  288.       {
  289.          swprintf_s (temp_string, WCHAR_SIZEOF (temp_string), L"%s\\engine\\init.txt", app_path);
  290.          ShellExecute (NULL, L"open", temp_string, NULL, NULL, SW_SHOWNORMAL); // open the engine initialization text file
  291.       }
  292.  
  293.       // else is it the rotate board check box ? if so, enable or disable the speed slider
  294.       else if (wParam_loword == CHECKBOX_OPTIONS_ROTATEBOARD)
  295.       {
  296.          EnableWindow (TabControl_GetItem (tab_control, STATICTEXT_OPTIONS_ROTATESPEED), Button_GetCheck (TabControl_GetItem (tab_control, CHECKBOX_OPTIONS_ROTATEBOARD)));
  297.          EnableWindow (TabControl_GetItem (tab_control, SLIDER_OPTIONS_ROTATESPEED), Button_GetCheck (TabControl_GetItem (tab_control, CHECKBOX_OPTIONS_ROTATEBOARD)));
  298.       }
  299.  
  300.       // else is it the I am an expert check box ? if so, enable or disable the expert settings button and adjust the engine level slider
  301.       else if (wParam_loword == CHECKBOX_OPTIONS_IAMANEXPERT)
  302.       {
  303.          options.engine.is_expert_mode = (Button_GetCheck (TabControl_GetItem (tab_control, CHECKBOX_OPTIONS_IAMANEXPERT)) == BST_CHECKED);
  304.          EnableWindow (TabControl_GetItem (tab_control, BUTTON_EXPERTSETTINGS), options.engine.is_expert_mode);
  305.          SendMessage (TabControl_GetItem (tab_control, SLIDER_ENGINE_DIFFICULTYLEVEL), TBM_SETRANGE, true, MAKELONG (1, options.engine.max_depth * (options.engine.is_expert_mode ? 3 : 1)));
  306.       }
  307.  
  308.       // else is it the allow engine blunders check box ? if so, enable or disable the blunder chance slider
  309.       else if (wParam_loword == CHECKBOX_OPTIONS_ALLOWENGINEBLUNDERS)
  310.       {
  311.          is_checked = Button_GetCheck (TabControl_GetItem (tab_control, CHECKBOX_OPTIONS_ALLOWENGINEBLUNDERS));
  312.          EnableWindow (TabControl_GetItem (tab_control, SLIDER_ENGINE_BLUNDERCHANCE), is_checked);
  313.          EnableWindow (TabControl_GetItem (tab_control, STATICTEXT_1PCCHANCE), is_checked);
  314.          EnableWindow (TabControl_GetItem (tab_control, STATICTEXT_100PCCHANCE), is_checked);
  315.          if (is_checked)
  316.          {
  317.             options.engine.blunder_chances = SendMessage (TabControl_GetItem (tab_control, SLIDER_ENGINE_BLUNDERCHANCE), TBM_GETPOS, 0, 0);
  318.             swprintf_s (value_string, WCHAR_SIZEOF (value_string), L"%d %%", options.engine.blunder_chances);
  319.          }
  320.          else
  321.          {
  322.             options.engine.blunder_chances = 0;
  323.             value_string[0] = 0;
  324.          }
  325.          SetWindowText (TabControl_GetItem (tab_control, STATICTEXT_ENGINEBLUNDERSVALUE), value_string);
  326.       }
  327.  
  328.       // else is it the allow engine resigns check box ? if so, enable or disable the blunder chance slider
  329.       else if (wParam_loword == CHECKBOX_OPTIONS_ALLOWENGINERESIGNS)
  330.       {
  331.          is_checked = Button_GetCheck (TabControl_GetItem (tab_control, CHECKBOX_OPTIONS_ALLOWENGINERESIGNS));
  332.          EnableWindow (TabControl_GetItem (tab_control, SLIDER_ENGINE_OBSTINACY), is_checked);
  333.          EnableWindow (TabControl_GetItem (tab_control, STATICTEXT_YIELDING), is_checked);
  334.          EnableWindow (TabControl_GetItem (tab_control, STATICTEXT_OBSTINATE), is_checked);
  335.          if (is_checked)
  336.          {
  337.             options.engine.obstinacy_level = SendMessage (TabControl_GetItem (tab_control, SLIDER_ENGINE_OBSTINACY), TBM_GETPOS, 0, 0);
  338.             swprintf_s (value_string, WCHAR_SIZEOF (value_string), L"%d", 1 + options.engine.obstinacy_level);
  339.          }
  340.          else
  341.          {
  342.             options.engine.obstinacy_level = -1;
  343.             value_string[0] = 0;
  344.          }
  345.          SetWindowText (TabControl_GetItem (tab_control, STATICTEXT_ENGINERESIGNVALUE), value_string);
  346.       }
  347.  
  348.       // else is it the enable filtering check box ? if so, enable or disable the high quality checkbox
  349.       else if (wParam_loword == CHECKBOX_OPTIONS_TEXTUREFILTERING)
  350.          EnableWindow (TabControl_GetItem (tab_control, CHECKBOX_OPTIONS_HIGHQUALITYFILTERING), Button_GetCheck (TabControl_GetItem (tab_control, CHECKBOX_OPTIONS_TEXTUREFILTERING)));
  351.  
  352.       // else is it the show game clock check box ? if so, enable or disable the game clock color button
  353.       else if (wParam_loword == CHECKBOX_OPTIONS_SHOWCLOCK)
  354.          EnableWindow (TabControl_GetItem (tab_control, BUTTON_COLORCLOCK), Button_GetCheck (TabControl_GetItem (tab_control, CHECKBOX_OPTIONS_SHOWCLOCK)));
  355.  
  356.       // else is it the game clock color button ?
  357.       else if (wParam_loword == BUTTON_COLORCLOCK)
  358.       {
  359.          // prepare a color pick dialog box
  360.          memset (&cc, 0, sizeof (cc));
  361.          cc.lStructSize = sizeof (cc);
  362.          cc.hwndOwner = hWnd;
  363.          cc.lpCustColors = (unsigned long *) custom_colors;
  364.          cc.rgbResult = selectedcolor_clock;
  365.          cc.Flags = CC_FULLOPEN | CC_RGBINIT;
  366.  
  367.          // fire it up
  368.          if (ChooseColor (&cc))
  369.             selectedcolor_clock = cc.rgbResult; // save away returned color
  370.       }
  371.  
  372.       // else is it the show game history check box ? if so, enable or disable the game history color button
  373.       else if (wParam_loword == CHECKBOX_OPTIONS_SHOWHISTORY)
  374.          EnableWindow (TabControl_GetItem (tab_control, BUTTON_COLORHISTORY), Button_GetCheck (TabControl_GetItem (tab_control, CHECKBOX_OPTIONS_SHOWHISTORY)));
  375.  
  376.       // else is it the game history color button ?
  377.       else if (wParam_loword == BUTTON_COLORHISTORY)
  378.       {
  379.          // prepare a color pick dialog box
  380.          memset (&cc, 0, sizeof (cc));
  381.          cc.lStructSize = sizeof (cc);
  382.          cc.hwndOwner = hWnd;
  383.          cc.lpCustColors = (unsigned long *) custom_colors;
  384.          cc.rgbResult = selectedcolor_history;
  385.          cc.Flags = CC_FULLOPEN | CC_RGBINIT;
  386.  
  387.          // fire it up
  388.          if (ChooseColor (&cc))
  389.             selectedcolor_history = cc.rgbResult; // save away returned color
  390.       }
  391.  
  392.       // else is it the create/manage account hyperlink ?
  393.       else if (wParam_loword == STATICTEXT_OPTIONS_SERVERURL)
  394.       {
  395.          swprintf_s (temp_string, WCHAR_SIZEOF (temp_string), ACCOUNTCREATION_URL, os_language); // build account creation url
  396.          ShellExecute (NULL, L"open", temp_string, NULL, NULL, SW_MAXIMIZE); // open the accounts page in the default browser, maximized
  397.       }
  398.    }
  399.  
  400.    // else is it a notification for a slider moving ?
  401.    else if (message == WM_HSCROLL)
  402.    {
  403.       // is it the engine prediction level slider ? if so, update the slider value text
  404.       if ((HWND) lParam == TabControl_GetItem (tab_control, SLIDER_ENGINE_DIFFICULTYLEVEL))
  405.       {
  406.          swprintf_s (value_string, WCHAR_SIZEOF (value_string), L"%d", SendMessage (TabControl_GetItem (tab_control, SLIDER_ENGINE_DIFFICULTYLEVEL), TBM_GETPOS, 0, 0));
  407.          SetWindowText (TabControl_GetItem (tab_control, STATICTEXT_ENGINESEARCHDEPTHVALUE), value_string);
  408.       }
  409.  
  410.       // else is it the engine blunders slider ? if so, update the slider value text
  411.       else if ((HWND) lParam == TabControl_GetItem (tab_control, SLIDER_ENGINE_BLUNDERCHANCE))
  412.       {
  413.          swprintf_s (value_string, WCHAR_SIZEOF (value_string), L"%d %%", SendMessage (TabControl_GetItem (tab_control, SLIDER_ENGINE_BLUNDERCHANCE), TBM_GETPOS, 0, 0));
  414.          SetWindowText (TabControl_GetItem (tab_control, STATICTEXT_ENGINEBLUNDERSVALUE), value_string);
  415.       }
  416.  
  417.       // else is it the engine obstinacy slider ? if so, update the slider value text
  418.       else if ((HWND) lParam == TabControl_GetItem (tab_control, SLIDER_ENGINE_OBSTINACY))
  419.       {
  420.          swprintf_s (value_string, WCHAR_SIZEOF (value_string), L"%d", 1 + SendMessage (TabControl_GetItem (tab_control, SLIDER_ENGINE_OBSTINACY), TBM_GETPOS, 0, 0));
  421.          SetWindowText (TabControl_GetItem (tab_control, STATICTEXT_ENGINERESIGNVALUE), value_string);
  422.       }
  423.    }
  424.  
  425.    // else is it a notification for the tab control ?
  426.    else if ((message == WM_NOTIFY) && (((NMHDR *) lParam)->hwndFrom == GetDlgItem (hWnd, TABBOX_OPTIONS)))
  427.       TabControl_Notify ((NMHDR *) lParam);
  428.  
  429.    // call the default dialog message processing function to keep things going
  430.    return (false);
  431. }
  432.