Handle pause correctly before the game has started

Since the clock doesn't start until after White's first move, it
shouldn't be possible to pause/unpause the game during this time,
either.  This means the pause button must be insensitive, and we don't
want to see any warnings if we unfocus the window prior to making the
first move.
This commit is contained in:
Michael Catanzaro 2013-08-03 14:06:55 -05:00
parent f751835018
commit 6d95ad3b3a
2 changed files with 11 additions and 2 deletions

View file

@ -81,7 +81,7 @@ public class ChessClock : Object
private bool is_active
{
get { return expire_timeout_id != 0; }
get { return timer != null && expire_timeout_id != 0; }
}
public void start ()

View file

@ -495,7 +495,6 @@ public class Application : Gtk.Application
scene.game = game;
info_bar.hide ();
save_button.sensitive = false;
pause_button.sensitive = (game.clock != null);
update_history_panel ();
update_control_buttons ();
@ -564,7 +563,14 @@ public class Application : Gtk.Application
game.start ();
if (moves.length > 0 && game.clock != null)
{
game.clock.start ();
pause_button.sensitive = true;
}
else
{
pause_button.sensitive = false;
}
if (game.result != ChessResult.IN_PROGRESS)
game_end_cb (game);
@ -673,6 +679,9 @@ public class Application : Gtk.Application
private void game_turn_cb (ChessGame game, ChessPlayer player)
{
if (game.clock != null)
pause_button.sensitive = true;
if (game.is_started && opponent_engine != null && player == opponent)
opponent_engine.request_move ();
}