gnome-games r8282 - trunk/iagno
- From: rancell svn gnome org
- To: svn-commits-list gnome org
- Subject: gnome-games r8282 - trunk/iagno
- Date: Sat, 8 Nov 2008 05:19:51 +0000 (UTC)
Author: rancell
Date: Sat Nov 8 05:19:50 2008
New Revision: 8282
URL: http://svn.gnome.org/viewvc/gnome-games?rev=8282&view=rev
Log:
Only run animation timer during animation (Bug #523589)
Modified:
trunk/iagno/gnothello.c
trunk/iagno/gnothello.h
trunk/iagno/othello.c
trunk/iagno/properties.c
Modified: trunk/iagno/gnothello.c
==============================================================================
--- trunk/iagno/gnothello.c (original)
+++ trunk/iagno/gnothello.c Sat Nov 8 05:19:50 2008
@@ -73,7 +73,8 @@
GdkPixmap *tiles_pixmap = NULL;
GdkPixmap *tiles_mask = NULL;
-gint flip_pixmaps_id = 0;
+static gint flip_pixmaps_id = 0;
+static gint flip_animation_speed = PIXMAP_FLIP_DELAY;
guint statusbar_id;
guint black_computer_level;
guint white_computer_level;
@@ -243,7 +244,7 @@
}
gui_status ();
- tiles_to_flip = 1;
+ start_animation ();
check_computer_players ();
}
@@ -432,14 +433,40 @@
g_free (fname);
}
+void
+set_animation_speed (gint speed)
+{
+ flip_animation_speed = speed;
+ if (flip_pixmaps_id) {
+ g_source_remove (flip_pixmaps_id);
+ flip_pixmaps_id = g_timeout_add (flip_animation_speed, flip_pixmaps, NULL);
+ }
+}
+
+void
+start_animation (void)
+{
+ if (flip_pixmaps_id == 0)
+ flip_pixmaps_id = g_timeout_add (flip_animation_speed, flip_pixmaps, NULL);
+ tiles_to_flip = 1;
+}
+
+void
+stop_animation (void)
+{
+ tiles_to_flip = 0;
+}
+
gint
flip_pixmaps (gpointer data)
{
guint i, j;
guint flipped_tiles = 0;
- if (!tiles_to_flip)
- return TRUE;
+ if (!tiles_to_flip) {
+ flip_pixmaps_id = 0;
+ return FALSE;
+ }
for (i = 0; i < 8; i++)
for (j = 0; j < 8; j++) {
@@ -505,7 +532,7 @@
}
if (!flipped_tiles)
- tiles_to_flip = 0;
+ stop_animation ();
return TRUE;
}
Modified: trunk/iagno/gnothello.h
==============================================================================
--- trunk/iagno/gnothello.h (original)
+++ trunk/iagno/gnothello.h Sat Nov 8 05:19:50 2008
@@ -72,6 +72,9 @@
gint button_press_event (GtkWidget * widget, GdkEventButton * event);
void gui_draw_pixmap (gint which, gint x, gint y);
void gui_draw_pixmap_buffer (gint which, gint x, gint y);
+void set_animation_speed (gint speed);
+void start_animation (void);
+void stop_animation (void);
gint flip_pixmaps (gpointer data);
void init_new_game (void);
void clear_board (void);
Modified: trunk/iagno/othello.c
==============================================================================
--- trunk/iagno/othello.c (original)
+++ trunk/iagno/othello.c Sat Nov 8 05:19:50 2008
@@ -101,8 +101,6 @@
extern gint bcount;
extern gint wcount;
-extern guint tiles_to_flip;
-
/* Initialization of data */
void
init (void)
@@ -275,7 +273,7 @@
gui_status ();
- tiles_to_flip = 1;
+ start_animation ();
check_valid_moves ();
check_computer_players ();
@@ -578,7 +576,7 @@
computer_move (gint level)
{
gint nn, aa, kind, best_xy;
-
+
vsquares[0][0] = -1;
nn = 64 - move_count;
if (nn > BEST)
@@ -646,7 +644,7 @@
guint white_pieces;
guint black_pieces;
guint adder = 0;
-
+
white_pieces = wcount;
black_pieces = bcount;
@@ -676,7 +674,7 @@
}
}
- tiles_to_flip = 1;
+ start_animation ();
return FALSE;
}
Modified: trunk/iagno/properties.c
==============================================================================
--- trunk/iagno/properties.c (original)
+++ trunk/iagno/properties.c Sat Nov 8 05:19:50 2008
@@ -61,7 +61,6 @@
extern gint8 pixmaps[8][8];
extern gint animate;
extern gint animate_stagger;
-extern gint flip_pixmaps_id;
extern gint flip_final;
extern gint grid;
gint sound;
@@ -127,15 +126,14 @@
switch (animate) {
case 0:
- flip_pixmaps_id = g_timeout_add (100, flip_pixmaps, NULL);
+ set_animation_speed (100);
break;
case 1:
- flip_pixmaps_id =
- g_timeout_add (PIXMAP_FLIP_DELAY * 8, flip_pixmaps, NULL);
+ set_animation_speed (PIXMAP_FLIP_DELAY * 8);
break;
default:
case 2:
- flip_pixmaps_id = g_timeout_add (PIXMAP_FLIP_DELAY, flip_pixmaps, NULL);
+ set_animation_speed (PIXMAP_FLIP_DELAY);
break;
}
}
@@ -298,21 +296,16 @@
animate = t_animate;
- if (flip_pixmaps_id) {
- g_source_remove (flip_pixmaps_id);
- flip_pixmaps_id = 0;
- }
-
switch (animate) {
case 0:
- flip_pixmaps_id = g_timeout_add (100, flip_pixmaps, NULL);
+ set_animation_speed (100);
break;
case 1:
- flip_pixmaps_id = g_timeout_add (PIXMAP_FLIP_DELAY * 8,
- flip_pixmaps, NULL);
+ set_animation_speed (PIXMAP_FLIP_DELAY * 8);
break;
+ default:
case 2:
- flip_pixmaps_id = g_timeout_add (PIXMAP_FLIP_DELAY, flip_pixmaps, NULL);
+ set_animation_speed (PIXMAP_FLIP_DELAY);
break;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]