[iagno/gnome-3-10] Add a delay between the last move and final flip
- From: Michael Catanzaro <mcatanzaro src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [iagno/gnome-3-10] Add a delay between the last move and final flip
- Date: Mon, 30 Sep 2013 00:07:45 +0000 (UTC)
commit ae14f209423440686296a57cecbc3283f283b2a0
Author: Michael Catanzaro <mcatanzaro gnome org>
Date: Sun Sep 29 18:40:25 2013 -0500
Add a delay between the last move and final flip
Currently, it often seems like the final player has placed a piece
of his opponent's color instead of his own, since after clicking the
piece that is shown placed on the board is the one that is fated to be
there after the final flip. This is confusing and made me think I was
seeing Bug #679137. Add a delay to prevent confusion.
src/game-view.vala | 27 +++++++++++++++++++++++++--
1 files changed, 25 insertions(+), 2 deletions(-)
---
diff --git a/src/game-view.vala b/src/game-view.vala
index 553e7fd..489af51 100644
--- a/src/game-view.vala
+++ b/src/game-view.vala
@@ -28,6 +28,9 @@ public class GameView : Gtk.DrawingArea
public signal void move (int x, int y);
+ /* Used for a delay between the last move and flipping the pieces */
+ private bool flip_final_result_now = false;
+
private int tile_size
{
get
@@ -216,8 +219,8 @@ public class GameView : Gtk.DrawingArea
{
var pixmap = get_pixmap (game.get_owner (x, y));
- /* If requested show the result by laying the tiles with winning color first */
- if (game.is_complete && flip_final_result && game.n_light_tiles > 0 && game.n_dark_tiles > 0)
+ /* Show the result by laying the tiles with winning color first */
+ if (flip_final_result_now && game.is_complete)
{
var n = y * game.width + x;
var winning_color = Player.LIGHT;
@@ -239,8 +242,28 @@ public class GameView : Gtk.DrawingArea
else
pixmap = get_pixmap (Player.NONE);
}
+ /* An undo occurred after the game was complete */
+ else if (flip_final_result_now && !game.is_complete)
+ {
+ flip_final_result_now = false;
+ }
set_square (x, y, pixmap);
+
+ if (game.is_complete && flip_final_result && game.n_light_tiles > 0 && game.n_dark_tiles > 0)
+ {
+ /*
+ * Show the actual final positions of the pieces before flipping the board.
+ * Otherwise, it could seem like the final player placed the others' piece.
+ */
+ Timeout.add (2000, () =>
+ {
+ flip_final_result_now = true;
+ square_changed_cb (x, y);
+ /* Disconnect from mainloop */
+ return false;
+ });
+ }
}
private void set_square (int x, int y, int pixmap)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]