[gnome-nibbles] Remember the number of human players/number of AI settings for the following runs.



commit 6f579d5b6aaa50e25e212d6fdd6c23a989367c07
Author: Iulian Radu <iulian radu67 gmail com>
Date:   Mon Feb 15 18:32:52 2016 +0200

    Remember the number of human players/number of AI settings for the
    following runs.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=762042

 data/org.gnome.nibbles.gschema.xml |   12 ++++++++++++
 src/gnome-nibbles.vala             |   13 +++++++++++++
 2 files changed, 25 insertions(+), 0 deletions(-)
---
diff --git a/data/org.gnome.nibbles.gschema.xml b/data/org.gnome.nibbles.gschema.xml
index 53ae856..817164c 100644
--- a/data/org.gnome.nibbles.gschema.xml
+++ b/data/org.gnome.nibbles.gschema.xml
@@ -48,6 +48,18 @@
       <summary>Enable fake bonuses</summary>
       <description>Enable fake bonuses.</description>
     </key>
+    <key name="players" type="i">
+      <default>1</default>
+      <range min="1" max="4"/>
+      <summary>Number of human players</summary>
+      <description>Number of human players.</description>
+    </key>
+    <key name="ai" type="i">
+      <default>3</default>
+      <range min="0" max="5"/>
+      <summary>Number of AI players</summary>
+      <description>Number of AI players.</description>
+    </key>
   </schema>
   <schema id="org.gnome.nibbles.worm0" path="/org/gnome/nibbles/worm0/">
     <key name="color" type="s">
diff --git a/src/gnome-nibbles.vala b/src/gnome-nibbles.vala
index b794215..24546a8 100644
--- a/src/gnome-nibbles.vala
+++ b/src/gnome-nibbles.vala
@@ -216,6 +216,10 @@ public class Nibbles : Gtk.Application
         frame.add (view);
         frame.show ();
 
+        /* Number of worms */
+        game.numhumans = settings.get_int ("players");
+        game.numai = settings.get_int ("ai");
+
         /* Controls screen */
         arrow_pixbuf = view.load_pixmap_file ("arrow.svg", 5 * game.tile_size, 5 * game.tile_size);
         arrow_key_pixbuf = view.load_pixmap_file ("arrow-key.svg", 5 * game.tile_size, 5 * game.tile_size);
@@ -505,6 +509,9 @@ public class Nibbles : Gtk.Application
         main_stack.set_transition_type (Gtk.StackTransitionType.NONE);
         main_stack.set_visible_child_name ("number_of_players");
         main_stack.set_transition_type (type);
+
+        number_of_players_buttons[game.numhumans - 1].set_active (true);
+        number_of_ai_buttons[game.numai].set_active (true);
     }
 
     private void show_controls_screen_cb ()
@@ -517,6 +524,9 @@ public class Nibbles : Gtk.Application
                 int numhumans = -1;
                 button.get_label ().scanf ("_%d", &numhumans);
                 game.numhumans = numhumans;
+
+                /* Remember the option for the following runs */
+                settings.set_int ("players", game.numhumans);
                 break;
             }
         }
@@ -529,6 +539,9 @@ public class Nibbles : Gtk.Application
                 int numai = -1;
                 button.get_label ().scanf ("_%d", &numai);
                 game.numai = numai;
+
+                /* Remember the option for the following runs */
+                settings.set_int ("ai", game.numai);
                 break;
             }
         }


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