[gnome-games/gsoc-seed-games] [lightsoff] Implement 'quit' and 'new game'



commit 8411d19a7569bdd49a834861b6a9b5f14013e720
Author: Tim Horton <hortont424 gmail com>
Date:   Fri Jun 26 22:36:14 2009 -0400

    [lightsoff] Implement 'quit' and 'new game'

 lightsoff/Game.js        |   27 +++++++++++++++++++++++++++
 lightsoff/main-window.ui |    9 ++-------
 lightsoff/main.js.in     |    8 ++++++++
 3 files changed, 37 insertions(+), 7 deletions(-)
---
diff --git a/lightsoff/Game.js b/lightsoff/Game.js
index 4f0ad15..2c419c9 100644
--- a/lightsoff/Game.js
+++ b/lightsoff/Game.js
@@ -129,6 +129,33 @@ GameView = new GType({
 		
 		// Public
 		
+		this.reset_game = function ()
+		{
+			if(timeline && timeline.is_playing())
+				return false;
+
+			current_level = 1;
+			
+			score_view.set_value(current_level);
+			
+			timeline = new Clutter.Timeline({duration: 500});
+			
+			create_next_board();
+			
+			new_board_view.depth = 250;
+			new_board_view.opacity = 0;
+			
+			new_board_view.show();
+			
+			new_board_view.swap_in(-1, timeline);
+			board_view.swap_out(-1, timeline);
+			timeline.signal.completed.connect(board_transition_complete);
+			
+			timeline.start();
+			
+			return false;
+		}
+		
 		// Implementation
 		
 		// TODO: wrong::
diff --git a/lightsoff/main-window.ui b/lightsoff/main-window.ui
index 8c0ae28..9e91d40 100644
--- a/lightsoff/main-window.ui
+++ b/lightsoff/main-window.ui
@@ -21,6 +21,7 @@
                     <property name="visible">True</property>
                     <child>
                       <object class="GtkImageMenuItem" id="imagemenuitem11">
+                        <signal name="activate" handler="reset_score"/>
                         <property name="label">games-new-game</property>
                         <property name="visible">True</property>
                         <property name="use_underline">True</property>
@@ -38,6 +39,7 @@
                     </child>
                     <child>
                       <object class="GtkImageMenuItem" id="imagemenuitem15">
+                        <signal name="activate" handler="quit"/>
                         <property name="label">gtk-quit</property>
                         <property name="visible">True</property>
                         <property name="use_underline">True</property>
@@ -49,13 +51,6 @@
               </object>
             </child>
             <child>
-              <object class="GtkMenuItem" id="menuitem7">
-                <property name="visible">True</property>
-                <property name="label" translatable="yes">_View</property>
-                <property name="use_underline">True</property>
-              </object>
-            </child>
-            <child>
               <object class="GtkMenuItem" id="menuitem8">
                 <property name="visible">True</property>
                 <property name="label" translatable="yes">_Help</property>
diff --git a/lightsoff/main.js.in b/lightsoff/main.js.in
index 5684c70..8bd2100 100755
--- a/lightsoff/main.js.in
+++ b/lightsoff/main.js.in
@@ -24,6 +24,14 @@ handlers = {
 	show_about: function(selector, ud)
 	{
 		About.show_about_dialog();
+	},
+	reset_score: function(selector, ud)
+	{
+		game.reset_game();
+	},
+	quit: function(selector, ud)
+	{
+		Gtk.main_quit();
 	}
 };
 



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