Example #1
0
static void
start_board (GcomprisBoard *agcomprisBoard)
{
  GHashTable *config = gc_db_get_board_conf();

  gc_locale_set(g_hash_table_lookup( config, "locale"));

  gchar *up_init_str = g_hash_table_lookup( config, "uppercase_only");

  if (up_init_str && (strcmp(up_init_str, "True")==0))
    uppercase_only = TRUE;
  else
    uppercase_only = FALSE;

  g_hash_table_destroy(config);

  if(agcomprisBoard!=NULL)
    {
      gcomprisBoard_missing=agcomprisBoard;
      gc_set_background(goo_canvas_get_root_item(gcomprisBoard_missing->canvas),
			"missing_letter/missingletter-bg.jpg");
       _init(agcomprisBoard);
      gc_bar_set(GC_BAR_CONFIG | GC_BAR_LEVEL);
      gc_bar_location(10, -1, 0.9);

      missing_letter_next_level();

      gamewon = FALSE;
      pause_board(FALSE);
    }
}
Example #2
0
static void start_board (GcomprisBoard *agcomprisBoard)
{

  if(agcomprisBoard!=NULL)
    {
      gcomprisBoard=agcomprisBoard;

      GHashTable *config = gc_db_get_board_conf();
      gc_locale_set(g_hash_table_lookup( config, "locale"));

      gchar *up_init_str = g_hash_table_lookup( config, "uppercase_only");
      if (up_init_str && (strcmp(up_init_str, "True")==0))
	uppercase_only = TRUE;
      else
	uppercase_only = FALSE;

      g_hash_table_destroy(config);

      /* disable im_context */
      //gcomprisBoard->disable_im_context = TRUE;

      gc_set_background(goo_canvas_get_root_item(gcomprisBoard->canvas),
			"wordsgame/scenery_background.png");


      gcomprisBoard->level = 1;
      gcomprisBoard->maxlevel = 6;
      gcomprisBoard->sublevel = 0;
      gc_bar_set(GC_BAR_LEVEL|GC_BAR_CONFIG);

      /* Default speed */
      speed=DEFAULT_SPEED;
      fallSpeed=DEFAULT_FALLSPEED;

      gc_wordlist = gc_wordlist_get_from_file("wordsgame/default-$LOCALE.xml");

      if(!gc_wordlist)
	{
	  /* Fallback to english */
	  gc_wordlist = gc_wordlist_get_from_file("wordsgame/default-en.xml");

	  if(!gc_wordlist)
	    {
	      gcomprisBoard = NULL;
	      gc_dialog(_("Error: We can't find\na list of words to play this game.\n"), gc_board_end);
	      return;
	    }
	}
      if(gc_wordlist)
      {
        gcomprisBoard->maxlevel = gc_wordlist->number_of_level;
      }
      wordsgame_next_level();
    }
}
Example #3
0
/* a GcomprisConfCallback
 */
static gboolean conf_ok(GHashTable *table)
{
  if (!table){
    if (gcomprisBoard)
      pause_board(FALSE);
    return TRUE;
  }

  g_hash_table_foreach(table, save_table, NULL);

  if (gcomprisBoard){
    GHashTable *config;

    if (profile_conf)
      config = gc_db_get_board_conf();
    else
      config = table;

    gc_locale_set(g_hash_table_lookup( config, "locale"));

    gchar *up_init_str = g_hash_table_lookup( config, "uppercase_only");

    if (up_init_str && (strcmp(up_init_str, "True")==0))
      uppercase_only = TRUE;
    else
      uppercase_only = FALSE;

    gchar *control_sound = g_hash_table_lookup( config, "with_sound");

    if (control_sound && strcmp(g_hash_table_lookup( config, "with_sound"),"True")==0)
      with_sound = TRUE;
    else
      with_sound = FALSE;

    if (profile_conf)
      g_hash_table_destroy(config);

    load_default_charset();

    level_set_score();
    gletters_next_level();

    pause_board(FALSE);

  }

  board_conf = NULL;
  profile_conf = NULL;
  return TRUE;
}
Example #4
0
static void
start_board (GcomprisBoard *agcomprisBoard)
{
  if(agcomprisBoard!=NULL)
    {
      gcomprisBoard=agcomprisBoard;
      gcomprisBoard->level=1;
      gcomprisBoard->sublevel=1;

      gc_bar_set(GC_BAR_LEVEL|GC_BAR_CONFIG);
      gc_bar_location(-1, -1, 0.7);

      if (strcmp(gcomprisBoard->mode, "count") == 0)
        board_mode = MODE_COUNT;
      else if (strcmp(gcomprisBoard->mode, "weight") == 0)
        board_mode = MODE_WEIGHT;
      else
        board_mode = DEFAULT_MODE;

      gcomprisBoard->maxlevel = (board_mode == MODE_COUNT) ? 4 : 5;
      gcomprisBoard->number_of_sublevel = (board_mode == MODE_COUNT) ? 5 : 3;
      bonus_item = (board_mode == MODE_COUNT) ? GC_BONUS_SMILEY : GC_BONUS_TUX;

      gamewon = FALSE;
      pause_board(FALSE);

      GHashTable *config = gc_db_get_board_conf();
      gchar *drag_mode_str = g_hash_table_lookup( config, "drag_mode");

      if (drag_mode_str && (strcmp (drag_mode_str, "NULL") != 0))
	drag_mode = g_ascii_strtod(drag_mode_str, NULL);
      else
	drag_mode = GC_DRAG_MODE_DEFAULT;

      gc_set_background(goo_canvas_get_root_item(gcomprisBoard->canvas),
			"scale/tabepice.jpg");

      gc_drag_start(goo_canvas_get_root_item(gcomprisBoard->canvas),
		    (GcDragFunc)scale_drag_event, drag_mode);

      gc_score_start(SCORESTYLE_NOTE,
		     BOARDWIDTH - 220,
		     450 ,
		     gcomprisBoard->number_of_sublevel);
      scale_next_level();

    }
}
Example #5
0
static gboolean
conf_ok(GHashTable *table)
{
  if (!table){
    if (gcomprisBoard_missing)
      pause_board(FALSE);
    return TRUE;
  }

  g_hash_table_foreach(table, (GHFunc) save_table, NULL);

  if (gcomprisBoard_missing){
    GHashTable *config;

    if (profile_conf)
      config = gc_db_get_board_conf();
    else
      config = table;

    gc_locale_set(g_hash_table_lookup( config, "locale"));

    gchar *up_init_str = g_hash_table_lookup( config, "uppercase_only");
    if (up_init_str)
      {
	if(strcmp(up_init_str, "True")==0)
	  uppercase_only = TRUE;
	else
	  uppercase_only = FALSE;
      }

    if (profile_conf)
      g_hash_table_destroy(config);

    missing_destroy_board_list(board_list);
    board_list = NULL;

    init_xml(gcomprisBoard_missing->level);

    missing_letter_next_level();

  }

    board_conf = NULL;
  profile_conf = NULL;
  pause_board(FALSE);

  return TRUE;
}
Example #6
0
static void
start_board (GcomprisBoard *agcomprisBoard)
{
  gchar *filename = NULL;
  GHashTable *config = gc_db_get_board_conf();

  gc_locale_set(g_hash_table_lookup( config, "locale"));

  g_hash_table_destroy(config);

  if(agcomprisBoard!=NULL)
    {
      gcomprisBoard=agcomprisBoard;
      gc_set_background(goo_canvas_get_root_item(gcomprisBoard->canvas),
			"imageid/imageid-bg.svgz");
      gcomprisBoard->level=1;
      gcomprisBoard->sublevel=1;

      /* Calculate the maxlevel based on the available data file for this board */
      gcomprisBoard->maxlevel=1;

      while( (filename = gc_file_find_absolute("%s/board%d.xml",
					       gcomprisBoard->boarddir,
					       gcomprisBoard->maxlevel++,
					       NULL)) )
	{
	  g_free(filename);

	}
      g_free(filename);

      gcomprisBoard->maxlevel -= 2;
      gc_bar_set(GC_BAR_CONFIG|GC_BAR_LEVEL);

      imageid_next_level();

      gamewon = FALSE;
      pause_board(FALSE);
    }
}
Example #7
0
static void start_board (GcomprisBoard *agcomprisBoard)
{
  GHashTable *config = gc_db_get_board_conf();

  gc_locale_set(g_hash_table_lookup( config, "locale"));

  gchar *up_init_str = g_hash_table_lookup( config, "uppercase_only");

  if (up_init_str && (strcmp(up_init_str, "True")==0))
    uppercase_only = TRUE;
  else
    uppercase_only = FALSE;

  gchar *control_sound = g_hash_table_lookup( config, "with_sound");

  if (control_sound && strcmp(g_hash_table_lookup( config, "with_sound"),"True")==0)
    with_sound = TRUE;
  else
    with_sound = FALSE;

  g_hash_table_destroy(config);

  if(agcomprisBoard!=NULL)
    {
      gcomprisBoard=agcomprisBoard;
      load_default_charset();
      gc_set_background(goo_canvas_get_root_item(gcomprisBoard->canvas),
			"gletters/scenery_background.png");
      gcomprisBoard->maxlevel=maxLevel;
      gcomprisBoard->level = 1;
      level_set_score();
      gletters_next_level();
      gamewon = FALSE;
      pause_board(FALSE);
    }
}
Example #8
0
static gboolean conf_ok(GHashTable *table)
{
  if (!table){
    if (gcomprisBoard)
      pause_board(FALSE);
    return TRUE;
  }

  g_hash_table_foreach(table, (GHFunc) save_table, NULL);

  if (gcomprisBoard) {
    GHashTable *config;

    if (profile_conf)
      config = gc_db_get_board_conf();
    else
      config = table;

    gc_locale_set(g_hash_table_lookup( config, "locale"));

    if (profile_conf)
      g_hash_table_destroy(config);

    destroy_board_list();
    init_xml(gcomprisBoard->level);

    imageid_next_level();

    pause_board(FALSE);
  }

  board_conf = NULL;
  profile_conf = NULL;

  return TRUE;
}
Example #9
0
static void start_board (GcomprisBoard *agcomprisBoard)
{
  GHashTable *config = gc_db_get_board_conf();
  guint ready;

  board_paused = TRUE;

  gc_locale_set(g_hash_table_lookup( config, "locale_sound"));

  g_hash_table_destroy(config);

  ready = sounds_are_fine();

  gc_sound_bg_pause();

  if (agcomprisBoard!=NULL)
    {
      gcomprisBoard=agcomprisBoard;

      if ( gcomprisBoard->mode && g_ascii_strcasecmp(gcomprisBoard->mode, "uppercase")==0 )
	uppercase_only = TRUE;
      else
	uppercase_only = FALSE;

      gc_set_background(goo_canvas_get_root_item(gcomprisBoard->canvas),
			      "click_on_letter/background.svgz");

      gc_score_start(SCORESTYLE_NOTE,
		     50,
		     50,
		     0);

      load_datafile();

      gcomprisBoard->level=1;
      gcomprisBoard->sublevel=1;

      carriage_svg_handle = gc_rsvg_load("click_on_letter/carriage.svgz");
      rsvg_handle_get_dimensions (carriage_svg_handle, &carriage_svg_dimension);

      cloud_svg_handle = gc_rsvg_load("click_on_letter/cloud.svgz");
      rsvg_handle_get_dimensions (cloud_svg_handle, &cloud_svg_dimension);

      if(ready)
	{
	  if(ready == OK)
	    click_on_letter_next_level();

	  gamewon = FALSE;
	  pause_board(FALSE);
	}

      RsvgHandle *svg_handle;
      svg_handle = gc_rsvg_load("click_on_letter/repeat.svg");
      if(svg_handle) {
	gc_bar_set_repeat_icon(svg_handle);
	g_object_unref(svg_handle);
	gc_bar_set(GC_BAR_CONFIG|GC_BAR_LEVEL|GC_BAR_REPEAT_ICON);
      } else {
	gc_bar_set(GC_BAR_CONFIG|GC_BAR_LEVEL|GC_BAR_REPEAT);
      }
      gc_bar_location(BOARDWIDTH-300, 5, 0.7);

    }

}
Example #10
0
static gboolean
conf_ok(GHashTable *table)
{
  if (!table){
    if (gcomprisBoard)
      pause_board(FALSE);

    return TRUE;
  }

  g_hash_table_foreach(table, (GHFunc) save_table, NULL);

  board_conf = NULL;
  profile_conf = NULL;

  if (gcomprisBoard){
    GHashTable *config;
    if (profile_conf)
      config = gc_db_get_board_conf();
    else
      config = table;

    gboolean has_error = FALSE;
    gtk_tree_model_foreach(GTK_TREE_MODEL(model), _check_errors, &has_error);

    /* Tell the config not to close the dialog to let the user fix the issues */
    if (has_error)
      return FALSE;


    printf("conf_ok =%s\n", (char*)g_hash_table_lookup(config, "locale_sound"));
    gc_locale_set(g_hash_table_lookup(config, "locale_sound"));

    if (profile_conf)
      g_hash_table_destroy(config);

    guint ready = sounds_are_fine();

    /*
     * Save the new editied value if needed
     */
    /* Keep a cache of the old model */
    gchar *old_levels = levels_to_desktop();
    create_levels_from_config_model();
    gchar *new_levels = levels_to_desktop();

    if ( gcomprisBoard->level > gcomprisBoard->maxlevel )
      gcomprisBoard->level = 1;

    if (strcmp(old_levels, new_levels) != 0)
      {
	/* The level has changed, save the new desktop file in the user's dir */
	gchar *filename = get_user_desktop_file();
	g_file_set_contents(filename, new_levels, -1, NULL);
	g_free(filename);
      }
    g_free(old_levels);
    g_free(new_levels);

    if(ready)
      {
	if(ready == OK)
	  click_on_letter_next_level();

	gamewon = FALSE;
	pause_board(FALSE);
      }

  }

  board_conf = NULL;
  profile_conf = NULL;
  return TRUE;
}