gcompris r3310 - in branches/GCOMPRIS_8_3: . src/boards src/gcompris
- From: bcoudoin svn gnome org
- To: svn-commits-list gnome org
- Subject: gcompris r3310 - in branches/GCOMPRIS_8_3: . src/boards src/gcompris
- Date: Sat, 15 Mar 2008 23:08:17 +0000 (GMT)
Author: bcoudoin
Date: Sat Mar 15 23:08:17 2008
New Revision: 3310
URL: http://svn.gnome.org/viewvc/gcompris?rev=3310&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:
branches/GCOMPRIS_8_3/ChangeLog
branches/GCOMPRIS_8_3/src/boards/erase.c
branches/GCOMPRIS_8_3/src/gcompris/about.c
branches/GCOMPRIS_8_3/src/gcompris/board.c
branches/GCOMPRIS_8_3/src/gcompris/bonus.c
branches/GCOMPRIS_8_3/src/gcompris/gameutil.c
branches/GCOMPRIS_8_3/src/gcompris/gameutil.h
branches/GCOMPRIS_8_3/src/gcompris/gcompris.c
branches/GCOMPRIS_8_3/src/gcompris/help.c
Modified: branches/GCOMPRIS_8_3/src/boards/erase.c
==============================================================================
--- branches/GCOMPRIS_8_3/src/boards/erase.c (original)
+++ branches/GCOMPRIS_8_3/src/boards/erase.c Sat Mar 15 23:08:17 2008
@@ -28,7 +28,6 @@
static GcomprisBoard *gcomprisBoard = NULL;
static gboolean board_paused = TRUE;
-static SoundPolicy sound_policy;
static GdkPixbuf *CoverPixmap[MAX_LAYERS];
static gulong event_handle_id;
@@ -203,10 +202,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)
{
@@ -240,7 +235,6 @@
erase_destroy_all_items();
}
gcomprisBoard = NULL;
- gc_sound_policy_set(sound_policy);
}
/* ======================================= */
@@ -450,6 +444,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);
@@ -458,17 +454,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: branches/GCOMPRIS_8_3/src/gcompris/about.c
==============================================================================
--- branches/GCOMPRIS_8_3/src/gcompris/about.c (original)
+++ branches/GCOMPRIS_8_3/src/gcompris/about.c Sat Mar 15 23:08:17 2008
@@ -238,7 +238,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: branches/GCOMPRIS_8_3/src/gcompris/board.c
==============================================================================
--- branches/GCOMPRIS_8_3/src/gcompris/board.c (original)
+++ branches/GCOMPRIS_8_3/src/gcompris/board.c Sat Mar 15 23:08:17 2008
@@ -367,6 +367,8 @@
bp->start_board(gcomprisBoard);
bp_data->playing = TRUE;
+ gc_activity_intro_play(gcomprisBoard);
+
return;
}
Modified: branches/GCOMPRIS_8_3/src/gcompris/bonus.c
==============================================================================
--- branches/GCOMPRIS_8_3/src/gcompris/bonus.c (original)
+++ branches/GCOMPRIS_8_3/src/gcompris/bonus.c Sat Mar 15 23:08:17 2008
@@ -217,9 +217,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 !");
@@ -254,9 +252,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);
@@ -291,14 +287,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: branches/GCOMPRIS_8_3/src/gcompris/gameutil.c
==============================================================================
--- branches/GCOMPRIS_8_3/src/gcompris/gameutil.c (original)
+++ branches/GCOMPRIS_8_3/src/gcompris/gameutil.c Sat Mar 15 23:08:17 2008
@@ -1,8 +1,6 @@
/* gcompris - gameutil.c
*
- * Time-stamp: <2006/08/20 12:41:31 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
@@ -658,3 +656,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("sounds/$LOCALE/activity/%s-intro.ogg",
+ gcomprisBoard->name, NULL);
+ gc_sound_play_ogg(str, NULL);
+ g_free(str);
+}
Modified: branches/GCOMPRIS_8_3/src/gcompris/gameutil.h
==============================================================================
--- branches/GCOMPRIS_8_3/src/gcompris/gameutil.h (original)
+++ branches/GCOMPRIS_8_3/src/gcompris/gameutil.h Sat Mar 15 23:08:17 2008
@@ -1,8 +1,6 @@
/* gcompris - gameutil.h
*
- * Time-stamp: <2000/07/16 00:32:26 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
@@ -67,4 +65,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: branches/GCOMPRIS_8_3/src/gcompris/gcompris.c
==============================================================================
--- branches/GCOMPRIS_8_3/src/gcompris/gcompris.c (original)
+++ branches/GCOMPRIS_8_3/src/gcompris/gcompris.c Sat Mar 15 23:08:17 2008
@@ -52,7 +52,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 */
@@ -69,6 +68,7 @@
GdkEventKey *event,
gpointer client_data);
void gc_terminate(int signum);
+static void single_instance_release();
/*
* For the Activation dialog
@@ -1036,6 +1036,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
@@ -1043,7 +1044,6 @@
#endif
gc_menu_destroy();
gc_prop_destroy(gc_prop_get());
- g_unlink(lock_file);
}
void gc_exit()
@@ -1397,6 +1397,60 @@
#endif
+/* 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()
+{
+ gchar *lock_file = g_strdup_printf("%s/%s", properties->config_dir, GC_LOCK_FILE);
+ if(!popt_nolockcheck)
+ {
+ GTimeVal current_time;
+ g_get_current_time(¤t_time);
+
+ if (g_file_test (lock_file, G_FILE_TEST_EXISTS))
+ {
+ char *result;
+ gsize length;
+ glong seconds;
+ /* Read it's content */
+ g_file_get_contents(lock_file,
+ &result,
+ &length,
+ NULL);
+ sscanf(result, "%ld", &seconds);
+
+ if(current_time.tv_sec - seconds < GC_LOCK_LIMIT)
+ {
+ printf(_("GCompris won't start because the lock file is less than %d seconds old.\n"),
+ GC_LOCK_LIMIT);
+ printf(_("The lock file is: %s\n"),
+ lock_file);
+ exit(0);
+ }
+ }
+
+ {
+ /* Update the date in it (in seconds) */
+ char date_str[64];
+ sprintf(date_str, "%ld", current_time.tv_sec);
+ g_file_set_contents(lock_file,
+ date_str,
+ strlen(date_str),
+ NULL);
+ }
+ }
+ g_free(lock_file);
+}
+
/*****************************************
* Main
*
@@ -1489,40 +1543,7 @@
*/
gc_prop_load(properties, GC_PROP_FROM_SYSTEM_CONF);
- /* Single instance Check */
- lock_file = g_strdup_printf("%s/%s", properties->config_dir, GC_LOCK_FILE);
- if(!popt_nolockcheck)
- {
- GTimeVal current_time;
- g_get_current_time(¤t_time);
-
- if (g_file_test (lock_file, G_FILE_TEST_EXISTS))
- {
- char *result;
- gsize length;
- glong seconds;
- /* Read it's content */
- g_file_get_contents(lock_file,
- &result,
- &length,
- NULL);
- sscanf(result, "%ld", &seconds);
-
- if(current_time.tv_sec - seconds < GC_LOCK_LIMIT)
- exit(0);
- }
-
- {
- /* Update the date in it (in seconds) */
- char date_str[64];
- sprintf(date_str, "%ld", current_time.tv_sec);
- g_file_set_contents(lock_file,
- date_str,
- strlen(date_str),
- NULL);
- }
- }
-
+ single_instance_check();
/* Set the locale */
#if defined WIN32
Modified: branches/GCOMPRIS_8_3/src/gcompris/help.c
==============================================================================
--- branches/GCOMPRIS_8_3/src/gcompris/help.c (original)
+++ branches/GCOMPRIS_8_3/src/gcompris/help.c Sat Mar 15 23:08:17 2008
@@ -1,8 +1,6 @@
/* gcompris - help.c
*
- * Time-stamp: <2006/08/21 23:26: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
@@ -102,6 +100,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]