[gnome-games/gnibbles-clutter] Added new files to the build and updated main.c



commit 4c3b563c007543793d227b71e7222ad07dd68eb1
Author: Guillaume Beland <guillaubel svn gnome org>
Date:   Wed May 20 21:52:05 2009 -0400

    Added new files to the build and updated main.c
---
 configure.in         |    2 +-
 gnibbles/Makefile.am |   10 ++++
 gnibbles/main.c      |  139 ++++++++++++++++++++++++++++++++++++++++++++++++--
 3 files changed, 146 insertions(+), 5 deletions(-)

diff --git a/configure.in b/configure.in
index fa9d64e..f387983 100644
--- a/configure.in
+++ b/configure.in
@@ -161,7 +161,7 @@ for game in $gamelist; do
     *) ;;
   esac
   case $game in
-    gnometris|lightsoff) need_clutter=yes ;;
+    gnometris|lightsoff|gnibbles) need_clutter=yes ;;
     *) ;;
   esac
 done
diff --git a/gnibbles/Makefile.am b/gnibbles/Makefile.am
index c75def3..b2367bd 100644
--- a/gnibbles/Makefile.am
+++ b/gnibbles/Makefile.am
@@ -24,6 +24,12 @@ gnibbles_SOURCES = \
 	scoreboard.c \
 	main.c \
 	main.h \
+	board.c \
+	board.h \
+	level.c \
+	level.h \
+	worm-clutter.c \
+	worm-clutter.h \
 	$(NULL)
 
 gnibbles_CPPFLAGS = \
@@ -32,11 +38,15 @@ gnibbles_CPPFLAGS = \
 
 gnibbles_CFLAGS = \
 	$(GTK_CFLAGS) \
+	$(CLUTTER_CFLAGS) \
+	$(CLUTTER_GTK_CFLAGS) \
 	$(AM_CFLAGS)
 
 gnibbles_LDADD = \
 	$(top_builddir)/libgames-support/libgames-support.la \
 	$(GTK_LIBS) \
+	$(CLUTTER_LIBS) \
+	$(CLUTTER_GTK_LIBS) \
 	$(INTLLIBS)
 
 if HAVE_GNOME
diff --git a/gnibbles/main.c b/gnibbles/main.c
index f93e767..e550c36 100644
--- a/gnibbles/main.c
+++ b/gnibbles/main.c
@@ -46,6 +46,11 @@
 #include "scoreboard.h"
 #include "warp.h"
 
+#include <clutter-gtk/clutter-gtk.h>
+#include <clutter/clutter.h>
+
+#include "board.h"
+
 #ifdef GGZ_CLIENT
 #include <libgames-support/games-dlg-chat.h>
 #include <libgames-support/games-dlg-players.h>
@@ -105,6 +110,7 @@ NULL};
 
 static gint add_bonus_cb (gpointer data);
 static void render_logo (void);
+static void render_logo_clutter (GnibblesBoard *board);
 static gint end_game_cb (GtkAction * action, gpointer data);
 
 static GtkAction *new_game_action;
@@ -318,7 +324,7 @@ draw_board (void)
 }
 
 static gboolean
-configure_event_cb (GtkWidget * widget, GdkEventConfigure * event)
+configure_event_cb (GtkWidget * widget, GdkEventConfigure * event, gpointer data)
 {
   int tilesize, ts_x, ts_y;
 
@@ -332,6 +338,11 @@ configure_event_cb (GtkWidget * widget, GdkEventConfigure * event)
     ts_y--;
   tilesize = MIN (ts_x, ts_y);
 
+  if (data) {
+    GnibblesBoard *board = (GnibblesBoard *)data;
+    gnibbles_board_resize (board, tilesize);
+  }
+
   /* But, has the tile size changed? */
   if (properties->tilesize == tilesize) {
 
@@ -363,9 +374,12 @@ configure_event_cb (GtkWidget * widget, GdkEventConfigure * event)
 
   if (game_running ())
     draw_board ();
-  else
+  else {
     render_logo ();
-
+    /*if (data && !((GnibblesBoard*)data)->level)
+      render_logo_clutter ((GnibblesBoard*)data);*/
+  }
+  
   return FALSE;
 }
 
@@ -857,6 +871,81 @@ create_menus (GtkUIManager * ui_manager)
 }
 
 static void
+setup_window_clutter (GnibblesBoard *board)
+{
+  GtkWidget *vbox;
+  GtkWidget *main_vbox;
+  GtkWidget *packing;
+  GtkWidget *menubar;
+  GtkUIManager *ui_manager;
+  GtkAccelGroup *accel_group;
+
+  window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
+  gtk_window_set_title (GTK_WINDOW (window), _("Nibbles"));
+
+  gtk_window_set_default_size (GTK_WINDOW (window), DEFAULT_WIDTH, DEFAULT_HEIGHT);
+  games_conf_add_window (GTK_WINDOW (window), KEY_PREFERENCES_GROUP);
+
+  g_signal_connect (G_OBJECT (window), "destroy", G_CALLBACK (gtk_main_quit), NULL);
+  g_signal_connect (G_OBJECT (window), "delete_event",
+		    G_CALLBACK (delete_cb), NULL);
+  g_signal_connect (G_OBJECT (window), "window_state_event",
+		    G_CALLBACK (window_state_cb), NULL);
+
+  gtk_widget_realize (window);
+
+  vbox = gtk_vbox_new (FALSE, 0);
+
+  games_stock_init ();
+  ui_manager = gtk_ui_manager_new ();
+  create_menus (ui_manager);
+  set_fullscreen_actions (FALSE);
+  notebook = gtk_notebook_new ();
+  gtk_notebook_set_show_tabs (GTK_NOTEBOOK (notebook), FALSE);
+
+  accel_group = gtk_ui_manager_get_accel_group (ui_manager);
+  gtk_window_add_accel_group (GTK_WINDOW (window), accel_group);
+
+  menubar = gtk_ui_manager_get_widget (ui_manager, "/MainMenu");
+  gtk_box_pack_start (GTK_BOX (vbox), menubar, FALSE, FALSE, 0);
+
+  packing = games_grid_frame_new (BOARDWIDTH, BOARDHEIGHT);
+  gtk_box_pack_start (GTK_BOX (vbox), packing, TRUE, TRUE, 0);
+  gtk_widget_show (packing);
+
+
+  gtk_container_add (GTK_CONTAINER (packing), board->clutter_widget);
+#ifdef GGZ_CLIENT
+  chat = create_chat_widget ();
+  gtk_box_pack_start (GTK_BOX (vbox), chat, FALSE, TRUE, 0);
+#endif
+
+  g_signal_connect (G_OBJECT (board->clutter_widget), "configure_event",
+		    G_CALLBACK (configure_event_cb), board);
+
+  g_signal_connect (G_OBJECT (window), "focus_out_event",
+		    G_CALLBACK (show_cursor_cb), NULL);
+
+  main_vbox = gtk_vbox_new (FALSE, 0);
+  gtk_box_pack_start (GTK_BOX (main_vbox), notebook, TRUE, TRUE, 0);
+  gtk_notebook_append_page (GTK_NOTEBOOK (notebook), vbox, NULL);
+  gtk_notebook_set_current_page (GTK_NOTEBOOK (notebook), MAIN_PAGE);
+
+  statusbar = gtk_statusbar_new ();
+  gtk_box_pack_start (GTK_BOX (main_vbox), statusbar, FALSE, FALSE, 0);
+
+  gtk_container_add (GTK_CONTAINER (window), main_vbox);
+
+
+  gtk_widget_show_all (window);
+#ifdef GGZ_CLIENT
+  gtk_widget_hide (chat);
+#endif
+
+  scoreboard = gnibbles_scoreboard_new (statusbar);
+}
+
+static void
 setup_window (void)
 {
   GdkPixmap *cursor_dot_pm;
@@ -959,6 +1048,39 @@ setup_window (void)
 
 }
 
+static void 
+render_logo_clutter (GnibblesBoard *board)
+{
+  
+  guint width, height;
+  ClutterActor *logo;
+  ClutterActor *text;
+  ClutterActor *desc;
+  ClutterColor actor_color = {0xff,0xff,0xff,0xff};
+
+  ClutterActor *stage = gnibbles_board_get_stage (board);
+
+  clutter_actor_get_size (CLUTTER_ACTOR (stage), &width, &height);
+  
+  logo = gtk_clutter_texture_new_from_pixbuf (logo_pixmap);
+  clutter_actor_set_size (CLUTTER_ACTOR (logo), width, height);
+  clutter_actor_set_position (CLUTTER_ACTOR (logo), 0, 0);
+  clutter_actor_show (logo);
+
+  text = clutter_text_new_full ("Sans Bold 70", _("Nibbles"), &actor_color);
+  clutter_actor_set_position (CLUTTER_ACTOR (text), (width / 2) - 200, height - 130);
+  clutter_actor_show (text);
+
+  desc = clutter_text_new_full ("Sans Bold 18", _("A worm game for GNOME."), &actor_color);
+  clutter_actor_set_position (CLUTTER_ACTOR (desc), (width / 2) - 170, height - 40);
+  clutter_actor_show (desc);
+
+  clutter_container_add (CLUTTER_CONTAINER (stage), logo, text, desc, NULL);
+  clutter_actor_raise_top (logo);
+  clutter_actor_raise (text, logo);
+  clutter_actor_raise (desc, logo);
+}
+
 static void
 render_logo (void)
 {
@@ -1087,10 +1209,19 @@ main (int argc, char **argv)
   gtk_action_set_visible (new_game_action, !ggz_network_mode);
   gtk_action_set_visible (player_list_action, ggz_network_mode);
 
+
+  // clutter fun
+  gtk_clutter_init (&argc, &argv);
+  GnibblesBoard *board = gnibbles_board_new (BOARDWIDTH, BOARDHEIGHT);
+  setup_window_clutter (board);
+  
+  gnibbles_board_load_level (board, gnibbles_level_new (1));
+
+  //render_logo_clutter (board);
+
   gtk_main ();
 
   gnibbles_properties_destroy (properties);
-
   games_conf_shutdown ();
 
   games_runtime_shutdown ();



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