Subversion Repositories Games.Chess Giants

Rev

Rev 59 | Rev 124 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 59 Rev 119
Line 62... Line 62...
62
{
62
{
63
   // message handler for the dialog box
63
   // message handler for the dialog box
64
 
64
 
65
   static wchar_t temp_string[MAX_PATH];
65
   static wchar_t temp_string[MAX_PATH];
66
   static wchar_t value_string[32];
66
   static wchar_t value_string[32];
67
   static WIN32_FIND_DATA wfd;
-
 
68
 
67
 
69
   unsigned short wParam_hiword;
68
   unsigned short wParam_hiword;
70
   unsigned short wParam_loword;
69
   unsigned short wParam_loword;
71
   wchar_t *port_string;
70
   wchar_t *port_string;
72
   int language_index;
71
   int language_index;
73
   int wanted_engine;
-
 
74
   int engine_count;
72
   int engine_index;
75
   HANDLE hFind;
-
 
76
   int is_checked;
73
   int is_checked;
77
 
74
 
78
   // filter out the commonly used message values
75
   // filter out the commonly used message values
79
   wParam_hiword = HIWORD (wParam);
76
   wParam_hiword = HIWORD (wParam);
80
   wParam_loword = LOWORD (wParam);
77
   wParam_loword = LOWORD (wParam);
Line 101... Line 98...
101
      TabControl_AddPage (tab_control, LOCALIZE (L"Options_DisplayParameters"), DIALOG_OPTIONS_DISPLAY);
98
      TabControl_AddPage (tab_control, LOCALIZE (L"Options_DisplayParameters"), DIALOG_OPTIONS_DISPLAY);
102
      TabControl_AddPage (tab_control, LOCALIZE (L"Options_GameplayParameters"), DIALOG_OPTIONS_GAMEPLAY);
99
      TabControl_AddPage (tab_control, LOCALIZE (L"Options_GameplayParameters"), DIALOG_OPTIONS_GAMEPLAY);
103
 
100
 
104
      // setup page 1 (computer play)
101
      // setup page 1 (computer play)
105
      SetWindowText (TabControl_GetItem (tab_control, STATICTEXT_ENGINEPROGRAMNAME), LOCALIZE (L"Options_EngineProgramName"));
102
      SetWindowText (TabControl_GetItem (tab_control, STATICTEXT_ENGINEPROGRAMNAME), LOCALIZE (L"Options_EngineProgramName"));
106
      engine_count = 0;
-
 
107
      wanted_engine = 0;
-
 
108
      swprintf_s (temp_string, sizeof (temp_string), L"%s\\engines\\*.*", app_path); // build the search pattern string out of the path
-
 
109
      hFind = FindFirstFile (temp_string, &wfd); // initiate search from that point
-
 
110
      if (hFind != INVALID_HANDLE_VALUE)
-
 
111
      {
-
 
112
         // start examining search results...
-
 
113
         do
-
 
114
         {
-
 
115
            if (!(wfd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) || (wfd.cFileName[0] == L'.'))
-
 
116
               continue; // skip everything that is NOT a directory, and every directories that begin with a dot
103
      for (engine_index = 0; engine_index < options.engine.program_count; engine_index++)
117
            ComboBox_AddString (TabControl_GetItem (tab_control, COMBOBOX_ENGINE), wfd.cFileName); // add it to the combo box
104
         ComboBox_AddString (TabControl_GetItem (tab_control, COMBOBOX_ENGINE), options.engine.programs[engine_index].name); // add all engine programs to the combo box
118
            if (wcscmp (wfd.cFileName, options.engine.program) == 0)
-
 
119
               wanted_engine = engine_count;
-
 
120
            engine_count++; // we've identified one engine more
-
 
121
         } while (FindNextFile (hFind, &wfd)); // ...and don't stop as long as there are files to go
-
 
122
         FindClose (hFind); // close the search handle
-
 
123
      }
-
 
124
      ComboBox_SetCurSel (TabControl_GetItem (tab_control, COMBOBOX_ENGINE), wanted_engine); // select the right entry
105
      ComboBox_SetCurSel (TabControl_GetItem (tab_control, COMBOBOX_ENGINE), options.engine.selected_program); // select the right entry
125
 
106
 
126
      SetWindowText (TabControl_GetItem (tab_control, STATICTEXT_ENGINESEARCHDEPTH), LOCALIZE (L"Options_EnginePredictionLevel"));
107
      SetWindowText (TabControl_GetItem (tab_control, STATICTEXT_ENGINESEARCHDEPTH), LOCALIZE (L"Options_EnginePredictionLevel"));
127
      SetWindowText (TabControl_GetItem (tab_control, STATICTEXT_EASY), LOCALIZE (L"Options_Easy"));
108
      SetWindowText (TabControl_GetItem (tab_control, STATICTEXT_EASY), LOCALIZE (L"Options_Easy"));
128
      SetWindowText (TabControl_GetItem (tab_control, STATICTEXT_HARD), LOCALIZE (L"Options_Hard"));
109
      SetWindowText (TabControl_GetItem (tab_control, STATICTEXT_HARD), LOCALIZE (L"Options_Hard"));
129
      swprintf_s (value_string, WCHAR_SIZEOF (value_string), L"%d", options.engine.depth);
110
      swprintf_s (value_string, WCHAR_SIZEOF (value_string), L"%d", options.engine.depth);
Line 310... Line 291...
310
         options.want_sounds = (Button_GetCheck (TabControl_GetItem (tab_control, CHECKBOX_OPTIONS_PLAYSOUNDS)) != 0);
291
         options.want_sounds = (Button_GetCheck (TabControl_GetItem (tab_control, CHECKBOX_OPTIONS_PLAYSOUNDS)) != 0);
311
         options.rotate_speed = SendMessage (TabControl_GetItem (tab_control, SLIDER_OPTIONS_ROTATESPEED), TBM_GETPOS, 0, 0);
292
         options.rotate_speed = SendMessage (TabControl_GetItem (tab_control, SLIDER_OPTIONS_ROTATESPEED), TBM_GETPOS, 0, 0);
312
 
293
 
313
         // engine options
294
         // engine options
314
         ComboBox_GetLBText (TabControl_GetItem (tab_control, COMBOBOX_ENGINE), ComboBox_GetCurSel (TabControl_GetItem (tab_control, COMBOBOX_ENGINE)), temp_string);
295
         ComboBox_GetLBText (TabControl_GetItem (tab_control, COMBOBOX_ENGINE), ComboBox_GetCurSel (TabControl_GetItem (tab_control, COMBOBOX_ENGINE)), temp_string);
-
 
296
         for (engine_index = 0; engine_index < options.engine.program_count; engine_index++)
315
         if (wcscmp (temp_string, options.engine.program) != 0)
297
            if (_wcsicmp (temp_string, options.engine.programs[engine_index].name) == 0)
316
         {
298
            {
317
            wcscpy_s (options.engine.program, temp_string);
299
               options.engine.selected_program = engine_index;
318
            MessageBox (hWnd, LOCALIZE (L"Options_ChessEngineChangeWillAffectNextGame"), LOCALIZE (L"ImportantMessage"), MB_ICONINFORMATION | MB_OK);
300
               MessageBox (hWnd, LOCALIZE (L"Options_ChessEngineChangeWillAffectNextGame"), LOCALIZE (L"ImportantMessage"), MB_ICONINFORMATION | MB_OK);
319
         }
301
            }
320
 
302
 
321
         options.engine.depth = SendMessage (TabControl_GetItem (tab_control, SLIDER_ENGINE_DIFFICULTYLEVEL), TBM_GETPOS, 0, 0);
303
         options.engine.depth = SendMessage (TabControl_GetItem (tab_control, SLIDER_ENGINE_DIFFICULTYLEVEL), TBM_GETPOS, 0, 0);
322
         if (Button_GetCheck (TabControl_GetItem (tab_control, CHECKBOX_OPTIONS_ALLOWENGINEBLUNDERS)))
304
         if (Button_GetCheck (TabControl_GetItem (tab_control, CHECKBOX_OPTIONS_ALLOWENGINEBLUNDERS)))
323
            options.engine.blunder_chances = SendMessage (TabControl_GetItem (tab_control, SLIDER_ENGINE_BLUNDERCHANCE), TBM_GETPOS, 0, 0);
305
            options.engine.blunder_chances = SendMessage (TabControl_GetItem (tab_control, SLIDER_ENGINE_BLUNDERCHANCE), TBM_GETPOS, 0, 0);
324
         else
306
         else