[gnome-nibbles/wip/vala: 23/64] Add save properties method for worms



commit e91329046e9e4d983bf7fa7f9c5a0802c0f8094d
Author: Iulian Radu <iulian radu67 gmail com>
Date:   Mon Jun 29 02:08:17 2015 +0300

    Add save properties method for worms

 src/nibbles-game.vala |   18 ++++++++++++++++--
 1 files changed, 16 insertions(+), 2 deletions(-)
---
diff --git a/src/nibbles-game.vala b/src/nibbles-game.vala
index 99dae79..3022ec9 100644
--- a/src/nibbles-game.vala
+++ b/src/nibbles-game.vala
@@ -107,8 +107,8 @@ public class NibblesGame : Object
 
     public void save_properties (Settings settings)
     {
-        tile_size = settings.get_int ("tile-size");
-        start_level = settings.get_int ("start-level");
+        settings.set_int ("tile-size", tile_size);
+        settings.set_int ("start-level", start_level);
     }
 
     public void load_worm_properties (Gee.ArrayList<Settings> worm_settings)
@@ -126,6 +126,20 @@ public class NibblesGame : Object
         }
     }
 
+    public void save_worm_properties (Gee.ArrayList<Settings> worm_settings)
+    {
+        foreach (var worm in worms)
+        {
+            var properties = worm_props.get (worm);
+
+            worm_settings[worm.id].set_string ("color", NibblesView.colorval_name (properties.color));
+            worm_settings[worm.id].set_int ("key-up", (int) properties.up);
+            worm_settings[worm.id].set_int ("key-down", (int) properties.down);
+            worm_settings[worm.id].set_int ("key-left", (int) properties.left);
+            worm_settings[worm.id].set_int ("key-right", (int) properties.right);
+        }
+    }
+
     public bool handle_keypress (uint keyval)
     {
         foreach (var worm in worms)


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