[gnome-games] Removed the stage from GnibblesBoard
- From: Jason Clinton <jclinton src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [gnome-games] Removed the stage from GnibblesBoard
- Date: Wed, 14 Oct 2009 02:52:25 +0000 (UTC)
commit cc958e884202fcbe58806edf9dbb243db25feace
Author: Guillaume Beland <guillaume beland gmail com>
Date: Tue Aug 4 13:59:46 2009 -0400
Removed the stage from GnibblesBoard
gnibbles/board.c | 25 ++++++++-----------------
gnibbles/board.h | 5 ++---
gnibbles/bonus.c | 3 ++-
gnibbles/gnibbles.c | 3 ++-
gnibbles/main.c | 27 ++++++++++++++++++++-------
gnibbles/warp.c | 4 ++--
6 files changed, 36 insertions(+), 31 deletions(-)
---
diff --git a/gnibbles/board.c b/gnibbles/board.c
index 2dba4d5..c41bfb3 100644
--- a/gnibbles/board.c
+++ b/gnibbles/board.c
@@ -46,11 +46,11 @@ extern GnibblesProperties *properties;
extern GnibblesWarpManager *warpmanager;
extern GnibblesBoni *boni;
extern GdkPixbuf *wall_pixmaps[];
+extern ClutterActor *stage;
GnibblesBoard *
-gnibbles_board_new (ClutterActor *stage)
+gnibbles_board_new (void)
{
- ClutterColor stage_color = {0x00,0x00,0x00,0xff};
gchar *filename;
const char *dirname;
GValue val = {0,};
@@ -60,23 +60,13 @@ gnibbles_board_new (ClutterActor *stage)
board->height = BOARDHEIGHT;
board->level = NULL;
board->surface = NULL;
- board->stage = stage;
-
- clutter_stage_set_color (CLUTTER_STAGE(stage), &stage_color);
-
- clutter_stage_set_user_resizable (CLUTTER_STAGE(stage), FALSE);
- clutter_actor_set_size (CLUTTER_ACTOR (stage),
- properties->tilesize * BOARDWIDTH,
- properties->tilesize * BOARDHEIGHT);
- clutter_stage_set_user_resizable (CLUTTER_STAGE (stage), FALSE);
- clutter_actor_show (stage);
dirname = games_runtime_get_directory (GAMES_RUNTIME_GAME_PIXMAP_DIRECTORY);
filename = g_build_filename (dirname, "wall-small-empty.svg", NULL);
board->surface = clutter_texture_new_from_file (filename, NULL);
- clutter_actor_set_opacity (board->surface, 0xff);
+ clutter_actor_set_opacity (CLUTTER_ACTOR (board->surface), 0xff);
g_value_init (&val, G_TYPE_BOOLEAN);
g_value_set_boolean ( &val, TRUE);
@@ -87,8 +77,9 @@ gnibbles_board_new (ClutterActor *stage)
clutter_actor_set_size (CLUTTER_ACTOR (board->surface),
properties->tilesize * BOARDWIDTH,
properties->tilesize * BOARDHEIGHT);
- clutter_container_add_actor (CLUTTER_CONTAINER (stage), board->surface);
- clutter_actor_show (board->surface);
+ clutter_container_add_actor (CLUTTER_CONTAINER (stage),
+ CLUTTER_ACTOR (board->surface));
+ clutter_actor_show (CLUTTER_ACTOR (board->surface));
return board;
}
@@ -167,7 +158,7 @@ gnibbles_board_load_level (GnibblesBoard *board)
}
}
- clutter_container_add_actor (CLUTTER_CONTAINER (board->stage), board->level);
+ clutter_container_add_actor (CLUTTER_CONTAINER (stage), board->level);
clutter_actor_raise (board->level, board->surface);
clutter_actor_set_opacity (board->level, 0);
@@ -191,7 +182,7 @@ gnibbles_board_resize (GnibblesBoard *board, gint newtile)
ClutterActor *tmp;
- clutter_actor_set_size (board->stage,
+ clutter_actor_set_size (stage,
BOARDWIDTH * newtile,
BOARDHEIGHT * newtile);
clutter_actor_set_size (board->surface,
diff --git a/gnibbles/board.h b/gnibbles/board.h
index 3b34f72..aab7b1a 100644
--- a/gnibbles/board.h
+++ b/gnibbles/board.h
@@ -34,11 +34,9 @@
#define EMPTYCHAR 'a'
#define WORMCHAR 'w'
-
typedef struct {
gint width;
gint height;
- ClutterActor *stage;
ClutterActor *surface;
ClutterActor *level;
@@ -46,8 +44,9 @@ typedef struct {
gint current_level;
} GnibblesBoard;
-GnibblesBoard* gnibbles_board_new (ClutterActor *stage);
+GnibblesBoard* gnibbles_board_new (void);
void gnibbles_board_resize (GnibblesBoard *board, gint newtile);
void gnibbles_board_level_new (GnibblesBoard *board, gint level);
void gnibbles_board_level_add_bonus (GnibblesBoard *board, gint regular);
+
#endif
diff --git a/gnibbles/bonus.c b/gnibbles/bonus.c
index 606fe34..4206d15 100644
--- a/gnibbles/bonus.c
+++ b/gnibbles/bonus.c
@@ -36,6 +36,7 @@
extern GdkPixbuf *boni_pixmaps[];
extern GnibblesProperties *properties;
extern GnibblesBoard *board;
+extern ClutterActor *stage;
GnibblesBonus *
gnibbles_bonus_new (gint t_x, gint t_y, gint t_type,
@@ -80,7 +81,7 @@ gnibbles_bonus_draw (GnibblesBonus *bonus)
boni_pixmaps[bonus->type],
NULL);
- clutter_container_add_actor (CLUTTER_CONTAINER (board->stage), bonus->actor);
+ clutter_container_add_actor (CLUTTER_CONTAINER (stage), bonus->actor);
clutter_actor_set_opacity (bonus->actor, 0);
g_signal_connect_after (
diff --git a/gnibbles/gnibbles.c b/gnibbles/gnibbles.c
index c2e3eae..7e1ffb4 100644
--- a/gnibbles/gnibbles.c
+++ b/gnibbles/gnibbles.c
@@ -79,6 +79,7 @@ extern GnibblesProperties *properties;
extern GnibblesScoreboard *scoreboard;
+extern ClutterActor *stage;
static GdkPixbuf *
gnibbles_load_pixmap_file (const gchar * pixmap, gint xsize, gint ysize)
@@ -215,7 +216,7 @@ gnibbles_init ()
for (i = 0; i < properties->numworms; i++) {
if (worms[i]) {
- clutter_container_add_actor (CLUTTER_CONTAINER (board->stage), worms[i]->actors);
+ clutter_container_add_actor (CLUTTER_CONTAINER (stage), worms[i]->actors);
clutter_actor_raise_top (worms[i]->actors);
gnibbles_worm_show (worms[i]);
}
diff --git a/gnibbles/main.c b/gnibbles/main.c
index 681b050..f04f5b7 100644
--- a/gnibbles/main.c
+++ b/gnibbles/main.c
@@ -90,6 +90,7 @@ GnibblesBoard *board;
GnibblesScoreboard *scoreboard;
GtkWidget *clutter_widget;
+ClutterActor *stage;
extern GnibblesWorm *worms[];
extern GnibblesBoni *boni;
@@ -127,7 +128,7 @@ static ClutterActor *logo;
static void
hide_cursor (void)
{
- clutter_stage_hide_cursor (CLUTTER_STAGE (board->stage));
+ clutter_stage_hide_cursor (CLUTTER_STAGE (stage));
}
static void
@@ -182,7 +183,7 @@ window_state_cb (GtkWidget * widget, GdkEventWindowState * event)
static void
show_cursor (void)
{
- clutter_stage_show_cursor (CLUTTER_STAGE (board->stage));
+ clutter_stage_show_cursor (CLUTTER_STAGE (stage));
}
gint
@@ -326,7 +327,7 @@ new_game_2_cb (GtkWidget * widget, gpointer data)
{
if (!paused) {
if (!keyboard_id)
- keyboard_id = g_signal_connect (G_OBJECT (board->stage),
+ keyboard_id = g_signal_connect (G_OBJECT (stage),
"key-press-event",
G_CALLBACK (key_press_cb), NULL);
#ifdef GGZ_CLIENT
@@ -798,11 +799,23 @@ setup_window ()
GtkUIManager *ui_manager;
GtkAccelGroup *accel_group;
+ ClutterColor stage_color = {0x00,0x00,0x00,0xff};
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
clutter_widget = gtk_clutter_embed_new ();
- board = gnibbles_board_new (gtk_clutter_embed_get_stage (
- GTK_CLUTTER_EMBED (clutter_widget)));
+ stage = gtk_clutter_embed_get_stage (GTK_CLUTTER_EMBED (clutter_widget));
+
+ clutter_stage_set_color (CLUTTER_STAGE(stage), &stage_color);
+
+ clutter_stage_set_user_resizable (CLUTTER_STAGE(stage), FALSE);
+ clutter_actor_set_size (CLUTTER_ACTOR (stage),
+ properties->tilesize * BOARDWIDTH,
+ properties->tilesize * BOARDHEIGHT);
+ clutter_stage_set_user_resizable (CLUTTER_STAGE (stage), FALSE);
+ clutter_actor_show (stage);
+
+ board = gnibbles_board_new ();
+
gtk_window_set_title (GTK_WINDOW (window), _("Nibbles"));
gtk_window_set_default_size (GTK_WINDOW (window),
@@ -879,7 +892,7 @@ render_logo (void)
logo = clutter_group_new ();
- clutter_actor_get_size (CLUTTER_ACTOR (board->stage), &width, &height);
+ clutter_actor_get_size (CLUTTER_ACTOR (stage), &width, &height);
if (!logo_pixmap)
gnibbles_load_logo ();
@@ -904,7 +917,7 @@ render_logo (void)
CLUTTER_ACTOR (desc),
NULL);
- clutter_container_add_actor (CLUTTER_CONTAINER (board->stage),
+ clutter_container_add_actor (CLUTTER_CONTAINER (stage),
CLUTTER_ACTOR (logo));
}
diff --git a/gnibbles/warp.c b/gnibbles/warp.c
index bccdd37..578ca4e 100644
--- a/gnibbles/warp.c
+++ b/gnibbles/warp.c
@@ -32,7 +32,7 @@
extern GnibblesProperties *properties;
extern GdkPixbuf *boni_pixmaps[];
extern GnibblesBoard *board;
-
+extern ClutterActor *stage;
GnibblesWarp *
gnibbles_warp_new (gint t_x, gint t_y, gint t_wx, gint t_wy)
{
@@ -58,7 +58,7 @@ gnibbles_warp_draw (GnibblesWarp *warp)
clutter_actor_set_position (CLUTTER_ACTOR (warp->actor),
properties->tilesize * warp->x,
properties->tilesize * warp->y);
- clutter_container_add_actor (CLUTTER_CONTAINER (board->stage), warp->actor);
+ clutter_container_add_actor (CLUTTER_CONTAINER (stage), warp->actor);
clutter_actor_set_opacity (warp->actor, 0);
clutter_actor_animate (warp->actor, CLUTTER_EASE_IN_QUAD, 410,
"opacity", 0xff,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]