gcompris r3521 - branches/gcomprixogoo/src/colors-activity
- From: bcoudoin svn gnome org
- To: svn-commits-list gnome org
- Subject: gcompris r3521 - branches/gcomprixogoo/src/colors-activity
- Date: Sun, 31 Aug 2008 21:19:59 +0000 (UTC)
Author: bcoudoin
Date: Sun Aug 31 21:19:59 2008
New Revision: 3521
URL: http://svn.gnome.org/viewvc/gcompris?rev=3521&view=rev
Log:
fixed bonus display
Modified:
branches/gcomprixogoo/src/colors-activity/colors.c
Modified: branches/gcomprixogoo/src/colors-activity/colors.c
==============================================================================
--- branches/gcomprixogoo/src/colors-activity/colors.c (original)
+++ branches/gcomprixogoo/src/colors-activity/colors.c Sun Aug 31 21:19:59 2008
@@ -51,6 +51,7 @@
gpointer data);
static int highlight_width, highlight_height;
static GList * listColors = NULL;
+static gint timer_id = 0;
static SoundPolicy sound_policy;
@@ -202,7 +203,11 @@
if(gcomprisBoard==NULL)
return;
- gc_bar_hide(FALSE);
+ if (timer_id) {
+ gtk_timeout_remove (timer_id);
+ timer_id = 0;
+ }
+
if(gamewon == TRUE && pause == FALSE) /* the game is won */
game_won();
@@ -215,10 +220,6 @@
static void start_board (GcomprisBoard *agcomprisBoard)
{
GcomprisProperties *properties = gc_prop_get();
- GList * list = NULL;
- int * item;
- int i, list_length;
-
GHashTable *config = gc_db_get_board_conf();
gc_locale_set(g_hash_table_lookup(config, "locale_sound"));
@@ -247,18 +248,6 @@
gamewon = FALSE;
- // we generate a list of color indexes in a random order
- for (i=0; i<LAST_COLOR; i++)
- list = g_list_append(list, GINT_TO_POINTER(i));
-
- while ((list_length = g_list_length(list))) {
- i = list_length == 1 ? 0 : g_random_int_range(0,g_list_length(list)-1);
- item = g_list_nth_data(list, i);
- listColors = g_list_append(listColors, item);
- list = g_list_remove(list, item);
- }
- g_list_free(list);
-
g_signal_connect(goo_canvas_get_root_item(gcomprisBoard->canvas),
"button_press_event", (GtkSignalFunc) item_event, NULL);
@@ -317,6 +306,25 @@
* =====================================================================*/
static void colors_next_level()
{
+ if (g_list_length(listColors) == 0)
+ {
+ GList * list = NULL;
+ int * item;
+ int i, list_length;
+
+ // we generate a list of color indexes in a random order
+ for (i=0; i<LAST_COLOR; i++)
+ list = g_list_append(list, GINT_TO_POINTER(i));
+
+ while ((list_length = g_list_length(list))) {
+ i = list_length == 1 ? 0 : g_random_int_range(0,g_list_length(list)-1);
+ item = g_list_nth_data(list, i);
+ listColors = g_list_append(listColors, item);
+ list = g_list_remove(list, item);
+ }
+ g_list_free(list);
+ }
+
colors_destroy_all_items();
gamewon = FALSE;
@@ -361,6 +369,11 @@
* =====================================================================*/
static void colors_destroy_all_items()
{
+ if (timer_id) {
+ gtk_timeout_remove (timer_id);
+ timer_id = 0;
+ }
+
if(boardRootItem!=NULL)
goo_canvas_item_remove(boardRootItem);
@@ -408,13 +421,6 @@
listColors = g_list_remove(listColors, g_list_nth_data(listColors,0));
- if( g_list_length(listColors) <= 0 )
- { // the current board is finished : restart it
- gamewon = TRUE;
- gc_bonus_display(gamewon, GC_BONUS_GNU);
- return;
- }
-
colors_next_level();
}
/* =====================================================================
@@ -422,15 +428,16 @@
* =====================================================================*/
static gboolean process_ok_timeout()
{
+ timer_id = 0;
gc_bonus_display(gamewon, GC_BONUS_GNU);
return FALSE;
}
static void process_ok()
{
- gc_bar_hide(TRUE);
// leave time to display the right answer
- g_timeout_add(TIME_CLICK_TO_BONUS, process_ok_timeout, NULL);
+ timer_id = g_timeout_add(TIME_CLICK_TO_BONUS,
+ process_ok_timeout, NULL);
}
/* =====================================================================
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]