gcompris r3309 - in trunk: . src/boards src/gcompris



Author: bcoudoin
Date: Sat Mar 15 22:49:39 2008
New Revision: 3309
URL: http://svn.gnome.org/viewvc/gcompris?rev=3309&view=rev

Log:
	- It is now possible to add activity introduction voices.
	  If provided, it will be played when the activity starts and when
	  it's help is requested.
	  To provide an activity intro, you must put it under:
	  boards/voices/<locale>/activity/<activity name>-intro.ogg

	* src/boards/erase.c: (start_board), (end_board),
	(erase_one_item): moved the audio mode PLAY_AND_INTERRUPT only on
	the last item to avoid an intro voice to be cut.
	* src/gcompris/about.c: (gc_about_start): copyright is 2008 now.
	* src/gcompris/board.c: (gc_board_play): added support to play an
	optional intro voice a the start of an activity
	* src/gcompris/help.c: (gc_board_play): added support to play an
	optional intro voice when the help is lanched.
	* src/gcompris/bonus.c: (gc_bonus_display), (bonus_image):
	cleanup, removed extra warnings.
	* src/gcompris/gcompris.c: (cleanup), (single_instance_release),
	(single_instance_check): fixed the release of the lock when GC is exited.
	* src/gcompris/gameutil.c: (gc_activity_intro_play) created this function



Modified:
   trunk/ChangeLog
   trunk/src/boards/erase.c
   trunk/src/gcompris/about.c
   trunk/src/gcompris/board.c
   trunk/src/gcompris/bonus.c
   trunk/src/gcompris/gameutil.c
   trunk/src/gcompris/gameutil.h
   trunk/src/gcompris/gcompris.c
   trunk/src/gcompris/help.c

Modified: trunk/src/boards/erase.c
==============================================================================
--- trunk/src/boards/erase.c	(original)
+++ trunk/src/boards/erase.c	Sat Mar 15 22:49:39 2008
@@ -27,7 +27,6 @@
 
 static GcomprisBoard *gcomprisBoard = NULL;
 static gboolean board_paused = TRUE;
-static SoundPolicy sound_policy;
 static GdkPixbuf *CoverPixmap[MAX_LAYERS];
 static gulong event_handle_id;
 
@@ -202,10 +201,6 @@
       gamewon = FALSE;
       pause_board(FALSE);
 
-      /* initial state to restore */
-      sound_policy = gc_sound_policy_get();
-      gc_sound_policy_set(PLAY_AND_INTERRUPT);
-
       GdkPixbuf *cursor_pixbuf = gc_pixmap_load("images/sponge.png");
       if(cursor_pixbuf)
 	{
@@ -239,7 +234,6 @@
       erase_destroy_all_items();
     }
   gcomprisBoard = NULL;
-  gc_sound_policy_set(sound_policy);
 }
 
 /* ======================================= */
@@ -449,6 +443,8 @@
 {
   double screen_x, screen_y;
   int x,y;
+  SoundPolicy sound_policy = gc_sound_policy_get();
+
   g_object_get(item, "x", &screen_x, "y", &screen_y, NULL);
   x = screen_x / (BOARDWIDTH/number_of_item_x);
   y = screen_y / (BOARDHEIGHT/number_of_item_y);
@@ -457,17 +453,26 @@
 
   gtk_object_destroy(GTK_OBJECT(item));
 
-  if(number_of_items%2)
-    gc_sound_play_ogg ("sounds/eraser1.wav", NULL);
-  else
-    gc_sound_play_ogg ("sounds/eraser2.wav", NULL);
-
   if(--number_of_items == 0)
     {
       gamewon = TRUE;
       erase_destroy_all_items();
       timer_id = gtk_timeout_add (4000, (GtkFunction) bonus, NULL);
     }
+
+  /* force a cleanup of the sound queue */
+  if(number_of_items == 0)
+      gc_sound_policy_set(PLAY_AND_INTERRUPT);
+
+  if(number_of_items%2)
+    gc_sound_play_ogg ("sounds/eraser1.wav", NULL);
+  else
+    gc_sound_play_ogg ("sounds/eraser2.wav", NULL);
+
+  if(number_of_items == 0)
+    gc_sound_policy_set(sound_policy);
+
+
   normal_delay_id = 0;
   return FALSE;
 }

Modified: trunk/src/gcompris/about.c
==============================================================================
--- trunk/src/gcompris/about.c	(original)
+++ trunk/src/gcompris/about.c	Sat Mar 15 22:49:39 2008
@@ -237,7 +237,7 @@
   // Copyright
   item = gnome_canvas_item_new (GNOME_CANVAS_GROUP(rootitem),
 				gnome_canvas_text_get_type (),
-				"text", "Copyright 2000-2007 Bruno Coudoin and Others",
+				"text", "Copyright 2000-2008 Bruno Coudoin and Others",
 				"font", gc_skin_font_content,
 				"x", (double)  BOARDWIDTH/2,
 				"y", (double)  y - 95,

Modified: trunk/src/gcompris/board.c
==============================================================================
--- trunk/src/gcompris/board.c	(original)
+++ trunk/src/gcompris/board.c	Sat Mar 15 22:49:39 2008
@@ -366,6 +366,8 @@
       bp->start_board(gcomprisBoard);
       bp_data->playing = TRUE;
 
+      gc_activity_intro_play(gcomprisBoard);
+
       return;
     }
 

Modified: trunk/src/gcompris/bonus.c
==============================================================================
--- trunk/src/gcompris/bonus.c	(original)
+++ trunk/src/gcompris/bonus.c	Sat Mar 15 22:49:39 2008
@@ -216,9 +216,7 @@
 
   g_assert(bonus_id < GC_BONUS_LAST);
 
-  g_warning("bar_hide...");
   gc_bar_hide(TRUE);
-  g_warning("bar_hide... ok");
 
   if (bonus_display_running) {
     g_warning("error bonus_display_running !");
@@ -253,9 +251,7 @@
   }
 
   /* First pause the board */
-  g_warning("Pausing board ...");
   gc_board_pause(TRUE);
-  g_warning("Pausing board ...ok");
 
   if(bonus_id==GC_BONUS_RANDOM)
     bonus_id = RAND(1, GC_BONUS_LAST);
@@ -290,14 +286,10 @@
   int x,y;
   GdkPixbuf *pixmap = NULL;
 
-  g_warning("Bonus_image: gc_board_get_current...");
-
   GcomprisBoard *gcomprisBoard = gc_board_get_current();
 
   g_assert(gcomprisBoard);
 
-  g_warning("Bonus_image: gc_board_get_current... ok");
-
   /* check that bonus_group is a singleton */
   if (bonus_group != NULL) {
     bonus_display_running = FALSE;

Modified: trunk/src/gcompris/gameutil.c
==============================================================================
--- trunk/src/gcompris/gameutil.c	(original)
+++ trunk/src/gcompris/gameutil.c	Sat Mar 15 22:49:39 2008
@@ -1,8 +1,6 @@
 /* gcompris - gameutil.c
  *
- * Time-stamp: <2007-08-22 01:21:20 bruno>
- *
- * Copyright (C) 2000-2006 Bruno Coudoin
+ * Copyright (C) 2000, 2008 Bruno Coudoin
  *
  *   This program is free software; you can redistribute it and/or modify
  *   it under the terms of the GNU General Public License as published by
@@ -657,3 +655,21 @@
 
   return(g_mkdir(rootdir, 0755));
 }
+
+
+/** Play the activity intro voice
+ *
+ * \param gcomprisboard
+ *
+ * return void
+ */
+void
+gc_activity_intro_play (GcomprisBoard *gcomprisBoard)
+{
+  gchar *str;
+
+  str = gc_file_find_absolute("voices/$LOCALE/activity/%s-intro.ogg",
+			      gcomprisBoard->name, NULL);
+  gc_sound_play_ogg(str, NULL);
+  g_free(str);
+}

Modified: trunk/src/gcompris/gameutil.h
==============================================================================
--- trunk/src/gcompris/gameutil.h	(original)
+++ trunk/src/gcompris/gameutil.h	Sat Mar 15 22:49:39 2008
@@ -1,8 +1,6 @@
 /* gcompris - gameutil.h
  *
- * Time-stamp: <2007-08-22 01:21:17 bruno>
- *
- * Copyright (C) 2000 Bruno Coudoin
+ * Copyright (C) 2000, 2008 Bruno Coudoin
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -66,4 +64,5 @@
 gchar		 *gc_file_find_absolute(const gchar *filename, ...);
 int               gc_util_create_rootdir (gchar *rootdir);
 
+void		 gc_activity_intro_play (GcomprisBoard *gcomprisBoard);
 #endif

Modified: trunk/src/gcompris/gcompris.c
==============================================================================
--- trunk/src/gcompris/gcompris.c	(original)
+++ trunk/src/gcompris/gcompris.c	Sat Mar 15 22:49:39 2008
@@ -51,7 +51,6 @@
 #define DEFAULT_DATABASE "gcompris_sqlite.db"
 
 /* Multiple instance check */
-static gchar *lock_file;
 #define GC_LOCK_FILE "gcompris.lock"
 #define GC_LOCK_LIMIT 30 /* seconds */
 
@@ -68,6 +67,7 @@
 					    GdkEventKey *event,
 					    gpointer     client_data);
 void gc_terminate(int signum);
+static void single_instance_release();
 
 /*
  * For the Activation dialog
@@ -1050,6 +1050,7 @@
   signal(SIGINT,  NULL);
   signal(SIGSEGV, NULL);
 
+  single_instance_release(); /* Must be done before property destroy */
   gc_board_stop();
   gc_db_exit();
 #ifdef XF86_VIDMODE
@@ -1057,7 +1058,6 @@
 #endif
   gc_menu_destroy();
   gc_prop_destroy(gc_prop_get());
-  g_unlink(lock_file);
 }
 
 void gc_exit()
@@ -1428,9 +1428,18 @@
 
 /* Single instance Check */
 static void
+single_instance_release()
+{
+  gchar *lock_file = g_strdup_printf("%s/%s", properties->config_dir, GC_LOCK_FILE);
+
+  g_unlink(lock_file);
+  g_free(lock_file);
+}
+
+static void
 single_instance_check()
 {
-  lock_file = g_strdup_printf("%s/%s", properties->config_dir, GC_LOCK_FILE);
+  gchar *lock_file = g_strdup_printf("%s/%s", properties->config_dir, GC_LOCK_FILE);
   if(!popt_nolockcheck)
     {
       GTimeVal current_time;

Modified: trunk/src/gcompris/help.c
==============================================================================
--- trunk/src/gcompris/help.c	(original)
+++ trunk/src/gcompris/help.c	Sat Mar 15 22:49:39 2008
@@ -1,8 +1,6 @@
 /* gcompris - help.c
  *
- * Time-stamp: <2007-08-22 01:21:30 bruno>
- *
- * Copyright (C) 2000 Bruno Coudoin
+ * Copyright (C) 2000, 2008 Bruno Coudoin
  *
  *   This program is free software; you can redistribute it and/or modify
  *   it under the terms of the GNU General Public License as published by
@@ -101,6 +99,8 @@
 
   gc_board_pause(TRUE);
 
+  gc_activity_intro_play(gcomprisBoard);
+
   item_selected = NULL;
   item_selected_text = NULL;
 



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