[gnome-games] gnometris: restore the functionality of the other themes



commit a31883bf6fe0c9648ac5c842e7bc84b69b9e8a3f
Author: Jason D. Clinton <me jasonclinton com>
Date:   Thu Aug 27 18:05:35 2009 -0500

    gnometris: restore the functionality of the other themes

 gnometris/blockops.cpp     |    6 ++++--
 gnometris/blockops.h       |    4 ++--
 gnometris/blocks-cache.cpp |    2 ++
 gnometris/preview.cpp      |    6 +++---
 gnometris/renderer.cpp     |    3 ++-
 5 files changed, 13 insertions(+), 8 deletions(-)
---
diff --git a/gnometris/blockops.cpp b/gnometris/blockops.cpp
index e5d641f..d632bf1 100644
--- a/gnometris/blockops.cpp
+++ b/gnometris/blockops.cpp
@@ -82,7 +82,7 @@ BlockOps::BlockOps() :
 	cell_width(0),
 	cell_height(0),
 	cache(NULL),
-	themeID(-1),
+	themeID(0),
 	blocknr(0),
 	rot(0),
 	color(0),
@@ -713,6 +713,8 @@ BlockOps::rescaleField ()
 
 	cairo_t *bg_cr;
 
+	if (!cache)
+		cache = blocks_cache_new ();
 	blocks_cache_set_theme (cache, themeID);
 
 	if (background) {
@@ -889,7 +891,7 @@ BlockOps::hideGameOverMessage()
 }
 
 void
-BlockOps::setTheme (gint id)
+BlockOps::setTheme (guint id)
 {
 	// don't waste time if theme is the same (like from initOptions)
 	if (themeID == id)
diff --git a/gnometris/blockops.h b/gnometris/blockops.h
index 3ce265c..3a8599c 100644
--- a/gnometris/blockops.h
+++ b/gnometris/blockops.h
@@ -56,7 +56,7 @@ public:
 	void hidePauseMessage ();
 	void showGameOverMessage ();
 	void hideGameOverMessage ();
-	void setTheme (gint id);
+	void setTheme (guint id);
 	void drawMessage ();
 
 	GList *destroy_actors;
@@ -105,7 +105,7 @@ private:
 	guint cell_width;
 	guint cell_height;
 	BlocksCache *cache;
-	gint themeID;
+	guint themeID;
 
 	Block **field;
 	Block **backfield;
diff --git a/gnometris/blocks-cache.cpp b/gnometris/blocks-cache.cpp
index 1e58d14..c13fd1a 100644
--- a/gnometris/blocks-cache.cpp
+++ b/gnometris/blocks-cache.cpp
@@ -303,6 +303,7 @@ blocks_cache_get_block_texture_by_id (BlocksCache *cache,
       return COGL_INVALID_HANDLE;
     }
 
+    cairo_scale (cr, 1.0 * 32, 1.0 * 32);
     renderer->drawCell (cr, colour);
     cairo_destroy (cr);
 
@@ -315,6 +316,7 @@ blocks_cache_get_block_texture_by_id (BlocksCache *cache,
                                          cr_surface_data);
     cairo_surface_destroy (cr_surface);
     g_free (cr_surface_data);
+    delete renderer;
 
     if (handle == COGL_INVALID_HANDLE) {
       priv->colours[colour] = FAILED_HANDLE;
diff --git a/gnometris/preview.cpp b/gnometris/preview.cpp
index 83660c2..3d609ed 100644
--- a/gnometris/preview.cpp
+++ b/gnometris/preview.cpp
@@ -91,9 +91,9 @@ Preview::setTheme (guint id)
 {
 	themeID = id;
 
-	if (cache)
-		g_object_unref (cache);
-	cache = blocks_cache_new ();
+	if (!cache)
+		cache = blocks_cache_new ();
+	blocks_cache_set_theme (cache, themeID);
 
 }
 
diff --git a/gnometris/renderer.cpp b/gnometris/renderer.cpp
index e438747..66ff06d 100644
--- a/gnometris/renderer.cpp
+++ b/gnometris/renderer.cpp
@@ -59,8 +59,10 @@ Renderer * rendererFactory (guint id)
 	switch (id) {
 	case 2:
 		r = new TangoBlock (TRUE);
+		break;
 	case 1:
 		r = new TangoBlock (FALSE);
+		break;
 	case 0:
 	default:
 		r = new Renderer ();
@@ -100,7 +102,6 @@ TangoBlock::TangoBlock (gboolean grad) : Renderer ()
 
 void TangoBlock::drawCell (cairo_t *cr, guint color)
 {
-
 	cairo_pattern_t *pat = NULL;
 	/* the following garbage is derived from the official tango style guide */
 	const gdouble colours[8][3][3] = {



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