gnome-games r8288 - trunk/same-gnome
- From: rancell svn gnome org
- To: svn-commits-list gnome org
- Subject: gnome-games r8288 - trunk/same-gnome
- Date: Sun, 9 Nov 2008 03:10:10 +0000 (UTC)
Author: rancell
Date: Sun Nov 9 03:10:10 2008
New Revision: 8288
URL: http://svn.gnome.org/viewvc/gnome-games?rev=8288&view=rev
Log:
Only start animation timer when required (Bug #523589)
Modified:
trunk/same-gnome/drawing.c
trunk/same-gnome/drawing.h
trunk/same-gnome/game.c
Modified: trunk/same-gnome/drawing.c
==============================================================================
--- trunk/same-gnome/drawing.c (original)
+++ trunk/same-gnome/drawing.c Sun Nov 9 03:10:10 2008
@@ -62,6 +62,8 @@
gboolean fast_animation = FALSE;
+static gint animation_timer_id = 0;
+
void
pixels_to_logical (gint px, gint py, gint * lx, gint * ly)
{
@@ -610,6 +612,7 @@
int i, j;
game_cell *p;
gboolean changestatep;
+ gboolean animating = FALSE;
if (!pixmaps_ready)
return TRUE;
@@ -697,6 +700,10 @@
}
break;
}
+
+ if(p->style != ANI_STILL)
+ animating = TRUE;
+
p--;
}
}
@@ -709,6 +716,7 @@
* game_state. However we only want to do these things once, so
* we flag them and check them down here once the loop has finished. */
if (changestatep) {
+ animating = TRUE;
/* FIXME: Is this really the place to change the game state ?
* We do need to signal the end of the animation though so maybe ...
* or maybe we move it over to game.c
@@ -752,7 +760,20 @@
}
}
- return TRUE;
+ if (animating) {
+ return TRUE;
+ } else {
+ animation_timer_id = 0;
+ return FALSE;
+ }
+}
+
+void
+start_animation (void)
+{
+ /* 16 frames/second. */
+ if (animation_timer_id == 0)
+ animation_timer_id = g_timeout_add (62, (GSourceFunc) animation_timer, NULL);
}
void
@@ -781,15 +802,6 @@
gboolean
configure_cb (GtkWidget * canvas, GdkEventConfigure * event)
{
- static gboolean first_run = TRUE;
-
- if (first_run) { /* Start the animation timer if necessary. */
- /* 16 frames/second. */
- g_timeout_add (62, (GSourceFunc) animation_timer, NULL);
-
- first_run = FALSE;
- }
-
canvaswidget = canvas;
drawing_area_width = event->width;
resize_graphics ();
@@ -817,6 +829,8 @@
p->frame = 0;
list++;
}
+
+ start_animation();
}
void
@@ -832,4 +846,6 @@
p->style = ANI_SPINBACK;
list++;
}
+
+ start_animation();
}
Modified: trunk/same-gnome/drawing.h
==============================================================================
--- trunk/same-gnome/drawing.h (original)
+++ trunk/same-gnome/drawing.h Sun Nov 9 03:10:10 2008
@@ -22,6 +22,8 @@
void pixels_to_logical (gint px, gint py, gint * lx, gint * ly);
+void start_animation (void);
+
void start_spinning (void);
void stop_spinning (void);
Modified: trunk/same-gnome/game.c
==============================================================================
--- trunk/same-gnome/game.c (original)
+++ trunk/same-gnome/game.c Sun Nov 9 03:10:10 2008
@@ -284,6 +284,8 @@
/* The end of game check is also not triggered here, we want the balls
* to settle first. It is called from the animation code. */
+
+ start_animation();
}
gint
@@ -312,6 +314,9 @@
}
p--;
}
+
+ if (count)
+ start_animation();
return count;
}
@@ -352,6 +357,8 @@
p->frame = MOVELFRAMESOFS;
p->style = ANI_MOVE_LEFT;
}
+
+ start_animation();
return TRUE;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]