[gnome-chess] Display a message if a human player is in check
- From: Michael Catanzaro <mcatanzaro src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-chess] Display a message if a human player is in check
- Date: Tue, 7 Jan 2014 21:13:47 +0000 (UTC)
commit a62746fe7510fb423d578ce8060059c9d8db18e9
Author: Michael Catanzaro <mcatanzaro gnome org>
Date: Tue Jan 7 15:12:24 2014 -0600
Display a message if a human player is in check
https://bugzilla.gnome.org/show_bug.cgi?id=703183
src/chess-game.vala | 2 +-
src/gnome-chess.vala | 13 ++++++++++++-
2 files changed, 13 insertions(+), 2 deletions(-)
---
diff --git a/src/chess-game.vala b/src/chess-game.vala
index 423b244..ee72992 100644
--- a/src/chess-game.vala
+++ b/src/chess-game.vala
@@ -861,7 +861,7 @@ public class ChessState
return CheckState.NONE;
}
- private bool is_in_check (ChessPlayer player)
+ public bool is_in_check (ChessPlayer player)
{
var opponent = player.color == Color.WHITE ? players[Color.BLACK] : players[Color.WHITE];
diff --git a/src/gnome-chess.vala b/src/gnome-chess.vala
index 61302d6..4cb42fc 100644
--- a/src/gnome-chess.vala
+++ b/src/gnome-chess.vala
@@ -1015,7 +1015,18 @@ public class Application : Gtk.Application
private void update_headerbar_title ()
{
- if (game.current_player.color == Color.WHITE)
+ if ((human_player == null ||
+ human_player.color == game.current_player.color) &&
+ game.current_state.is_in_check (game.current_player))
+ {
+ if (game.current_player.color == Color.WHITE)
+ /* Window title on a White human's turn if he is in check */
+ headerbar.set_title (_("White is in Check"));
+ else
+ /* Window title on a Black human's turn if he is in check */
+ headerbar.set_title (_("Black is in Check"));
+ }
+ else if (game.current_player.color == Color.WHITE)
{
if (human_player == null || human_player.color == Color.WHITE)
/* Window title on White's turn if White is human */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]