[gnome-tetravex] Move some methods.
- From: Arnaud B. <arnaudb src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-tetravex] Move some methods.
- Date: Fri, 8 Nov 2019 21:19:19 +0000 (UTC)
commit 7d36b673a625cfa6b94c4594d8bdc4314b44cbd5
Author: Arnaud Bonatti <arnaud bonatti gmail com>
Date: Tue Nov 5 23:54:24 2019 +0100
Move some methods.
src/puzzle-view.vala | 28 +++-------------------------
src/puzzle.vala | 28 ++++++++++++++++++++++++++++
2 files changed, 31 insertions(+), 25 deletions(-)
---
diff --git a/src/puzzle-view.vala b/src/puzzle-view.vala
index 7a30f82..6a82216 100644
--- a/src/puzzle-view.vala
+++ b/src/puzzle-view.vala
@@ -716,7 +716,7 @@ private class PuzzleView : Gtk.DrawingArea
{
uint8 x;
uint8 y;
- if (only_one_remaining_tile (out x, out y))
+ if (puzzle.only_one_remaining_tile (out x, out y))
{
uint8 selected_x, selected_y;
puzzle.get_tile_location (((!) selected_tile).tile, out selected_x, out selected_y);
@@ -745,26 +745,6 @@ private class PuzzleView : Gtk.DrawingArea
return false;
}
- private inline bool only_one_remaining_tile (out uint8 empty_x, out uint8 empty_y)
- {
- bool empty_found = false;
- empty_x = uint8.MAX; // garbage
- empty_y = uint8.MAX; // garbage
- for (uint8 x = 0; x < puzzle.size; x++)
- for (uint8 y = 0; y < puzzle.size; y++)
- if (puzzle.get_tile (x, y) == null)
- {
- if (empty_found)
- return false;
- empty_found = true;
- empty_x = x;
- empty_y = y;
- }
-
- if (!empty_found)
- assert_not_reached ();
- return true;
- }
protected override bool button_release_event (Gdk.EventButton event)
{
@@ -823,9 +803,7 @@ private class PuzzleView : Gtk.DrawingArea
internal void finish ()
{
- for (uint8 x = 0; x < puzzle.size; x++)
- for (uint8 y = 0; y < puzzle.size; y++)
- puzzle.switch_tiles (x + puzzle.size, y, x, y, final_animation_duration);
+ puzzle.finish (final_animation_duration);
}
internal void release_selected_tile ()
@@ -966,7 +944,7 @@ private class PuzzleView : Gtk.DrawingArea
{
uint8 x;
uint8 y;
- if (only_one_remaining_tile (out x, out y))
+ if (puzzle.only_one_remaining_tile (out x, out y))
{
uint8 selected_x, selected_y;
puzzle.get_tile_location ((!) tile, out selected_x, out selected_y);
diff --git a/src/puzzle.vala b/src/puzzle.vala
index 49b0230..104664d 100644
--- a/src/puzzle.vala
+++ b/src/puzzle.vala
@@ -497,6 +497,34 @@ private class Puzzle : Object
stop_clock ();
}
+ internal void finish (uint duration)
+ {
+ for (uint8 x = 0; x < size; x++)
+ for (uint8 y = 0; y < size; y++)
+ switch_tiles (x + size, y, x, y, duration);
+ }
+
+ internal bool only_one_remaining_tile (out uint8 empty_x, out uint8 empty_y)
+ {
+ bool empty_found = false;
+ empty_x = uint8.MAX; // garbage
+ empty_y = uint8.MAX; // garbage
+ for (uint8 x = 0; x < size; x++)
+ for (uint8 y = 0; y < size; y++)
+ if (get_tile (x, y) == null)
+ {
+ if (empty_found)
+ return false;
+ empty_found = true;
+ empty_x = x;
+ empty_y = y;
+ }
+
+ if (!empty_found)
+ return false;
+ return true;
+ }
+
/*\
* * clock
\*/
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]