[gnome-games/gsoc-seed-games] [same-gnome-clutter] Size changing works now
- From: Tim Horton <hortont src gnome org>
- To: svn-commits-list gnome org
- Subject: [gnome-games/gsoc-seed-games] [same-gnome-clutter] Size changing works now
- Date: Mon, 13 Jul 2009 01:44:28 +0000 (UTC)
commit 29577f00cf0d2f4c9c1aee5ae1a00213a0080110
Author: Tim Horton <hortont424 gmail com>
Date: Sun Jul 12 21:41:16 2009 -0400
[same-gnome-clutter] Size changing works now
same-gnome-clutter/src/Board.js | 10 +++++-----
same-gnome-clutter/src/Settings.js | 4 ++--
same-gnome-clutter/src/main.js | 27 ++++++++++++++++++++++++---
3 files changed, 31 insertions(+), 10 deletions(-)
---
diff --git a/same-gnome-clutter/src/Board.js b/same-gnome-clutter/src/Board.js
index 2a12f69..29926a9 100644
--- a/same-gnome-clutter/src/Board.js
+++ b/same-gnome-clutter/src/Board.js
@@ -231,7 +231,7 @@ Board = new GType({
li.set_light_y(parseInt(y,10));
var new_x = real_x * main.tile_size + main.offset;
- var new_y = (main.tiles_h - y - 1) * main.tile_size + main.offset;
+ var new_y = (main.size_o.columns - y - 1) * main.tile_size + main.offset;
if(!li.get_closed() && ((new_x != li.x) ||
(new_y != li.y)))
@@ -254,7 +254,7 @@ Board = new GType({
anim_timeline.signal.completed.connect(done_animating);
anim_timeline.start();
- for(; real_x < main.tiles_w; real_x++)
+ for(; real_x < main.size_o.columns; real_x++)
lights[real_x] = null;
update_score(cl.length);
@@ -278,10 +278,10 @@ Board = new GType({
all_lights = [];
- for(var x = 0; x < main.tiles_w; x++)
+ for(var x = 0; x < main.size_o.columns; x++)
{
lights[x] = [];
- for(var y = 0; y < main.tiles_h; y++)
+ for(var y = 0; y < main.size_o.rows; y++)
{
var li = new Light.Light();
@@ -289,7 +289,7 @@ Board = new GType({
li.set_light_y(y);
li.set_position(x * main.tile_size + main.offset,
- (main.tiles_h - y - 1) * main.tile_size + main.offset);
+ (main.size_o.rows - y - 1) * main.tile_size + main.offset);
self.add_actor(li);
li.signal.button_release_event.connect(self.remove_region);
li.signal.enter_event.connect(light_entered);
diff --git a/same-gnome-clutter/src/Settings.js b/same-gnome-clutter/src/Settings.js
index b035a60..4e00b74 100644
--- a/same-gnome-clutter/src/Settings.js
+++ b/same-gnome-clutter/src/Settings.js
@@ -114,7 +114,7 @@ handlers = {
{
new_size = widget.get_active();
- if(new_size == size);
+ if(new_size == size)
return;
size = new_size;
@@ -127,7 +127,7 @@ handlers = {
{
print("Couldn't save settings to GConf.");
}
-
+
Watcher.signal.size_changed.emit();
},
update_colors: function(widget, ud)
diff --git a/same-gnome-clutter/src/main.js b/same-gnome-clutter/src/main.js
index 7c243af..e40b446 100755
--- a/same-gnome-clutter/src/main.js
+++ b/same-gnome-clutter/src/main.js
@@ -54,6 +54,8 @@ handlers = {
}
};
+size_o = Settings.sizes[Settings.size];
+
b = new Gtk.Builder();
b.add_from_file(imports.Path.file_prefix + "/same-gnome.ui");
b.connect_signals(handlers);
@@ -69,8 +71,10 @@ stage.signal.hide.connect(Gtk.main_quit);
stage.set_use_fog(false);
stage.color = {alpha: 0};
-stage.set_size((tiles_w * tile_size),(tiles_h * tile_size));
-clutter_embed.set_size_request((tiles_w * tile_size),(tiles_h * tile_size));
+stage.set_size((size_o.columns * tile_size),
+ (size_o.rows * tile_size));
+clutter_embed.set_size_request((size_o.columns * tile_size),
+ (size_o.rows * tile_size));
// NOTE: show the window before the stage, and the stage before any children
window.show_all();
@@ -78,7 +82,24 @@ stage.show_all();
ThemeLoader.load_theme(stage, Settings.theme);
-//Settings.Watcher.signal.size_changed.connect(size_changed);
+function size_changed()
+{
+ size_o = Settings.sizes[Settings.size];
+
+ stage.set_size((size_o.columns * tile_size),
+ (size_o.rows * tile_size));
+ clutter_embed.set_size_request((size_o.columns * tile_size),
+ (size_o.rows * tile_size));
+
+ var new_board = new Board.Board();
+ new_board.new_game();
+ stage.add_actor(new_board);
+ stage.remove_actor(board);
+ board.show();
+ board = new_board;
+}
+
+Settings.Watcher.signal.size_changed.connect(size_changed);
var board = new Board.Board();
stage.add_actor(board);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]