[gnome-nibbles] Implement controls screen



commit 90deeb316ed01a74a9a3dbd9dc29adae1459b503
Author: Iulian Radu <iulian radu67 gmail com>
Date:   Tue Aug 4 22:09:33 2015 +0300

    Implement controls screen

 arrow.svg                          |   35 ++++++++++
 data/controls-grid.ui              |  125 ++++++++++++++++++++++++++++++++++++
 data/nibbles.ui                    |   43 ++++++++++--
 data/org.gnome.nibbles.gschema.xml |   24 ++++----
 data/pix/Makefile.am               |   10 +++-
 data/pix/arrow-key.svg             |   36 ++++++++++
 data/pix/arrow.svg                 |   36 ++++++++++
 src/gnome-nibbles.gresource.xml.in |    1 +
 src/gnome-nibbles.vala             |  111 ++++++++++++++++++++++++++++++-
 src/nibbles-game.vala              |    3 +-
 src/nibbles-view.vala              |    2 +-
 src/worm.vala                      |    4 +-
 12 files changed, 400 insertions(+), 30 deletions(-)
---
diff --git a/arrow.svg b/arrow.svg
new file mode 100644
index 0000000..c042069
--- /dev/null
+++ b/arrow.svg
@@ -0,0 +1,35 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<svg
+   xmlns:dc="http://purl.org/dc/elements/1.1/";
+   xmlns:cc="http://creativecommons.org/ns#";
+   xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#";
+   xmlns:svg="http://www.w3.org/2000/svg";
+   xmlns="http://www.w3.org/2000/svg";
+   version="1.1"
+   height="100.00000mm"
+   width="100.00000mm"
+   id="svg836">
+  <metadata
+     id="metadata10">
+    <rdf:RDF>
+      <cc:Work
+         rdf:about="">
+        <dc:format>image/svg+xml</dc:format>
+        <dc:type
+           rdf:resource="http://purl.org/dc/dcmitype/StillImage"; />
+        <dc:title></dc:title>
+      </cc:Work>
+    </rdf:RDF>
+  </metadata>
+  <defs
+     id="defs838" />
+  <path
+     
style="fill:#ffffff;stroke:#4a90d9;stroke-width:18.68995857;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
+     d="m 175.98387,281.61317 0,-139.62335"
+     id="path13667" />
+  <path
+     
style="color:#000000;clip-rule:nonzero;display:inline;overflow:visible;visibility:visible;opacity:1;isolation:auto;mix-blend-mode:normal;color-interpolation:sRGB;color-interpolation-filters:linearRGB;solid-color:#000000;solid-opacity:1;fill:#4a90d9;fill-opacity:1;fill-rule:nonzero;stroke:#4a90d9;stroke-width:1.81623495;stroke-linecap:square;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;marker:none;color-rendering:auto;image-rendering:auto;shape-rendering:auto;text-rendering:auto;enable-background:accumulate"
+     id="path13669"
+     d="m -1352.9978,-483.29435 -8.5363,0 -8.5362,0 4.2681,-7.39259 4.2681,-7.39259 4.2682,7.39259 z"
+     transform="matrix(5.5795475,0,0,4.7447543,7772.7271,2463.3855)" />
+</svg>
diff --git a/data/controls-grid.ui b/data/controls-grid.ui
new file mode 100644
index 0000000..76f4a92
--- /dev/null
+++ b/data/controls-grid.ui
@@ -0,0 +1,125 @@
+<interface>
+    <template class="ControlsGrid" parent="GtkGrid">
+        <property name="visible">True</property>
+        <property name="valign">center</property>
+        <property name="halign">center</property>
+        <property name="vexpand">True</property>
+        <property name="row_spacing">5</property>
+        <property name="column_spacing">5</property>
+        <child>
+            <object class="GtkLabel" id="name_label">
+                <property name="visible">True</property>
+                <property name="label" translatable="yes">Player</property>
+            </object>
+            <packing>
+                <property name="left-attach">0</property>
+                <property name="top-attach">0</property>
+                <property name="width">5</property>
+            </packing>
+        </child>
+        <child>
+            <object class="GtkImage" id="arrow_up">
+                <property name="visible">True</property>
+            </object>
+            <packing>
+                <property name="left-attach">2</property>
+                <property name="top-attach">1</property>
+            </packing>
+        </child>
+        <child>
+            <object class="GtkOverlay" id="move_up">
+                <property name="visible">True</property>
+                <child>
+                    <object class="GtkLabel" id="move_up_label">
+                        <property name="visible">True</property>
+                        <property name="height-request">36</property>
+                        <property name="width-request">36</property>
+                        <style><class name="button"/></style>
+                    </object>
+                </child>
+            </object>
+            <packing>
+                <property name="left-attach">2</property>
+                <property name="top-attach">2</property>
+            </packing>
+        </child>
+        <child>
+            <object class="GtkImage" id="arrow_left">
+                <property name="visible">True</property>
+            </object>
+            <packing>
+                <property name="left-attach">0</property>
+                <property name="top-attach">3</property>
+            </packing>
+        </child>
+        <child>
+            <object class="GtkOverlay" id="move_left">
+                <property name="visible">True</property>
+                <child>
+                    <object class="GtkLabel" id="move_left_label">
+                        <property name="visible">True</property>
+                        <property name="height-request">36</property>
+                        <property name="width-request">36</property>
+                        <style><class name="button"/></style>
+                    </object>
+                </child>
+            </object>
+            <packing>
+                <property name="left-attach">1</property>
+                <property name="top-attach">3</property>
+            </packing>
+        </child>
+        <child>
+            <object class="GtkOverlay" id="move_right">
+                <property name="visible">True</property>
+                <child>
+                    <object class="GtkLabel" id="move_right_label">
+                        <property name="visible">True</property>
+                        <property name="height-request">36</property>
+                        <property name="width-request">36</property>
+                        <style><class name="button"/></style>
+                    </object>
+                </child>
+            </object>
+            <packing>
+                <property name="left-attach">3</property>
+                <property name="top-attach">3</property>
+            </packing>
+        </child>
+        <child>
+            <object class="GtkImage" id="arrow_right">
+                <property name="visible">True</property>
+            </object>
+            <packing>
+                <property name="left-attach">4</property>
+                <property name="top-attach">3</property>
+            </packing>
+        </child>
+        <child>
+            <object class="GtkOverlay" id="move_down">
+                <property name="visible">True</property>
+                <child>
+                    <object class="GtkLabel" id="move_down_label">
+                        <property name="visible">True</property>
+                        <property name="height-request">36</property>
+                        <property name="width-request">36</property>
+                        <style><class name="button"/></style>
+                    </object>
+                </child>
+            </object>
+            <packing>
+                <property name="left-attach">2</property>
+                <property name="top-attach">4</property>
+            </packing>
+        </child>
+        <child>
+            <object class="GtkImage" id="arrow_down">
+                <property name="visible">True</property>
+            </object>
+            <packing>
+                <property name="left-attach">2</property>
+                <property name="top-attach">5</property>
+            </packing>
+        </child>
+    </template>
+</interface>
diff --git a/data/nibbles.ui b/data/nibbles.ui
index 9f1b062..c1ac98b 100644
--- a/data/nibbles.ui
+++ b/data/nibbles.ui
@@ -115,13 +115,13 @@
                                         <property name="orientation">horizontal</property>
                                         <property name="width-request">250</property>
                                         <property name="height-request">250</property>
-                                        <property name="valign">3</property>
-                                        <property name="halign">3</property>
+                                        <property name="valign">center</property>
                                         <property name="spacing">10</property>
+                                        <property name="vexpand">True</property>
                                         <child>
                                             <object class="GtkToggleButton" id="players1">
                                                 <property name="visible">True</property>
-                                                <property name="label" translatable="yes">1</property>
+                                                <property name="label">1</property>
                                                 <property name="width-request">200</property>
                                                 <property name="height-request">120</property>
                                                 <property name="valign">3</property>
@@ -135,7 +135,35 @@
                                         <child>
                                             <object class="GtkToggleButton" id="players2">
                                                 <property name="visible">True</property>
-                                                <property name="label" translatable="yes">2</property>
+                                                <property name="label">2</property>
+                                                <property name="width-request">200</property>
+                                                <property name="height-request">120</property>
+                                                <property name="valign">3</property>
+                                                <property name="halign">3</property>
+                                                <style><class name="number-box"/></style>
+                                            </object>
+                                            <packing>
+                                                <property name="pack-type">start</property>
+                                            </packing>
+                                        </child>
+                                        <child>
+                                            <object class="GtkToggleButton" id="players3">
+                                                <property name="visible">True</property>
+                                                <property name="label">3</property>
+                                                <property name="width-request">200</property>
+                                                <property name="height-request">120</property>
+                                                <property name="valign">3</property>
+                                                <property name="halign">3</property>
+                                                <style><class name="number-box"/></style>
+                                            </object>
+                                            <packing>
+                                                <property name="pack-type">start</property>
+                                            </packing>
+                                        </child>
+                                        <child>
+                                            <object class="GtkToggleButton" id="players4">
+                                                <property name="visible">True</property>
+                                                <property name="label">4</property>
                                                 <property name="width-request">200</property>
                                                 <property name="height-request">120</property>
                                                 <property name="valign">3</property>
@@ -200,11 +228,10 @@
                                     </packing>
                                 </child>
                                 <child>
-                                    <object class="GtkLabel">
+                                    <object class="GtkBox" id="grids_box">
                                         <property name="visible">True</property>
-                                        <property name="label" translatable="yes">TODO</property>
-                                        <property name="valign">3</property>
-                                        <style><class name="title"/></style>
+                                        <property name="orientation">horizontal</property>
+                                        <property name="homogeneous">True</property>
                                     </object>
                                     <packing>
                                         <property name="pack-type">start</property>
diff --git a/data/org.gnome.nibbles.gschema.xml b/data/org.gnome.nibbles.gschema.xml
index 011d2d2..3d3af8d 100644
--- a/data/org.gnome.nibbles.gschema.xml
+++ b/data/org.gnome.nibbles.gschema.xml
@@ -77,22 +77,22 @@
       <description>Use relative movement (ie. left or right only).</description>
     </key>
     <key name="key-up" type="i">
-      <default>65362</default>
+      <default>119</default>
       <summary>Move up</summary>
       <description>Key to use for motion up.</description>
     </key>
     <key name="key-down" type="i">
-      <default>65364</default>
+      <default>115</default>
       <summary>Move down</summary>
       <description>Key to use for motion down.</description>
     </key>
     <key name="key-left" type="i">
-      <default>65361</default>
+      <default>97</default>
       <summary>Move left</summary>
       <description>Key to use for motion left.</description>
     </key>
     <key name="key-right" type="i">
-      <default>65363</default>
+      <default>100</default>
       <summary>Move right</summary>
       <description>Key to use for motion right.</description>
     </key>
@@ -109,22 +109,22 @@
       <description>Use relative movement (ie. left or right only).</description>
     </key>
     <key name="key-up" type="i">
-      <default>65362</default>
+      <default>116</default>
       <summary>Move up</summary>
       <description>Key to use for motion up.</description>
     </key>
     <key name="key-down" type="i">
-      <default>65364</default>
+      <default>106</default>
       <summary>Move down</summary>
       <description>Key to use for motion down.</description>
     </key>
     <key name="key-left" type="i">
-      <default>65361</default>
+      <default>104</default>
       <summary>Move left</summary>
       <description>Key to use for motion left.</description>
     </key>
     <key name="key-right" type="i">
-      <default>65363</default>
+      <default>107</default>
       <summary>Move right</summary>
       <description>Key to use for motion right.</description>
     </key>
@@ -141,22 +141,22 @@
       <description>Use relative movement (ie. left or right only).</description>
     </key>
     <key name="key-up" type="i">
-      <default>65362</default>
+      <default>56</default>
       <summary>Move up</summary>
       <description>Key to use for motion up.</description>
     </key>
     <key name="key-down" type="i">
-      <default>65364</default>
+      <default>53</default>
       <summary>Move down</summary>
       <description>Key to use for motion down.</description>
     </key>
     <key name="key-left" type="i">
-      <default>65361</default>
+      <default>52</default>
       <summary>Move left</summary>
       <description>Key to use for motion left.</description>
     </key>
     <key name="key-right" type="i">
-      <default>65363</default>
+      <default>54</default>
       <summary>Move right</summary>
       <description>Key to use for motion right.</description>
     </key>
diff --git a/data/pix/Makefile.am b/data/pix/Makefile.am
index 2e02f09..8b7ce32 100644
--- a/data/pix/Makefile.am
+++ b/data/pix/Makefile.am
@@ -34,6 +34,14 @@ SMALL_PIX = \
 SCOREBOARD_PIX = \
        scoreboard-life.svg
 
-dist_pixmap_DATA = ${BONUS_PIX} ${SMALL_PIX} ${SCOREBOARD_PIX}
+CONTROLS_PIX = \
+       arrow.svg \
+       arrow-key.svg
+
+dist_pixmap_DATA = \
+       ${BONUS_PIX} \
+       ${SMALL_PIX} \
+       ${SCOREBOARD_PIX} \
+       ${CONTROLS_PIX}
 
 -include $(top_srcdir)/git.mk
diff --git a/data/pix/arrow-key.svg b/data/pix/arrow-key.svg
new file mode 100644
index 0000000..ce67fc1
--- /dev/null
+++ b/data/pix/arrow-key.svg
@@ -0,0 +1,36 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<svg
+   xmlns:dc="http://purl.org/dc/elements/1.1/";
+   xmlns:cc="http://creativecommons.org/ns#";
+   xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#";
+   xmlns:svg="http://www.w3.org/2000/svg";
+   xmlns="http://www.w3.org/2000/svg";
+   version="1.1"
+   height="100.00000mm"
+   width="100.00000mm"
+   id="svg836">
+  <metadata
+     id="metadata10">
+    <rdf:RDF>
+      <cc:Work
+         rdf:about="">
+        <dc:format>image/svg+xml</dc:format>
+        <dc:type
+           rdf:resource="http://purl.org/dc/dcmitype/StillImage"; />
+        <dc:title></dc:title>
+        <dc:title></dc:title>
+      </cc:Work>
+    </rdf:RDF>
+  </metadata>
+  <defs
+     id="defs838" />
+  <text
+     xml:space="preserve"
+     
style="font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;font-size:264.02740479px;line-height:125%;font-family:'Open
 Sans';-inkscape-font-specification:'Open Sans 
Bold';text-align:center;letter-spacing:0px;word-spacing:0px;text-anchor:middle;fill:#e5e5e5;fill-opacity:1;stroke:none"
+     x="179.54773"
+     y="250.86105"
+     id="text13643"><tspan
+       id="tspan13645"
+       x="179.54773"
+       y="250.86105">↑</tspan></text>
+</svg>
diff --git a/data/pix/arrow.svg b/data/pix/arrow.svg
new file mode 100644
index 0000000..cbee402
--- /dev/null
+++ b/data/pix/arrow.svg
@@ -0,0 +1,36 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<svg
+   xmlns:dc="http://purl.org/dc/elements/1.1/";
+   xmlns:cc="http://creativecommons.org/ns#";
+   xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#";
+   xmlns:svg="http://www.w3.org/2000/svg";
+   xmlns="http://www.w3.org/2000/svg";
+   version="1.1"
+   height="100.00000mm"
+   width="100.00000mm"
+   id="svg836">
+  <metadata
+     id="metadata10">
+    <rdf:RDF>
+      <cc:Work
+         rdf:about="">
+        <dc:format>image/svg+xml</dc:format>
+        <dc:type
+           rdf:resource="http://purl.org/dc/dcmitype/StillImage"; />
+        <dc:title></dc:title>
+        <dc:title></dc:title>
+      </cc:Work>
+    </rdf:RDF>
+  </metadata>
+  <defs
+     id="defs838" />
+  <path
+     
style="fill:#ffffff;stroke:#4a90d9;stroke-width:18.81783104;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
+     d="m 180.12079,241.14357 0,-140.57851"
+     id="path13667" />
+  <path
+     
style="color:#000000;clip-rule:nonzero;display:inline;overflow:visible;visibility:visible;opacity:1;isolation:auto;mix-blend-mode:normal;color-interpolation:sRGB;color-interpolation-filters:linearRGB;solid-color:#000000;solid-opacity:1;fill:#4a90d9;fill-opacity:1;fill-rule:nonzero;stroke:#4a90d9;stroke-width:1.81623495;stroke-linecap:square;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;marker:none;color-rendering:auto;image-rendering:auto;shape-rendering:auto;text-rendering:auto;enable-background:accumulate"
+     id="path13669"
+     d="m -1352.9978,-483.29435 -8.5363,0 -8.5362,0 4.2681,-7.39259 4.2681,-7.39259 4.2682,7.39259 z"
+     transform="matrix(5.6177215,0,0,4.7772168,7828.8386,2437.8429)" />
+</svg>
diff --git a/src/gnome-nibbles.gresource.xml.in b/src/gnome-nibbles.gresource.xml.in
index b1819c0..3ea56cd 100644
--- a/src/gnome-nibbles.gresource.xml.in
+++ b/src/gnome-nibbles.gresource.xml.in
@@ -5,6 +5,7 @@
     <file alias="nibbles.css">@top_srcdir@/data/nibbles.css</file>
     <file alias="scoreboard.ui">@top_srcdir@/data/scoreboard.ui</file>
     <file alias="player-score-box.ui">@top_srcdir@/data/player-score-box.ui</file>
+    <file alias="controls-grid.ui">@top_srcdir@/data/controls-grid.ui</file>
   </gresource>
   <gresource prefix="/org/gnome/nibbles/gtk">
     <file alias="menus.ui">@top_srcdir@/data/nibbles-menus.ui</file>
diff --git a/src/gnome-nibbles.vala b/src/gnome-nibbles.vala
index 485ba41..5e03345 100644
--- a/src/gnome-nibbles.vala
+++ b/src/gnome-nibbles.vala
@@ -38,6 +38,12 @@ public class Nibbles : Gtk.Application
     private Gee.LinkedList<Gtk.ToggleButton> number_of_players_buttons;
     private Gtk.Revealer next_button_revealer;
 
+    /* Controls screen grids and pixbufs */
+    private Gtk.Box grids_box;
+    private Gee.LinkedList<ControlsGrid> controls_grids;
+    private Gdk.Pixbuf arrow_pixbuf;
+    private Gdk.Pixbuf arrow_key_pixbuf;
+
     /* Used for handling the game's scores */
     private Games.Scores.Context scores_context;
     private Gee.LinkedList<Games.Scores.Category> scorecats;
@@ -132,7 +138,7 @@ public class Nibbles : Gtk.Application
             number_of_players_buttons.add (button);
         }
         next_button_revealer = (Gtk.Revealer) builder.get_object ("next_button_revealer");
-
+        grids_box = (Gtk.Box) builder.get_object ("grids_box");
         window.set_titlebar (headerbar);
 
         add_window (window);
@@ -157,13 +163,17 @@ public class Nibbles : Gtk.Application
         frame.add (view);
         frame.show ();
 
+        /* Controls screen */
+        controls_grids = new Gee.LinkedList<ControlsGrid> ();
+        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);
+
         /* Check wether to display the first run screen */
         var first_run = settings.get_boolean ("first-run");
         if (first_run)
             show_first_run_screen ();
         else
             show_new_game_screen_cb ();
-            // start_game_cb ();
 
         window.show_all ();
 
@@ -247,8 +257,6 @@ public class Nibbles : Gtk.Application
         settings.set_boolean ("first-run", false);
 
         game.current_level = game.start_level;
-        game.create_worms ();
-        game.load_worm_properties (worm_settings);
 
         view.new_level (game.current_level);
         view.create_name_labels ();
@@ -333,6 +341,20 @@ public class Nibbles : Gtk.Application
             }
         }
 
+        /* Create worms and load properties */
+        game.create_worms ();
+        game.load_worm_properties (worm_settings);
+
+        foreach (var worm in game.worms)
+        {
+            if (worm.is_human)
+            {
+                var grid = new ControlsGrid (worm.id, game.worm_props.get (worm), arrow_pixbuf, 
arrow_key_pixbuf);
+                grids_box.add (grid);
+                controls_grids.add (grid);
+            }
+        }
+
         main_stack.set_visible_child_name ("controls");
     }
 
@@ -638,3 +660,84 @@ public class PlayerScoreBox : Gtk.Box
         }
     }
 }
+
+[GtkTemplate (ui = "/org/gnome/nibbles/ui/controls-grid.ui")]
+public class ControlsGrid : Gtk.Grid
+{
+    [GtkChild]
+    private Gtk.Label name_label;
+    [GtkChild]
+    private Gtk.Image arrow_up;
+    [GtkChild]
+    private Gtk.Image arrow_down;
+    [GtkChild]
+    private Gtk.Image arrow_left;
+    [GtkChild]
+    private Gtk.Image arrow_right;
+    [GtkChild]
+    private Gtk.Overlay move_up;
+    [GtkChild]
+    private Gtk.Label move_up_label;
+    [GtkChild]
+    private Gtk.Overlay move_down;
+    [GtkChild]
+    private Gtk.Label move_down_label;
+    [GtkChild]
+    private Gtk.Overlay move_left;
+    [GtkChild]
+    private Gtk.Label move_left_label;
+    [GtkChild]
+    private Gtk.Overlay move_right;
+    [GtkChild]
+    private Gtk.Label move_right_label;
+
+    public ControlsGrid (int worm_id, WormProperties worm_props, Gdk.Pixbuf arrow, Gdk.Pixbuf arrow_key)
+    {
+        var color = Pango.Color ();
+        color.parse (NibblesView.colorval_name (worm_props.color));
+
+        name_label.set_markup (@"<b><span color=\"$(color.to_string ())\">Player $(worm_id + 1)</span></b>");
+
+        arrow_up.set_from_pixbuf (arrow.rotate_simple (Gdk.PixbufRotation.NONE));
+        arrow_down.set_from_pixbuf (arrow.rotate_simple (Gdk.PixbufRotation.UPSIDEDOWN));
+        arrow_left.set_from_pixbuf (arrow.rotate_simple (Gdk.PixbufRotation.COUNTERCLOCKWISE));
+        arrow_right.set_from_pixbuf (arrow.rotate_simple (Gdk.PixbufRotation.CLOCKWISE));
+
+        string upper_key;
+        upper_key = Gdk.keyval_name (worm_props.up).up ();
+        if (upper_key == "UP")
+        {
+            var rotated_pixbuf = arrow_key.rotate_simple (Gdk.PixbufRotation.NONE);
+            move_up.add_overlay (new Gtk.Image.from_pixbuf (rotated_pixbuf));
+        }
+        else
+            move_up_label.set_markup (@"<b>$(upper_key)</b>");
+
+        upper_key = Gdk.keyval_name (worm_props.down).up ();
+        if (upper_key == "DOWN")
+        {
+            var rotated_pixbuf = arrow_key.rotate_simple (Gdk.PixbufRotation.UPSIDEDOWN);
+            move_down.add_overlay (new Gtk.Image.from_pixbuf (rotated_pixbuf));
+        }
+        else
+            move_down_label.set_markup (@"<b>$(upper_key)</b>");
+
+        upper_key = Gdk.keyval_name (worm_props.left).up ();
+        if (upper_key == "LEFT")
+        {
+            var rotated_pixbuf = arrow_key.rotate_simple (Gdk.PixbufRotation.COUNTERCLOCKWISE);
+            move_left.add_overlay (new Gtk.Image.from_pixbuf (rotated_pixbuf));
+        }
+        else
+            move_left_label.set_markup (@"<b>$(upper_key)</b>");
+
+        upper_key = Gdk.keyval_name (worm_props.right).up ();
+        if (upper_key == "RIGHT")
+        {
+            var rotated_pixbuf = arrow_key.rotate_simple (Gdk.PixbufRotation.CLOCKWISE);
+            move_right.add_overlay (new Gtk.Image.from_pixbuf (rotated_pixbuf));
+        }
+        else
+            move_right_label.set_markup (@"<b>$(upper_key)</b>");
+    }
+}
diff --git a/src/nibbles-game.vala b/src/nibbles-game.vala
index 8adbf98..f61f03e 100644
--- a/src/nibbles-game.vala
+++ b/src/nibbles-game.vala
@@ -42,7 +42,7 @@ public class NibblesGame : Object
     public const int GAMEDELAY = 35;
     public const int BONUSDELAY = 100;
 
-    public const int NUMHUMANS = 2;
+    public const int NUMHUMANS = 4;
     public const int NUMAI = 0;
     public const int NUMWORMS = NUMHUMANS + NUMAI;
 
@@ -175,7 +175,6 @@ public class NibblesGame : Object
     public void create_worms ()
     {
         numworms = numai + numhumans;
-        stderr.printf("[Debug] Numw %d\n", numworms);
         for (int i = 0; i < numworms; i++)
         {
             var worm = new Worm (i);
diff --git a/src/nibbles-view.vala b/src/nibbles-view.vala
index ed10361..8a7c407 100644
--- a/src/nibbles-view.vala
+++ b/src/nibbles-view.vala
@@ -173,7 +173,6 @@ public class NibblesView : GtkClutter.Embed
     public Gdk.Pixbuf load_pixmap_file (string pixmap, int xsize, int ysize)
     {
         var filename = Path.build_filename (PKGDATADIR, "pixmaps", pixmap, null);
-
         if (filename == null)
         {
             /* Fatal console error when the game's data files are missing. */
@@ -189,6 +188,7 @@ public class NibblesView : GtkClutter.Embed
         {
             warning ("Failed to load pixmap file: %s", e.message);
         }
+
         return image;
     }
 
diff --git a/src/worm.vala b/src/worm.vala
index b5533f7..a11f95c 100644
--- a/src/worm.vala
+++ b/src/worm.vala
@@ -359,8 +359,8 @@ public enum WormDirection
 public struct WormProperties
 {
     int color;
-    uint left;
-    uint right;
     uint up;
     uint down;
+    uint left;
+    uint right;
 }


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