[gnome-chess/gnome-3-12] Do not unpause the game when the engine moves
- From: Michael Catanzaro <mcatanzaro src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-chess/gnome-3-12] Do not unpause the game when the engine moves
- Date: Mon, 14 Apr 2014 18:07:58 +0000 (UTC)
commit 92297dd81e3291409eb4022ce1cf17bc3248131c
Author: Michael Catanzaro <mcatanzaro gnome org>
Date: Mon Apr 14 13:05:37 2014 -0500
Do not unpause the game when the engine moves
Instead, wait until the player unpauses the game, and only then report
the move.
src/gnome-chess.vala | 28 ++++++++++++++++++++++++++--
1 files changed, 26 insertions(+), 2 deletions(-)
---
diff --git a/src/gnome-chess.vala b/src/gnome-chess.vala
index f9bf268..93c0468 100644
--- a/src/gnome-chess.vala
+++ b/src/gnome-chess.vala
@@ -665,13 +665,37 @@ public class Application : Gtk.Application
view.queue_draw ();
}
}
-
- private void engine_move_cb (ChessEngine engine, string move)
+
+ private void do_engine_move (string move)
{
if (!opponent.move (move))
game.stop (ChessResult.BUG, ChessRule.BUG);
}
+ private void engine_move_cb (ChessEngine engine, string move)
+ {
+ if (!game.is_paused)
+ {
+ do_engine_move (move);
+ }
+ else
+ {
+ Timeout.add_seconds (1, () => {
+ if (game.is_paused)
+ {
+ /* Keep waiting */
+ return true;
+ }
+ else
+ {
+ do_engine_move (move);
+ /* Disconnect from main loop */
+ return false;
+ }
+ });
+ }
+ }
+
private void engine_resigned_cb (ChessEngine engine)
{
opponent.resign ();
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]