[gnome-2048] Improve a bit responsiveness.
- From: Arnaud B. <arnaudb src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-2048] Improve a bit responsiveness.
- Date: Fri, 1 Feb 2019 12:10:54 +0000 (UTC)
commit 32ce636b4eb2f883c1eb27eb1c3315fd4438c6ee
Author: Arnaud Bonatti <arnaud bonatti gmail com>
Date: Fri Feb 1 13:03:54 2019 +0100
Improve a bit responsiveness.
Not sure why, but each move finished
by a 100ms timeout that was blocking
game. Just delay that way the finish
dialog, and allow an immediate play.
src/game.vala | 28 +++++++++++++++++-----------
1 file changed, 17 insertions(+), 11 deletions(-)
---
diff --git a/src/game.vala b/src/game.vala
index 41867dd..0733454 100644
--- a/src/game.vala
+++ b/src/game.vala
@@ -33,7 +33,6 @@ private class Game : Object
private Grid _grid;
- private uint _finish_move_id = 0;
private RoundedRectangle [,] _background;
private bool _background_init_done = false;
private TileView? [,] _foreground_cur;
@@ -54,9 +53,6 @@ private class Game : Object
private uint _resize_view_id;
- internal signal void finished ();
- internal signal void target_value_reached (uint val);
-
internal Game (GLib.Settings settings)
{
Object ();
@@ -121,8 +117,7 @@ private class Game : Object
internal void new_game ()
{
- if (_finish_move_id > 0)
- Source.remove (_finish_move_id);
+ _clean_finish_move_animation ();
_grid.clear ();
_clear_history ();
@@ -542,6 +537,11 @@ private class Game : Object
* * new tile animation
\*/
+ internal signal void finished ();
+ internal signal void target_value_reached (uint val);
+
+ private uint _finish_move_id = 0;
+
private void _create_show_hide_transition (bool animate)
{
_show_hide_trans = new Clutter.TransitionGroup ();
@@ -579,11 +579,6 @@ private class Game : Object
_foreground_cur [pos.row, pos.col] = null;
}
- _finish_move_id = GLib.Timeout.add (100, _finish_move);
- }
-
- private bool _finish_move ()
- {
if (_state == GameState.SHOWING_FIRST_TILE)
{
_state = GameState.SHOWING_SECOND_TILE;
@@ -628,6 +623,11 @@ private class Game : Object
_grid.target_value_reached = false;
}
+ _finish_move_id = GLib.Timeout.add (100, _finish_move);
+ }
+
+ private bool _finish_move ()
+ {
if (_grid.is_finished ())
finished ();
@@ -635,6 +635,12 @@ private class Game : Object
return false;
}
+ private inline void _clean_finish_move_animation ()
+ {
+ if (_finish_move_id > 0)
+ Source.remove (_finish_move_id);
+ }
+
/*\
* * history
\*/
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]