[gnome-games] Only show the preview block in the correct circumstances



commit ec7d1d26aa2211e248196861be963eaa6e723d20
Author: Craig Duncan <bugzilla duncanc co uk>
Date:   Thu Aug 19 15:32:06 2010 +0100

    Only show the preview block in the correct circumstances
    
    This patch is closely related to 168273 and probably depends on it
    http://bugzilla-attachments.gnome.org/attachment.cgi?id=168273
    
    It stops the preview from being generated when either the preview blocks option is off, or the difficult blocks option is on.
    However the preview still needs to be generated for the theme selection dialog.
    So I've added a force parameter to previewBlock() function for this scenario
    
    https://bugzilla.gnome.org/show_bug.cgi?id=617093

 quadrapassel/preview.cpp |   18 ++++++++++++------
 quadrapassel/preview.h   |    2 +-
 quadrapassel/tetris.cpp  |    8 ++++----
 quadrapassel/tetris.h    |    1 +
 4 files changed, 18 insertions(+), 11 deletions(-)
---
diff --git a/quadrapassel/preview.cpp b/quadrapassel/preview.cpp
index d5f9bdf..3153b6d 100644
--- a/quadrapassel/preview.cpp
+++ b/quadrapassel/preview.cpp
@@ -91,25 +91,31 @@ Preview::setTheme (guint id)
 	if (!cache)
 		cache = blocks_cache_new ();
 	blocks_cache_set_theme (cache, themeID);
-	previewBlock (blocknr, color);
+	previewBlock (blocknr, color, TRUE);
 }
 
 void
-Preview::previewBlock(gint bnr, gint bcol)
+Preview::previewBlock(gint bnr, gint bcol, bool force)
 {
 	ClutterActor *stage;
 	stage = gtk_clutter_embed_get_stage (GTK_CLUTTER_EMBED (w));
 
 	int x, y;
+	bool disable = FALSE;
 
 	blocknr = bnr;
 	color = bcol;
 
+	if(!force && (!do_preview || bastard_mode))
+	{
+		disable = TRUE;
+	}
+
 	for (x = 0; x < PREVIEW_WIDTH; x++) {
 		for (y = 0; y < PREVIEW_HEIGHT; y++) {
-			if ((blocknr != -1) &&
-			    blockTable[blocknr][rot_next][x][y] &&
-			    !bastard_mode) {
+			if (!disable && 
+			    (blocknr != -1) &&
+			    blockTable[blocknr][rot_next][x][y]) {
 				blocks[x][y].emptyCell ();
 				blocks[x][y].what = LAYING;
 				blocks[x][y].createActor (piece,
@@ -142,7 +148,7 @@ Preview::resize(GtkWidget *widget, GtkAllocation *allocation, Preview *p)
 	if (!p->cache)
 		p->cache = blocks_cache_new ();
 	blocks_cache_set_size (p->cache, p->cell_size);
-	p->previewBlock (p->blocknr, p->color);
+	p->previewBlock (p->blocknr, p->color, TRUE);
 	return FALSE;
 }
 
diff --git a/quadrapassel/preview.h b/quadrapassel/preview.h
index 7d553c5..906c09e 100644
--- a/quadrapassel/preview.h
+++ b/quadrapassel/preview.h
@@ -38,7 +38,7 @@ public:
 
 	void enable (bool enable);
 	void setTheme (guint id);
-	void previewBlock (int bnr, int bcolor);
+	void previewBlock (int bnr, int bcolor, bool force);
 
 private:
 	GtkWidget *w;
diff --git a/quadrapassel/tetris.cpp b/quadrapassel/tetris.cpp
index 80d1c87..32e0087 100644
--- a/quadrapassel/tetris.cpp
+++ b/quadrapassel/tetris.cpp
@@ -784,7 +784,7 @@ Tetris::gameProperties(GtkAction *action, void *d)
 	t->theme_preview->setTheme (t->themeno);
 	gtk_box_pack_start(GTK_BOX(fvbox), t->theme_preview->getWidget(), TRUE, TRUE, 0);
 
-	t->theme_preview->previewBlock(4, 0);
+	t->theme_preview->previewBlock(4, 0, TRUE);
 
 	gtk_widget_show_all (t->setupdialog);
 	gtk_action_set_sensitive(t->new_game_action, FALSE);
@@ -1201,7 +1201,7 @@ Tetris::generate()
 	if (field->generateFallingBlock())
 	{
 		field->putBlockInField(FALLING);
-		preview->previewBlock(blocknr_next, color_next);
+		preview->previewBlock(blocknr_next, color_next, FALSE);
 		onePause = true;
 	}
 	else
@@ -1225,7 +1225,7 @@ Tetris::endOfGame()
 	color_next = -1;
 	blocknr_next = -1;
 	rot_next = -1;
-	preview->previewBlock(-1, -1);
+	preview->previewBlock(-1, -1, FALSE);
 	field->hidePauseMessage();
 	field->showGameOverMessage();
 	games_sound_play ("gameover");
@@ -1271,7 +1271,7 @@ Tetris::gameNew(GtkAction *action, void *d)
 
 	t->field->generateFallingBlock();
 	t->field->putBlockInField(FALLING);
-	t->preview->previewBlock(blocknr_next, color_next);
+	t->preview->previewBlock(blocknr_next, color_next, FALSE);
 
 	gtk_action_set_sensitive(t->pause_action, TRUE);
 	gtk_action_set_sensitive(t->end_game_action, TRUE);
diff --git a/quadrapassel/tetris.h b/quadrapassel/tetris.h
index 30f214f..399d1ac 100644
--- a/quadrapassel/tetris.h
+++ b/quadrapassel/tetris.h
@@ -66,6 +66,7 @@ extern int rot_next;
 
 extern bool random_block_colors;
 extern bool bastard_mode;
+extern bool do_preview;
 
 class Preview;
 class BlockOps;



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