[swell-foop/arnaudb/cursor-fixes] Fix keyboard cursor move.
- From: Arnaud B. <arnaudb src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [swell-foop/arnaudb/cursor-fixes] Fix keyboard cursor move.
- Date: Wed, 13 May 2020 20:16:35 +0000 (UTC)
commit e02743cefea08fc2ccde14355a6e6e176ddb7fc7
Author: Arnaud Bonatti <arnaud bonatti gmail com>
Date: Wed May 13 21:55:32 2020 +0200
Fix keyboard cursor move.
On empty tiles on loaded game.
src/game-view.vala | 6 ++++--
src/game.vala | 9 +++------
2 files changed, 7 insertions(+), 8 deletions(-)
---
diff --git a/src/game-view.vala b/src/game-view.vala
index 0f47413..1d98ecb 100644
--- a/src/game-view.vala
+++ b/src/game-view.vala
@@ -265,8 +265,10 @@ private class GameView : Clutter.Group
private TileActor? find_tile_at_position (int position_x, int position_y)
{
foreach (TileActor actor in tiles)
- if (actor.tile.grid_x == position_x &&
- actor.tile.grid_y == position_y)
+ if (actor != null
+ && actor.tile != null
+ && actor.tile.grid_x == position_x
+ && actor.tile.grid_y == position_y)
return actor;
return null;
}
diff --git a/src/game.vala b/src/game.vala
index 50a8be7..1c0f842 100644
--- a/src/game.vala
+++ b/src/game.vala
@@ -68,7 +68,7 @@ private class Tile : Object
*/
private class Game : Object
{
- private Tile[,] tiles;
+ private Tile? [,] tiles;
private bool is_started = false;
/* Game score */
@@ -125,7 +125,7 @@ private class Game : Object
{
var cl = new List<Tile> ();
- if (li.visited || li.closed)
+ if (li == null || li.visited || li.closed)
return cl;
var x = li.grid_x;
@@ -344,10 +344,7 @@ private class Game : Object
Variant tmp_variant_3 = tmp_variant_2.get_child_value (j);
uint8 color = tmp_variant_3.get_byte ();
if (color == 0)
- {
- tiles [rows - i - 1, j] = new Tile (j, (int) (rows - i - 1), 0);
- tiles [rows - i - 1, j].closed = true;
- }
+ tiles [rows - i - 1, j] = null;
else
tiles [rows - i - 1, j] = new Tile (j, (int) (rows - i - 1), color - 1);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]