[gnome-2048] Start new game if settings changed



commit 09f1b705ccc68c6647f173b6e3fba4560f199cdf
Author: Juan R. GarcĂ­a Blanco <juanrgar gmail com>
Date:   Thu Jan 8 21:04:47 2015 +0100

    Start new game if settings changed
    
    After Preferences dialog is closed, start new game only if settings have
    changed.

 src/application.vala |    5 +++--
 src/game.vala        |    6 +++++-
 2 files changed, 8 insertions(+), 3 deletions(-)
---
diff --git a/src/application.vala b/src/application.vala
index d6463e8..83ac41a 100644
--- a/src/application.vala
+++ b/src/application.vala
@@ -213,8 +213,9 @@ public class Application : Gtk.Application
       _preferences_dialog.hide_on_delete ();
     });
     _preferences_dialog.delete_event.connect ((response_id) => {
-      _game.reload_settings ();
-      _game.new_game ();
+      bool settings_changed = _game.reload_settings ();
+      if (settings_changed)
+        _game.new_game ();
       return _preferences_dialog.hide_on_delete ();
     });
 
diff --git a/src/game.vala b/src/game.vala
index 93f101b..0060256 100644
--- a/src/game.vala
+++ b/src/game.vala
@@ -114,7 +114,7 @@ public class Game : GLib.Object
     return false;
   }
 
-  public void reload_settings ()
+  public bool reload_settings ()
   {
     int n_rows = _settings.get_int ("rows");
     int n_cols = _settings.get_int ("cols");
@@ -128,7 +128,11 @@ public class Game : GLib.Object
       _init_background ();
 
       _grid = new Grid (_n_rows, _n_cols);
+
+      return true;
     }
+
+    return false;
   }
 
   private uint _upper_key (uint keyval)


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