[gnome-taquin] More useful notifications.



commit e820d9cd8b978991b936e266927d48e5a263779e
Author: Arnaud Bonatti <arnaud bonatti gmail com>
Date:   Thu Jan 24 12:56:58 2019 +0100

    More useful notifications.
    
    When a game is finished again, specify if
    the user has improved against best score.

 src/game-headerbar.vala | 40 +++++++++++++++++++++++++++++++++++++++-
 src/game-window.vala    |  6 +++---
 2 files changed, 42 insertions(+), 4 deletions(-)
---
diff --git a/src/game-headerbar.vala b/src/game-headerbar.vala
index e7871c2..38ec29a 100644
--- a/src/game-headerbar.vala
+++ b/src/game-headerbar.vala
@@ -251,12 +251,50 @@ private class GameHeaderBar : BaseHeaderBar
     \*/
 
     private uint best_score = 0;
-    internal void save_best_score ()
+    internal void save_best_score (out string best_score_string)
     {
+        get_best_score_string (ref best_score, ref last_moves_count, out best_score_string);
+
         if ((best_score == 0) || (last_moves_count < best_score))
             best_score = last_moves_count;
         generate_moves_menu ();
     }
+    private static inline void get_best_score_string (ref uint best_score, ref uint last_moves_count, out 
string best_score_string)
+    {
+        if (best_score == 0)
+        {
+            best_score_string = usual_best_score_string;
+            return;
+        }
+
+        if (last_moves_count < best_score)
+        {
+            /* Translators: in-window notification; on both games, if the user solved the puzzle more than 
one time */
+            best_score_string =    _("Bravo! You improved your best score!");
+            if (best_score_string != "Bravo! You improved your best score!")
+                return;
+        }
+        else if (last_moves_count == best_score)
+        {
+            /* Translators: in-window notification; on both games, if the user solved the puzzle more than 
one time */
+            best_score_string =    _("Bravo! You equalized your best score.");
+            if (best_score_string != "Bravo! You equalized your best score.")
+                return;
+        }
+        else
+        {
+            /* Translators: in-window notification; on both games, if the user solved the puzzle more than 
one time */
+            best_score_string =    _("Bravo! You finished the game again.");
+            if (best_score_string != "Bravo! You finished the game again.")
+                return;
+        }
+
+        if (usual_best_score_string_untranslated != usual_best_score_string)
+            best_score_string = usual_best_score_string;
+    }
+    /* Translators: in-window notification; on both games, if the user solves the puzzle the first time */
+    private const string usual_best_score_string              = _("Bravo! You finished the game!");
+    private const string usual_best_score_string_untranslated =   "Bravo! You finished the game!" ;
 
     private void generate_moves_menu ()
     {
diff --git a/src/game-window.vala b/src/game-window.vala
index d0492db..964554f 100644
--- a/src/game-window.vala
+++ b/src/game-window.vala
@@ -149,9 +149,9 @@ private class GameWindow : BaseWindow, AdaptativeWidget
     {
         game_finished = true;
         headerbar.new_game_button_grab_focus ();
-        headerbar.save_best_score ();
-        /* Translators: notification, as a subtitle of the headerbar; on both games, if the user solves the 
puzzle */
-        show_notification (_("Bravo! You finished the game!"));
+        string best_score_string;
+        headerbar.save_best_score (out best_score_string);
+        show_notification (best_score_string);
     }
 
     protected override bool escape_pressed ()


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