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