[gnome-mines] Fixed theme preview dialog
- From: Robert Roth <robertroth src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-mines] Fixed theme preview dialog
- Date: Wed, 2 Nov 2016 06:46:16 +0000 (UTC)
commit eef0370d0f304c02f3bdd899beebc1d5a6f97953
Author: Robert Roth <robert roth off gmail com>
Date: Wed Nov 2 08:46:03 2016 +0200
Fixed theme preview dialog
src/theme-selector-dialog.vala | 40 +++++++++++++++++++++++++++++++---------
1 files changed, 31 insertions(+), 9 deletions(-)
---
diff --git a/src/theme-selector-dialog.vala b/src/theme-selector-dialog.vala
index e7f9e37..26ba3c2 100644
--- a/src/theme-selector-dialog.vala
+++ b/src/theme-selector-dialog.vala
@@ -1,8 +1,21 @@
private class PreviewField : Minefield
{
+ private static const Neighbour neighbour_map[] =
+ {
+ {-1, 1},
+ {0, 1},
+ {1, 1},
+ {1, 0},
+ {1, -1},
+ {0, -1},
+ {-1, -1},
+ {-1, 0}
+ };
+
+ private const int SIZE = 7;
public PreviewField ()
{
- base (7, 7, 20);
+ base (SIZE, SIZE, 3*SIZE);
place_mines (0, 0);
placed_mines = true;
@@ -10,21 +23,30 @@ private class PreviewField : Minefield
protected new void place_mines (uint x, uint y)
{
- for (int i = 0; i < 7; i++)
+ for (int i = 0; i < SIZE; i++)
locations[i, 0].has_mine = i >= 5;
- for (int i = 0; i < 7; i++)
+ for (int i = 0; i < SIZE; i++)
locations[i, 1].has_mine = false;
- for (int i = 0; i < 7; i++)
+ for (int i = 0; i < SIZE; i++)
locations[i, 2].has_mine = i == 0 || i == 3;
- for (int i = 0; i < 7; i++)
+ for (int i = 0; i < SIZE; i++)
locations[i, 3].has_mine = i == 0 || i == 2;
- for (int i = 0; i < 7; i++)
+ for (int i = 0; i < SIZE; i++)
locations[i, 4].has_mine = i == 0 || i == 2 || i > 3;
- for (int i = 0; i < 7; i++)
+ for (int i = 0; i < SIZE; i++)
locations[i, 5].has_mine = i % 2 == 0;
- for (int i = 0; i < 7; i++)
+ for (int i = 0; i < SIZE; i++)
locations[i, 6].has_mine = i != 1;
-
+ for (int i = 0; i < SIZE; i++)
+ for (int j = 0; j < SIZE; j++)
+ foreach (var neighbour in neighbour_map)
+ {
+ var nx = i + neighbour.x;
+ var ny = j + neighbour.y;
+ if (is_location(nx, ny) && locations[nx, ny].has_mine)
+ locations[i, j].adjacent_mines++;
+ }
+
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]