[iagno] Clear impossible-to-move-here warning.



commit a538fb2bd54e1e9211969f7b0ffb818d44a8e6ef
Author: Arnaud Bonatti <arnaud bonatti gmail com>
Date:   Fri Jun 21 15:29:06 2019 +0200

    Clear impossible-to-move-here warning.

 src/game-view.vala   | 7 +++++++
 src/game-window.vala | 5 +++++
 src/iagno.vala       | 7 +++++++
 3 files changed, 19 insertions(+)
---
diff --git a/src/game-view.vala b/src/game-view.vala
index 50f87c9..73f05cb 100644
--- a/src/game-view.vala
+++ b/src/game-view.vala
@@ -111,6 +111,7 @@ private class GameView : Gtk.DrawingArea
     private int current_player_number = 0;
 
     internal signal void move (uint8 x, uint8 y);
+    internal signal void clear_impossible_to_move_here_warning ();
 
     private bool game_is_set = false;
     private uint8 game_size;
@@ -908,6 +909,9 @@ private class GameView : Gtk.DrawingArea
         bool old_show_mouse_highlight = show_mouse_highlight;
         show_mouse_highlight = game.test_placing_tile (x, y);
 
+        if (show_mouse_highlight)
+            clear_impossible_to_move_here_warning ();
+
         if (old_show_mouse_highlight && !show_mouse_highlight)
         {
             old_highlight_x = uint8.MAX;
@@ -1055,6 +1059,9 @@ private class GameView : Gtk.DrawingArea
 
         highlight_set = true;
 
+        if (key != "space" && key != "Return" && key != "KP_Enter")
+            clear_impossible_to_move_here_warning ();
+
         if (key == "Escape")
             show_highlight = false;
         else if (show_highlight)
diff --git a/src/game-window.vala b/src/game-window.vala
index 33081cb..9ae536c 100644
--- a/src/game-window.vala
+++ b/src/game-window.vala
@@ -270,6 +270,11 @@ private class GameWindow : ApplicationWindow
         headerbar.set_subtitle (subtitle);
     }
 
+    internal void clear_subtitle ()
+    {
+        headerbar.set_subtitle (null);
+    }
+
     internal void finish_game ()
     {
         game_finished = true;
diff --git a/src/iagno.vala b/src/iagno.vala
index cefc83b..fa62579 100644
--- a/src/iagno.vala
+++ b/src/iagno.vala
@@ -214,6 +214,7 @@ private class Iagno : Gtk.Application
 
         view = new GameView (this);
         view.move.connect (player_move_cb);
+        view.clear_impossible_to_move_here_warning.connect (clear_impossible_to_move_here_warning);
 
         DrawingArea scoredrawing = (DrawingArea) builder.get_object ("scoredrawing");
         view.scoreboard = scoredrawing;
@@ -536,6 +537,12 @@ private class Iagno : Gtk.Application
         }
     }
 
+    private void clear_impossible_to_move_here_warning ()
+        requires (game_is_set)
+    {
+        window.clear_subtitle ();
+    }
+
     /*\
     * * Sound
     \*/


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]