[gnome-chess/gnome-3-14] Load completed saved games properly
- From: Michael Catanzaro <mcatanzaro src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-chess/gnome-3-14] Load completed saved games properly
- Date: Sun, 28 Dec 2014 17:09:16 +0000 (UTC)
commit b089b2f31c33a3d0ec6e4c0183c322711ccae814
Author: Sahil Sareen <sahil sareen hotmail com>
Date: Sun Dec 28 21:24:47 2014 +0530
Load completed saved games properly
Update game.result from the pgn-result when loading
a completed game. Stop the game and timer accordingly
and display the winner.
https://bugzilla.gnome.org/show_bug.cgi?id=705002
src/gnome-chess.vala | 16 +++++++++++++---
1 files changed, 13 insertions(+), 3 deletions(-)
---
diff --git a/src/gnome-chess.vala b/src/gnome-chess.vala
index a4c5953..959606c 100644
--- a/src/gnome-chess.vala
+++ b/src/gnome-chess.vala
@@ -572,6 +572,15 @@ public class ChessApplication : Gtk.Application
}
game.start ();
+
+ // If loading a completed saved game
+ if (pgn_game.result == PGNGame.RESULT_WHITE)
+ game.result = ChessResult.WHITE_WON;
+ else if (pgn_game.result == PGNGame.RESULT_BLACK)
+ game.result = ChessResult.BLACK_WON;
+ else if (pgn_game.result == PGNGame.RESULT_DRAW)
+ game.result = ChessResult.DRAW;
+
if (opponent_engine != null)
opponent_engine.start_game ();
@@ -585,9 +594,6 @@ public class ChessApplication : Gtk.Application
disable_window_action (PAUSE_RESUME_ACTION_NAME);
}
- if (game.result != ChessResult.IN_PROGRESS)
- game_end_cb (game);
-
update_history_panel ();
update_action_status ();
update_pause_resume_button ();
@@ -604,6 +610,10 @@ public class ChessApplication : Gtk.Application
assert (opponent_engine != null);
opponent_engine.move ();
}
+
+ // If loading a completed saved game
+ if (game.result != ChessResult.IN_PROGRESS)
+ game.stop (game.result, game.rule);
}
private ChessEngine? get_engine (string name, string difficulty)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]