[gnome-games] [same-gnome-clutter] Show current/next score in "statusbar"



commit ad96f2648088c7b1490746da9d0da713053cf020
Author: Tim Horton <hortont svn gnome org>
Date:   Sun Jul 19 18:25:42 2009 -0400

    [same-gnome-clutter] Show current/next score in "statusbar"
    
    All strings should match normal same-gnome.

 same-gnome-clutter/data/same-gnome.ui |   26 +++++++++++++++++++++++++-
 same-gnome-clutter/src/About.js       |    2 +-
 same-gnome-clutter/src/Board.js       |   21 ++++++++++++++++-----
 same-gnome-clutter/src/main.js        |    2 ++
 4 files changed, 44 insertions(+), 7 deletions(-)
---
diff --git a/same-gnome-clutter/data/same-gnome.ui b/same-gnome-clutter/data/same-gnome.ui
index c02510d..aed8f58 100644
--- a/same-gnome-clutter/data/same-gnome.ui
+++ b/same-gnome-clutter/data/same-gnome.ui
@@ -130,7 +130,31 @@
 					<object class="GtkClutterEmbed" id="clutter" />
 				</child>
 				<child>
-					<object class="GtkStatusbar" id="statusbar">
+					<object class="GtkHSeparator" id="separator5" />
+				</child>
+				<child>
+					<object class="GtkHBox" id="statusbar">
+						<property name="homogeneous">True</property>
+						<child>
+							<object class="GtkLabel" id="message_label">
+								<property name="visible">True</property>
+								<property name="label"></property>
+							</object>
+							<packing>
+								<property name="expand">True</property>
+								<property name="fill">False</property>
+							</packing>
+						</child>
+						<child>
+							<object class="GtkLabel" id="score_label">
+								<property name="visible">True</property>
+								<property name="label"></property>
+							</object>
+							<packing>
+								<property name="expand">True</property>
+								<property name="fill">False</property>
+							</packing>
+						</child>
 					</object>
 				</child>
 			</object>
diff --git a/same-gnome-clutter/src/About.js b/same-gnome-clutter/src/About.js
index 8773343..36ef6c7 100644
--- a/same-gnome-clutter/src/About.js
+++ b/same-gnome-clutter/src/About.js
@@ -4,7 +4,7 @@ GnomeGamesSupport = imports.gi.GnomeGamesSupport;
 main = imports.main;
 
 // Not sure that this is acceptable; if it is, should it be in a Seed extension?
-var _ = imports.gettext.gettext;
+_ = imports.gettext.gettext;
 
 function show_about_dialog()
 {
diff --git a/same-gnome-clutter/src/Board.js b/same-gnome-clutter/src/Board.js
index de66605..a36c8c0 100644
--- a/same-gnome-clutter/src/Board.js
+++ b/same-gnome-clutter/src/Board.js
@@ -4,6 +4,8 @@ Light = imports.Light;
 Score = imports.Score;
 main = imports.main;
 Settings = imports.Settings;
+gettext = imports.gettext;
+_ = gettext.gettext;
 
 Board = new GType({
 	parent: Clutter.Group.type,
@@ -92,6 +94,8 @@ Board = new GType({
 				cl[i].opacity = 255;
 			
 			oldcl = cl;
+			
+			return cl;
 		}
 		
 		function update_score(tiles)
@@ -106,8 +110,6 @@ Board = new GType({
 			
 			main.current_score += points_awarded;
 			
-			print(main.current_score);
-			
 			if(self.has_completed())
 			{
 				if(self.has_won())
@@ -115,9 +117,9 @@ Board = new GType({
 				
 				final_score = new Score.Score();
 				final_score.animate_final_score(main.current_score);
-				
-				print("Done with: " + main.current_score + " points!");
 			}
+			
+			main.score_label.label = Seed.sprintf(_("Score: %d"), main.current_score);
 		}
 		
 		function light_entered(actor, event)
@@ -127,7 +129,14 @@ Board = new GType({
 			
 			last_light = actor;
 			
-			light_lights_from(actor);
+			var lights_lit = light_lights_from(actor).length;
+			var new_score = calculate_score(lights_lit);
+			var score_string = "No points";
+			
+			if(new_score > 0)
+				score_string = Seed.sprintf(gettext.ngettext("%d point", "%d points", new_score), new_score);
+			
+			main.message_label.label = score_string;
 			
 			return false;
 		}
@@ -140,6 +149,8 @@ Board = new GType({
 				if(!connected[i].get_closed())
 					connected[i].opacity = 180;
 			
+			main.message_label.label = "";
+			
 			return false;
 		}
 		
diff --git a/same-gnome-clutter/src/main.js b/same-gnome-clutter/src/main.js
index e404734..3f1557e 100755
--- a/same-gnome-clutter/src/main.js
+++ b/same-gnome-clutter/src/main.js
@@ -61,6 +61,8 @@ b.connect_signals(handlers);
 
 var window = b.get_object("game_window");
 var clutter_embed = b.get_object("clutter");
+var message_label = b.get_object("message_label");
+var score_label = b.get_object("score_label");
 
 var stage = clutter_embed.get_stage();
 



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