Rev 30 | Rev 44 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 30 | Rev 41 | ||
---|---|---|---|
Line 35... | Line 35... | ||
35 | int array_index; |
35 | int array_index; |
36 | bool is_success; |
36 | bool is_success; |
37 | char *endptr; |
37 | char *endptr; |
38 | wchar_t app_pathname[MAX_PATH]; |
38 | wchar_t app_pathname[MAX_PATH]; |
39 | wchar_t font_pathname[MAX_PATH]; |
39 | wchar_t font_pathname[MAX_PATH]; |
40 | wchar_t |
40 | wchar_t temp_string[100]; |
41 | struct _stat fileinfo; |
41 | struct _stat fileinfo; |
42 | HACCEL hAccelerators; |
42 | HACCEL hAccelerators; |
43 | ACCEL accelerators[] = |
43 | ACCEL accelerators[] = |
44 | { |
44 | { |
45 | {FVIRTKEY | FCONTROL, L'O', MENUID_GAME_LOAD}, |
45 | {FVIRTKEY | FCONTROL, L'O', MENUID_GAME_LOAD}, |
Line 216... | Line 216... | ||
216 | wc.hInstance = hAppInstance; |
216 | wc.hInstance = hAppInstance; |
217 | wc.hIcon = LoadIcon (hAppInstance, (wchar_t *) ICON_MAIN); |
217 | wc.hIcon = LoadIcon (hAppInstance, (wchar_t *) ICON_MAIN); |
218 | wc.hCursor = LoadCursor (NULL, IDC_ARROW); |
218 | wc.hCursor = LoadCursor (NULL, IDC_ARROW); |
219 | wc.lpszClassName = PROGRAM_NAME L" WndClass"; |
219 | wc.lpszClassName = PROGRAM_NAME L" WndClass"; |
220 | RegisterClassEx (&wc); |
220 | RegisterClassEx (&wc); |
221 | swprintf_s ( |
221 | swprintf_s (temp_string, WCHAR_SIZEOF (temp_string), PROGRAM_NAME L"%s", (is_registered ? L"" : LOCALIZE (L"EvaluationMode"))); // build window title |
222 | if (options.want_fullscreen) |
222 | if (options.want_fullscreen) |
223 | hMainWnd = CreateWindowEx (0, wc.lpszClassName, |
223 | hMainWnd = CreateWindowEx (0, wc.lpszClassName, temp_string, WS_POPUPWINDOW, // temp_string holds window title |
224 | 0, 0, GetSystemMetrics (SM_CXSCREEN), GetSystemMetrics (SM_CYSCREEN), |
224 | 0, 0, GetSystemMetrics (SM_CXSCREEN), GetSystemMetrics (SM_CYSCREEN), |
225 | NULL, hMenu, hAppInstance, NULL); |
225 | NULL, hMenu, hAppInstance, NULL); |
226 | else |
226 | else |
227 | { |
227 | { |
228 | // in windowed mode, ensure window width and height aren't greater than screen size nor lower than a safe minimum |
228 | // in windowed mode, ensure window width and height aren't greater than screen size nor lower than a safe minimum |
Line 233... | Line 233... | ||
233 | if (options.window_width < 640) |
233 | if (options.window_width < 640) |
234 | options.window_width = 640; // check this secondly in case screen size is reported incorrect |
234 | options.window_width = 640; // check this secondly in case screen size is reported incorrect |
235 | if (options.window_height < 480) |
235 | if (options.window_height < 480) |
236 | options.window_height = 480; |
236 | options.window_height = 480; |
237 | 237 | ||
238 | hMainWnd = CreateWindowEx (0, wc.lpszClassName, |
238 | hMainWnd = CreateWindowEx (0, wc.lpszClassName, temp_string, WS_OVERLAPPEDWINDOW, // temp_string holds window title |
239 | GetSystemMetrics (SM_CXSCREEN) / 2 - options.window_width / 2, |
239 | GetSystemMetrics (SM_CXSCREEN) / 2 - options.window_width / 2, |
240 | GetSystemMetrics (SM_CYSCREEN) / 2 - options.window_height / 2, |
240 | GetSystemMetrics (SM_CYSCREEN) / 2 - options.window_height / 2, |
241 | options.window_width, |
241 | options.window_width, |
242 | options.window_height, |
242 | options.window_height, |
243 | NULL, hMenu, hAppInstance, NULL); |
243 | NULL, hMenu, hAppInstance, NULL); |
Line 333... | Line 333... | ||
333 | { |
333 | { |
334 | while (*lpCmdLine == '"') |
334 | while (*lpCmdLine == '"') |
335 | lpCmdLine++; // skip leading quotes |
335 | lpCmdLine++; // skip leading quotes |
336 | if ((endptr = strchr (lpCmdLine, '"')) != NULL) |
336 | if ((endptr = strchr (lpCmdLine, '"')) != NULL) |
337 | *endptr = 0; // break the string at the first ending quote |
337 | *endptr = 0; // break the string at the first ending quote |
- | 338 | ||
- | 339 | #ifndef NDEBUG |
|
- | 340 | // is it a registration info ? if so, parse it |
|
- | 341 | if ((strncmp (lpCmdLine, "/r=", 3) == 0) && ((endptr = strchr (&lpCmdLine[3], ',')) != NULL)) |
|
- | 342 | { |
|
- | 343 | *endptr = 0; // break the string at the separator between user email and activation code |
|
- | 344 | ConvertToWideChar (temp_string, WCHAR_SIZEOF (temp_string), &lpCmdLine[3]); // read user email |
|
- | 345 | is_registered = IsRegistrationCorrect (temp_string, atoi (endptr + 1)); // and see whether we're registered or not |
|
- | 346 | DialogBox_NewGame (); // still open the "new game" dialog box |
|
- | 347 | } |
|
- | 348 | #endif // !NDEBUG |
|
- | 349 | ||
- | 350 | // is it a file that exists ? |
|
338 | if (_stat (lpCmdLine, &fileinfo) == 0) |
351 | if (_stat (lpCmdLine, &fileinfo) == 0) |
339 | { |
352 | { |
340 | ConvertToWideChar (load_pathname, WCHAR_SIZEOF (load_pathname), lpCmdLine); // save pathname string |
353 | ConvertToWideChar (load_pathname, WCHAR_SIZEOF (load_pathname), lpCmdLine); // save pathname string |
341 | is_dialogbox_load_validated = true; // and act as if the user just validated a load dialog box |
354 | is_dialogbox_load_validated = true; // and act as if the user just validated a load dialog box |
342 | } |
355 | } |
Line 349... | Line 362... | ||
349 | // enter the main loop |
362 | // enter the main loop |
350 | while (!terminate_everything) |
363 | while (!terminate_everything) |
351 | { |
364 | { |
352 | // see what time it is |
365 | // see what time it is |
353 | current_time = ProcessTime (); |
366 | current_time = ProcessTime (); |
354 | 367 | ||
355 | // are we in demo mode and is it time to quit ? |
368 | // are we in demo mode and is it time to quit ? |
356 | if (!is_registered && (current_time > DEMO_TIMEOUT)) |
369 | if (!is_registered && (current_time > DEMO_TIMEOUT)) |
357 | DestroyWindow (hMainWnd); // if so, send a quit message in order to break the loop |
370 | DestroyWindow (hMainWnd); // if so, send a quit message in order to break the loop |
358 | 371 | ||
359 | // grab the current window size |
372 | // grab the current window size |
360 | GetWindowRect (hMainWnd, &rect); |
373 | GetWindowRect (hMainWnd, &rect); |
361 | options.window_width = rect.right - rect.left; |
374 | options.window_width = rect.right - rect.left; |
362 | options.window_height = rect.bottom - rect.top; |
375 | options.window_height = rect.bottom - rect.top; |
363 | 376 | ||
364 | // are we in the middle of an animation or just after it ? |
377 | // are we in the middle of an animation or just after it ? |
365 | if (current_time < animation_endtime + 0.5f) |
378 | if (current_time < animation_endtime + 0.5f) |
366 | the_scene.update = true; // always update during animations |
379 | the_scene.update = true; // always update during animations |
367 | else |
380 | else |
368 | the_scene.update |= Board_Think (&the_board); // make the board (i.e, both players) think |
381 | the_scene.update |= Board_Think (&the_board); // make the board (i.e, both players) think |
Line 537... | Line 550... | ||
537 | 550 | ||
538 | static void MainLoop_EvaluateGameState (void) |
551 | static void MainLoop_EvaluateGameState (void) |
539 | { |
552 | { |
540 | // function to evaluate the game state in the main loop when a part has just moved |
553 | // function to evaluate the game state in the main loop when a part has just moved |
541 | 554 | ||
542 | wchar_t window_title[256]; |
555 | static wchar_t window_title[256]; |
- | 556 | ||
543 | player_t *current_player; |
557 | player_t *current_player; |
544 | player_t *opposite_player; |
558 | player_t *opposite_player; |
545 | player_t *network_player; |
559 | player_t *network_player; |
546 | boardmove_t *last_move; |
560 | boardmove_t *last_move; |
547 | int enabled_value; |
561 | int enabled_value; |