Rev 11 | Rev 18 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
| Rev 11 | Rev 14 | ||
|---|---|---|---|
| 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 window_title[100]; |
|
| 40 | struct _stat fileinfo; |
41 | struct _stat fileinfo; |
| 41 | HACCEL hAccelerators; |
42 | HACCEL hAccelerators; |
| 42 | ACCEL accelerators[] = |
43 | ACCEL accelerators[] = |
| 43 | { |
44 | { |
| 44 | {FVIRTKEY | FCONTROL, L'O', MENUID_GAME_LOAD}, |
45 | {FVIRTKEY | FCONTROL, L'O', MENUID_GAME_LOAD}, |
| Line 71... | Line 72... | ||
| 71 | GetModuleFileName (NULL, app_pathname, WCHAR_SIZEOF (app_pathname)); |
72 | GetModuleFileName (NULL, app_pathname, WCHAR_SIZEOF (app_pathname)); |
| 72 | GetDirectoryPath (app_pathname, app_path); |
73 | GetDirectoryPath (app_pathname, app_path); |
| 73 | SetCurrentDirectoryW (app_path); |
74 | SetCurrentDirectoryW (app_path); |
| 74 | 75 | ||
| 75 | // initialize stuff |
76 | // initialize stuff |
| - | 77 | is_registered = false; |
|
| 76 | terminate_everything = false; |
78 | terminate_everything = false; |
| 77 | hMainWnd = NULL; |
79 | hMainWnd = NULL; |
| 78 | hChatterChannelsWnd = NULL; |
80 | hChatterChannelsWnd = NULL; |
| 79 | hGamesWnd = NULL; |
81 | hGamesWnd = NULL; |
| 80 | hMOTDWnd = NULL; |
82 | hMOTDWnd = NULL; |
| Line 114... | Line 116... | ||
| 114 | save_pathname[0] = 0; |
116 | save_pathname[0] = 0; |
| 115 | srand ((unsigned int) time (NULL)); // initialize PRNG |
117 | srand ((unsigned int) time (NULL)); // initialize PRNG |
| 116 | 118 | ||
| 117 | // read configuration data |
119 | // read configuration data |
| 118 | Config_Load (); |
120 | Config_Load (); |
| - | 121 | ||
| - | 122 | // see if the program is registered |
|
| - | 123 | is_registered = IsRegistrationCorrect (options.registration.user_email, options.registration.activation_code); |
|
| 119 | 124 | ||
| 120 | // read texts in the right language, if such a translation exists |
125 | // read texts in the right language, if such a translation exists |
| 121 | is_success = false; |
126 | is_success = false; |
| 122 | GetLocaleInfo (LOCALE_SYSTEM_DEFAULT, LOCALE_SENGLANGUAGE, os_language, WCHAR_SIZEOF (os_language)); |
127 | GetLocaleInfo (LOCALE_SYSTEM_DEFAULT, LOCALE_SENGLANGUAGE, os_language, WCHAR_SIZEOF (os_language)); |
| 123 | is_success = LocalizedTexts_Init (L"%s/data/languages/%s.ini", app_path, os_language); |
128 | is_success = LocalizedTexts_Init (L"%s/data/languages/%s.ini", app_path, os_language); |
| Line 199... | Line 204... | ||
| 199 | wc.hInstance = hAppInstance; |
204 | wc.hInstance = hAppInstance; |
| 200 | wc.hIcon = LoadIcon (hAppInstance, (wchar_t *) ICON_MAIN); |
205 | wc.hIcon = LoadIcon (hAppInstance, (wchar_t *) ICON_MAIN); |
| 201 | wc.hCursor = LoadCursor (NULL, IDC_ARROW); |
206 | wc.hCursor = LoadCursor (NULL, IDC_ARROW); |
| 202 | wc.lpszClassName = PROGRAM_NAME L" WndClass"; |
207 | wc.lpszClassName = PROGRAM_NAME L" WndClass"; |
| 203 | RegisterClassEx (&wc); |
208 | RegisterClassEx (&wc); |
| - | 209 | swprintf_s (window_title, WCHAR_SIZEOF (window_title), PROGRAM_NAME L"%s", (is_registered ? L"" : LOCALIZE (L"EvaluationMode"))); |
|
| 204 | if (options.want_fullscreen) |
210 | if (options.want_fullscreen) |
| 205 | hMainWnd = CreateWindowEx (0, wc.lpszClassName, |
211 | hMainWnd = CreateWindowEx (0, wc.lpszClassName, window_title, WS_POPUPWINDOW, |
| 206 | 0, 0, GetSystemMetrics (SM_CXSCREEN), GetSystemMetrics (SM_CYSCREEN), |
212 | 0, 0, GetSystemMetrics (SM_CXSCREEN), GetSystemMetrics (SM_CYSCREEN), |
| 207 | NULL, hMenu, hAppInstance, NULL); |
213 | NULL, hMenu, hAppInstance, NULL); |
| 208 | else |
214 | else |
| 209 | { |
215 | { |
| 210 | // in windowed mode, ensure window width and height aren't greater than screen size nor lower than a safe minimum |
216 | // in windowed mode, ensure window width and height aren't greater than screen size nor lower than a safe minimum |
| Line 215... | Line 221... | ||
| 215 | if (options.window_width < 640) |
221 | if (options.window_width < 640) |
| 216 | options.window_width = 640; // check this secondly in case screen size is reported incorrect |
222 | options.window_width = 640; // check this secondly in case screen size is reported incorrect |
| 217 | if (options.window_height < 480) |
223 | if (options.window_height < 480) |
| 218 | options.window_height = 480; |
224 | options.window_height = 480; |
| 219 | 225 | ||
| 220 | hMainWnd = CreateWindowEx (0, wc.lpszClassName, |
226 | hMainWnd = CreateWindowEx (0, wc.lpszClassName, window_title, WS_OVERLAPPEDWINDOW, |
| 221 | GetSystemMetrics (SM_CXSCREEN) / 2 - options.window_width / 2, |
227 | GetSystemMetrics (SM_CXSCREEN) / 2 - options.window_width / 2, |
| 222 | GetSystemMetrics (SM_CYSCREEN) / 2 - options.window_height / 2, |
228 | GetSystemMetrics (SM_CYSCREEN) / 2 - options.window_height / 2, |
| 223 | options.window_width, |
229 | options.window_width, |
| 224 | options.window_height, |
230 | options.window_height, |
| 225 | NULL, hMenu, hAppInstance, NULL); |
231 | NULL, hMenu, hAppInstance, NULL); |
| Line 334... | Line 340... | ||
| 334 | while (!terminate_everything) |
340 | while (!terminate_everything) |
| 335 | { |
341 | { |
| 336 | // see what time it is |
342 | // see what time it is |
| 337 | current_time = ProcessTime (); |
343 | current_time = ProcessTime (); |
| 338 | 344 | ||
| 339 | #ifdef DEMO |
- | |
| 340 | // are we in demo mode and is it time to quit ? |
345 | // are we in demo mode and is it time to quit ? |
| 341 | if (current_time > DEMO_TIMEOUT) |
346 | if (!is_registered && (current_time > DEMO_TIMEOUT)) |
| 342 | terminate_everything = true; // if so, send a quit message in order to break the loop |
347 | terminate_everything = true; // if so, send a quit message in order to break the loop |
| 343 | #endif |
- | |
| 344 | 348 | ||
| 345 | // grab the current window size |
349 | // grab the current window size |
| 346 | GetWindowRect (hMainWnd, &rect); |
350 | GetWindowRect (hMainWnd, &rect); |
| 347 | options.window_width = rect.right - rect.left; |
351 | options.window_width = rect.right - rect.left; |
| 348 | options.window_height = rect.bottom - rect.top; |
352 | options.window_height = rect.bottom - rect.top; |
| Line 487... | Line 491... | ||
| 487 | 491 | ||
| 488 | // destroy the game menu |
492 | // destroy the game menu |
| 489 | if (IsMenu (hMenu)) |
493 | if (IsMenu (hMenu)) |
| 490 | DestroyMenu (hMenu); |
494 | DestroyMenu (hMenu); |
| 491 | hMenu = NULL; |
495 | hMenu = NULL; |
| - | 496 | ||
| - | 497 | // are we not registered yet ? |
|
| - | 498 | if (!is_registered) |
|
| - | 499 | DialogBox_Registration (); |
|
| 492 | 500 | ||
| 493 | // save configuration data |
501 | // save configuration data |
| 494 | Config_Save (); |
502 | Config_Save (); |
| 495 | 503 | ||
| 496 | // unload localized texts |
504 | // unload localized texts |
| Line 700... | Line 708... | ||
| 700 | EnableMenuItem (GetMenu (hMainWnd), MENUID_CHESSBOARD_SWAPSIDES, MF_GRAYED); |
708 | EnableMenuItem (GetMenu (hMainWnd), MENUID_CHESSBOARD_SWAPSIDES, MF_GRAYED); |
| 701 | 709 | ||
| 702 | // update window title |
710 | // update window title |
| 703 | if ((the_board.players[COLOR_WHITE].name[0] != 0) && (the_board.players[COLOR_BLACK].name[0] != 0)) |
711 | if ((the_board.players[COLOR_WHITE].name[0] != 0) && (the_board.players[COLOR_BLACK].name[0] != 0)) |
| 704 | { |
712 | { |
| 705 | swprintf_s (window_title, WCHAR_SIZEOF (window_title), L"%s %s %s - " |
713 | swprintf_s (window_title, WCHAR_SIZEOF (window_title), L"%s %s %s - " PROGRAM_NAME L"%s", the_board.players[COLOR_WHITE].name, LOCALIZE (L"Versus"), the_board.players[COLOR_BLACK].name, (is_registered ? L"" : LOCALIZE (L"EvaluationMode"))); |
| 706 | SetWindowText (hMainWnd, window_title); // update window title |
714 | SetWindowText (hMainWnd, window_title); // update window title |
| 707 | } |
715 | } |
| 708 | else if (the_board.players[COLOR_WHITE].name[0] != 0) |
716 | else if (the_board.players[COLOR_WHITE].name[0] != 0) |
| 709 | { |
717 | { |
| 710 | swprintf_s (window_title, WCHAR_SIZEOF (window_title), L"%s - " |
718 | swprintf_s (window_title, WCHAR_SIZEOF (window_title), L"%s - " PROGRAM_NAME L"%s", the_board.players[COLOR_WHITE].name, (is_registered ? L"" : LOCALIZE (L"EvaluationMode"))); |
| 711 | SetWindowText (hMainWnd, window_title); // update window title |
719 | SetWindowText (hMainWnd, window_title); // update window title |
| 712 | } |
720 | } |
| 713 | 721 | ||
| 714 | // are we in internet mode AND are we logged in ? |
722 | // are we in internet mode AND are we logged in ? |
| 715 | if ((network_player != NULL) && network_player->is_logged_in) |
723 | if ((network_player != NULL) && network_player->is_logged_in) |