예제 #1
0
/*
 * return TRUE if the sound is found and the audio is activated
 *        FALSE if the sound was not played
 */
static gboolean _repeat ()
{
  gboolean retval = FALSE;

  gchar *str1 = NULL;
  gchar *right_letter_ogg = NULL;


  GcomprisProperties *properties = gc_prop_get();
  if( !properties->fx )
    return FALSE;

  str1 = gc_sound_alphabet(right_letter);

  right_letter_ogg = g_strdup_printf("voices/$LOCALE/alphabet/%s", str1);
  g_free(str1);

  if(right_letter_ogg) {

    /* Let's check the file exist to be abble to return FALSE */
    gchar *absolute_file = gc_file_find_absolute(right_letter_ogg, NULL);
    if (absolute_file)
      {
	gc_sound_play_ogg_cb(right_letter_ogg, sound_played);
	g_free(absolute_file);
	retval = TRUE;
      }
  }

  g_free(right_letter_ogg);

  return retval;
}
예제 #2
0
static guint sounds_are_fine()
{
  char *letter_str;
  char *str2;
  GcomprisProperties *properties = gc_prop_get();
  gchar *text_mode_str = _("This activity will be played with questions displayed as text"
			   " instead of being spoken");

  if(!properties->fx)
    {
      gchar *msg = g_strconcat( _("Error: this activity cannot be played with the\n"
				  "sound effects disabled.\nGo to the configuration"
				  " dialog to\nenable the sound"),
			       "\n", text_mode_str, NULL);
      gc_dialog(msg, click_on_letter_next_level);
      g_free(msg);
      return(OK_NO_INIT);
    }

  alphabet = get_alphabet();

  gchar *letter = g_new0(gchar, 8);
  g_unichar_to_utf8(g_utf8_get_char(alphabet), letter);
  letter_str = gc_sound_alphabet(letter);
  g_free(letter);

  str2 = gc_file_find_absolute("voices/$LOCALE/alphabet/%s", letter_str);
  g_free(letter_str);

  if (!str2)
    {
      gchar *msg2 = g_strdup_printf( _("Error: this activity requires that you first install\nthe packages with GCompris voices for the %s locale."),
				     gc_locale_get_name( gc_locale_get() ) );
      gchar *msg = g_strconcat(msg2, "\n", text_mode_str, NULL);
      g_free(msg2);
      gc_dialog(msg, click_on_letter_next_level);
      g_free(msg);
      return (OK_NO_INIT);
    }

  return(OK);
}
예제 #3
0
/** Play the audio number given in @number
 */
static void
planegame_speak_number(int number)
{
    /* Play the audio level number */
    gchar *number_str = g_strdup_printf("%d", number);

    if ( number < 10 )
    {
        /* Set the number as unicode */
        gchar *level_str = gc_sound_alphabet(number_str);
        g_free(number_str);
        number_str = level_str;
    }

    gchar *audio_str = g_strdup_printf("voices/$LOCALE/alphabet/%s", number_str);

    gc_sound_play_ogg(audio_str, NULL);

    g_free(number_str);
    g_free(audio_str);
}
예제 #4
0
/** Play the audio number given in @level
 */
void
gc_bar_play_level_voice(int level)
{
  /* Play the audio level number */
  gchar *number_str = g_strdup_printf("%d", level);

  if ( level < 10 )
    {
      /* Set the number as unicode */
      gchar *level_str = gc_sound_alphabet(number_str);
      g_free(number_str);
      number_str = level_str;
    }

  gchar *audio_str = g_strdup_printf("voices/$LOCALE/alphabet/%s", number_str);

  gc_sound_play_ogg("voices/$LOCALE/misc/level.ogg", audio_str, NULL);

  g_free(number_str);
  g_free(audio_str);
}
예제 #5
0
static GooCanvasItem *gletters_create_item(GooCanvasItem *parent)
{
  GooCanvasItem *item;
  gint i,j,k;
  guint x;
  gunichar *lettersItem;
  gchar *str_p, *letter;

  if (!letters_table)
    {
      letters_table = g_hash_table_new_full (g_int_hash, g_int_equal, g_free, destroy_canvas_item);
    }

  /* Beware, since we put the letters in a hash table, we do not allow the same
   * letter to be displayed two times
   */

  g_warning("dump: %d, %s\n",gcomprisBoard->level,letters_array[gcomprisBoard->level-1]);

  k = g_utf8_strlen(letters_array[gcomprisBoard->level-1],-1);

  lettersItem = g_new(gunichar,1);
  gint attempt=0;
  do
    {
      attempt++;
      str_p = letters_array[gcomprisBoard->level-1];
      i = g_random_int_range(0,k);

      for(j = 0; j < i; j++)
	{
	  str_p=g_utf8_next_char(str_p);
	}

      *lettersItem = g_utf8_get_char (str_p);

    } while((attempt<MAX_RAND_ATTEMPTS) && (item_find_by_title(lettersItem)!=NULL));

  if (item_find_by_title(lettersItem)!=NULL)
    {
      g_free(lettersItem);
      return NULL;
    }

  letter = g_new0(gchar, 6);
  g_unichar_to_utf8 ( *lettersItem, letter);

  if (with_sound)
    {
      gchar *str2 = NULL;
      gchar *letter_unichar_name = gc_sound_alphabet(letter);

      str2 = g_strdup_printf("voices/$LOCALE/alphabet/%s", letter_unichar_name);

      gc_sound_play_ogg(str2, NULL);

      g_free(letter_unichar_name);
      g_free(str2);
    }

  item = \
    goo_canvas_group_new (parent,
			  NULL);
  goo_canvas_item_translate(item, 0, -12);

  x = g_random_int_range( 80, BOARDWIDTH-160);
  goo_canvas_text_new (item,
		       letter,
		       x,
		       -20,
		       -1,
		       GTK_ANCHOR_CENTER,
		       "font", gc_skin_font_board_huge_bold,
		       "fill_color_rgba", 0x8c8cFFFF,
		       NULL);
  x -= 2;
  goo_canvas_text_new (item,
		       letter,
		       x,
		       -22,
		       -1,
		       GTK_ANCHOR_CENTER,
		       "font", gc_skin_font_board_huge_bold,
		       "fill_color_rgba", 0x254c87FF,
		       NULL);

  g_object_set_data (G_OBJECT(item), "unichar_key", lettersItem);
  g_object_set_data (G_OBJECT(item), "utf8_key", letter);

  item_list = g_list_append (item_list, item);
  ++actors_count;

  /* Add letter to hash table of all falling letters. */
  g_hash_table_insert (letters_table, lettersItem, item);

  g_free(letter);

  return (item);
}