[iagno] Place highlight on previously played tile when undoing.
- From: Arnaud Bonatti <arnaudb src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [iagno] Place highlight on previously played tile when undoing.
- Date: Sat, 11 Apr 2015 20:31:00 +0000 (UTC)
commit c2277b98dc54884c7b8638e4d4822e9620ab18cd
Author: Arnaud Bonatti <arnaud bonatti gmail com>
Date: Sat Apr 11 22:11:03 2015 +0200
Place highlight on previously played tile when undoing.
src/game-view.vala | 16 +++++++++++++---
src/game.vala | 6 +++---
2 files changed, 16 insertions(+), 6 deletions(-)
---
diff --git a/src/game-view.vala b/src/game-view.vala
index 9f94a2a..5428fdb 100644
--- a/src/game-view.vala
+++ b/src/game-view.vala
@@ -355,7 +355,17 @@ public class GameView : Gtk.DrawingArea
}
}
- private void square_changed_cb (int x, int y)
+ private void square_changed_cb (int x, int y, Player replacement)
+ {
+ if (replacement == Player.NONE)
+ {
+ highlight_x = x;
+ highlight_y = y;
+ }
+ update_square (x, y);
+ }
+
+ private void update_square (int x, int y)
{
int pixmap = get_pixmap (game.get_owner (x, y));
@@ -398,7 +408,7 @@ public class GameView : Gtk.DrawingArea
*/
Timeout.add_seconds (2, () => {
flip_final_result_now = true;
- square_changed_cb (x, y);
+ update_square (x, y);
return Source.REMOVE;
});
}
@@ -432,7 +442,7 @@ public class GameView : Gtk.DrawingArea
for (int y = 0; y < game.size; y++)
{
int old = pixmaps[x, y];
- square_changed_cb (x, y);
+ update_square (x, y);
if (pixmaps[x, y] != old)
animating = true;
}
diff --git a/src/game.vala b/src/game.vala
index ee16b7b..0a4d235 100644
--- a/src/game.vala
+++ b/src/game.vala
@@ -46,7 +46,7 @@ public class Game : Object
/* Indicate that a player should move */
public signal void turn_ended ();
/* Indicate a square has changed */
- public signal void square_changed (int x, int y);
+ public signal void square_changed (int x, int y, Player new_color);
/*\
* * Number of tiles on the board
@@ -339,7 +339,7 @@ public class Game : Object
history_index++;
undo_stack[history_index] = x + y * size;
tiles[x, y] = current_color;
- square_changed (x, y);
+ square_changed (x, y, current_color);
}
/*\
@@ -388,6 +388,6 @@ public class Game : Object
var x = tile_number % size;
var y = tile_number / size;
tiles [x, y] = replacement_color;
- square_changed (x, y);
+ square_changed (x, y, replacement_color);
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]