Subversion Repositories Games.Chess Giants

Rev

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