Subversion Repositories Games.Chess Giants

Rev

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

Rev 133 Rev 136
Line 535... Line 535...
535
   {
535
   {
536
      // game has started, enable the "save" and "save as" menu options
536
      // game has started, enable the "save" and "save as" menu options
537
      EnableMenuItem (GetMenu (hMainWnd), MENUID_GAME_SAVE, MF_ENABLED);
537
      EnableMenuItem (GetMenu (hMainWnd), MENUID_GAME_SAVE, MF_ENABLED);
538
      EnableMenuItem (GetMenu (hMainWnd), MENUID_GAME_SAVEAS, MF_ENABLED);
538
      EnableMenuItem (GetMenu (hMainWnd), MENUID_GAME_SAVEAS, MF_ENABLED);
539
      EnableMenuItem (GetMenu (hMainWnd), MENUID_GAME_SAVEPOSITIONAS, MF_ENABLED);
539
      EnableMenuItem (GetMenu (hMainWnd), MENUID_GAME_SAVEPOSITIONAS, MF_ENABLED);
-
 
540
 
-
 
541
      // disable the start position setup mode
-
 
542
      EnableMenuItem (GetMenu (hMainWnd), MENUID_GAME_SETUPPOSITION, MF_GRAYED);
540
 
543
 
541
      // enable the "go to move" menu option
544
      // enable the "go to move" menu option
542
      EnableMenuItem (GetMenu (hMainWnd), MENUID_CHESSBOARD_GOTOMOVE, MF_ENABLED);
545
      EnableMenuItem (GetMenu (hMainWnd), MENUID_MOVE_GOTOMOVE, MF_ENABLED);
543
 
546
 
544
      // are we watching the last move ?
547
      // are we watching the last move ?
545
      if (the_board.viewed_move == the_board.move_count - 1)
548
      if (the_board.viewed_move == the_board.move_count - 1)
546
      {
549
      {
547
         // get a quick acccess to the last move
550
         // get a quick acccess to the last move
548
         last_move = &the_board.moves[the_board.move_count - 1];
551
         last_move = &the_board.moves[the_board.move_count - 1];
549
 
552
 
550
         // if the current player is a human AND its opponent is a computer, allow him to ask us for a hint
553
         // if the current player is a human AND its opponent is a computer, allow him to ask us for a hint
551
         if ((current_player->type == PLAYER_HUMAN) && (opposite_player->type == PLAYER_COMPUTER))
554
         if ((current_player->type == PLAYER_HUMAN) && (opposite_player->type == PLAYER_COMPUTER))
552
            EnableMenuItem (GetMenu (hMainWnd), MENUID_CHESSBOARD_SUGGESTMOVE, MF_ENABLED);
555
            EnableMenuItem (GetMenu (hMainWnd), MENUID_MOVE_SUGGESTMOVE, MF_ENABLED);
553
         else
556
         else
554
            EnableMenuItem (GetMenu (hMainWnd), MENUID_CHESSBOARD_SUGGESTMOVE, MF_GRAYED);
557
            EnableMenuItem (GetMenu (hMainWnd), MENUID_MOVE_SUGGESTMOVE, MF_GRAYED);
555
 
558
 
556
         // (if the current player is a human
559
         // (if the current player is a human
557
         //  AND (its opponent is another human AND there's at least one move played)
560
         //  AND (its opponent is another human AND there's at least one move played)
558
         //       OR (its opponent is a computer AND there are at least two moves played)
561
         //       OR (its opponent is a computer AND there are at least two moves played)
559
         //       OR (its opponent is a remote player AND we're in game AND there are at least two moves played))
562
         //       OR (its opponent is a remote player AND we're in game AND there are at least two moves played))
Line 561... Line 564...
561
         if (((current_player->type == PLAYER_HUMAN)
564
         if (((current_player->type == PLAYER_HUMAN)
562
              && ((opposite_player->type == PLAYER_HUMAN)
565
              && ((opposite_player->type == PLAYER_HUMAN)
563
                  || ((opposite_player->type == PLAYER_COMPUTER) && (the_board.move_count > 2))
566
                  || ((opposite_player->type == PLAYER_COMPUTER) && (the_board.move_count > 2))
564
                  || ((opposite_player->type == PLAYER_INTERNET) && (opposite_player->is_in_game) && (the_board.move_count > 2))))
567
                  || ((opposite_player->type == PLAYER_INTERNET) && (opposite_player->is_in_game) && (the_board.move_count > 2))))
565
             || ((current_player->type == PLAYER_INTERNET) && (current_player->is_in_game) && (the_board.move_count > 2)))
568
             || ((current_player->type == PLAYER_INTERNET) && (current_player->is_in_game) && (the_board.move_count > 2)))
566
            EnableMenuItem (GetMenu (hMainWnd), MENUID_CHESSBOARD_CANCELLASTMOVE, MF_ENABLED);
569
            EnableMenuItem (GetMenu (hMainWnd), MENUID_MOVE_CANCELLASTMOVE, MF_ENABLED);
567
         else
570
         else
568
            EnableMenuItem (GetMenu (hMainWnd), MENUID_CHESSBOARD_CANCELLASTMOVE, MF_GRAYED);
571
            EnableMenuItem (GetMenu (hMainWnd), MENUID_MOVE_CANCELLASTMOVE, MF_GRAYED);
569
 
572
 
570
         // is the current player in check ? (to play the right sound)
573
         // is the current player in check ? (to play the right sound)
571
         // read as: was the last move an opponent's move AND did it put us to check ?
574
         // read as: was the last move an opponent's move AND did it put us to check ?
572
         if (last_move->is_check)
575
         if (last_move->is_check)
573
         {
576
         {
574
            // is it a checkmate ? (checkmate == check + stalemate)
577
            // is it a checkmate ? (checkmate == check + stalemate)
575
            if (last_move->is_stalemate)
578
            if (last_move->is_stalemate)
576
            {
579
            {
577
               // display the game over dialog box
580
               // display the game over dialog box
578
               the_board.game_state = (Board_ColorToMove (&the_board) == COLOR_WHITE ? STATE_BLACKWIN_CHECKMATE : STATE_WHITEWIN_CHECKMATE);
581
               the_board.game_state = (Board_ColorToMove (&the_board) == COLOR_WHITE ? STATE_BLACKWIN_CHECKMATE : STATE_WHITEWIN_CHECKMATE);
579
               DialogBox_EndGame ();
582
               DialogBox_EndGame ();
580
            }
583
            }
581
         }
584
         }
582
         else
585
         else
583
         {
586
         {
584
            // is it a stalemate ?
587
            // is it a stalemate ?
585
            if (last_move->is_stalemate)
588
            if (last_move->is_stalemate)
586
            {
589
            {
587
               // display the game over dialog box
590
               // display the game over dialog box
588
               the_board.game_state = STATE_DRAW_STALEMATE;
591
               the_board.game_state = STATE_DRAW_STALEMATE;
589
               DialogBox_EndGame ();
592
               DialogBox_EndGame ();
590
            }
593
            }
591
         }
594
         }
592
 
595
 
593
         // have there 50 moves been played each side (i.e, 100 plies) AND is the current player human ?
596
         // have there 50 moves been played each side (i.e, 100 plies) AND is the current player human ?
594
         if ((the_board.move_count > 100) && (current_player->type == PLAYER_HUMAN))
597
         if ((the_board.move_count > 100) && (current_player->type == PLAYER_HUMAN))
595
         {
598
         {
Line 627... Line 630...
627
         else if (the_board.game_state == STATE_DRAW_OTHER)
630
         else if (the_board.game_state == STATE_DRAW_OTHER)
628
            Scene_SetText (&the_scene.gui.arrow_text, 3.3f, 5.0f, -1, ALIGN_CENTER, ALIGN_TOP, ALIGN_CENTER, arrow_fontindex,
631
            Scene_SetText (&the_scene.gui.arrow_text, 3.3f, 5.0f, -1, ALIGN_CENTER, ALIGN_TOP, ALIGN_CENTER, arrow_fontindex,
629
                           RGBACOLOR_SETALPHA (options.clock_color, 0x7f), 999999.0f, false, LOCALIZE (L"EndGame_DrawOther"));
632
                           RGBACOLOR_SETALPHA (options.clock_color, 0x7f), 999999.0f, false, LOCALIZE (L"EndGame_DrawOther"));
630
 
633
 
631
         // enable the "comment on this move" menu option
634
         // enable the "comment on this move" menu option
632
         EnableMenuItem (GetMenu (hMainWnd), MENUID_CHESSBOARD_COMMENTMOVE, MF_ENABLED);
635
         EnableMenuItem (GetMenu (hMainWnd), MENUID_MOVE_COMMENTMOVE, MF_ENABLED);
633
      }
636
      }
634
 
637
 
635
      // else are we watching another move, but not the beginning of the game ?
638
      // else are we watching another move, but not the beginning of the game ?
636
      else if (the_board.viewed_move > 0)
639
      else if (the_board.viewed_move > 0)
637
      {
640
      {
638
         GUIBUTTON_ENABLE (the_scene.gui.larrow); // enable "back" arrow if it isn't displayed yet
641
         GUIBUTTON_ENABLE (the_scene.gui.larrow); // enable "back" arrow if it isn't displayed yet
639
         GUIBUTTON_ENABLE (the_scene.gui.rarrow); // enable "forward" arrow if it isn't displayed yet
642
         GUIBUTTON_ENABLE (the_scene.gui.rarrow); // enable "forward" arrow if it isn't displayed yet
640
         Scene_SetText (&the_scene.gui.arrow_text, 3.3f, 5.0f, -1, ALIGN_CENTER, ALIGN_TOP, ALIGN_CENTER, arrow_fontindex,
643
         Scene_SetText (&the_scene.gui.arrow_text, 3.3f, 5.0f, -1, ALIGN_CENTER, ALIGN_TOP, ALIGN_CENTER, arrow_fontindex,
641
                        RGBACOLOR_SETALPHA (options.clock_color, 0x7f), 999999.0f, false,
644
                        RGBACOLOR_SETALPHA (options.clock_color, 0x7f), 999999.0f, false,
642
                        L"%s %d\n%s", LOCALIZE (L"Move"), (the_board.viewed_move + 1) / 2, (the_board.viewed_move % 2 ? LOCALIZE (L"Games_White"): LOCALIZE (L"Games_Black")));
645
                        L"%s %d\n%s", LOCALIZE (L"Move"), (the_board.viewed_move + 1) / 2, (the_board.viewed_move % 2 ? LOCALIZE (L"Games_White"): LOCALIZE (L"Games_Black")));
-
 
646
 
-
 
647
         // hints are not usable when watching the game history
-
 
648
         EnableMenuItem (GetMenu (hMainWnd), MENUID_MOVE_SUGGESTMOVE, MF_GRAYED);
643
 
649
 
644
         // enable the "save position as" and "comment on this move" menu options
650
         // enable the "save position as" and "comment on this move" menu options
645
         EnableMenuItem (GetMenu (hMainWnd), MENUID_GAME_SAVEPOSITIONAS, MF_ENABLED);
651
         EnableMenuItem (GetMenu (hMainWnd), MENUID_GAME_SAVEPOSITIONAS, MF_ENABLED);
646
         EnableMenuItem (GetMenu (hMainWnd), MENUID_CHESSBOARD_COMMENTMOVE, MF_ENABLED);
652
         EnableMenuItem (GetMenu (hMainWnd), MENUID_MOVE_COMMENTMOVE, MF_ENABLED);
647
      }
653
      }
648
 
654
 
649
      // else we must be watching the beginning of the game (no move yet)
655
      // else we must be watching the beginning of the game (no move yet)
650
      else
656
      else
651
      {
657
      {
652
         GUIBUTTON_DISABLE (the_scene.gui.larrow); // disable "back" arrow if it's already displayed
658
         GUIBUTTON_DISABLE (the_scene.gui.larrow); // disable "back" arrow if it's already displayed
653
         GUIBUTTON_ENABLE (the_scene.gui.rarrow); // enable "forward" arrow if it isn't displayed yet
659
         GUIBUTTON_ENABLE (the_scene.gui.rarrow); // enable "forward" arrow if it isn't displayed yet
654
         Scene_SetText (&the_scene.gui.arrow_text, 3.3f, 5.0f, -1, ALIGN_CENTER, ALIGN_TOP, ALIGN_CENTER, arrow_fontindex,
660
         Scene_SetText (&the_scene.gui.arrow_text, 3.3f, 5.0f, -1, ALIGN_CENTER, ALIGN_TOP, ALIGN_CENTER, arrow_fontindex,
655
                        RGBACOLOR_SETALPHA (options.clock_color, 0x7f), 999999.0f, false, LOCALIZE (L"Beginning"));
661
                        RGBACOLOR_SETALPHA (options.clock_color, 0x7f), 999999.0f, false, LOCALIZE (L"Beginning"));
-
 
662
 
-
 
663
         // hints are not usable when watching the game history
-
 
664
         EnableMenuItem (GetMenu (hMainWnd), MENUID_MOVE_SUGGESTMOVE, MF_GRAYED);
656
 
665
 
657
         // disable the "save position as" and "comment on this move" menu options
666
         // disable the "save position as" and "comment on this move" menu options
658
         EnableMenuItem (GetMenu (hMainWnd), MENUID_GAME_SAVEPOSITIONAS, MF_GRAYED);
667
         EnableMenuItem (GetMenu (hMainWnd), MENUID_GAME_SAVEPOSITIONAS, MF_GRAYED);
659
         EnableMenuItem (GetMenu (hMainWnd), MENUID_CHESSBOARD_COMMENTMOVE, MF_GRAYED);
668
         EnableMenuItem (GetMenu (hMainWnd), MENUID_MOVE_COMMENTMOVE, MF_GRAYED);
660
      }
669
      }
661
   }
670
   }
662
   else
671
   else
663
   {
672
   {
664
      // game has not started, disable the "save", "save as" and "save position as" menu options
673
      // game has not started, disable the "save", "save as" and "save position as" menu options
665
      EnableMenuItem (GetMenu (hMainWnd), MENUID_GAME_SAVE, MF_GRAYED);
674
      EnableMenuItem (GetMenu (hMainWnd), MENUID_GAME_SAVE, MF_GRAYED);
666
      EnableMenuItem (GetMenu (hMainWnd), MENUID_GAME_SAVEAS, MF_GRAYED);
675
      EnableMenuItem (GetMenu (hMainWnd), MENUID_GAME_SAVEAS, MF_GRAYED);
667
      EnableMenuItem (GetMenu (hMainWnd), MENUID_GAME_SAVEPOSITIONAS, MF_GRAYED);
676
      EnableMenuItem (GetMenu (hMainWnd), MENUID_GAME_SAVEPOSITIONAS, MF_GRAYED);
-
 
677
 
-
 
678
      // if we are NOT on Internet play AND no longer in closeup mode, enable the start position setup mode
-
 
679
      EnableMenuItem (GetMenu (hMainWnd), MENUID_GAME_SETUPPOSITION, ((network_player == NULL) && (current_distance != CLOSEUP_VIEW_DISTANCE) && (current_pitch != CLOSEUP_VIEW_PITCH) ? MF_ENABLED : MF_GRAYED));
668
 
680
 
669
      // if the current player is a human AND its opponent is a computer, allow him to ask us for a hint
681
      // if the current player is a human AND its opponent is a computer, allow him to ask us for a hint
670
      if ((current_player->type == PLAYER_HUMAN) && (opposite_player->type == PLAYER_COMPUTER))
682
      if ((current_player->type == PLAYER_HUMAN) && (opposite_player->type == PLAYER_COMPUTER))
671
         EnableMenuItem (GetMenu (hMainWnd), MENUID_CHESSBOARD_SUGGESTMOVE, MF_ENABLED);
683
         EnableMenuItem (GetMenu (hMainWnd), MENUID_MOVE_SUGGESTMOVE, MF_ENABLED);
672
      else
684
      else
673
         EnableMenuItem (GetMenu (hMainWnd), MENUID_CHESSBOARD_SUGGESTMOVE, MF_GRAYED);
685
         EnableMenuItem (GetMenu (hMainWnd), MENUID_MOVE_SUGGESTMOVE, MF_GRAYED);
674
 
686
 
675
      // disable the "cancel last move", "comment move" and "go to move" menu options
687
      // disable the "cancel last move", "comment move" and "go to move" menu options
676
      EnableMenuItem (GetMenu (hMainWnd), MENUID_CHESSBOARD_CANCELLASTMOVE, MF_GRAYED);
688
      EnableMenuItem (GetMenu (hMainWnd), MENUID_MOVE_CANCELLASTMOVE, MF_GRAYED);
677
      EnableMenuItem (GetMenu (hMainWnd), MENUID_CHESSBOARD_COMMENTMOVE, MF_GRAYED);
689
      EnableMenuItem (GetMenu (hMainWnd), MENUID_MOVE_COMMENTMOVE, MF_GRAYED);
678
      EnableMenuItem (GetMenu (hMainWnd), MENUID_CHESSBOARD_GOTOMOVE, MF_GRAYED);
690
      EnableMenuItem (GetMenu (hMainWnd), MENUID_MOVE_GOTOMOVE, MF_GRAYED);
679
 
691
 
680
      is_paused = false; // clear pause status (we can only pause a game when it's been started)
692
      is_paused = false; // clear pause status (we can only pause a game when it's been started)
681
 
693
 
682
      // and disable the two arrows and the arrow text
694
      // and disable the two arrows and the arrow text
683
      GUIBUTTON_DISABLE (the_scene.gui.larrow);
695
      GUIBUTTON_DISABLE (the_scene.gui.larrow);
Line 740... Line 752...
740
      EnableMenuItem (GetMenu (hMainWnd), MENUID_GAME_STATISTICS, MF_GRAYED); // disable stats
752
      EnableMenuItem (GetMenu (hMainWnd), MENUID_GAME_STATISTICS, MF_GRAYED); // disable stats
741
 
753
 
742
      enabled_value = MF_GRAYED; // remember to disable the internet-related menu items
754
      enabled_value = MF_GRAYED; // remember to disable the internet-related menu items
743
   }
755
   }
744
 
756
 
745
   EnableMenuItem (GetMenu (hMainWnd), MENUID_GAME_SETUPPOSITION, !enabled_value); // note the inversion
-
 
746
   EnableMenuItem (GetMenu (hMainWnd), MENUID_INTERNET_SHOWONLINEPLAYERS, enabled_value);
757
   EnableMenuItem (GetMenu (hMainWnd), MENUID_INTERNET_SHOWONLINEPLAYERS, enabled_value);
747
   EnableMenuItem (GetMenu (hMainWnd), MENUID_INTERNET_SHOWSOUGHTGAMES, enabled_value);
758
   EnableMenuItem (GetMenu (hMainWnd), MENUID_INTERNET_SHOWSOUGHTGAMES, enabled_value);
748
   EnableMenuItem (GetMenu (hMainWnd), MENUID_INTERNET_SEEKGAME, enabled_value);
759
   EnableMenuItem (GetMenu (hMainWnd), MENUID_INTERNET_SEEKGAME, enabled_value);
749
   if (!options.network.want_publicchat)
760
   if (!options.network.want_publicchat)
750
   {
761
   {