Subversion Repositories Games.Chess Giants

Rev

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