Rev 60 | Rev 83 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 60 | Rev 75 | ||
---|---|---|---|
Line 54... | Line 54... | ||
54 | hChatterChannelsWnd = NULL; |
54 | hChatterChannelsWnd = NULL; |
55 | hGamesWnd = NULL; |
55 | hGamesWnd = NULL; |
56 | hMOTDWnd = NULL; |
56 | hMOTDWnd = NULL; |
57 | hOpponentsWnd = NULL; |
57 | hOpponentsWnd = NULL; |
58 | hSoughtWnd = NULL; |
58 | hSoughtWnd = NULL; |
- | 59 | is_paused = false; // clear pause status |
|
59 | #ifdef NDEBUG |
60 | #ifdef NDEBUG |
60 | want_framerate = false; // release mode, don't display framerate |
61 | want_framerate = false; // release mode, don't display framerate |
61 | #else |
62 | #else |
62 | want_framerate = true; // display framerate in debug mode |
63 | want_framerate = true; // display framerate in debug mode |
63 | #endif // NDEBUG |
64 | #endif // NDEBUG |
Line 65... | Line 66... | ||
65 | is_dialogbox_challenge_validated = false; |
66 | is_dialogbox_challenge_validated = false; |
66 | is_dialogbox_changeappearance_validated = false; |
67 | is_dialogbox_changeappearance_validated = false; |
67 | is_dialogbox_comment_validated = false; |
68 | is_dialogbox_comment_validated = false; |
68 | is_dialogbox_endgame_validated = false; |
69 | is_dialogbox_endgame_validated = false; |
69 | is_dialogbox_gotomove_validated = false; |
70 | is_dialogbox_gotomove_validated = false; |
- | 71 | is_dialogbox_renamesides_validated = false; |
|
70 | is_dialogbox_load_validated = false; |
72 | is_dialogbox_load_validated = false; |
71 | is_dialogbox_message_validated = false; |
73 | is_dialogbox_message_validated = false; |
72 | is_dialogbox_newgame_validated = false; |
74 | is_dialogbox_newgame_validated = false; |
73 | is_dialogbox_options_validated = false; |
75 | is_dialogbox_options_validated = false; |
74 | is_dialogbox_pawnpromotion_validated = false; |
76 | is_dialogbox_pawnpromotion_validated = false; |
Line 200... | Line 202... | ||
200 | hFontChat = CreateFont (17, 0, 0, 0, FW_DONTCARE, false, false, false, ANSI_CHARSET, OUT_DEFAULT_PRECIS, |
202 | hFontChat = CreateFont (17, 0, 0, 0, FW_DONTCARE, false, false, false, ANSI_CHARSET, OUT_DEFAULT_PRECIS, |
201 | CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH | FF_SWISS, L"Comic Sans MS"); |
203 | CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH | FF_SWISS, L"Comic Sans MS"); |
202 | 204 | ||
203 | // before any rendering is done, it's a good idea to know what time it is |
205 | // before any rendering is done, it's a good idea to know what time it is |
204 | current_time = ProcessTime (); |
206 | current_time = ProcessTime (); |
- | 207 | stoppage_time = 0; |
|
205 | screensaverwatchdog_feedtime = current_time + 50.0f; // feed screensaver watchdog every 50 seconds |
208 | screensaverwatchdog_feedtime = current_time + 50.0f; // feed screensaver watchdog every 50 seconds |
206 | 209 | ||
207 | // initialize renderer |
210 | // initialize renderer |
208 | if (!Render_Init ()) |
211 | if (!Render_Init ()) |
209 | return (-1); // bomb out on error |
212 | return (-1); // bomb out on error |
Line 266... | Line 269... | ||
266 | // enter the main loop |
269 | // enter the main loop |
267 | while (!terminate_everything) |
270 | while (!terminate_everything) |
268 | { |
271 | { |
269 | // see what time it is |
272 | // see what time it is |
270 | current_time = ProcessTime (); |
273 | current_time = ProcessTime (); |
- | 274 | if (is_paused) |
|
- | 275 | stoppage_time += (current_time - previous_time); // if we're paused, increase stoppage time |
|
271 | 276 | ||
272 | // is it time to feed the screensaver watchdog ? (to prevent it from starting) |
277 | // is it time to feed the screensaver watchdog ? (to prevent it from starting) |
273 | if (screensaverwatchdog_feedtime < current_time) |
278 | if (screensaverwatchdog_feedtime < current_time) |
274 | { |
279 | { |
275 | mousemove_input.type = INPUT_MOUSE; |
280 | mousemove_input.type = INPUT_MOUSE; |
Line 313... | Line 318... | ||
313 | if (is_dialogbox_challenge_validated) DialogBox_Challenge_Validated (); |
318 | if (is_dialogbox_challenge_validated) DialogBox_Challenge_Validated (); |
314 | if (is_dialogbox_changeappearance_validated) DialogBox_ChangeAppearance_Validated (); |
319 | if (is_dialogbox_changeappearance_validated) DialogBox_ChangeAppearance_Validated (); |
315 | if (is_dialogbox_comment_validated) DialogBox_Comment_Validated (); |
320 | if (is_dialogbox_comment_validated) DialogBox_Comment_Validated (); |
316 | if (is_dialogbox_endgame_validated) DialogBox_EndGame_Validated (); |
321 | if (is_dialogbox_endgame_validated) DialogBox_EndGame_Validated (); |
317 | if (is_dialogbox_gotomove_validated) DialogBox_GoToMove_Validated (); |
322 | if (is_dialogbox_gotomove_validated) DialogBox_GoToMove_Validated (); |
- | 323 | if (is_dialogbox_renamesides_validated) DialogBox_RenameSides_Validated (); |
|
318 | if (is_dialogbox_load_validated) DialogBox_Load_Validated (); |
324 | if (is_dialogbox_load_validated) DialogBox_Load_Validated (); |
319 | if (is_dialogbox_message_validated) DialogBox_Message_Validated (); |
325 | if (is_dialogbox_message_validated) DialogBox_Message_Validated (); |
320 | if (is_dialogbox_newgame_validated) DialogBox_NewGame_Validated (); |
326 | if (is_dialogbox_newgame_validated) DialogBox_NewGame_Validated (); |
321 | if (is_dialogbox_options_validated) DialogBox_Options_Validated (); |
327 | if (is_dialogbox_options_validated) DialogBox_Options_Validated (); |
322 | if (is_dialogbox_pawnpromotion_validated) DialogBox_PawnPromotion_Validated (); |
328 | if (is_dialogbox_pawnpromotion_validated) DialogBox_PawnPromotion_Validated (); |
Line 567... | Line 573... | ||
567 | if (the_scene.gui.rarrow.state != 0) |
573 | if (the_scene.gui.rarrow.state != 0) |
568 | the_scene.gui.rarrow.state = 0; // disable "forward" arrow if it's already displayed |
574 | the_scene.gui.rarrow.state = 0; // disable "forward" arrow if it's already displayed |
569 | 575 | ||
570 | if (the_board.game_state == STATE_PLAYING) |
576 | if (the_board.game_state == STATE_PLAYING) |
571 | Scene_SetText (&the_scene.gui.arrow_text, 3.3f, 5.0f, -1, ALIGN_CENTER, ALIGN_TOP, ALIGN_CENTER, arrow_fontindex, |
577 | Scene_SetText (&the_scene.gui.arrow_text, 3.3f, 5.0f, -1, ALIGN_CENTER, ALIGN_TOP, ALIGN_CENTER, arrow_fontindex, |
572 | RGBACOLOR_SETALPHA (options.clock_color, 0x7f), 999999.0f, false, LOCALIZE (L"Current")); |
578 | RGBACOLOR_SETALPHA (options.clock_color, 0x7f), 999999.0f, false, LOCALIZE (is_paused ? L"Paused" : L"Current")); |
573 | else if ((the_board.game_state == STATE_BLACKWIN_CHECKMATE) || (the_board.game_state == STATE_WHITEWIN_CHECKMATE)) |
579 | else if ((the_board.game_state == STATE_BLACKWIN_CHECKMATE) || (the_board.game_state == STATE_WHITEWIN_CHECKMATE)) |
574 | Scene_SetText (&the_scene.gui.arrow_text, 3.3f, 5.0f, -1, ALIGN_CENTER, ALIGN_TOP, ALIGN_CENTER, arrow_fontindex, |
580 | Scene_SetText (&the_scene.gui.arrow_text, 3.3f, 5.0f, -1, ALIGN_CENTER, ALIGN_TOP, ALIGN_CENTER, arrow_fontindex, |
575 | RGBACOLOR_SETALPHA (options.clock_color, 0x7f), 999999.0f, false, LOCALIZE (L"EndGame_CheckMate")); |
581 | RGBACOLOR_SETALPHA (options.clock_color, 0x7f), 999999.0f, false, LOCALIZE (L"EndGame_CheckMate")); |
576 | else if ((the_board.game_state == STATE_WHITEWIN_RESIGNORFORFEIT) || (the_board.game_state == STATE_BLACKWIN_RESIGNORFORFEIT)) |
582 | else if ((the_board.game_state == STATE_WHITEWIN_RESIGNORFORFEIT) || (the_board.game_state == STATE_BLACKWIN_RESIGNORFORFEIT)) |
577 | Scene_SetText (&the_scene.gui.arrow_text, 3.3f, 5.0f, -1, ALIGN_CENTER, ALIGN_TOP, ALIGN_CENTER, arrow_fontindex, |
583 | Scene_SetText (&the_scene.gui.arrow_text, 3.3f, 5.0f, -1, ALIGN_CENTER, ALIGN_TOP, ALIGN_CENTER, arrow_fontindex, |
Line 636... | Line 642... | ||
636 | 642 | ||
637 | // disable the "cancel last move", "comment move" and "go to move" menu options |
643 | // disable the "cancel last move", "comment move" and "go to move" menu options |
638 | EnableMenuItem (GetMenu (hMainWnd), MENUID_CHESSBOARD_CANCELLASTMOVE, MF_GRAYED); |
644 | EnableMenuItem (GetMenu (hMainWnd), MENUID_CHESSBOARD_CANCELLASTMOVE, MF_GRAYED); |
639 | EnableMenuItem (GetMenu (hMainWnd), MENUID_CHESSBOARD_COMMENTMOVE, MF_GRAYED); |
645 | EnableMenuItem (GetMenu (hMainWnd), MENUID_CHESSBOARD_COMMENTMOVE, MF_GRAYED); |
640 | EnableMenuItem (GetMenu (hMainWnd), MENUID_CHESSBOARD_GOTOMOVE, MF_GRAYED); |
646 | EnableMenuItem (GetMenu (hMainWnd), MENUID_CHESSBOARD_GOTOMOVE, MF_GRAYED); |
- | 647 | ||
- | 648 | is_paused = false; // clear pause status (we can only pause a game when it's been started) |
|
641 | 649 | ||
642 | // and disable the two arrows and the arrow text |
650 | // and disable the two arrows and the arrow text |
643 | the_scene.gui.larrow.state = 0; |
651 | the_scene.gui.larrow.state = 0; |
644 | the_scene.gui.rarrow.state = 0; |
652 | the_scene.gui.rarrow.state = 0; |
645 | the_scene.gui.arrow_text.is_displayed = false; |
653 | the_scene.gui.arrow_text.is_displayed = false; |
646 | } |
654 | } |
647 | 655 | ||
648 | // no matter whether the game started or not, if the current player is a human AND its opponent is a computer, allow him to swap sides |
656 | // no matter whether the game started or not, if the current player is a human AND its opponent is a computer, allow him to swap sides |
649 | if ((current_player->type == PLAYER_HUMAN) && (opposite_player->type == PLAYER_COMPUTER)) |
657 | if ((current_player->type == PLAYER_HUMAN) && (opposite_player->type == PLAYER_COMPUTER)) |
650 | EnableMenuItem (GetMenu (hMainWnd), MENUID_CHESSBOARD_SWAPSIDES, MF_ENABLED); |
658 | EnableMenuItem (GetMenu (hMainWnd), MENUID_CHESSBOARD_SWAPSIDES, MF_ENABLED); |
651 | else |
659 | else |
652 | EnableMenuItem (GetMenu (hMainWnd), MENUID_CHESSBOARD_SWAPSIDES, MF_GRAYED); |
660 | EnableMenuItem (GetMenu (hMainWnd), MENUID_CHESSBOARD_SWAPSIDES, MF_GRAYED); |
- | 661 | ||
- | 662 | // no matter whether the game started or not, enable players renaming only if we are NOT in internet mode |
|
- | 663 | EnableMenuItem (GetMenu (hMainWnd), MENUID_CHESSBOARD_RENAMESIDES, (network_player == NULL ? MF_ENABLED : MF_GRAYED)); |
|
653 | 664 | ||
654 | // update window title |
665 | // update window title |
655 | if ((the_board.players[COLOR_WHITE].name[0] != 0) && (the_board.players[COLOR_BLACK].name[0] != 0)) |
666 | if ((the_board.players[COLOR_WHITE].name[0] != 0) && (the_board.players[COLOR_BLACK].name[0] != 0)) |
656 | { |
667 | { |
657 | 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"))); |
668 | 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"))); |
Line 679... | Line 690... | ||
679 | GUIBUTTON_DISABLE (the_scene.gui.chatbutton); // disable chat button if it was enabled |
690 | GUIBUTTON_DISABLE (the_scene.gui.chatbutton); // disable chat button if it was enabled |
680 | GUIBUTTON_ENABLE (the_scene.gui.gamesbutton); // enable games button if it's not enabled yet |
691 | GUIBUTTON_ENABLE (the_scene.gui.gamesbutton); // enable games button if it's not enabled yet |
681 | GUIBUTTON_ENABLE (the_scene.gui.peoplebutton); // enable people button if it's not enabled yet |
692 | GUIBUTTON_ENABLE (the_scene.gui.peoplebutton); // enable people button if it's not enabled yet |
682 | EnableMenuItem (GetMenu (hMainWnd), MENUID_GAME_RESIGN, MF_GRAYED); // disable ability to resign |
693 | EnableMenuItem (GetMenu (hMainWnd), MENUID_GAME_RESIGN, MF_GRAYED); // disable ability to resign |
683 | } |
694 | } |
- | 695 | EnableMenuItem (GetMenu (hMainWnd), MENUID_GAME_PAUSE, MF_DISABLED); // disallow pause |
|
684 | EnableMenuItem (GetMenu (hMainWnd), MENUID_GAME_STATISTICS, MF_ENABLED); // enable stats |
696 | EnableMenuItem (GetMenu (hMainWnd), MENUID_GAME_STATISTICS, MF_ENABLED); // enable stats |
685 | 697 | ||
686 | enabled_value = MF_ENABLED; // remember to enable the internet-related menu items |
698 | enabled_value = MF_ENABLED; // remember to enable the internet-related menu items |
687 | } |
699 | } |
688 | // else it's a local or vs. computer game |
700 | // else it's a local or vs. computer game |
689 | else |
701 | else |
690 | { |
702 | { |
691 | GUIBUTTON_DISABLE (the_scene.gui.chatbutton); // disable chat button if it was enabled |
703 | GUIBUTTON_DISABLE (the_scene.gui.chatbutton); // disable chat button if it was enabled |
692 | GUIBUTTON_DISABLE (the_scene.gui.gamesbutton); // disable games button if it was enabled |
704 | GUIBUTTON_DISABLE (the_scene.gui.gamesbutton); // disable games button if it was enabled |
693 | GUIBUTTON_DISABLE (the_scene.gui.peoplebutton); // disable people button if it was enabled |
705 | GUIBUTTON_DISABLE (the_scene.gui.peoplebutton); // disable people button if it was enabled |
- | 706 | EnableMenuItem (GetMenu (hMainWnd), MENUID_GAME_PAUSE, (the_board.move_count > 1 ? MF_ENABLED : MF_GRAYED)); // allow pause if the game has started |
|
694 | EnableMenuItem (GetMenu (hMainWnd), MENUID_GAME_RESIGN, MF_ENABLED) |
707 | EnableMenuItem (GetMenu (hMainWnd), MENUID_GAME_RESIGN, (the_board.move_count > 1 ? MF_ENABLED : MF_GRAYED)); // allow resigning if the game has started |
695 | EnableMenuItem (GetMenu (hMainWnd), MENUID_GAME_STATISTICS, MF_GRAYED); // disable stats |
708 | EnableMenuItem (GetMenu (hMainWnd), MENUID_GAME_STATISTICS, MF_GRAYED); // disable stats |
696 | 709 | ||
697 | enabled_value = MF_GRAYED; // remember to disable the internet-related menu items |
710 | enabled_value = MF_GRAYED; // remember to disable the internet-related menu items |
698 | } |
711 | } |
699 | 712 |