[gnome-games] [lightsoff] Centralize score updating in a more reasonable place
- From: Tim Horton <hortont src gnome org>
- To: svn-commits-list gnome org
- Subject: [gnome-games] [lightsoff] Centralize score updating in a more reasonable place
- Date: Thu, 16 Jul 2009 22:30:11 +0000 (UTC)
commit 9aef6059b7cd591feb593d34b11931145881e3ae
Author: Tim Horton <hortont424 gmail com>
Date: Fri Jun 26 23:01:13 2009 -0400
[lightsoff] Centralize score updating in a more reasonable place
lightsoff/Game.js | 33 +++++++++++++++++++++++----------
lightsoff/LED.js | 10 ----------
lightsoff/Settings.js | 2 +-
3 files changed, 24 insertions(+), 21 deletions(-)
---
diff --git a/lightsoff/Game.js b/lightsoff/Game.js
index 2c419c9..ca2d31d 100644
--- a/lightsoff/Game.js
+++ b/lightsoff/Game.js
@@ -52,7 +52,8 @@ GameView = new GType({
return false;
var direction, sign;
- score_view.set_value(++current_level);
+
+ score_changed(++current_level);
// Make sure the board transition is different than the previous.
do
@@ -90,7 +91,7 @@ GameView = new GType({
return false;
}
- score_view.set_value(current_level);
+ score_changed(current_level);
timeline = new Clutter.Timeline({duration: 500});
@@ -127,16 +128,31 @@ GameView = new GType({
timeline.start();
}
+ var score_changed = function(new_score)
+ {
+ current_level = new_score;
+
+ try
+ {
+ Settings.gconf_client.set_int("/apps/lightsoff/score",
+ current_level);
+ }
+ catch(e)
+ {
+ print("Couldn't save score to GConf.");
+ }
+
+ score_view.set_value(current_level);
+ }
+
// Public
this.reset_game = function ()
{
if(timeline && timeline.is_playing())
return false;
-
- current_level = 1;
- score_view.set_value(current_level);
+ score_changed(1);
timeline = new Clutter.Timeline({duration: 500});
@@ -160,8 +176,8 @@ GameView = new GType({
// TODO: wrong::
- current_level = Settings.score;
- Seed.print(current_level);
+ score_view.set_width(5);
+ score_changed(Settings.score);
// Set up and show the initial board
board_view.signal.game_won.connect(game_won);
@@ -188,9 +204,6 @@ GameView = new GType({
left_arrow.signal.button_release_event.connect(swap_board, {direction: -1});
right_arrow.signal.button_release_event.connect(swap_board, {direction: 1});
- score_view.set_width(5);
- score_view.set_value(current_level);
-
this.set_size(board_view.width, score_view.y + score_view.height);
Settings.Watcher.signal.theme_changed.connect(theme_changed);
diff --git a/lightsoff/LED.js b/lightsoff/LED.js
index 38fa20f..e6e6d0c 100644
--- a/lightsoff/LED.js
+++ b/lightsoff/LED.js
@@ -168,16 +168,6 @@ LEDView = new GType({
digits[i].set_value(Math.floor(d_val % 10));
d_val /= 10;
}
-
- // TODO: this is a /really/ bad place to do this...
- try
- {
- Settings.gconf_client.set_int("/apps/lightsoff/score", value);
- }
- catch(e)
- {
- Seed.print("Couldn't save score to GConf.");
- }
}
this.get_value = function()
diff --git a/lightsoff/Settings.js b/lightsoff/Settings.js
index 12ed578..b83c8e9 100644
--- a/lightsoff/Settings.js
+++ b/lightsoff/Settings.js
@@ -17,7 +17,7 @@ try
}
catch(e)
{
- Seed.print("Couldn't load settings from GConf.");
+ print("Couldn't load settings from GConf.");
theme = imports.themes["tango"].theme;
score = 1;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]