[gnome-games] [same-gnome-clutter] Rough beginnings of high-scores display



commit e62342ac399d955d3c37b46da3a8c158f03cedb1
Author: Tim Horton <hortont svn gnome org>
Date:   Mon Jul 27 20:33:42 2009 -0400

    [same-gnome-clutter] Rough beginnings of high-scores display
    
    There seems to be a problem with libgames-support (probably on our side,
    though), which is preventing me from using GameScoreDialog and friends.

 same-gnome-clutter/src/About.js |    1 -
 same-gnome-clutter/src/Score.js |   36 +++++++++++++++++++++++++++++++++++-
 same-gnome-clutter/src/main.js  |    8 ++++++--
 3 files changed, 41 insertions(+), 4 deletions(-)
---
diff --git a/same-gnome-clutter/src/About.js b/same-gnome-clutter/src/About.js
index 36ef6c7..77fdcbc 100644
--- a/same-gnome-clutter/src/About.js
+++ b/same-gnome-clutter/src/About.js
@@ -3,7 +3,6 @@ GnomeGamesSupport = imports.gi.GnomeGamesSupport;
 
 main = imports.main;
 
-// Not sure that this is acceptable; if it is, should it be in a Seed extension?
 _ = imports.gettext.gettext;
 
 function show_about_dialog()
diff --git a/same-gnome-clutter/src/Score.js b/same-gnome-clutter/src/Score.js
index 22c3147..60e6377 100644
--- a/same-gnome-clutter/src/Score.js
+++ b/same-gnome-clutter/src/Score.js
@@ -1,11 +1,14 @@
+GnomeGamesSupport = imports.gi.GnomeGamesSupport;
 Clutter = imports.gi.Clutter;
 Pango = imports.gi.Pango;
 main = imports.main;
 Settings = imports.Settings;
-_ = imports.gettext.gettext;
+gettext = imports.gettext;
+_ = gettext.gettext;
 
 var current_score = 0;
 var final_score;
+var highscores;
 
 function set_score(score)
 {
@@ -45,6 +48,23 @@ function game_completed(won)
 	final_score.animate_final_score(current_score);
 }
 
+function show_scores_dialog()
+{
+	var highscores_dialog = new GnomeGamesSupport.ScoresDialog();
+	highscores_dialog.parent_window = main.window;
+	highscores_dialog.scores = highscores;
+	highscores_dialog.title = _("Same GNOME Scores");
+	//highscores_dialog.add_category("
+	
+	// TODO: set up high scores categories (for different board sizes)
+	
+	highscores_dialog.set_buttons(GnomeGamesSupport.ScoresButtons.QUIT_BUTTON);
+	
+	highscores_dialog.run();
+	
+	highscores_dialog.hide();
+}
+
 ScoreView = new GType({
 	parent: Clutter.Group.type,
 	name: "Score",
@@ -116,3 +136,17 @@ ScoreView = new GType({
 	}
 });
 
+// Initialize high scores with libgames-support
+
+/*highscores = new GnomeGamesSupport.Scores({app_name: "same-gnome-clutter"});
+
+highscores.add_category("Small", _("Small"));*/
+
+/*cat = new GnomeGamesSupport.ScoresCategory();
+cat.key = "Small";
+cat.name = "Small";
+
+highscores = new GnomeGamesSupport.Scores.c_new("same-gnome", [cat],
+                                                1, "board size", null, 0, 0);
+*/
+//highscores.add_category("Small", _("Small"));
diff --git a/same-gnome-clutter/src/main.js b/same-gnome-clutter/src/main.js
index bf31c2f..58c2c31 100755
--- a/same-gnome-clutter/src/main.js
+++ b/same-gnome-clutter/src/main.js
@@ -1,7 +1,5 @@
 #!/usr/bin/env seed
 
-// Configuration
-
 var tile_size = 50;
 var offset = tile_size/2;
 
@@ -13,6 +11,7 @@ GtkBuilder = imports.gtkbuilder;
 Clutter = imports.gi.Clutter;
 GConf = imports.gi.GConf;
 GnomeGamesSupport = imports.gi.GnomeGamesSupport;
+_ = imports.gettext.gettext;
 
 GtkClutter.init(Seed.argv);
 GnomeGamesSupport.runtime_init("same-gnome");
@@ -38,6 +37,7 @@ handlers = {
 	},
 	show_scores: function(selector, ud)
 	{
+		Score.show_scores_dialog();
 	},
 	show_help: function(selector, ud)
 	{
@@ -108,3 +108,7 @@ board.new_game();
 
 Gtk.main();
 
+// should use GGS conf stuff instead of gconf?
+//GnomeGamesSupport.Conf.get_default().shutdown();
+GnomeGamesSupport.runtime_shutdown();
+



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