Rev 124 | Rev 140 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
| Rev | Author | Line No. | Line |
|---|---|---|---|
| 1 | pmbaty | 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 | |||
| 124 | pmbaty | 57 | the_board.reevaluate = true; // refresh the GUI buttons if needed |
| 1 | pmbaty | 58 | return; // _endthread() implied |
| 59 | } |
||
| 60 | |||
| 61 | |||
| 62 | static int CALLBACK DialogProc_ThisDialog (HWND hWnd, unsigned int message, WPARAM wParam, LPARAM lParam) |
||
| 63 | { |
||
| 64 | // message handler for the dialog box |
||
| 65 | |||
| 29 | pmbaty | 66 | static wchar_t temp_string[MAX_PATH]; |
| 26 | pmbaty | 67 | static wchar_t value_string[32]; |
| 1 | pmbaty | 68 | |
| 69 | unsigned short wParam_hiword; |
||
| 70 | unsigned short wParam_loword; |
||
| 71 | wchar_t *port_string; |
||
| 59 | pmbaty | 72 | int language_index; |
| 119 | pmbaty | 73 | int engine_index; |
| 1 | pmbaty | 74 | int is_checked; |
| 75 | |||
| 76 | // filter out the commonly used message values |
||
| 77 | wParam_hiword = HIWORD (wParam); |
||
| 78 | wParam_loword = LOWORD (wParam); |
||
| 79 | |||
| 80 | // have we just fired up this window ? |
||
| 81 | if (message == WM_INITDIALOG) |
||
| 82 | { |
||
| 83 | // center the window |
||
| 84 | CenterWindow (hWnd, hMainWnd); |
||
| 85 | |||
| 86 | // set dialog icons (small one for title bar & big one for task manager) |
||
| 87 | SendMessage (hWnd, WM_SETICON, ICON_SMALL, (LPARAM) LoadIcon (hAppInstance, MAKEINTRESOURCE (ICON_MAIN))); |
||
| 88 | SendMessage (hWnd, WM_SETICON, ICON_BIG, (LPARAM) LoadIcon (hAppInstance, MAKEINTRESOURCE (ICON_MAIN))); |
||
| 89 | |||
| 90 | // set window title and control texts |
||
| 91 | SetWindowText (hWnd, LOCALIZE (L"Options_Title")); |
||
| 92 | SetWindowText (GetDlgItem (hWnd, BUTTON_OK), LOCALIZE (L"Button_OK")); |
||
| 93 | SetWindowText (GetDlgItem (hWnd, BUTTON_CANCEL), LOCALIZE (L"Button_Cancel")); |
||
| 94 | |||
| 95 | // create the tab control and populate it |
||
| 96 | tab_control = TabControl_New (GetDlgItem (hWnd, TABBOX_OPTIONS), (WNDPROC) DialogProc_ThisDialog); |
||
| 97 | TabControl_AddPage (tab_control, LOCALIZE (L"Options_OfflineGameParameters"), DIALOG_OPTIONS_ENGINE); |
||
| 98 | TabControl_AddPage (tab_control, LOCALIZE (L"Options_OnlineGameParameters"), DIALOG_OPTIONS_INTERNET); |
||
| 99 | TabControl_AddPage (tab_control, LOCALIZE (L"Options_DisplayParameters"), DIALOG_OPTIONS_DISPLAY); |
||
| 100 | TabControl_AddPage (tab_control, LOCALIZE (L"Options_GameplayParameters"), DIALOG_OPTIONS_GAMEPLAY); |
||
| 101 | |||
| 102 | // setup page 1 (computer play) |
||
| 33 | pmbaty | 103 | SetWindowText (TabControl_GetItem (tab_control, STATICTEXT_ENGINEPROGRAMNAME), LOCALIZE (L"Options_EngineProgramName")); |
| 119 | pmbaty | 104 | for (engine_index = 0; engine_index < options.engine.program_count; engine_index++) |
| 105 | ComboBox_AddString (TabControl_GetItem (tab_control, COMBOBOX_ENGINE), options.engine.programs[engine_index].name); // add all engine programs to the combo box |
||
| 106 | ComboBox_SetCurSel (TabControl_GetItem (tab_control, COMBOBOX_ENGINE), options.engine.selected_program); // select the right entry |
||
| 33 | pmbaty | 107 | |
| 1 | pmbaty | 108 | SetWindowText (TabControl_GetItem (tab_control, STATICTEXT_ENGINESEARCHDEPTH), LOCALIZE (L"Options_EnginePredictionLevel")); |
| 109 | SetWindowText (TabControl_GetItem (tab_control, STATICTEXT_EASY), LOCALIZE (L"Options_Easy")); |
||
| 110 | SetWindowText (TabControl_GetItem (tab_control, STATICTEXT_HARD), LOCALIZE (L"Options_Hard")); |
||
| 26 | pmbaty | 111 | swprintf_s (value_string, WCHAR_SIZEOF (value_string), L"%d", options.engine.depth); |
| 112 | SetWindowText (TabControl_GetItem (tab_control, STATICTEXT_ENGINESEARCHDEPTHVALUE), value_string); |
||
| 113 | |||
| 1 | pmbaty | 114 | SetWindowText (TabControl_GetItem (tab_control, CHECKBOX_OPTIONS_ALLOWENGINEBLUNDERS), LOCALIZE (L"Options_AllowEngineBlunders")); |
| 115 | SetWindowText (TabControl_GetItem (tab_control, STATICTEXT_1PCCHANCE), LOCALIZE (L"Options_1PercentChance")); |
||
| 116 | SetWindowText (TabControl_GetItem (tab_control, STATICTEXT_100PCCHANCE), LOCALIZE (L"Options_100PercentChance")); |
||
| 40 | pmbaty | 117 | if (options.engine.blunder_chances > 0) |
| 26 | pmbaty | 118 | swprintf_s (value_string, WCHAR_SIZEOF (value_string), L"%d %%", options.engine.blunder_chances); |
| 119 | else |
||
| 120 | value_string[0] = 0; |
||
| 121 | SetWindowText (TabControl_GetItem (tab_control, STATICTEXT_ENGINEBLUNDERSVALUE), value_string); |
||
| 122 | |||
| 1 | pmbaty | 123 | SetWindowText (TabControl_GetItem (tab_control, CHECKBOX_OPTIONS_ALLOWENGINERESIGNS), LOCALIZE (L"Options_AllowEngineResigns")); |
| 124 | SetWindowText (TabControl_GetItem (tab_control, STATICTEXT_YIELDING), LOCALIZE (L"Options_Yielding")); |
||
| 125 | SetWindowText (TabControl_GetItem (tab_control, STATICTEXT_OBSTINATE), LOCALIZE (L"Options_Obstinate")); |
||
| 26 | pmbaty | 126 | if (options.engine.obstinacy_level != -1) |
| 127 | swprintf_s (value_string, WCHAR_SIZEOF (value_string), L"%d", 1 + options.engine.obstinacy_level); |
||
| 128 | else |
||
| 129 | value_string[0] = 0; |
||
| 130 | SetWindowText (TabControl_GetItem (tab_control, STATICTEXT_ENGINERESIGNVALUE), value_string); |
||
| 29 | pmbaty | 131 | SetWindowText (TabControl_GetItem (tab_control, STATICTEXT_EXPERTSETTINGS), LOCALIZE (L"Options_ExpertSettingsHelpText")); |
| 132 | SetWindowText (TabControl_GetItem (tab_control, CHECKBOX_OPTIONS_IAMANEXPERT), LOCALIZE (L"Options_IAmAnExpert")); |
||
| 133 | SetWindowText (TabControl_GetItem (tab_control, BUTTON_EXPERTSETTINGS), LOCALIZE (L"Options_ExpertSettings")); |
||
| 1 | pmbaty | 134 | |
| 135 | Button_SetCheck (TabControl_GetItem (tab_control, CHECKBOX_OPTIONS_ALLOWENGINEBLUNDERS), (options.engine.blunder_chances > 0 ? BST_CHECKED : BST_UNCHECKED)); |
||
| 136 | EnableWindow (TabControl_GetItem (tab_control, SLIDER_ENGINE_BLUNDERCHANCE), (options.engine.blunder_chances > 0)); |
||
| 137 | EnableWindow (TabControl_GetItem (tab_control, STATICTEXT_1PCCHANCE), (options.engine.blunder_chances > 0)); |
||
| 138 | EnableWindow (TabControl_GetItem (tab_control, STATICTEXT_100PCCHANCE), (options.engine.blunder_chances > 0)); |
||
| 139 | EnableWindow (TabControl_GetItem (tab_control, SLIDER_ENGINE_BLUNDERCHANCE), (options.engine.blunder_chances > 0)); |
||
| 140 | Button_SetCheck (TabControl_GetItem (tab_control, CHECKBOX_OPTIONS_ALLOWENGINERESIGNS), (options.engine.obstinacy_level >= 0 ? BST_CHECKED : BST_UNCHECKED)); |
||
| 141 | EnableWindow (TabControl_GetItem (tab_control, SLIDER_ENGINE_OBSTINACY), (options.engine.obstinacy_level >= 0)); |
||
| 142 | EnableWindow (TabControl_GetItem (tab_control, STATICTEXT_YIELDING), (options.engine.obstinacy_level >= 0)); |
||
| 143 | EnableWindow (TabControl_GetItem (tab_control, STATICTEXT_OBSTINATE), (options.engine.obstinacy_level >= 0)); |
||
| 29 | pmbaty | 144 | Button_SetCheck (TabControl_GetItem (tab_control, CHECKBOX_OPTIONS_IAMANEXPERT), (options.engine.is_expert_mode ? BST_CHECKED : BST_UNCHECKED)); |
| 145 | EnableWindow (TabControl_GetItem (tab_control, BUTTON_EXPERTSETTINGS), options.engine.is_expert_mode); |
||
| 146 | SendMessage (TabControl_GetItem (tab_control, SLIDER_ENGINE_DIFFICULTYLEVEL), TBM_SETRANGE, true, MAKELONG (1, options.engine.max_depth * (options.engine.is_expert_mode ? 3 : 1))); |
||
| 1 | pmbaty | 147 | SendMessage (TabControl_GetItem (tab_control, SLIDER_ENGINE_DIFFICULTYLEVEL), TBM_SETPOS, true, options.engine.depth); |
| 148 | SendMessage (TabControl_GetItem (tab_control, SLIDER_ENGINE_BLUNDERCHANCE), TBM_SETRANGE, true, MAKELONG (1, 100)); |
||
| 149 | SendMessage (TabControl_GetItem (tab_control, SLIDER_ENGINE_BLUNDERCHANCE), TBM_SETPOS, true, (options.engine.blunder_chances > 0 ? options.engine.blunder_chances : 1)); |
||
| 150 | SendMessage (TabControl_GetItem (tab_control, SLIDER_ENGINE_OBSTINACY), TBM_SETRANGE, true, MAKELONG (0, 9)); |
||
| 151 | SendMessage (TabControl_GetItem (tab_control, SLIDER_ENGINE_OBSTINACY), TBM_SETPOS, true, (options.engine.obstinacy_level >= 0 ? options.engine.obstinacy_level : 9)); |
||
| 152 | |||
| 153 | // setup page 2 (Internet play) |
||
| 154 | SetWindowText (TabControl_GetItem (tab_control, STATICTEXT_OPTIONS_SERVERADDRESS), LOCALIZE (L"Options_ServerAddress")); |
||
| 155 | SetWindowText (TabControl_GetItem (tab_control, STATICTEXT_OPTIONS_SERVERLOGIN), LOCALIZE (L"Options_ServerLogin")); |
||
| 156 | SetWindowText (TabControl_GetItem (tab_control, STATICTEXT_OPTIONS_SERVERPASSWORD), LOCALIZE (L"Options_ServerPassword")); |
||
| 157 | SetWindowText (TabControl_GetItem (tab_control, CHECKBOX_OPTIONS_SHOWSERVERMESSAGES), LOCALIZE (L"Options_ShowServerMessages")); |
||
| 158 | SetWindowText (TabControl_GetItem (tab_control, CHECKBOX_OPTIONS_SHOWPUBLICCHAT), LOCALIZE (L"Options_ShowPublicChat")); |
||
| 159 | SetWindowText (TabControl_GetItem (tab_control, STATICTEXT_OPTIONS_SERVERURL), LOCALIZE (L"Options_CreateAccount")); |
||
| 160 | ConvertStaticToHyperlink (TabControl_GetItem (tab_control, STATICTEXT_OPTIONS_SERVERURL)); |
||
| 161 | SetWindowText (TabControl_GetItem (tab_control, STATICTEXT_OPTIONS_SERVERWARNING), LOCALIZE (L"Options_ServerWarning")); |
||
| 162 | |||
| 163 | swprintf_s (server_string, WCHAR_SIZEOF (server_string), L"%s:%d", options.network.server_address, options.network.server_port); |
||
| 164 | SetWindowText (TabControl_GetItem (tab_control, EDITBOX_SERVERADDRESS), server_string); |
||
| 165 | 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 |
||
| 166 | SetWindowText (TabControl_GetItem (tab_control, EDITBOX_LOGIN), options.network.login); |
||
| 167 | SetWindowText (TabControl_GetItem (tab_control, EDITBOX_PASSWORD), options.network.password); |
||
| 168 | Button_SetCheck (TabControl_GetItem (tab_control, CHECKBOX_OPTIONS_SHOWPUBLICCHAT), (options.network.want_publicchat ? BST_CHECKED : BST_UNCHECKED)); |
||
| 169 | Button_SetCheck (TabControl_GetItem (tab_control, CHECKBOX_OPTIONS_SHOWSERVERMESSAGES), (options.network.want_servermessages ? BST_CHECKED : BST_UNCHECKED)); |
||
| 170 | |||
| 171 | // setup page 3 (display) |
||
| 59 | pmbaty | 172 | SetWindowText (TabControl_GetItem (tab_control, STATICTEXT_LANGUAGE), LOCALIZE (L"Options_Language")); |
| 124 | pmbaty | 173 | ComboBox_AddString (TabControl_GetItem (tab_control, COMBOBOX_LANGUAGE), LOCALIZE (L"Options_SystemLanguage")); |
| 59 | pmbaty | 174 | for (language_index = 0; language_index < language_count; language_index++) |
| 175 | ComboBox_AddString (TabControl_GetItem (tab_control, COMBOBOX_LANGUAGE), languages[language_index].name); // add it to the combo box |
||
| 124 | pmbaty | 176 | if (is_language_auto) |
| 177 | ComboBox_SetCurSel (TabControl_GetItem (tab_control, COMBOBOX_LANGUAGE), 0); // select the right entry |
||
| 178 | else |
||
| 179 | ComboBox_SetCurSel (TabControl_GetItem (tab_control, COMBOBOX_LANGUAGE), 1 + language_id); // select the right entry |
||
| 59 | pmbaty | 180 | |
| 1 | pmbaty | 181 | SetWindowText (TabControl_GetItem (tab_control, CHECKBOX_OPTIONS_FULLSCREEN), LOCALIZE (L"Options_Fullscreen")); |
| 182 | SetWindowText (TabControl_GetItem (tab_control, CHECKBOX_OPTIONS_TEXTUREFILTERING), LOCALIZE (L"Options_TextureFiltering")); |
||
| 183 | SetWindowText (TabControl_GetItem (tab_control, CHECKBOX_OPTIONS_HIGHQUALITYFILTERING), LOCALIZE (L"Options_HiQualityFiltering")); |
||
| 184 | SetWindowText (TabControl_GetItem (tab_control, CHECKBOX_OPTIONS_SPECULARLIGHTING), LOCALIZE (L"Options_SpecularLighting")); |
||
| 185 | SetWindowText (TabControl_GetItem (tab_control, CHECKBOX_OPTIONS_SHOWREFLECTIONS), LOCALIZE (L"Options_ShowReflections")); |
||
| 186 | |||
| 187 | Button_SetCheck (TabControl_GetItem (tab_control, CHECKBOX_OPTIONS_FULLSCREEN), (options.want_fullscreen ? BST_CHECKED : BST_UNCHECKED)); |
||
| 188 | Button_SetCheck (TabControl_GetItem (tab_control, CHECKBOX_OPTIONS_TEXTUREFILTERING), (options.want_filtering ? BST_CHECKED : BST_UNCHECKED)); |
||
| 189 | EnableWindow (TabControl_GetItem (tab_control, CHECKBOX_OPTIONS_HIGHQUALITYFILTERING), options.want_filtering); |
||
| 190 | Button_SetCheck (TabControl_GetItem (tab_control, CHECKBOX_OPTIONS_HIGHQUALITYFILTERING), (options.want_hiquality ? BST_CHECKED : BST_UNCHECKED)); |
||
| 191 | Button_SetCheck (TabControl_GetItem (tab_control, CHECKBOX_OPTIONS_SPECULARLIGHTING), (options.want_specularlighting ? BST_CHECKED : BST_UNCHECKED)); |
||
| 192 | Button_SetCheck (TabControl_GetItem (tab_control, CHECKBOX_OPTIONS_SHOWREFLECTIONS), (options.want_reflections ? BST_CHECKED : BST_UNCHECKED)); |
||
| 193 | |||
| 194 | // setup page 4 (gameplay) |
||
| 195 | SetWindowText (TabControl_GetItem (tab_control, CHECKBOX_OPTIONS_SHOWLASTMOVE), LOCALIZE (L"Options_ShowLastMove")); |
||
| 196 | SetWindowText (TabControl_GetItem (tab_control, CHECKBOX_OPTIONS_SHOWPOSSIBLEMOVES), LOCALIZE (L"Options_ShowPossibleMoves")); |
||
| 197 | SetWindowText (TabControl_GetItem (tab_control, CHECKBOX_OPTIONS_SHOWTHREATS), LOCALIZE (L"Options_ShowThreats")); |
||
| 198 | SetWindowText (TabControl_GetItem (tab_control, CHECKBOX_OPTIONS_SHOWANIMATIONS), LOCALIZE (L"Options_ShowAnimations")); |
||
| 130 | pmbaty | 199 | SetWindowText (TabControl_GetItem (tab_control, CHECKBOX_OPTIONS_SHOWSLIDINGANIMATIONS), LOCALIZE (L"Options_ShowSlidingAnimations")); |
| 1 | pmbaty | 200 | SetWindowText (TabControl_GetItem (tab_control, CHECKBOX_OPTIONS_SHOWTAKENPARTS), LOCALIZE (L"Options_ShowTakenParts")); |
| 201 | SetWindowText (TabControl_GetItem (tab_control, CHECKBOX_OPTIONS_SHOWTURN), LOCALIZE (L"Options_ShowTurn")); |
||
| 202 | SetWindowText (TabControl_GetItem (tab_control, CHECKBOX_OPTIONS_SHOWCLOCK), LOCALIZE (L"Options_ShowClock")); |
||
| 203 | SetWindowText (TabControl_GetItem (tab_control, BUTTON_COLORCLOCK), LOCALIZE (L"Button_Color")); |
||
| 204 | SetWindowText (TabControl_GetItem (tab_control, CHECKBOX_OPTIONS_SHOWHISTORY), LOCALIZE (L"Options_ShowHistory")); |
||
| 205 | SetWindowText (TabControl_GetItem (tab_control, BUTTON_COLORHISTORY), LOCALIZE (L"Button_Color")); |
||
| 206 | SetWindowText (TabControl_GetItem (tab_control, CHECKBOX_OPTIONS_USESEPIAFORHISTORY), LOCALIZE (L"Options_UseSepiaForHistory")); |
||
| 207 | SetWindowText (TabControl_GetItem (tab_control, CHECKBOX_OPTIONS_ROTATEBOARD), LOCALIZE (L"Options_RotateBoard")); |
||
| 208 | SetWindowText (TabControl_GetItem (tab_control, STATICTEXT_OPTIONS_ROTATESPEED), LOCALIZE (L"Options_RotateSpeed")); |
||
| 209 | SetWindowText (TabControl_GetItem (tab_control, CHECKBOX_OPTIONS_PLAYSOUNDS), LOCALIZE (L"Options_PlaySounds")); |
||
| 210 | |||
| 211 | Button_SetCheck (TabControl_GetItem (tab_control, CHECKBOX_OPTIONS_SHOWLASTMOVE), (options.want_lastmove ? BST_CHECKED : BST_UNCHECKED)); |
||
| 212 | Button_SetCheck (TabControl_GetItem (tab_control, CHECKBOX_OPTIONS_SHOWPOSSIBLEMOVES), (options.want_possiblemoves ? BST_CHECKED : BST_UNCHECKED)); |
||
| 213 | Button_SetCheck (TabControl_GetItem (tab_control, CHECKBOX_OPTIONS_SHOWTHREATS), (options.want_threats ? BST_CHECKED : BST_UNCHECKED)); |
||
| 214 | Button_SetCheck (TabControl_GetItem (tab_control, CHECKBOX_OPTIONS_SHOWANIMATIONS), (options.want_animations ? BST_CHECKED : BST_UNCHECKED)); |
||
| 130 | pmbaty | 215 | Button_SetCheck (TabControl_GetItem (tab_control, CHECKBOX_OPTIONS_SHOWSLIDINGANIMATIONS), (options.want_slidinganimations ? BST_CHECKED : BST_UNCHECKED)); |
| 1 | pmbaty | 216 | Button_SetCheck (TabControl_GetItem (tab_control, CHECKBOX_OPTIONS_SHOWTAKENPARTS), (options.want_takenparts ? BST_CHECKED : BST_UNCHECKED)); |
| 217 | Button_SetCheck (TabControl_GetItem (tab_control, CHECKBOX_OPTIONS_SHOWTURN), (options.want_turn ? BST_CHECKED : BST_UNCHECKED)); |
||
| 218 | Button_SetCheck (TabControl_GetItem (tab_control, CHECKBOX_OPTIONS_SHOWCLOCK), (options.want_clock ? BST_CHECKED : BST_UNCHECKED)); |
||
| 219 | Button_SetCheck (TabControl_GetItem (tab_control, CHECKBOX_OPTIONS_SHOWHISTORY), (options.want_history ? BST_CHECKED : BST_UNCHECKED)); |
||
| 220 | Button_SetCheck (TabControl_GetItem (tab_control, CHECKBOX_OPTIONS_USESEPIAFORHISTORY), (options.want_sepiafilter ? BST_CHECKED : BST_UNCHECKED)); |
||
| 221 | Button_SetCheck (TabControl_GetItem (tab_control, CHECKBOX_OPTIONS_ROTATEBOARD), (options.want_autorotateon1vs1 ? BST_CHECKED : BST_UNCHECKED)); |
||
| 222 | Button_SetCheck (TabControl_GetItem (tab_control, CHECKBOX_OPTIONS_PLAYSOUNDS), (options.want_sounds ? BST_CHECKED : BST_UNCHECKED)); |
||
| 223 | SendMessage (TabControl_GetItem (tab_control, SLIDER_OPTIONS_ROTATESPEED), TBM_SETRANGE, true, MAKELONG (5, 80)); |
||
| 224 | SendMessage (TabControl_GetItem (tab_control, SLIDER_OPTIONS_ROTATESPEED), TBM_SETPOS, true, options.rotate_speed); |
||
| 225 | |||
| 226 | // set the selected color to the current game clock color (convert from RGBA to GDI BGR) |
||
| 227 | selectedcolor_clock = ((options.clock_color & 0x0000ff00) << 8) |
||
| 228 | | ((options.clock_color & 0x00ff0000) >> 8) |
||
| 229 | | ((options.clock_color & 0xff000000) >> 24); |
||
| 230 | |||
| 231 | // set the selected color to the current game history color (convert from RGBA to GDI BGR) |
||
| 232 | selectedcolor_history = ((options.history_color & 0x0000ff00) << 8) |
||
| 233 | | ((options.history_color & 0x00ff0000) >> 8) |
||
| 234 | | ((options.history_color & 0xff000000) >> 24); |
||
| 235 | |||
| 236 | // set focus on the first settable item |
||
| 237 | SendMessage (TabControl_GetItem (tab_control, EDITBOX_LOGIN), EM_SETSEL, 0, -1); // select all text |
||
| 238 | SetFocus (TabControl_GetItem (tab_control, EDITBOX_LOGIN)); |
||
| 239 | } |
||
| 240 | |||
| 241 | // else did we click the close button on the title bar ? |
||
| 242 | else if (message == WM_CLOSE) |
||
| 243 | EndDialog (hWnd, 0); // close the dialog box |
||
| 244 | |||
| 245 | // else did we take action on one of the controls ? |
||
| 246 | else if (message == WM_COMMAND) |
||
| 247 | { |
||
| 248 | // did we cancel the dialog box ? (IDCANCEL is a system-wide dialog box handler value, that catches the ESC key) |
||
| 249 | if (wParam_loword == IDCANCEL) |
||
| 250 | EndDialog (hWnd, 0); // close the dialog box |
||
| 251 | |||
| 252 | // else was it the OK button ? |
||
| 253 | else if (wParam_loword == BUTTON_OK) |
||
| 254 | { |
||
| 255 | // grab the new parameters and close the dialog box |
||
| 256 | |||
| 257 | // set the server address, login and password |
||
| 258 | GetWindowText (TabControl_GetItem (tab_control, EDITBOX_SERVERADDRESS), server_string, WCHAR_SIZEOF (server_string)); |
||
| 259 | options.network.server_address[0] = 0; // default values |
||
| 260 | options.network.server_port = 0; |
||
| 261 | port_string = wcschr (server_string, L':'); // find the address:port separator |
||
| 262 | if (port_string != NULL) |
||
| 263 | { |
||
| 264 | port_string[0] = 0; // split the string |
||
| 265 | options.network.server_port = _wtoi (&port_string[1]); // and read the port |
||
| 266 | } |
||
| 267 | wcscpy_s (options.network.server_address, WCHAR_SIZEOF (options.network.server_address), server_string); // now read the address |
||
| 268 | GetWindowText (TabControl_GetItem (tab_control, EDITBOX_LOGIN), options.network.login, WCHAR_SIZEOF (options.network.login)); |
||
| 269 | GetWindowText (TabControl_GetItem (tab_control, EDITBOX_PASSWORD), options.network.password, WCHAR_SIZEOF (options.network.password)); |
||
| 270 | |||
| 59 | pmbaty | 271 | // display |
| 124 | pmbaty | 272 | language_index = ComboBox_GetCurSel (TabControl_GetItem (tab_control, COMBOBOX_LANGUAGE)); |
| 273 | is_language_auto = (language_index == 0); // first, see if the system language is selected |
||
| 274 | if (!is_language_auto) |
||
| 275 | language_id = language_index - 1; // because slot #0 of the list is taken by "System Language" |
||
| 59 | pmbaty | 276 | CreateOrUpdateApplicationMenu (); // on language change, update the application menu |
| 1 | pmbaty | 277 | options.want_fullscreen = (Button_GetCheck (TabControl_GetItem (tab_control, CHECKBOX_OPTIONS_FULLSCREEN)) != 0); |
| 278 | options.want_filtering = (Button_GetCheck (TabControl_GetItem (tab_control, CHECKBOX_OPTIONS_TEXTUREFILTERING)) != 0); |
||
| 279 | options.want_specularlighting = (Button_GetCheck (TabControl_GetItem (tab_control, CHECKBOX_OPTIONS_SPECULARLIGHTING)) != 0); |
||
| 280 | options.want_reflections = (Button_GetCheck (TabControl_GetItem (tab_control, CHECKBOX_OPTIONS_SHOWREFLECTIONS)) != 0); |
||
| 59 | pmbaty | 281 | |
| 282 | // gameplay |
||
| 283 | options.network.want_servermessages = (Button_GetCheck (TabControl_GetItem (tab_control, CHECKBOX_OPTIONS_SHOWSERVERMESSAGES)) != 0); |
||
| 284 | options.network.want_publicchat = (Button_GetCheck (TabControl_GetItem (tab_control, CHECKBOX_OPTIONS_SHOWPUBLICCHAT)) != 0); |
||
| 1 | pmbaty | 285 | options.want_lastmove = (Button_GetCheck (TabControl_GetItem (tab_control, CHECKBOX_OPTIONS_SHOWLASTMOVE)) != 0); |
| 286 | options.want_possiblemoves = (Button_GetCheck (TabControl_GetItem (tab_control, CHECKBOX_OPTIONS_SHOWPOSSIBLEMOVES)) != 0); |
||
| 287 | options.want_threats = (Button_GetCheck (TabControl_GetItem (tab_control, CHECKBOX_OPTIONS_SHOWTHREATS)) != 0); |
||
| 288 | options.want_animations = (Button_GetCheck (TabControl_GetItem (tab_control, CHECKBOX_OPTIONS_SHOWANIMATIONS)) != 0); |
||
| 130 | pmbaty | 289 | options.want_slidinganimations = (Button_GetCheck (TabControl_GetItem (tab_control, CHECKBOX_OPTIONS_SHOWSLIDINGANIMATIONS)) != 0); |
| 1 | pmbaty | 290 | options.want_takenparts = (Button_GetCheck (TabControl_GetItem (tab_control, CHECKBOX_OPTIONS_SHOWTAKENPARTS)) != 0); |
| 291 | options.want_turn = (Button_GetCheck (TabControl_GetItem (tab_control, CHECKBOX_OPTIONS_SHOWTURN)) != 0); |
||
| 292 | options.want_clock = (Button_GetCheck (TabControl_GetItem (tab_control, CHECKBOX_OPTIONS_SHOWCLOCK)) != 0); |
||
| 293 | options.clock_color = 0 | ((selectedcolor_clock & 0x000000ff) << 24) |
||
| 294 | | ((selectedcolor_clock & 0x0000ff00) << 8) |
||
| 295 | | ((selectedcolor_clock & 0x00ff0000) >> 8); // convert from GDI BGR to RGBA |
||
| 296 | options.want_history = (Button_GetCheck (TabControl_GetItem (tab_control, CHECKBOX_OPTIONS_SHOWHISTORY)) != 0); |
||
| 297 | options.history_color = 0 | ((selectedcolor_history & 0x000000ff) << 24) |
||
| 298 | | ((selectedcolor_history & 0x0000ff00) << 8) |
||
| 299 | | ((selectedcolor_history & 0x00ff0000) >> 8); // convert from GDI BGR to RGBA |
||
| 300 | options.want_sepiafilter = (Button_GetCheck (TabControl_GetItem (tab_control, CHECKBOX_OPTIONS_USESEPIAFORHISTORY)) != 0); |
||
| 301 | options.want_autorotateon1vs1 = (Button_GetCheck (TabControl_GetItem (tab_control, CHECKBOX_OPTIONS_ROTATEBOARD)) != 0); |
||
| 302 | options.want_sounds = (Button_GetCheck (TabControl_GetItem (tab_control, CHECKBOX_OPTIONS_PLAYSOUNDS)) != 0); |
||
| 40 | pmbaty | 303 | options.rotate_speed = SendMessage (TabControl_GetItem (tab_control, SLIDER_OPTIONS_ROTATESPEED), TBM_GETPOS, 0, 0); |
| 1 | pmbaty | 304 | |
| 40 | pmbaty | 305 | // engine options |
| 306 | ComboBox_GetLBText (TabControl_GetItem (tab_control, COMBOBOX_ENGINE), ComboBox_GetCurSel (TabControl_GetItem (tab_control, COMBOBOX_ENGINE)), temp_string); |
||
| 119 | pmbaty | 307 | for (engine_index = 0; engine_index < options.engine.program_count; engine_index++) |
| 130 | pmbaty | 308 | if ((_wcsicmp (temp_string, options.engine.programs[engine_index].name) == 0) && (engine_index != options.engine.selected_program)) |
| 119 | pmbaty | 309 | { |
| 310 | options.engine.selected_program = engine_index; |
||
| 311 | MessageBox (hWnd, LOCALIZE (L"Options_ChessEngineChangeWillAffectNextGame"), LOCALIZE (L"ImportantMessage"), MB_ICONINFORMATION | MB_OK); |
||
| 312 | } |
||
| 40 | pmbaty | 313 | |
| 1 | pmbaty | 314 | options.engine.depth = SendMessage (TabControl_GetItem (tab_control, SLIDER_ENGINE_DIFFICULTYLEVEL), TBM_GETPOS, 0, 0); |
| 40 | pmbaty | 315 | if (Button_GetCheck (TabControl_GetItem (tab_control, CHECKBOX_OPTIONS_ALLOWENGINEBLUNDERS))) |
| 316 | options.engine.blunder_chances = SendMessage (TabControl_GetItem (tab_control, SLIDER_ENGINE_BLUNDERCHANCE), TBM_GETPOS, 0, 0); |
||
| 317 | else |
||
| 318 | options.engine.blunder_chances = 0; |
||
| 319 | if (Button_GetCheck (TabControl_GetItem (tab_control, CHECKBOX_OPTIONS_ALLOWENGINERESIGNS))) |
||
| 320 | options.engine.obstinacy_level = SendMessage (TabControl_GetItem (tab_control, SLIDER_ENGINE_OBSTINACY), TBM_GETPOS, 0, 0); |
||
| 321 | else |
||
| 322 | options.engine.obstinacy_level = -1; |
||
| 1 | pmbaty | 323 | |
| 324 | EndDialog (hWnd, 0); // close the dialog box |
||
| 325 | } |
||
| 326 | |||
| 327 | // else was it the cancel button ? |
||
| 328 | else if (wParam_loword == BUTTON_CANCEL) |
||
| 329 | EndDialog (hWnd, 0); // close the dialog box |
||
| 330 | |||
| 29 | pmbaty | 331 | // else was it the expert settings button ? |
| 332 | else if (wParam_loword == BUTTON_EXPERTSETTINGS) |
||
| 333 | { |
||
| 59 | pmbaty | 334 | ComboBox_GetLBText (TabControl_GetItem (tab_control, COMBOBOX_ENGINE), ComboBox_GetCurSel (TabControl_GetItem (tab_control, COMBOBOX_ENGINE)), value_string); |
| 335 | swprintf_s (temp_string, WCHAR_SIZEOF (temp_string), L"%s\\engines\\%s\\init.txt", app_path, value_string); |
||
| 29 | pmbaty | 336 | ShellExecute (NULL, L"open", temp_string, NULL, NULL, SW_SHOWNORMAL); // open the engine initialization text file |
| 337 | } |
||
| 338 | |||
| 1 | pmbaty | 339 | // else is it the rotate board check box ? if so, enable or disable the speed slider |
| 340 | else if (wParam_loword == CHECKBOX_OPTIONS_ROTATEBOARD) |
||
| 341 | { |
||
| 342 | EnableWindow (TabControl_GetItem (tab_control, STATICTEXT_OPTIONS_ROTATESPEED), Button_GetCheck (TabControl_GetItem (tab_control, CHECKBOX_OPTIONS_ROTATEBOARD))); |
||
| 343 | EnableWindow (TabControl_GetItem (tab_control, SLIDER_OPTIONS_ROTATESPEED), Button_GetCheck (TabControl_GetItem (tab_control, CHECKBOX_OPTIONS_ROTATEBOARD))); |
||
| 344 | } |
||
| 345 | |||
| 29 | pmbaty | 346 | // 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 |
| 347 | else if (wParam_loword == CHECKBOX_OPTIONS_IAMANEXPERT) |
||
| 348 | { |
||
| 349 | options.engine.is_expert_mode = (Button_GetCheck (TabControl_GetItem (tab_control, CHECKBOX_OPTIONS_IAMANEXPERT)) == BST_CHECKED); |
||
| 350 | EnableWindow (TabControl_GetItem (tab_control, BUTTON_EXPERTSETTINGS), options.engine.is_expert_mode); |
||
| 351 | SendMessage (TabControl_GetItem (tab_control, SLIDER_ENGINE_DIFFICULTYLEVEL), TBM_SETRANGE, true, MAKELONG (1, options.engine.max_depth * (options.engine.is_expert_mode ? 3 : 1))); |
||
| 352 | } |
||
| 353 | |||
| 1 | pmbaty | 354 | // else is it the allow engine blunders check box ? if so, enable or disable the blunder chance slider |
| 355 | else if (wParam_loword == CHECKBOX_OPTIONS_ALLOWENGINEBLUNDERS) |
||
| 356 | { |
||
| 357 | is_checked = Button_GetCheck (TabControl_GetItem (tab_control, CHECKBOX_OPTIONS_ALLOWENGINEBLUNDERS)); |
||
| 358 | EnableWindow (TabControl_GetItem (tab_control, SLIDER_ENGINE_BLUNDERCHANCE), is_checked); |
||
| 359 | EnableWindow (TabControl_GetItem (tab_control, STATICTEXT_1PCCHANCE), is_checked); |
||
| 360 | EnableWindow (TabControl_GetItem (tab_control, STATICTEXT_100PCCHANCE), is_checked); |
||
| 26 | pmbaty | 361 | if (is_checked) |
| 40 | pmbaty | 362 | swprintf_s (value_string, WCHAR_SIZEOF (value_string), L"%d %%", SendMessage (TabControl_GetItem (tab_control, SLIDER_ENGINE_BLUNDERCHANCE), TBM_GETPOS, 0, 0)); |
| 26 | pmbaty | 363 | else |
| 364 | value_string[0] = 0; |
||
| 365 | SetWindowText (TabControl_GetItem (tab_control, STATICTEXT_ENGINEBLUNDERSVALUE), value_string); |
||
| 1 | pmbaty | 366 | } |
| 367 | |||
| 368 | // else is it the allow engine resigns check box ? if so, enable or disable the blunder chance slider |
||
| 369 | else if (wParam_loword == CHECKBOX_OPTIONS_ALLOWENGINERESIGNS) |
||
| 370 | { |
||
| 371 | is_checked = Button_GetCheck (TabControl_GetItem (tab_control, CHECKBOX_OPTIONS_ALLOWENGINERESIGNS)); |
||
| 372 | EnableWindow (TabControl_GetItem (tab_control, SLIDER_ENGINE_OBSTINACY), is_checked); |
||
| 373 | EnableWindow (TabControl_GetItem (tab_control, STATICTEXT_YIELDING), is_checked); |
||
| 374 | EnableWindow (TabControl_GetItem (tab_control, STATICTEXT_OBSTINATE), is_checked); |
||
| 26 | pmbaty | 375 | if (is_checked) |
| 40 | pmbaty | 376 | swprintf_s (value_string, WCHAR_SIZEOF (value_string), L"%d", 1 + SendMessage (TabControl_GetItem (tab_control, SLIDER_ENGINE_OBSTINACY), TBM_GETPOS, 0, 0)); |
| 26 | pmbaty | 377 | else |
| 378 | value_string[0] = 0; |
||
| 379 | SetWindowText (TabControl_GetItem (tab_control, STATICTEXT_ENGINERESIGNVALUE), value_string); |
||
| 1 | pmbaty | 380 | } |
| 381 | |||
| 382 | // else is it the enable filtering check box ? if so, enable or disable the high quality checkbox |
||
| 383 | else if (wParam_loword == CHECKBOX_OPTIONS_TEXTUREFILTERING) |
||
| 384 | EnableWindow (TabControl_GetItem (tab_control, CHECKBOX_OPTIONS_HIGHQUALITYFILTERING), Button_GetCheck (TabControl_GetItem (tab_control, CHECKBOX_OPTIONS_TEXTUREFILTERING))); |
||
| 385 | |||
| 130 | pmbaty | 386 | // else is it the show animations check box ? if so, enable or disable the show sliding animations checkbox too |
| 387 | else if (wParam_loword == CHECKBOX_OPTIONS_SHOWANIMATIONS) |
||
| 388 | EnableWindow (TabControl_GetItem (tab_control, CHECKBOX_OPTIONS_SHOWSLIDINGANIMATIONS), Button_GetCheck (TabControl_GetItem (tab_control, CHECKBOX_OPTIONS_SHOWANIMATIONS))); |
||
| 389 | |||
| 1 | pmbaty | 390 | // else is it the show game clock check box ? if so, enable or disable the game clock color button |
| 391 | else if (wParam_loword == CHECKBOX_OPTIONS_SHOWCLOCK) |
||
| 392 | EnableWindow (TabControl_GetItem (tab_control, BUTTON_COLORCLOCK), Button_GetCheck (TabControl_GetItem (tab_control, CHECKBOX_OPTIONS_SHOWCLOCK))); |
||
| 393 | |||
| 394 | // else is it the game clock color button ? |
||
| 395 | else if (wParam_loword == BUTTON_COLORCLOCK) |
||
| 396 | { |
||
| 397 | // prepare a color pick dialog box |
||
| 398 | memset (&cc, 0, sizeof (cc)); |
||
| 399 | cc.lStructSize = sizeof (cc); |
||
| 400 | cc.hwndOwner = hWnd; |
||
| 401 | cc.lpCustColors = (unsigned long *) custom_colors; |
||
| 402 | cc.rgbResult = selectedcolor_clock; |
||
| 403 | cc.Flags = CC_FULLOPEN | CC_RGBINIT; |
||
| 404 | |||
| 405 | // fire it up |
||
| 406 | if (ChooseColor (&cc)) |
||
| 407 | selectedcolor_clock = cc.rgbResult; // save away returned color |
||
| 408 | } |
||
| 409 | |||
| 410 | // else is it the show game history check box ? if so, enable or disable the game history color button |
||
| 411 | else if (wParam_loword == CHECKBOX_OPTIONS_SHOWHISTORY) |
||
| 412 | EnableWindow (TabControl_GetItem (tab_control, BUTTON_COLORHISTORY), Button_GetCheck (TabControl_GetItem (tab_control, CHECKBOX_OPTIONS_SHOWHISTORY))); |
||
| 413 | |||
| 414 | // else is it the game history color button ? |
||
| 415 | else if (wParam_loword == BUTTON_COLORHISTORY) |
||
| 416 | { |
||
| 417 | // prepare a color pick dialog box |
||
| 418 | memset (&cc, 0, sizeof (cc)); |
||
| 419 | cc.lStructSize = sizeof (cc); |
||
| 420 | cc.hwndOwner = hWnd; |
||
| 421 | cc.lpCustColors = (unsigned long *) custom_colors; |
||
| 422 | cc.rgbResult = selectedcolor_history; |
||
| 423 | cc.Flags = CC_FULLOPEN | CC_RGBINIT; |
||
| 424 | |||
| 425 | // fire it up |
||
| 426 | if (ChooseColor (&cc)) |
||
| 427 | selectedcolor_history = cc.rgbResult; // save away returned color |
||
| 428 | } |
||
| 429 | |||
| 430 | // else is it the create/manage account hyperlink ? |
||
| 431 | else if (wParam_loword == STATICTEXT_OPTIONS_SERVERURL) |
||
| 432 | { |
||
| 59 | pmbaty | 433 | swprintf_s (temp_string, WCHAR_SIZEOF (temp_string), ACCOUNTCREATION_URL, languages[language_id].name); // build account creation url |
| 29 | pmbaty | 434 | ShellExecute (NULL, L"open", temp_string, NULL, NULL, SW_MAXIMIZE); // open the accounts page in the default browser, maximized |
| 1 | pmbaty | 435 | } |
| 436 | } |
||
| 437 | |||
| 26 | pmbaty | 438 | // else is it a notification for a slider moving ? |
| 439 | else if (message == WM_HSCROLL) |
||
| 440 | { |
||
| 441 | // is it the engine prediction level slider ? if so, update the slider value text |
||
| 442 | if ((HWND) lParam == TabControl_GetItem (tab_control, SLIDER_ENGINE_DIFFICULTYLEVEL)) |
||
| 443 | { |
||
| 444 | swprintf_s (value_string, WCHAR_SIZEOF (value_string), L"%d", SendMessage (TabControl_GetItem (tab_control, SLIDER_ENGINE_DIFFICULTYLEVEL), TBM_GETPOS, 0, 0)); |
||
| 445 | SetWindowText (TabControl_GetItem (tab_control, STATICTEXT_ENGINESEARCHDEPTHVALUE), value_string); |
||
| 446 | } |
||
| 447 | |||
| 448 | // else is it the engine blunders slider ? if so, update the slider value text |
||
| 449 | else if ((HWND) lParam == TabControl_GetItem (tab_control, SLIDER_ENGINE_BLUNDERCHANCE)) |
||
| 450 | { |
||
| 451 | swprintf_s (value_string, WCHAR_SIZEOF (value_string), L"%d %%", SendMessage (TabControl_GetItem (tab_control, SLIDER_ENGINE_BLUNDERCHANCE), TBM_GETPOS, 0, 0)); |
||
| 452 | SetWindowText (TabControl_GetItem (tab_control, STATICTEXT_ENGINEBLUNDERSVALUE), value_string); |
||
| 453 | } |
||
| 454 | |||
| 455 | // else is it the engine obstinacy slider ? if so, update the slider value text |
||
| 456 | else if ((HWND) lParam == TabControl_GetItem (tab_control, SLIDER_ENGINE_OBSTINACY)) |
||
| 457 | { |
||
| 458 | swprintf_s (value_string, WCHAR_SIZEOF (value_string), L"%d", 1 + SendMessage (TabControl_GetItem (tab_control, SLIDER_ENGINE_OBSTINACY), TBM_GETPOS, 0, 0)); |
||
| 459 | SetWindowText (TabControl_GetItem (tab_control, STATICTEXT_ENGINERESIGNVALUE), value_string); |
||
| 460 | } |
||
| 461 | } |
||
| 462 | |||
| 1 | pmbaty | 463 | // else is it a notification for the tab control ? |
| 464 | else if ((message == WM_NOTIFY) && (((NMHDR *) lParam)->hwndFrom == GetDlgItem (hWnd, TABBOX_OPTIONS))) |
||
| 465 | TabControl_Notify ((NMHDR *) lParam); |
||
| 466 | |||
| 467 | // call the default dialog message processing function to keep things going |
||
| 468 | return (false); |
||
| 469 | } |