Subversion Repositories Games.Chess Giants

Rev

Rev 26 | Go to most recent revision | Details | 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
 
65
   static wchar_t accountcreation_url[MAX_PATH];
66
 
67
   unsigned short wParam_hiword;
68
   unsigned short wParam_loword;
69
   wchar_t *port_string;
70
   int is_checked;
71
 
72
   // filter out the commonly used message values
73
   wParam_hiword = HIWORD (wParam);
74
   wParam_loword = LOWORD (wParam);
75
 
76
   // have we just fired up this window ?
77
   if (message == WM_INITDIALOG)
78
   {
79
      // center the window
80
      CenterWindow (hWnd, hMainWnd);
81
 
82
      // set dialog icons (small one for title bar & big one for task manager)
83
      SendMessage (hWnd, WM_SETICON, ICON_SMALL, (LPARAM) LoadIcon (hAppInstance, MAKEINTRESOURCE (ICON_MAIN)));
84
      SendMessage (hWnd, WM_SETICON, ICON_BIG, (LPARAM) LoadIcon (hAppInstance, MAKEINTRESOURCE (ICON_MAIN)));
85
 
86
      // set window title and control texts
87
      SetWindowText (hWnd, LOCALIZE (L"Options_Title"));
88
      SetWindowText (GetDlgItem (hWnd, BUTTON_OK), LOCALIZE (L"Button_OK"));
89
      SetWindowText (GetDlgItem (hWnd, BUTTON_CANCEL), LOCALIZE (L"Button_Cancel"));
90
 
91
      // create the tab control and populate it
92
      tab_control = TabControl_New (GetDlgItem (hWnd, TABBOX_OPTIONS), (WNDPROC) DialogProc_ThisDialog);
93
      TabControl_AddPage (tab_control, LOCALIZE (L"Options_OfflineGameParameters"), DIALOG_OPTIONS_ENGINE);
94
      TabControl_AddPage (tab_control, LOCALIZE (L"Options_OnlineGameParameters"), DIALOG_OPTIONS_INTERNET);
95
      TabControl_AddPage (tab_control, LOCALIZE (L"Options_DisplayParameters"), DIALOG_OPTIONS_DISPLAY);
96
      TabControl_AddPage (tab_control, LOCALIZE (L"Options_GameplayParameters"), DIALOG_OPTIONS_GAMEPLAY);
97
 
98
      // setup page 1 (computer play)
99
      SetWindowText (TabControl_GetItem (tab_control, STATICTEXT_ENGINESEARCHDEPTH), LOCALIZE (L"Options_EnginePredictionLevel"));
100
      SetWindowText (TabControl_GetItem (tab_control, STATICTEXT_EASY), LOCALIZE (L"Options_Easy"));
101
      SetWindowText (TabControl_GetItem (tab_control, STATICTEXT_HARD), LOCALIZE (L"Options_Hard"));
102
      SetWindowText (TabControl_GetItem (tab_control, CHECKBOX_OPTIONS_ALLOWENGINEBLUNDERS), LOCALIZE (L"Options_AllowEngineBlunders"));
103
      SetWindowText (TabControl_GetItem (tab_control, STATICTEXT_1PCCHANCE), LOCALIZE (L"Options_1PercentChance"));
104
      SetWindowText (TabControl_GetItem (tab_control, STATICTEXT_100PCCHANCE), LOCALIZE (L"Options_100PercentChance"));
105
      SetWindowText (TabControl_GetItem (tab_control, CHECKBOX_OPTIONS_ALLOWENGINERESIGNS), LOCALIZE (L"Options_AllowEngineResigns"));
106
      SetWindowText (TabControl_GetItem (tab_control, STATICTEXT_YIELDING), LOCALIZE (L"Options_Yielding"));
107
      SetWindowText (TabControl_GetItem (tab_control, STATICTEXT_OBSTINATE), LOCALIZE (L"Options_Obstinate"));
108
 
109
      Button_SetCheck (TabControl_GetItem (tab_control, CHECKBOX_OPTIONS_ALLOWENGINEBLUNDERS), (options.engine.blunder_chances > 0 ? BST_CHECKED : BST_UNCHECKED));
110
      EnableWindow (TabControl_GetItem (tab_control, SLIDER_ENGINE_BLUNDERCHANCE), (options.engine.blunder_chances > 0));
111
      EnableWindow (TabControl_GetItem (tab_control, STATICTEXT_1PCCHANCE), (options.engine.blunder_chances > 0));
112
      EnableWindow (TabControl_GetItem (tab_control, STATICTEXT_100PCCHANCE), (options.engine.blunder_chances > 0));
113
      EnableWindow (TabControl_GetItem (tab_control, SLIDER_ENGINE_BLUNDERCHANCE), (options.engine.blunder_chances > 0));
114
      Button_SetCheck (TabControl_GetItem (tab_control, CHECKBOX_OPTIONS_ALLOWENGINERESIGNS), (options.engine.obstinacy_level >= 0 ? BST_CHECKED : BST_UNCHECKED));
115
      EnableWindow (TabControl_GetItem (tab_control, SLIDER_ENGINE_OBSTINACY), (options.engine.obstinacy_level >= 0));
116
      EnableWindow (TabControl_GetItem (tab_control, STATICTEXT_YIELDING), (options.engine.obstinacy_level >= 0));
117
      EnableWindow (TabControl_GetItem (tab_control, STATICTEXT_OBSTINATE), (options.engine.obstinacy_level >= 0));
118
      SendMessage (TabControl_GetItem (tab_control, SLIDER_ENGINE_DIFFICULTYLEVEL), TBM_SETRANGE, true, MAKELONG (1, options.engine.max_depth));
119
      SendMessage (TabControl_GetItem (tab_control, SLIDER_ENGINE_DIFFICULTYLEVEL), TBM_SETPOS, true, options.engine.depth);
120
      SendMessage (TabControl_GetItem (tab_control, SLIDER_ENGINE_BLUNDERCHANCE), TBM_SETRANGE, true, MAKELONG (1, 100));
121
      SendMessage (TabControl_GetItem (tab_control, SLIDER_ENGINE_BLUNDERCHANCE), TBM_SETPOS, true, (options.engine.blunder_chances > 0 ? options.engine.blunder_chances : 1));
122
      SendMessage (TabControl_GetItem (tab_control, SLIDER_ENGINE_OBSTINACY), TBM_SETRANGE, true, MAKELONG (0, 9));
123
      SendMessage (TabControl_GetItem (tab_control, SLIDER_ENGINE_OBSTINACY), TBM_SETPOS, true, (options.engine.obstinacy_level >= 0 ? options.engine.obstinacy_level : 9));
124
 
125
      // setup page 2 (Internet play)
126
      SetWindowText (TabControl_GetItem (tab_control, STATICTEXT_OPTIONS_SERVERADDRESS), LOCALIZE (L"Options_ServerAddress"));
127
      SetWindowText (TabControl_GetItem (tab_control, STATICTEXT_OPTIONS_SERVERLOGIN), LOCALIZE (L"Options_ServerLogin"));
128
      SetWindowText (TabControl_GetItem (tab_control, STATICTEXT_OPTIONS_SERVERPASSWORD), LOCALIZE (L"Options_ServerPassword"));
129
      SetWindowText (TabControl_GetItem (tab_control, CHECKBOX_OPTIONS_SHOWSERVERMESSAGES), LOCALIZE (L"Options_ShowServerMessages"));
130
      SetWindowText (TabControl_GetItem (tab_control, CHECKBOX_OPTIONS_SHOWPUBLICCHAT), LOCALIZE (L"Options_ShowPublicChat"));
131
      SetWindowText (TabControl_GetItem (tab_control, STATICTEXT_OPTIONS_SERVERURL), LOCALIZE (L"Options_CreateAccount"));
132
      ConvertStaticToHyperlink (TabControl_GetItem (tab_control, STATICTEXT_OPTIONS_SERVERURL));
133
      SetWindowText (TabControl_GetItem (tab_control, STATICTEXT_OPTIONS_SERVERWARNING), LOCALIZE (L"Options_ServerWarning"));
134
 
135
      swprintf_s (server_string, WCHAR_SIZEOF (server_string), L"%s:%d", options.network.server_address, options.network.server_port);
136
      SetWindowText (TabControl_GetItem (tab_control, EDITBOX_SERVERADDRESS), server_string);
137
      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
138
      SetWindowText (TabControl_GetItem (tab_control, EDITBOX_LOGIN), options.network.login);
139
      SetWindowText (TabControl_GetItem (tab_control, EDITBOX_PASSWORD), options.network.password);
140
      Button_SetCheck (TabControl_GetItem (tab_control, CHECKBOX_OPTIONS_SHOWPUBLICCHAT), (options.network.want_publicchat ? BST_CHECKED : BST_UNCHECKED));
141
      Button_SetCheck (TabControl_GetItem (tab_control, CHECKBOX_OPTIONS_SHOWSERVERMESSAGES), (options.network.want_servermessages ? BST_CHECKED : BST_UNCHECKED));
142
 
143
      // setup page 3 (display)
144
      SetWindowText (TabControl_GetItem (tab_control, CHECKBOX_OPTIONS_FULLSCREEN), LOCALIZE (L"Options_Fullscreen"));
145
      SetWindowText (TabControl_GetItem (tab_control, CHECKBOX_OPTIONS_TEXTUREFILTERING), LOCALIZE (L"Options_TextureFiltering"));
146
      SetWindowText (TabControl_GetItem (tab_control, CHECKBOX_OPTIONS_HIGHQUALITYFILTERING), LOCALIZE (L"Options_HiQualityFiltering"));
147
      SetWindowText (TabControl_GetItem (tab_control, CHECKBOX_OPTIONS_SPECULARLIGHTING), LOCALIZE (L"Options_SpecularLighting"));
148
      SetWindowText (TabControl_GetItem (tab_control, CHECKBOX_OPTIONS_SHOWREFLECTIONS), LOCALIZE (L"Options_ShowReflections"));
149
 
150
      Button_SetCheck (TabControl_GetItem (tab_control, CHECKBOX_OPTIONS_FULLSCREEN), (options.want_fullscreen ? BST_CHECKED : BST_UNCHECKED));
151
      Button_SetCheck (TabControl_GetItem (tab_control, CHECKBOX_OPTIONS_TEXTUREFILTERING), (options.want_filtering ? BST_CHECKED : BST_UNCHECKED));
152
      EnableWindow (TabControl_GetItem (tab_control, CHECKBOX_OPTIONS_HIGHQUALITYFILTERING), options.want_filtering);
153
      Button_SetCheck (TabControl_GetItem (tab_control, CHECKBOX_OPTIONS_HIGHQUALITYFILTERING), (options.want_hiquality ? BST_CHECKED : BST_UNCHECKED));
154
      Button_SetCheck (TabControl_GetItem (tab_control, CHECKBOX_OPTIONS_SPECULARLIGHTING), (options.want_specularlighting ? BST_CHECKED : BST_UNCHECKED));
155
      Button_SetCheck (TabControl_GetItem (tab_control, CHECKBOX_OPTIONS_SHOWREFLECTIONS), (options.want_reflections ? BST_CHECKED : BST_UNCHECKED));
156
 
157
      // setup page 4 (gameplay)
158
      SetWindowText (TabControl_GetItem (tab_control, CHECKBOX_OPTIONS_SHOWLASTMOVE), LOCALIZE (L"Options_ShowLastMove"));
159
      SetWindowText (TabControl_GetItem (tab_control, CHECKBOX_OPTIONS_SHOWPOSSIBLEMOVES), LOCALIZE (L"Options_ShowPossibleMoves"));
160
      SetWindowText (TabControl_GetItem (tab_control, CHECKBOX_OPTIONS_SHOWTHREATS), LOCALIZE (L"Options_ShowThreats"));
161
      SetWindowText (TabControl_GetItem (tab_control, CHECKBOX_OPTIONS_SHOWANIMATIONS), LOCALIZE (L"Options_ShowAnimations"));
162
      SetWindowText (TabControl_GetItem (tab_control, CHECKBOX_OPTIONS_SHOWTAKENPARTS), LOCALIZE (L"Options_ShowTakenParts"));
163
      SetWindowText (TabControl_GetItem (tab_control, CHECKBOX_OPTIONS_SHOWTURN), LOCALIZE (L"Options_ShowTurn"));
164
      SetWindowText (TabControl_GetItem (tab_control, CHECKBOX_OPTIONS_SHOWCLOCK), LOCALIZE (L"Options_ShowClock"));
165
      SetWindowText (TabControl_GetItem (tab_control, BUTTON_COLORCLOCK), LOCALIZE (L"Button_Color"));
166
      SetWindowText (TabControl_GetItem (tab_control, CHECKBOX_OPTIONS_SHOWHISTORY), LOCALIZE (L"Options_ShowHistory"));
167
      SetWindowText (TabControl_GetItem (tab_control, BUTTON_COLORHISTORY), LOCALIZE (L"Button_Color"));
168
      SetWindowText (TabControl_GetItem (tab_control, CHECKBOX_OPTIONS_USESEPIAFORHISTORY), LOCALIZE (L"Options_UseSepiaForHistory"));
169
      SetWindowText (TabControl_GetItem (tab_control, CHECKBOX_OPTIONS_ROTATEBOARD), LOCALIZE (L"Options_RotateBoard"));
170
      SetWindowText (TabControl_GetItem (tab_control, STATICTEXT_OPTIONS_ROTATESPEED), LOCALIZE (L"Options_RotateSpeed"));
171
      SetWindowText (TabControl_GetItem (tab_control, CHECKBOX_OPTIONS_PLAYSOUNDS), LOCALIZE (L"Options_PlaySounds"));
172
 
173
      Button_SetCheck (TabControl_GetItem (tab_control, CHECKBOX_OPTIONS_SHOWLASTMOVE), (options.want_lastmove ? BST_CHECKED : BST_UNCHECKED));
174
      Button_SetCheck (TabControl_GetItem (tab_control, CHECKBOX_OPTIONS_SHOWPOSSIBLEMOVES), (options.want_possiblemoves ? BST_CHECKED : BST_UNCHECKED));
175
      Button_SetCheck (TabControl_GetItem (tab_control, CHECKBOX_OPTIONS_SHOWTHREATS), (options.want_threats ? BST_CHECKED : BST_UNCHECKED));
176
      Button_SetCheck (TabControl_GetItem (tab_control, CHECKBOX_OPTIONS_SHOWANIMATIONS), (options.want_animations ? BST_CHECKED : BST_UNCHECKED));
177
      Button_SetCheck (TabControl_GetItem (tab_control, CHECKBOX_OPTIONS_SHOWTAKENPARTS), (options.want_takenparts ? BST_CHECKED : BST_UNCHECKED));
178
      Button_SetCheck (TabControl_GetItem (tab_control, CHECKBOX_OPTIONS_SHOWTURN), (options.want_turn ? BST_CHECKED : BST_UNCHECKED));
179
      Button_SetCheck (TabControl_GetItem (tab_control, CHECKBOX_OPTIONS_SHOWCLOCK), (options.want_clock ? BST_CHECKED : BST_UNCHECKED));
180
      Button_SetCheck (TabControl_GetItem (tab_control, CHECKBOX_OPTIONS_SHOWHISTORY), (options.want_history ? BST_CHECKED : BST_UNCHECKED));
181
      Button_SetCheck (TabControl_GetItem (tab_control, CHECKBOX_OPTIONS_USESEPIAFORHISTORY), (options.want_sepiafilter ? BST_CHECKED : BST_UNCHECKED));
182
      Button_SetCheck (TabControl_GetItem (tab_control, CHECKBOX_OPTIONS_ROTATEBOARD), (options.want_autorotateon1vs1 ? BST_CHECKED : BST_UNCHECKED));
183
      Button_SetCheck (TabControl_GetItem (tab_control, CHECKBOX_OPTIONS_PLAYSOUNDS), (options.want_sounds ? BST_CHECKED : BST_UNCHECKED));
184
      SendMessage (TabControl_GetItem (tab_control, SLIDER_OPTIONS_ROTATESPEED), TBM_SETRANGE, true, MAKELONG (5, 80));
185
      SendMessage (TabControl_GetItem (tab_control, SLIDER_OPTIONS_ROTATESPEED), TBM_SETPOS, true, options.rotate_speed);
186
 
187
      // set the selected color to the current game clock color (convert from RGBA to GDI BGR)
188
      selectedcolor_clock = ((options.clock_color & 0x0000ff00) << 8)
189
                            | ((options.clock_color & 0x00ff0000) >> 8)
190
                            | ((options.clock_color & 0xff000000) >> 24);
191
 
192
      // set the selected color to the current game history color (convert from RGBA to GDI BGR)
193
      selectedcolor_history = ((options.history_color & 0x0000ff00) << 8)
194
                              | ((options.history_color & 0x00ff0000) >> 8)
195
                              | ((options.history_color & 0xff000000) >> 24);
196
 
197
      // set focus on the first settable item
198
      SendMessage (TabControl_GetItem (tab_control, EDITBOX_LOGIN), EM_SETSEL, 0, -1); // select all text
199
      SetFocus (TabControl_GetItem (tab_control, EDITBOX_LOGIN));
200
   }
201
 
202
   // else did we click the close button on the title bar ?
203
   else if (message == WM_CLOSE)
204
      EndDialog (hWnd, 0); // close the dialog box
205
 
206
   // else did we take action on one of the controls ?
207
   else if (message == WM_COMMAND)
208
   {
209
      // did we cancel the dialog box ? (IDCANCEL is a system-wide dialog box handler value, that catches the ESC key)
210
      if (wParam_loword == IDCANCEL)
211
         EndDialog (hWnd, 0); // close the dialog box
212
 
213
      // else was it the OK button ?
214
      else if (wParam_loword == BUTTON_OK)
215
      {
216
         // grab the new parameters and close the dialog box
217
 
218
         // set the server address, login and password
219
         GetWindowText (TabControl_GetItem (tab_control, EDITBOX_SERVERADDRESS), server_string, WCHAR_SIZEOF (server_string));
220
         options.network.server_address[0] = 0; // default values
221
         options.network.server_port = 0;
222
         port_string = wcschr (server_string, L':'); // find the address:port separator
223
         if (port_string != NULL)
224
         {
225
            port_string[0] = 0; // split the string
226
            options.network.server_port = _wtoi (&port_string[1]); // and read the port
227
         }
228
         wcscpy_s (options.network.server_address, WCHAR_SIZEOF (options.network.server_address), server_string); // now read the address
229
         GetWindowText (TabControl_GetItem (tab_control, EDITBOX_LOGIN), options.network.login, WCHAR_SIZEOF (options.network.login));
230
         GetWindowText (TabControl_GetItem (tab_control, EDITBOX_PASSWORD), options.network.password, WCHAR_SIZEOF (options.network.password));
231
 
232
         options.network.want_servermessages = (Button_GetCheck (TabControl_GetItem (tab_control, CHECKBOX_OPTIONS_SHOWSERVERMESSAGES)) != 0);
233
         options.network.want_publicchat = (Button_GetCheck (TabControl_GetItem (tab_control, CHECKBOX_OPTIONS_SHOWPUBLICCHAT)) != 0);
234
         options.want_fullscreen = (Button_GetCheck (TabControl_GetItem (tab_control, CHECKBOX_OPTIONS_FULLSCREEN)) != 0);
235
         options.want_filtering = (Button_GetCheck (TabControl_GetItem (tab_control, CHECKBOX_OPTIONS_TEXTUREFILTERING)) != 0);
236
         options.want_specularlighting = (Button_GetCheck (TabControl_GetItem (tab_control, CHECKBOX_OPTIONS_SPECULARLIGHTING)) != 0);
237
         options.want_reflections = (Button_GetCheck (TabControl_GetItem (tab_control, CHECKBOX_OPTIONS_SHOWREFLECTIONS)) != 0);
238
         options.want_lastmove = (Button_GetCheck (TabControl_GetItem (tab_control, CHECKBOX_OPTIONS_SHOWLASTMOVE)) != 0);
239
         options.want_possiblemoves = (Button_GetCheck (TabControl_GetItem (tab_control, CHECKBOX_OPTIONS_SHOWPOSSIBLEMOVES)) != 0);
240
         options.want_threats = (Button_GetCheck (TabControl_GetItem (tab_control, CHECKBOX_OPTIONS_SHOWTHREATS)) != 0);
241
         options.want_animations = (Button_GetCheck (TabControl_GetItem (tab_control, CHECKBOX_OPTIONS_SHOWANIMATIONS)) != 0);
242
         options.want_takenparts = (Button_GetCheck (TabControl_GetItem (tab_control, CHECKBOX_OPTIONS_SHOWTAKENPARTS)) != 0);
243
         options.want_turn = (Button_GetCheck (TabControl_GetItem (tab_control, CHECKBOX_OPTIONS_SHOWTURN)) != 0);
244
         options.want_clock = (Button_GetCheck (TabControl_GetItem (tab_control, CHECKBOX_OPTIONS_SHOWCLOCK)) != 0);
245
         options.clock_color = 0 | ((selectedcolor_clock & 0x000000ff) << 24)
246
                                 | ((selectedcolor_clock & 0x0000ff00) << 8)
247
                                 | ((selectedcolor_clock & 0x00ff0000) >> 8); // convert from GDI BGR to RGBA
248
         options.want_history = (Button_GetCheck (TabControl_GetItem (tab_control, CHECKBOX_OPTIONS_SHOWHISTORY)) != 0);
249
         options.history_color = 0 | ((selectedcolor_history & 0x000000ff) << 24)
250
                                   | ((selectedcolor_history & 0x0000ff00) << 8)
251
                                   | ((selectedcolor_history & 0x00ff0000) >> 8); // convert from GDI BGR to RGBA
252
         options.want_sepiafilter = (Button_GetCheck (TabControl_GetItem (tab_control, CHECKBOX_OPTIONS_USESEPIAFORHISTORY)) != 0);
253
         options.want_autorotateon1vs1 = (Button_GetCheck (TabControl_GetItem (tab_control, CHECKBOX_OPTIONS_ROTATEBOARD)) != 0);
254
         options.want_sounds = (Button_GetCheck (TabControl_GetItem (tab_control, CHECKBOX_OPTIONS_PLAYSOUNDS)) != 0);
255
 
256
         options.engine.depth = SendMessage (TabControl_GetItem (tab_control, SLIDER_ENGINE_DIFFICULTYLEVEL), TBM_GETPOS, 0, 0);
257
         if (Button_GetCheck (TabControl_GetItem (tab_control, CHECKBOX_OPTIONS_ALLOWENGINEBLUNDERS)))
258
            options.engine.blunder_chances = SendMessage (TabControl_GetItem (tab_control, SLIDER_ENGINE_BLUNDERCHANCE), TBM_GETPOS, 0, 0);
259
         else
260
            options.engine.blunder_chances = 0;
261
         if (Button_GetCheck (TabControl_GetItem (tab_control, CHECKBOX_OPTIONS_ALLOWENGINERESIGNS)))
262
            options.engine.obstinacy_level = SendMessage (TabControl_GetItem (tab_control, SLIDER_ENGINE_OBSTINACY), TBM_GETPOS, 0, 0);
263
         else
264
            options.engine.obstinacy_level = -1;
265
         options.rotate_speed = SendMessage (TabControl_GetItem (tab_control, SLIDER_OPTIONS_ROTATESPEED), TBM_GETPOS, 0, 0);
266
 
267
         EndDialog (hWnd, 0); // close the dialog box
268
      }
269
 
270
      // else was it the cancel button ?
271
      else if (wParam_loword == BUTTON_CANCEL)
272
         EndDialog (hWnd, 0); // close the dialog box
273
 
274
      // else is it the rotate board check box ? if so, enable or disable the speed slider
275
      else if (wParam_loword == CHECKBOX_OPTIONS_ROTATEBOARD)
276
      {
277
         EnableWindow (TabControl_GetItem (tab_control, STATICTEXT_OPTIONS_ROTATESPEED), Button_GetCheck (TabControl_GetItem (tab_control, CHECKBOX_OPTIONS_ROTATEBOARD)));
278
         EnableWindow (TabControl_GetItem (tab_control, SLIDER_OPTIONS_ROTATESPEED), Button_GetCheck (TabControl_GetItem (tab_control, CHECKBOX_OPTIONS_ROTATEBOARD)));
279
      }
280
 
281
      // else is it the allow engine blunders check box ? if so, enable or disable the blunder chance slider
282
      else if (wParam_loword == CHECKBOX_OPTIONS_ALLOWENGINEBLUNDERS)
283
      {
284
         is_checked = Button_GetCheck (TabControl_GetItem (tab_control, CHECKBOX_OPTIONS_ALLOWENGINEBLUNDERS));
285
         EnableWindow (TabControl_GetItem (tab_control, SLIDER_ENGINE_BLUNDERCHANCE), is_checked);
286
         EnableWindow (TabControl_GetItem (tab_control, STATICTEXT_1PCCHANCE), is_checked);
287
         EnableWindow (TabControl_GetItem (tab_control, STATICTEXT_100PCCHANCE), is_checked);
288
      }
289
 
290
      // else is it the allow engine resigns check box ? if so, enable or disable the blunder chance slider
291
      else if (wParam_loword == CHECKBOX_OPTIONS_ALLOWENGINERESIGNS)
292
      {
293
         is_checked = Button_GetCheck (TabControl_GetItem (tab_control, CHECKBOX_OPTIONS_ALLOWENGINERESIGNS));
294
         EnableWindow (TabControl_GetItem (tab_control, SLIDER_ENGINE_OBSTINACY), is_checked);
295
         EnableWindow (TabControl_GetItem (tab_control, STATICTEXT_YIELDING), is_checked);
296
         EnableWindow (TabControl_GetItem (tab_control, STATICTEXT_OBSTINATE), is_checked);
297
      }
298
 
299
      // else is it the enable filtering check box ? if so, enable or disable the high quality checkbox
300
      else if (wParam_loword == CHECKBOX_OPTIONS_TEXTUREFILTERING)
301
         EnableWindow (TabControl_GetItem (tab_control, CHECKBOX_OPTIONS_HIGHQUALITYFILTERING), Button_GetCheck (TabControl_GetItem (tab_control, CHECKBOX_OPTIONS_TEXTUREFILTERING)));
302
 
303
      // else is it the show game clock check box ? if so, enable or disable the game clock color button
304
      else if (wParam_loword == CHECKBOX_OPTIONS_SHOWCLOCK)
305
         EnableWindow (TabControl_GetItem (tab_control, BUTTON_COLORCLOCK), Button_GetCheck (TabControl_GetItem (tab_control, CHECKBOX_OPTIONS_SHOWCLOCK)));
306
 
307
      // else is it the game clock color button ?
308
      else if (wParam_loword == BUTTON_COLORCLOCK)
309
      {
310
         // prepare a color pick dialog box
311
         memset (&cc, 0, sizeof (cc));
312
         cc.lStructSize = sizeof (cc);
313
         cc.hwndOwner = hWnd;
314
         cc.lpCustColors = (unsigned long *) custom_colors;
315
         cc.rgbResult = selectedcolor_clock;
316
         cc.Flags = CC_FULLOPEN | CC_RGBINIT;
317
 
318
         // fire it up
319
         if (ChooseColor (&cc))
320
            selectedcolor_clock = cc.rgbResult; // save away returned color
321
      }
322
 
323
      // else is it the show game history check box ? if so, enable or disable the game history color button
324
      else if (wParam_loword == CHECKBOX_OPTIONS_SHOWHISTORY)
325
         EnableWindow (TabControl_GetItem (tab_control, BUTTON_COLORHISTORY), Button_GetCheck (TabControl_GetItem (tab_control, CHECKBOX_OPTIONS_SHOWHISTORY)));
326
 
327
      // else is it the game history color button ?
328
      else if (wParam_loword == BUTTON_COLORHISTORY)
329
      {
330
         // prepare a color pick dialog box
331
         memset (&cc, 0, sizeof (cc));
332
         cc.lStructSize = sizeof (cc);
333
         cc.hwndOwner = hWnd;
334
         cc.lpCustColors = (unsigned long *) custom_colors;
335
         cc.rgbResult = selectedcolor_history;
336
         cc.Flags = CC_FULLOPEN | CC_RGBINIT;
337
 
338
         // fire it up
339
         if (ChooseColor (&cc))
340
            selectedcolor_history = cc.rgbResult; // save away returned color
341
      }
342
 
343
      // else is it the create/manage account hyperlink ?
344
      else if (wParam_loword == STATICTEXT_OPTIONS_SERVERURL)
345
      {
346
         swprintf_s (accountcreation_url, WCHAR_SIZEOF (accountcreation_url), ACCOUNTCREATION_URL, os_language); // build account creation url
347
         ShellExecute (NULL, L"open", accountcreation_url, NULL, NULL, SW_MAXIMIZE); // open the accounts page in the default browser, maximized
348
      }
349
   }
350
 
351
   // else is it a notification for the tab control ?
352
   else if ((message == WM_NOTIFY) && (((NMHDR *) lParam)->hwndFrom == GetDlgItem (hWnd, TABBOX_OPTIONS)))
353
      TabControl_Notify ((NMHDR *) lParam);
354
 
355
   // call the default dialog message processing function to keep things going
356
   return (false);
357
}