gnome-games r8658 - trunk/gnometris
- From: jclinton svn gnome org
- To: svn-commits-list gnome org
- Subject: gnome-games r8658 - trunk/gnometris
- Date: Thu, 5 Feb 2009 22:25:02 +0000 (UTC)
Author: jclinton
Date: Thu Feb 5 22:25:01 2009
New Revision: 8658
URL: http://svn.gnome.org/viewvc/gnome-games?rev=8658&view=rev
Log:
This is the rest of the change that was supposed to be introduced
in the previous commit.
Modified:
trunk/gnometris/Makefile.am
trunk/gnometris/blockops.cpp
trunk/gnometris/blockops.h
trunk/gnometris/preview.cpp
trunk/gnometris/preview.h
trunk/gnometris/renderer.h
trunk/gnometris/tetris.cpp
trunk/gnometris/tetris.h
Modified: trunk/gnometris/Makefile.am
==============================================================================
--- trunk/gnometris/Makefile.am (original)
+++ trunk/gnometris/Makefile.am Thu Feb 5 22:25:01 2009
@@ -15,8 +15,6 @@
if HAVE_CLUTTER
gnometris_SOURCES += \
- field.cpp \
- field.h \
preview.cpp \
preview.h \
blockops.cpp \
Modified: trunk/gnometris/blockops.cpp
==============================================================================
--- trunk/gnometris/blockops.cpp (original)
+++ trunk/gnometris/blockops.cpp Thu Feb 5 22:25:01 2009
@@ -22,13 +22,57 @@
#include <config.h>
#include "blockops.h"
#include "blocks.h"
+#include <libgames-support/games-clutter-embed.h>
+
+#define FONT "Sans Bold"
+
+
+Block::Block ():
+ what(EMPTY),
+ actor(NULL)
+{
+}
+
+Block::~Block ()
+{
+ if (actor)
+ clutter_actor_destroy (CLUTTER_ACTOR(actor));
+}
+
+void
+Block::createActor (ClutterActor* chamber, ClutterActor* texture_source)
+{
+ if (actor) {
+ clutter_actor_destroy (CLUTTER_ACTOR(actor));
+ actor = NULL;
+ }
+ actor = clutter_clone_texture_new (CLUTTER_TEXTURE(texture_source));
+ clutter_group_add (CLUTTER_GROUP (chamber), actor);
+}
+
+Block&
+Block::operator= (const Block& b)
+{
+ if (this != &b) {
+ what = b.what;
+ if (actor) {
+ clutter_actor_destroy (CLUTTER_ACTOR(actor));
+ }
+ actor = b.actor;
+ }
+ return *this;
+}
BlockOps::BlockOps() :
+ background(NULL),
+ foreground(NULL),
blocknr (0),
rot (0),
color (0)
{
field = new Block*[COLUMNS];
+ renderer = NULL;
+ themeID = -1;
posx = COLUMNS / 2;
posy = 0;
@@ -36,6 +80,13 @@
for (int i = 0; i < COLUMNS; ++i)
field[i] = new Block[LINES];
+ w = games_clutter_embed_new ();
+
+ g_signal_connect (w, "configure_event", G_CALLBACK (configure), this);
+ g_signal_connect (w, "size_allocate", G_CALLBACK (resize), this);
+
+ gtk_widget_set_size_request (w, COLUMNS*190/LINES, 190);
+
emptyField();
}
@@ -201,11 +252,13 @@
for (int x = 0; x < COLUMNS; ++x)
{
field[x][y] = field[x][y - 1];
-
field[x][y - 1].what = EMPTY;
- field[x][y - 1].color = 0;
+ field[x][y - 1].actor = NULL;
}
}
+ ClutterActor *stage;
+ stage = games_clutter_embed_get_stage (GAMES_CLUTTER_EMBED (w));
+ rescaleBlockPos (stage);
}
int
@@ -272,6 +325,8 @@
void
BlockOps::emptyField(int filled_lines, int fill_prob)
{
+ ClutterActor *stage;
+ stage = games_clutter_embed_get_stage (GAMES_CLUTTER_EMBED (w));
int blank;
for (int y = 0; y < LINES; ++y)
@@ -282,13 +337,18 @@
for (int x = 0; x < COLUMNS; ++x)
{
field[x][y].what = EMPTY;
- field[x][y].color = 0;
+ if (field[x][y].actor) {
+ clutter_actor_destroy (CLUTTER_ACTOR(field[x][y].actor));
+ field[x][y].actor = NULL;
+ }
if ((y>=(LINES - filled_lines)) && (x != blank) &&
((g_random_int_range(0, 10)) < fill_prob)) {
field[x][y].what = LAYING;
- field[x][y].color =
- g_random_int_range(0, NCOLOURS);
+ field[x][y].createActor (stage, renderer->getCacheCellById
+ (g_random_int_range(0, NCOLOURS)));
+ clutter_actor_set_position (CLUTTER_ACTOR(field[x][y].actor),
+ x*(cell_height), y*(cell_height));
}
}
}
@@ -304,20 +364,27 @@
BlockOps::putBlockInField (int bx, int by, int block, int rotation,
SlotType fill)
{
- for (int x = 0; x < 4; ++x)
- {
- for (int y = 0; y < 4; ++y)
- {
- if (blockTable[block][rotation][x][y])
- {
+ ClutterActor *stage;
+ stage = games_clutter_embed_get_stage (GAMES_CLUTTER_EMBED (w));
+
+ for (int x = 0; x < 4; ++x) {
+ for (int y = 0; y < 4; ++y) {
+ if (blockTable[block][rotation][x][y]) {
int i = bx - 2 + x;
int j = y + by;
field[i][j].what = fill;
- if ((fill == FALLING) || (fill == LAYING))
- field[i][j].color = color;
- else
- field[i][j].color = 0;
+ if ((fill == FALLING) || (fill == LAYING)) {
+ field[i][j].createActor (stage, renderer->getCacheCellById
+ (color));
+ clutter_actor_set_position (CLUTTER_ACTOR(field[i][j].actor),
+ i*(cell_height), j*(cell_height));
+ } else {
+ if (field[i][j].actor) {
+ clutter_actor_destroy (CLUTTER_ACTOR(field[i][j].actor));
+ field[i][j].actor = NULL;
+ }
+ }
}
}
}
@@ -345,3 +412,240 @@
return true;
}
+
+gboolean
+BlockOps::configure(GtkWidget *widget, GdkEventConfigure *event, BlockOps *field)
+{
+ return FALSE;
+}
+
+gboolean
+BlockOps::resize(GtkWidget *widget, GdkEventConfigure *event, BlockOps *field)
+{
+ field->width = field->w->allocation.width;
+ field->height = field->w->allocation.height;
+ field->cell_width = field->width/COLUMNS;
+ field->cell_height = field->height/LINES;
+ field->rescaleField();
+ return FALSE;
+}
+
+void
+BlockOps::rescaleBlockPos (ClutterActor* stage)
+{
+ for (int y = 0; y < LINES; ++y) {
+ for (int x = 0; x < COLUMNS; ++x) {
+ if (field[x][y].actor)
+ clutter_actor_set_position (CLUTTER_ACTOR(field[x][y].actor),
+ x*(cell_height), y*(cell_height));
+ }
+ }
+}
+
+void
+BlockOps::rescaleField ()
+{
+ // don't waste our time if GTK+ is just going through allocation
+ if (width < 1 or height < 1)
+ return;
+
+ ClutterActor *stage;
+ stage = games_clutter_embed_get_stage (GAMES_CLUTTER_EMBED (w));
+
+ cairo_t *bg_cr;
+
+ if (renderer)
+ renderer->rescaleCache (cell_width, cell_height);
+ else {
+ renderer = rendererFactory (themeID, cell_width, cell_height);
+ }
+
+ if (background) {
+ clutter_actor_set_size (CLUTTER_ACTOR(background), width, height);
+ clutter_cairo_surface_resize (CLUTTER_CAIRO(background),
+ width, height);
+ } else {
+ background = clutter_cairo_new (width, height);
+ /*FIXME jclinton: eventually allow solid color background
+ * for software rendering case */
+ ClutterColor stage_color = { 0x61, 0x64, 0x8c, 0xff };
+ clutter_stage_set_color (CLUTTER_STAGE (stage),
+ &stage_color);
+ clutter_group_add (CLUTTER_GROUP (stage),
+ background);
+ clutter_actor_set_position (CLUTTER_ACTOR(background),
+ 0, 0);
+ }
+
+ rescaleBlockPos (stage);
+
+ if (foreground) {
+ clutter_actor_set_size (CLUTTER_ACTOR(foreground),
+ width, height);
+ clutter_cairo_surface_resize (CLUTTER_CAIRO(foreground),
+ width, height);
+ } else {
+ foreground = clutter_cairo_new (width, height);
+ clutter_group_add (CLUTTER_GROUP (stage),
+ foreground);
+ clutter_actor_set_position (CLUTTER_ACTOR(foreground),
+ 0, 0);
+ clutter_actor_raise (CLUTTER_ACTOR(foreground),
+ CLUTTER_ACTOR(background));
+ }
+
+
+ bg_cr = clutter_cairo_create (CLUTTER_CAIRO(background));
+ cairo_set_operator (bg_cr, CAIRO_OPERATOR_CLEAR);
+ cairo_paint(bg_cr);
+ cairo_set_operator (bg_cr, CAIRO_OPERATOR_OVER);
+
+ if (useBGImage && backgroundImage) {
+ gdouble xscale, yscale;
+ cairo_matrix_t m;
+
+ /* FIXME: This doesn't handle tiled backgrounds in the obvious way. */
+ gdk_cairo_set_source_pixbuf (bg_cr, backgroundImage, 0, 0);
+ xscale = 1.0*gdk_pixbuf_get_width (backgroundImage)/width;
+ yscale = 1.0*gdk_pixbuf_get_height (backgroundImage)/height;
+ cairo_matrix_init_scale (&m, xscale, yscale);
+ cairo_pattern_set_matrix (cairo_get_source (bg_cr), &m);
+ } else if (backgroundColor)
+ gdk_cairo_set_source_color (bg_cr, backgroundColor);
+ else
+ cairo_set_source_rgb (bg_cr, 0., 0., 0.);
+
+ cairo_paint (bg_cr);
+ cairo_destroy (bg_cr);
+ drawMessage ();
+ clutter_actor_show_all (stage);
+}
+
+void
+BlockOps::drawMessage()
+{
+ PangoLayout *dummy_layout;
+ PangoLayout *layout;
+ PangoFontDescription *desc;
+ int lw, lh;
+ cairo_t *cr;
+ char *msg;
+
+ cr = clutter_cairo_create (CLUTTER_CAIRO(foreground));
+ cairo_set_operator (cr, CAIRO_OPERATOR_CLEAR);
+ cairo_paint(cr);
+ cairo_set_operator (cr, CAIRO_OPERATOR_OVER);
+
+ if (showPause)
+ msg = _("Paused");
+ else if (showGameOver)
+ msg = _("Game Over");
+ else {
+ cairo_destroy (cr);
+ return;
+ }
+
+ // Center coordinates
+ cairo_translate (cr, width / 2, height / 2);
+
+ desc = pango_font_description_from_string(FONT);
+
+ layout = pango_cairo_create_layout (cr);
+ pango_layout_set_text (layout, msg, -1);
+
+ dummy_layout = pango_layout_copy (layout);
+ pango_layout_set_font_description (dummy_layout, desc);
+ pango_layout_get_size (dummy_layout, &lw, &lh);
+ g_object_unref (dummy_layout);
+
+ // desired height : lh = widget width * 0.9 : lw
+ pango_font_description_set_absolute_size (desc, ((float) lh / lw) * PANGO_SCALE * width * 0.8);
+ pango_layout_set_font_description (layout, desc);
+ pango_font_description_free (desc);
+
+ pango_layout_get_size (layout, &lw, &lh);
+ cairo_move_to (cr, -((double)lw / PANGO_SCALE) / 2, -((double)lh / PANGO_SCALE) / 2);
+ pango_cairo_layout_path (cr, layout);
+ cairo_set_source_rgb (cr, 1.0, 1.0, 1.0);
+ cairo_fill_preserve (cr);
+ cairo_set_source_rgb (cr, 0.0, 0.0, 0.0);
+ /* A linewidth of 2 pixels at the default size. */
+ cairo_set_line_width (cr, width/220.0);
+ cairo_stroke (cr);
+
+ g_object_unref(layout);
+ cairo_destroy (cr);
+}
+
+void
+BlockOps::setBackground(GdkPixbuf *bgImage)//, bool tiled)
+{
+ backgroundImage = (GdkPixbuf *) g_object_ref(bgImage);
+ useBGImage = true;
+// backgroundImageTiled = tiled;
+
+ rescaleField ();
+}
+
+void
+BlockOps::setBackground(GdkColor *bgColor)
+{
+ backgroundColor = gdk_color_copy(bgColor);
+ if (backgroundImage) {
+ g_object_unref (backgroundImage);
+ backgroundImage = NULL;
+ }
+ useBGImage = false;
+
+ rescaleField ();
+}
+
+void
+BlockOps::showPauseMessage()
+{
+ showPause = true;
+
+ drawMessage ();
+}
+
+void
+BlockOps::hidePauseMessage()
+{
+ showPause = false;
+
+ drawMessage ();
+}
+
+void
+BlockOps::showGameOverMessage()
+{
+ showGameOver = true;
+
+ drawMessage ();
+}
+
+void
+BlockOps::hideGameOverMessage()
+{
+ showGameOver = false;
+
+ drawMessage ();
+}
+
+void
+BlockOps::setTheme (gint id)
+{
+ // don't waste time if theme is the same (like from initOptions)
+ if (themeID == id)
+ return;
+
+ themeID = id;
+ if (renderer) {
+ delete renderer;
+ renderer = rendererFactory (themeID, cell_width,
+ cell_height);
+ } else {
+ renderer = rendererFactory (themeID, cell_width,
+ cell_height);
+ }
+}
Modified: trunk/gnometris/blockops.h
==============================================================================
--- trunk/gnometris/blockops.h (original)
+++ trunk/gnometris/blockops.h Thu Feb 5 22:25:01 2009
@@ -23,6 +23,9 @@
*/
#include "tetris.h"
+#include "renderer.h"
+
+#include <clutter/clutter.h>
enum SlotType {
EMPTY,
@@ -30,9 +33,18 @@
LAYING
};
-struct Block {
+class Block {
+public:
+ Block ();
+ ~Block ();
+
+ Block& operator=(const Block& b);
+
SlotType what;
- int color;
+ ClutterActor* actor;
+
+ void createActor (ClutterActor* chamber, ClutterActor* texture_source);
+ void associateActor (ClutterActor* chamber, ClutterActor* other_actor);
};
class BlockOps {
@@ -54,21 +66,61 @@
int getLinesToBottom ();
bool isFieldEmpty (void);
+ void setBackground (GdkPixbuf * bgImage); //, bool tiled); fixme: move tiling here.
+ void setBackground (GdkColor * bgColor);
+ void placeBlock (int x, int y, int bcolor, bool remove);
+ void showPauseMessage ();
+ void hidePauseMessage ();
+ void showGameOverMessage ();
+ void hideGameOverMessage ();
+ void setTheme (gint id);
+ void drawMessage ();
+
+ GtkWidget *getWidget () {
+ return w;
+ }
+
private:
void putBlockInField (int bx, int by, int blocknr, int rotation,
SlotType fill);
bool blockOkHere (int x, int y, int b, int r);
void eliminateLine (int l);
-protected:
+ GtkWidget * w;
+
+ ClutterActor *background;
+ ClutterActor *foreground;
+ guint width;
+ guint height;
+ guint cell_width;
+ guint cell_height;
+ Renderer *renderer;
+ gint themeID;
+
Block **field;
int blocknr;
int rot;
int color;
+ bool showPause;
+ bool showGameOver;
+
+ GdkPixbuf *backgroundImage;
+ bool backgroundImageTiled;
+ bool useBGImage;
+ GdkColor *backgroundColor;
+
+ void rescaleField ();
+ void rescaleBlockPos (ClutterActor *stage);
+
int posx;
int posy;
+
+ static gboolean configure (GtkWidget * widget, GdkEventConfigure * event,
+ BlockOps * field);
+ static gboolean resize (GtkWidget * widget, GdkEventConfigure * event,
+ BlockOps * field);
};
#endif //__blockops_h__
Modified: trunk/gnometris/preview.cpp
==============================================================================
--- trunk/gnometris/preview.cpp (original)
+++ trunk/gnometris/preview.cpp Thu Feb 5 22:25:01 2009
@@ -31,19 +31,13 @@
Preview::Preview():
blocknr(-1),
- blockrot(0),
- blockcolor(0),
- enabled(true),
- themeID (0),
- background (0)
+ themeID(-1),
+ renderer(NULL),
+ enabled(true)
{
blocks = new Block*[PREVIEW_WIDTH];
for (int i = 0; i < PREVIEW_WIDTH; i++) {
blocks[i] = new Block [PREVIEW_HEIGHT];
- for (int j = 0; j < PREVIEW_HEIGHT; j++) {
- blocks[i][j].what = EMPTY;
- blocks[i][j].color = 0;
- }
}
w = games_clutter_embed_new();
@@ -55,8 +49,16 @@
* fixed-aspect box. */
gtk_widget_set_size_request (w, PREVIEW_SIZE * 20,
PREVIEW_SIZE * 20);
+ ClutterActor *stage;
+ stage = games_clutter_embed_get_stage (GAMES_CLUTTER_EMBED (w));
- gtk_widget_show (w);
+ ClutterColor stage_color = { 0x61, 0x64, 0x8c, 0xff };
+ clutter_stage_set_color (CLUTTER_STAGE (stage),
+ &stage_color);
+ rotar = clutter_group_new ();
+ clutter_group_add (CLUTTER_GROUP (stage),
+ rotar);
+ clutter_actor_show_all (stage);
}
Preview::~Preview ()
@@ -65,6 +67,7 @@
delete[] blocks[i];
delete[] blocks;
+ delete renderer;
}
void
@@ -74,60 +77,84 @@
}
void
-Preview::setTheme (int id)
+Preview::setTheme (gint id)
{
+ if (themeID == id)
+ return;
+
themeID = id;
+
+ if (renderer) {
+ delete renderer;
+ renderer = rendererFactory (themeID, PREVIEW_SIZE, PREVIEW_SIZE);
+ } else {
+ renderer = rendererFactory (themeID, PREVIEW_SIZE, PREVIEW_SIZE);
+ }
+}
+
+void
+Preview::regenerateRenderer ()
+{
+ if (renderer)
+ renderer->rescaleCache (PREVIEW_SIZE, PREVIEW_SIZE);
+ else {
+ renderer = rendererFactory (themeID, PREVIEW_SIZE, PREVIEW_SIZE);
+ }
}
void
-Preview::previewBlock(int bnr, int brot, int bcolor)
+Preview::previewBlock(gint bnr, gint bcol)
{
+ ClutterActor *stage;
+ stage = games_clutter_embed_get_stage (GAMES_CLUTTER_EMBED (w));
+
int x, y;
blocknr = bnr;
- blockrot = brot;
- blockcolor = bcolor;
+ color = bcol;
for (x = 1; x < PREVIEW_WIDTH - 1; x++) {
for (y = 1; y < PREVIEW_HEIGHT - 1; y++) {
if ((blocknr != -1) &&
- blockTable[blocknr][blockrot][x-1][y-1]) {
+ blockTable[blocknr][0][x-1][y-1]) {
blocks[x][y].what = LAYING;
- blocks[x][y].color = blockcolor;
+ blocks[x][y].createActor (rotar,
+ renderer->getCacheCellById (color));
+ clutter_actor_set_position (CLUTTER_ACTOR(blocks[x][y].actor),
+ x*PREVIEW_SIZE, y*PREVIEW_SIZE);
} else {
blocks[x][y].what = EMPTY;
+ if (blocks[x][y].actor) {
+ clutter_actor_destroy (blocks[x][y].actor);
+ blocks[x][y].actor = NULL;
+ }
}
}
}
+ positionRotar ();
+ clutter_actor_show_all (stage);
+}
+
+void
+Preview::positionRotar()
+{
+ clutter_actor_set_anchor_pointu (CLUTTER_ACTOR(rotar),
+ CLUTTER_UNITS_FROM_PARENT_WIDTH_PERCENTAGE(rotar, 50),
+ CLUTTER_UNITS_FROM_PARENT_HEIGHT_PERCENTAGE(rotar, 50));
+ clutter_actor_set_positionu (CLUTTER_ACTOR(rotar),
+ CLUTTER_UNITS_FROM_STAGE_WIDTH_PERCENTAGE(50),
+ CLUTTER_UNITS_FROM_STAGE_HEIGHT_PERCENTAGE(50));
}
gint
Preview::configure(GtkWidget * widget, GdkEventConfigure * event, Preview * preview)
{
- cairo_t *cr;
-
preview->width = event->width;
preview->height = event->height;
- cr = gdk_cairo_create (widget->window);
-
- if (preview->background)
- cairo_surface_destroy (preview->background);
-
- preview->background =
- cairo_surface_create_similar (cairo_get_target (cr),
- CAIRO_CONTENT_COLOR,
- event->width,
- event->height);
-
- cairo_destroy (cr);
-
- cr = cairo_create (preview->background);
- cairo_set_source_rgb (cr, 0.0, 0.0, 0.0);
- cairo_paint (cr);
- cairo_destroy (cr);
-
+ preview->regenerateRenderer ();
+ preview->positionRotar ();
return TRUE;
}
Modified: trunk/gnometris/preview.h
==============================================================================
--- trunk/gnometris/preview.h (original)
+++ trunk/gnometris/preview.h Thu Feb 5 22:25:01 2009
@@ -27,7 +27,7 @@
#include "renderer.h"
#include "blocks.h"
-#include <clutter-cairo/clutter-cairo.h>
+#include <clutter/clutter.h>
#include <libgames-support/games-clutter-embed.h>
class Preview {
@@ -40,26 +40,27 @@
}
void enable (bool enable);
- void previewBlock (int bnr, int brot, int bcolor);
- void setTheme (int id);
+ void setTheme (gint id);
+ void previewBlock (int bnr, int bcolor);
+ void positionRotar();
+ void regenerateRenderer ();
private:
GtkWidget * w;
gint width;
gint height;
+ gint blocknr;
+ gint color;
+ gint themeID;
- int blocknr;
- int blockrot;
- int blockcolor;
+ Block **blocks;
+ ClutterActor* rotar;
+ Renderer* renderer;
bool enabled;
- int themeID;
- cairo_surface_t *background;
-
static gint configure (GtkWidget * widget, GdkEventConfigure * event,
Preview * preview);
- Block **blocks;
};
#endif //__preview_h__
Modified: trunk/gnometris/renderer.h
==============================================================================
--- trunk/gnometris/renderer.h (original)
+++ trunk/gnometris/renderer.h Thu Feb 5 22:25:01 2009
@@ -29,7 +29,7 @@
#include <clutter-cairo/clutter-cairo.h>
#include "blocks.h"
-#include "blockops.h"
+#include "tetris.h"
struct ThemeTableEntry {
const gchar *name;
Modified: trunk/gnometris/tetris.cpp
==============================================================================
--- trunk/gnometris/tetris.cpp (original)
+++ trunk/gnometris/tetris.cpp Thu Feb 5 22:25:01 2009
@@ -45,7 +45,6 @@
#ifdef HAVE_CLUTTER
#include "preview.h"
-#include "field.h"
#include "renderer.h"
#include "blockops.h"
#else
@@ -189,8 +188,10 @@
games_conf_add_window (GTK_WINDOW (w), KEY_SAVED_GROUP);
preview = new Preview ();
+#ifdef HAVE_CLUTTER
+ field = new BlockOps ();
+#else
field = new Field();
-#ifndef HAVE_CLUTTER
field->setUseTarget (false);
#endif
@@ -263,6 +264,7 @@
gtk_widget_show(vb2);
gtk_widget_show(aspect_frame);
gtk_widget_show(field->getWidget());
+ gtk_widget_show(preview->getWidget());
scoreFrame->show();
gtk_widget_show(w);
@@ -281,6 +283,7 @@
delete field;
delete preview;
delete scoreFrame;
+ delete high_scores;
if (bgimage)
g_object_unref (G_OBJECT (bgimage));
@@ -497,7 +500,9 @@
if (theme_preview) {
theme_preview->setTheme (themeno);
+#ifndef HAVE_CLUTTER
gtk_widget_queue_draw(theme_preview->getWidget());
+#endif
}
}
@@ -805,7 +810,11 @@
t->theme_preview->setTheme (t->themeno);
gtk_box_pack_start(GTK_BOX(fvbox), t->theme_preview->getWidget(), TRUE, TRUE, 0);
+#ifndef HAVE_CLUTTER
t->theme_preview->previewBlock(4, 0, 0);
+#else
+ t->theme_preview->previewBlock(4, 0);
+#endif
gtk_widget_show_all (t->setupdialog);
gtk_action_set_sensitive(t->new_game_action, FALSE);
@@ -1234,8 +1243,12 @@
if (field->generateFallingBlock())
{
field->putBlockInField(false);
+#ifndef HAVE_CLUTTER
preview->previewBlock(blocknr_next, rot_next, color_next);
gtk_widget_queue_draw(preview->getWidget());
+#else
+ preview->previewBlock(blocknr_next, color_next);
+#endif
onePause = true;
}
else
@@ -1259,8 +1272,12 @@
color_next = -1;
blocknr_next = -1;
rot_next = -1;
+#ifndef HAVE_CLUTTER
preview->previewBlock(-1, -1, -1);
gtk_widget_queue_draw(preview->getWidget());
+#else
+ preview->previewBlock(-1, -1);
+#endif
field->hidePauseMessage();
field->showGameOverMessage();
games_sound_play ("gameover");
@@ -1315,9 +1332,12 @@
t->field->generateFallingBlock();
#ifndef HAVE_CLUTTER
t->field->redraw();
-#endif
+
t->preview->previewBlock(blocknr_next, rot_next, color_next);
gtk_widget_queue_draw(t->preview->getWidget());
+#else
+ t->preview->previewBlock(blocknr_next, color_next);
+#endif
gtk_action_set_visible(t->pause_action, TRUE);
gtk_action_set_visible(t->resume_action, FALSE);
Modified: trunk/gnometris/tetris.h
==============================================================================
--- trunk/gnometris/tetris.h (original)
+++ trunk/gnometris/tetris.h Thu Feb 5 22:25:01 2009
@@ -65,7 +65,9 @@
extern bool random_block_colors;
+#ifndef HAVE_CLUTTER
class Field;
+#endif
class Preview;
class BlockOps;
class ScoreFrame;
@@ -93,9 +95,12 @@
char *defaultPixmap;
gint themeno;
+#ifdef HAVE_CLUTTER
+ BlockOps *field;
+#else
Field *field;
+#endif
Preview *preview;
- BlockOps *ops;
ScoreFrame *scoreFrame;
HighScores *high_scores;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]