[gnome-nibbles/wip/vala] Pause the game when displaying the scores dialog



commit 003a75bfe42d2463d265742269bb4e5dff04ecc0
Author: Michael Catanzaro <mcatanzaro gnome org>
Date:   Sat Sep 19 22:12:29 2015 -0500

    Pause the game when displaying the scores dialog

 src/gnome-nibbles.vala |   11 +++++++++++
 1 files changed, 11 insertions(+), 0 deletions(-)
---
diff --git a/src/gnome-nibbles.vala b/src/gnome-nibbles.vala
index 1ca3bc5..a060daa 100644
--- a/src/gnome-nibbles.vala
+++ b/src/gnome-nibbles.vala
@@ -620,6 +620,13 @@ public class Nibbles : Gtk.Application
 
     private void scores_cb ()
     {
+        var should_unpause = false;
+        if (game.is_running)
+        {
+            pause_action.activate (null);
+            should_unpause = true;
+        }
+
         try
         {
             scores_context.run_dialog ();
@@ -629,6 +636,10 @@ public class Nibbles : Gtk.Application
             // Translators: This error is displayed when the scores dialog fails to load
             error (_("Failed to run scores dialog: %s"), e.message);
         }
+
+        // Be quite careful about whether to unpause. Don't unpause if the game has not started.
+        if (should_unpause)
+            pause_action.activate (null);
     }
 
     private void level_completed_cb ()


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