seed r589 - trunk/examples/lightsoff



Author: hortont
Date: Wed Dec 31 02:10:13 2008
New Revision: 589
URL: http://svn.gnome.org/viewvc/seed?rev=589&view=rev

Log:
Restructuring and reindenting lightsoff.


Modified:
   trunk/examples/lightsoff/arrow.js
   trunk/examples/lightsoff/board.js
   trunk/examples/lightsoff/light.js
   trunk/examples/lightsoff/menu.js
   trunk/examples/lightsoff/score.js

Modified: trunk/examples/lightsoff/arrow.js
==============================================================================
--- trunk/examples/lightsoff/arrow.js	(original)
+++ trunk/examples/lightsoff/arrow.js	Wed Dec 31 02:10:13 2008
@@ -1,59 +1,54 @@
-function pushed_arrow(actor, event)
-{
-	if(animating_board)
-		return true;
+Arrow = new GType({
+	parent: Clutter.Group.type,
+	name: "Arrow",
+	instance_init: function(klass)
+	{
+		var flipped = 0;
+		
+		this.set_arrow_direction = function (dir)
+		{
+			var bkg;
+			
+			flipped = dir;
+			this.remove_all();
+
+			if(dir)
+				bkg = Clutter.Texture.new_from_file("./arrow-r.svg");
+			else
+				bkg = Clutter.Texture.new_from_file("./arrow-l.svg");
+			
+			bkg.filter_quality = Clutter.TextureQuality.High;
+			
+			this.add_actor(bkg);
+		}
 		
-	// TODO: Need to check that click count is 1
-	var direction = (actor.flipped ? 1 : -1);
+		var toggle_arrow = function (actor, event)
+		{
+			if(animating_board)
+				return true;
 	
-	if(score.value + direction < 1)
-		return true;
+			var direction = (flipped ? 1 : -1);
 	
-	score.set_value(score.value + direction);
-	swap_animation(direction);
-
-	try
-	{
-		gconf_client.set_int("/apps/lightsoff/score", score.value);
-	}
-	catch(e)
-	{
-		Seed.print("Couldn't save score to GConf.");
-	}
+			if(score.value + direction < 1)
+				return true;
 	
-	return true;
-}
-
-ArrowType = {
-    parent: Clutter.Group.type,
-    name: "Arrow",
-    class_init: function(klass, prototype)
-    {
-    	prototype.set_arrow_direction = function (dir)
-    	{
-    		this.flipped = dir;
-    		this.remove_all();
+			score.set_value(score.value + direction);
+			swap_animation(direction);
 
-			if(dir)
+			try
 			{
-    		    var bkg = Clutter.Texture.new_from_file("./arrow-r.svg");
-			    bkg.filter_quality = Clutter.TextureQuality.High;
+				gconf_client.set_int("/apps/lightsoff/score", score.value);
 			}
-			else
+			catch(e)
 			{
-				var bkg = Clutter.Texture.new_from_file("./arrow-l.svg");
-				bkg.filter_quality = Clutter.TextureQuality.High;
+				Seed.print("Couldn't save score to GConf.");
 			}
-			this.add_actor(bkg);
-    	}
-    },
-    instance_init: function(klass)
-    {
-    	this.flipped = 0;
-    	
-		this.reactive = true;
-		this.signal.button_press_event.connect(pushed_arrow);
-    }};
+	
+			return true;
+		}
 
-Arrow = new GType(ArrowType);
+		this.reactive = true;
+		this.signal.button_press_event.connect(toggle_arrow);
+	}
+});
 

Modified: trunk/examples/lightsoff/board.js
==============================================================================
--- trunk/examples/lightsoff/board.js	(original)
+++ trunk/examples/lightsoff/board.js	Wed Dec 31 02:10:13 2008
@@ -146,10 +146,10 @@
 }
 
 BoardType = {
-    parent: Clutter.Group.type,
-    name: "Board",
-    class_init: function(klass, prototype)
-    {
+	parent: Clutter.Group.type,
+	name: "Board",
+	class_init: function(klass, prototype)
+	{
 		prototype.cleared = function ()
 		{
 			for(x in this.lights)
@@ -190,12 +190,12 @@
 
 			in_setup = false;
 		}
-    },
-    instance_init: function(klass)
-    {
-    	animating_board = false;
-    	in_fade = false;
-    	
+	},
+	instance_init: function(klass)
+	{
+		animating_board = false;
+		in_fade = false;
+		
 		this.lights = new Array();
 
 		for(var x = 0; x < tiles; x++)
@@ -213,6 +213,6 @@
 		}
 		
 		this.randomize();
-    }};
+	}};
 
 Board = new GType(BoardType);

Modified: trunk/examples/lightsoff/light.js
==============================================================================
--- trunk/examples/lightsoff/light.js	(original)
+++ trunk/examples/lightsoff/light.js	Wed Dec 31 02:10:13 2008
@@ -10,10 +10,10 @@
 off_svg.filter_quality = Clutter.TextureQuality.High;
 
 LightType = {
-    parent: Clutter.Group.type,
-    name: "Light",
-    class_init: function(klass, prototype)
-    {
+	parent: Clutter.Group.type,
+	name: "Light",
+	class_init: function(klass, prototype)
+	{
 		prototype.flip = function (fadeline)
 		{
 			this.state = !this.state;
@@ -36,15 +36,15 @@
 
 			return true;
 		}
-    },
-    instance_init: function(klass)
-    {
-    	this.state = false;
-    	
-    	this.scale_x = .9;
+	},
+	instance_init: function(klass)
+	{
+		this.state = false;
+		
+		this.scale_x = .9;
 		this.scale_y = .9;
-    	
-    	this.on = new Clutter.CloneTexture({parent_texture: on_svg,
+		
+		this.on = new Clutter.CloneTexture({parent_texture: on_svg,
 											reactive: true});
 		this.off = new Clutter.CloneTexture({parent_texture: off_svg, 
 											 reactive: true});
@@ -62,6 +62,6 @@
 		this.add_actor(this.off);
 		this.add_actor(this.on);
 		
-    }};
+	}};
 
 Light = new GType(LightType);

Modified: trunk/examples/lightsoff/menu.js
==============================================================================
--- trunk/examples/lightsoff/menu.js	(original)
+++ trunk/examples/lightsoff/menu.js	Wed Dec 31 02:10:13 2008
@@ -1,43 +1,43 @@
 function create_board_size_menu()
 {
-    var menu = new Gtk.Menu();
-    
-    var size_5 = new Gtk.MenuItem({"child": new Gtk.Label({"label": "5x5"})});
-    var size_7 = new Gtk.MenuItem({"child": new Gtk.Label({"label": "7x7"})});
-    var size_9 = new Gtk.MenuItem({"child": new Gtk.Label({"label": "9x9"})});
-    
-    menu.append(size_5);
-    menu.append(size_7);
-    menu.append(size_9);
+	var menu = new Gtk.Menu();
+	
+	var size_5 = new Gtk.MenuItem({"child": new Gtk.Label({"label": "5x5"})});
+	var size_7 = new Gtk.MenuItem({"child": new Gtk.Label({"label": "7x7"})});
+	var size_9 = new Gtk.MenuItem({"child": new Gtk.Label({"label": "9x9"})});
+	
+	menu.append(size_5);
+	menu.append(size_7);
+	menu.append(size_9);
 
-    //size_5.signal.activate.connect(change_size, {size: 5});
-    //size_7.signal.activate.connect(change_size, {size: 7});
-    //size_9.signal.activate.connect(change_size, {size: 9});
-    return menu;
+	//size_5.signal.activate.connect(change_size, {size: 5});
+	//size_7.signal.activate.connect(change_size, {size: 7});
+	//size_9.signal.activate.connect(change_size, {size: 9});
+	return menu;
 }
 
 function create_menu()
 {
-    var menu = new Gtk.MenuBar();
-    
-    var game_menu = new Gtk.Menu();
-    var size_item = new Gtk.MenuItem({"child":
-                                      new Gtk.Label({"label": "Board Size"})});
+	var menu = new Gtk.MenuBar();
+	
+	var game_menu = new Gtk.Menu();
+	var size_item = new Gtk.MenuItem({"child":
+									  new Gtk.Label({"label": "Board Size"})});
 
-    size_item.submenu = create_board_size_menu();
-    
-    var quit_item = new Gtk.MenuItem({"child":
-                                      new Gtk.Label({"label": "Quit"})});
-    quit_item.signal.activate.connect(Gtk.main_quit);
-    
-    game_menu.append(size_item);
-    game_menu.append(quit_item);
-    
-    var game_menu_item = new Gtk.MenuItem({"child":
-                                           new Gtk.Label({"label": "Game"})});
-    game_menu_item.submenu = game_menu;
-    
-    menu.append(game_menu_item);
-    
-    return menu;
+	size_item.submenu = create_board_size_menu();
+	
+	var quit_item = new Gtk.MenuItem({"child":
+									  new Gtk.Label({"label": "Quit"})});
+	quit_item.signal.activate.connect(Gtk.main_quit);
+	
+	game_menu.append(size_item);
+	game_menu.append(quit_item);
+	
+	var game_menu_item = new Gtk.MenuItem({"child":
+										   new Gtk.Label({"label": "Game"})});
+	game_menu_item.submenu = game_menu;
+	
+	menu.append(game_menu_item);
+	
+	return menu;
 }

Modified: trunk/examples/lightsoff/score.js
==============================================================================
--- trunk/examples/lightsoff/score.js	(original)
+++ trunk/examples/lightsoff/score.js	Wed Dec 31 02:10:13 2008
@@ -1,9 +1,9 @@
 ScoreType = {
-    parent: Clutter.Group.type,
-    name: "Score",
-    class_init: function(klass, prototype)
-    {
-	   	prototype.set_value = function (val)
+	parent: Clutter.Group.type,
+	name: "Score",
+	class_init: function(klass, prototype)
+	{
+		prototype.set_value = function (val)
 		{
 			this.value = val;
 			
@@ -33,12 +33,12 @@
 			
 			this.bkg_top.raise_top();
 		}
-    },
-    instance_init: function(klass)
-    {
-    	this.current_set = null;
-    	
-    	this.bkg_top = Clutter.Texture.new_from_file("./lcd-front.svg");
+	},
+	instance_init: function(klass)
+	{
+		this.current_set = null;
+		
+		this.bkg_top = Clutter.Texture.new_from_file("./lcd-front.svg");
 		var bkg = Clutter.Texture.new_from_file("./lcd-back.svg");
 		var off_svg = Clutter.Texture.new_from_file("./lcd-off.svg");
 
@@ -76,7 +76,7 @@
 		
 		if(this.value == 0)
 			this.set_value(1);
-    }};
+	}};
 
 Score = new GType(ScoreType);
 



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