Exemplo n.º 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);
    }
}
Exemplo n.º 2
0
static void start_board (GcomprisBoard *agcomprisBoard)
{

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

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

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


        /* set initial values for this level */
        gcomprisBoard->level = 1;
        gcomprisBoard->maxlevel = 2;
        gc_bar_set(GC_BAR_LEVEL);
        gc_bar_location(10, -1, 0.6);

        planegame_next_level();

        pause_board(FALSE);

    }

}
Exemplo n.º 3
0
static void start_board (GcomprisBoard *agcomprisBoard)
{

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

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

      gcomprisBoard->level=1;
      gcomprisBoard->maxlevel=NUMBER_OF_TARGET;
      gcomprisBoard->sublevel=1;
      gcomprisBoard->number_of_sublevel=1; /* Go to next level after this number of 'play' */

      gc_set_background(goo_canvas_get_root_item(gcomprisBoard->canvas),
			"target/target_background.svgz");

      gc_bar_set(GC_BAR_LEVEL);
      gc_bar_location(BOARDWIDTH-200, -1, 0.8);

      target_next_level();

      gamewon = FALSE;
      pause_board(FALSE);
    }
}
Exemplo n.º 4
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();
    }
}
Exemplo n.º 5
0
static void
threeDdisplay()
{
  gc_sound_play_ogg ("sounds/flip.wav", NULL);
  gc_set_background(goo_canvas_get_root_item(gcomprisBoard->canvas),
		    "maze/maze-bg.svgz");
  g_object_set (boardRootItem, "visibility",
		GOO_CANVAS_ITEM_INVISIBLE, NULL);
  threeDactive=TRUE;
  draw3D();
}
Exemplo n.º 6
0
/* =====================================================================
 * set initial values for the next level
 * =====================================================================*/
static void colors_next_level() {
  gchar *str = NULL;
  int i, list_length;
  GList * list = NULL;
  int * item;

  colors_destroy_all_items();
  gamewon = FALSE;

  gc_score_set(gcomprisBoard->sublevel);
  gc_bar_set_level(gcomprisBoard);

  /* initialize board only once*/
  if (gcomprisBoard->sublevel == 1) {
    errors = MAX_ERRORS;
    // we generate a list of color indexes in a random order
    while (g_list_length(listColors) > 0)
      listColors = g_list_remove(listColors, g_list_nth_data(listColors,0));

    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);
    }

    /* set background */
    str = g_strdup_printf("%s/%s", gcomprisBoard->boarddir, backgroundFile);
    g_warning("background = %s\n", str);
    gc_set_background(goo_canvas_get_root_item(gcomprisBoard->canvas), str);
    g_free(str);
  }

  colors_create_item(goo_canvas_get_root_item(gcomprisBoard->canvas));

  /* show text of color to find */
  color_item = goo_canvas_text_new (boardRootItem,
				    colors[GPOINTER_TO_INT(g_list_nth_data(listColors,0))],
				    (color_x1+color_x2)/2,
				    (color_y1+color_y2)/2,
				    -1,
				    GTK_ANCHOR_CENTER,
				    "font", gc_skin_font_board_title_bold,
				    "fill-color", "darkblue",
				    NULL);

}
Exemplo n.º 7
0
/* =====================================================================
 *
 * =====================================================================*/
static void start_board (GcomprisBoard *agcomprisBoard) {
  if(agcomprisBoard!=NULL) {
    gcomprisBoard=agcomprisBoard;
    gc_set_background(goo_canvas_get_root_item(gcomprisBoard->canvas), "submarine/sub_bg.jpg");
    gcomprisBoard->level=1;
    gcomprisBoard->maxlevel=3;
    gcomprisBoard->sublevel=1;
    gc_bar_set(GC_BAR_LEVEL);
    gc_bar_location(0, -1, 0.6);
    submarine_next_level();
    gamewon = FALSE;
    pause_board(FALSE);
  }
}
Exemplo n.º 8
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();

    }
}
Exemplo n.º 9
0
static void start_board (GcomprisBoard *agcomprisBoard)
{

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

      gcomprisBoard->level = 1;
      gcomprisBoard->maxlevel = 1;
      gc_bar_set(0);

      gc_set_background(goo_canvas_get_root_item(gcomprisBoard->canvas),
			"tangram/gtans_bg.svgz");

      selectedgrande = FALSE;
      taninitstart();
    }
}
Exemplo n.º 10
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);
    }
}
Exemplo n.º 11
0
static void start_board (GcomprisBoard *agcomprisBoard)
{

  if(agcomprisBoard!=NULL)
    {
      gcomprisBoard=agcomprisBoard;
      gcomprisBoard->level=1;
      gcomprisBoard->maxlevel=6;
      gcomprisBoard->sublevel=1;
      gcomprisBoard->number_of_sublevel=6; /* Go to next level after this number of 'play' */
      gc_bar_set(GC_BAR_LEVEL);
      gc_bar_location(30, -1, -1);

      gc_set_background(goo_canvas_get_root_item(gcomprisBoard->canvas),
			"superbrain/superbrain_background.svgz");

      superbrain_next_level();

      gamewon = FALSE;
      pause_board(FALSE);
    }
}
Exemplo n.º 12
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);
    }
}
Exemplo n.º 13
0
static void setup_gcs(void)
{
  ss->basic_gc = gc_new();
  gc_set_background(ss->basic_gc, ss->graph_color);
  gc_set_foreground(ss->basic_gc, ss->data_color);

  ss->combined_basic_gc = gc_new();
  gc_set_background(ss->combined_basic_gc, ss->graph_color);
  gc_set_foreground(ss->combined_basic_gc, ss->data_color);

  ss->mix_gc = gc_new();
  gc_set_background(ss->mix_gc, ss->graph_color);
  gc_set_foreground(ss->mix_gc, ss->mix_color);

  ss->cursor_gc = gc_new();
  gc_set_background(ss->cursor_gc, ss->graph_color);
  gc_set_colors(ss->cursor_gc, ss->cursor_color, ss->graph_color);

  ss->selection_gc = gc_new();
  gc_set_background(ss->selection_gc, ss->graph_color);
  gc_set_colors(ss->selection_gc, ss->selection_color, ss->graph_color);

  ss->mark_gc = gc_new();
  gc_set_background(ss->mark_gc, ss->graph_color);
  gc_set_colors(ss->mark_gc, ss->mark_color, ss->graph_color);

  ss->erase_gc = gc_new();
  gc_set_background(ss->erase_gc, ss->data_color);
  gc_set_foreground(ss->erase_gc, ss->graph_color);

  ss->selected_basic_gc = gc_new();
  gc_set_background(ss->selected_basic_gc, ss->selected_graph_color);
  gc_set_foreground(ss->selected_basic_gc, ss->selected_data_color);

  ss->selected_cursor_gc = gc_new();
  gc_set_background(ss->selected_cursor_gc, ss->graph_color);
  gc_set_colors(ss->selected_cursor_gc, ss->cursor_color, ss->graph_color);

  ss->selected_selection_gc = gc_new();
  gc_set_background(ss->selected_selection_gc, ss->graph_color);
  gc_set_colors(ss->selected_selection_gc, ss->selection_color, ss->graph_color);

  ss->selected_mark_gc = gc_new();
  gc_set_background(ss->selected_mark_gc, ss->selected_graph_color);
  gc_set_colors(ss->selected_mark_gc, ss->mark_color, ss->selected_graph_color);

  ss->selected_erase_gc = gc_new();
  gc_set_background(ss->selected_erase_gc, ss->selected_data_color);
  gc_set_foreground(ss->selected_erase_gc, ss->selected_graph_color);

  ss->fltenv_basic_gc = gc_new();
  gc_set_background(ss->fltenv_basic_gc, ss->basic_color);
  gc_set_foreground(ss->fltenv_basic_gc, ss->black);

  ss->fltenv_data_gc = gc_new();
  gc_set_background(ss->fltenv_data_gc, ss->basic_color);
  gc_set_foreground(ss->fltenv_data_gc, ss->filter_control_waveform_color);

  initialize_colormap();
}
Exemplo n.º 14
0
static void start_board (GcomprisBoard *agcomprisBoard)
{

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

      gcomprisBoard->level = 1;
      gcomprisBoard->maxlevel = 9;
      gc_bar_set(GC_BAR_LEVEL);

      /* Default mode */

      if(!gcomprisBoard->mode){
	currentMode=MODE_NORMAL;
	currentUiMode=UIMODE_NORMAL;
	currentBoardMode=BOARDMODE_NORMAL;
      } else {
	if(g_ascii_strcasecmp(gcomprisBoard->mode, "tux")==0){
	  currentMode=MODE_TUX;
	  currentUiMode=UIMODE_NORMAL;
	  currentBoardMode=BOARDMODE_NORMAL;
	} else {
	  if(g_ascii_strcasecmp(gcomprisBoard->mode, "sound")==0){
	    currentMode=MODE_NORMAL;
	    currentUiMode=UIMODE_SOUND;
	    currentBoardMode=BOARDMODE_SOUND;
	  } else {
	    if(g_ascii_strcasecmp(gcomprisBoard->mode, "sound_tux")==0){
	      currentMode=MODE_TUX;
	      currentUiMode=UIMODE_SOUND;
	      currentBoardMode=BOARDMODE_SOUND;
	    } else {
	      if(g_ascii_strcasecmp(gcomprisBoard->mode, "add")==0){
		currentMode=MODE_NORMAL;
		currentUiMode=UIMODE_NORMAL;
		currentBoardMode=BOARDMODE_ADD;
	      } else {
		if(g_ascii_strcasecmp(gcomprisBoard->mode, "add_tux")==0){
		  currentMode=MODE_TUX;
		  currentUiMode=UIMODE_NORMAL;
		  currentBoardMode=BOARDMODE_ADD;
		} else {
		  if(g_ascii_strcasecmp(gcomprisBoard->mode, "minus")==0){
		    currentMode=MODE_NORMAL;
		    currentUiMode=UIMODE_NORMAL;
		    currentBoardMode=BOARDMODE_MINUS;
		  } else {
		    if(g_ascii_strcasecmp(gcomprisBoard->mode, "minus_tux")==0){
		      currentMode=MODE_TUX;
		      currentUiMode=UIMODE_NORMAL;
		      currentBoardMode=BOARDMODE_MINUS;
		    } else {
		      if(g_ascii_strcasecmp(gcomprisBoard->mode, "mult")==0){
			currentMode=MODE_NORMAL;
			currentUiMode=UIMODE_NORMAL;
			currentBoardMode=BOARDMODE_MULT;
		      } else {
			if(g_ascii_strcasecmp(gcomprisBoard->mode, "mult_tux")==0){
			  currentMode=MODE_TUX;
			  currentUiMode=UIMODE_NORMAL;
			  currentBoardMode=BOARDMODE_MULT;
			} else {
			  if(g_ascii_strcasecmp(gcomprisBoard->mode, "div")==0){
			    currentMode=MODE_NORMAL;
			    currentUiMode=UIMODE_NORMAL;
			    currentBoardMode=BOARDMODE_DIV;
			  } else {
			    if(g_ascii_strcasecmp(gcomprisBoard->mode, "div_tux")==0){
			      currentMode=MODE_TUX;
			      currentUiMode=UIMODE_NORMAL;
			      currentBoardMode=BOARDMODE_DIV;
			    } else {
			      if(g_ascii_strcasecmp(gcomprisBoard->mode, "add_minus")==0){
				currentMode=MODE_NORMAL;
				currentUiMode=UIMODE_NORMAL;
				currentBoardMode=BOARDMODE_ADD_MINUS;
			      } else {
				if(g_ascii_strcasecmp(gcomprisBoard->mode, "add_minus_tux")==0){
				  currentMode=MODE_TUX;
				  currentUiMode=UIMODE_NORMAL;
				  currentBoardMode=BOARDMODE_ADD_MINUS;
				} else {
				  if(g_ascii_strcasecmp(gcomprisBoard->mode, "mult_div")==0){
				    currentMode=MODE_NORMAL;
				    currentUiMode=UIMODE_NORMAL;
				    currentBoardMode=BOARDMODE_MULT_DIV;
				  } else {
				    if(g_ascii_strcasecmp(gcomprisBoard->mode, "mult_div_tux")==0){
				      currentMode=MODE_TUX;
				      currentUiMode=UIMODE_NORMAL;
				      currentBoardMode=BOARDMODE_MULT_DIV;
				    } else {
				      if(g_ascii_strcasecmp(gcomprisBoard->mode, "add_minus_mult_div")==0){
					currentMode=MODE_NORMAL;
					currentUiMode=UIMODE_NORMAL;
					currentBoardMode=BOARDMODE_ADD_MINUS_MULT_DIV;
				      } else {
					if(g_ascii_strcasecmp(gcomprisBoard->mode, "add_minus_mult_div_tux")==0){
					  currentMode=MODE_TUX;
					  currentUiMode=UIMODE_NORMAL;
					  currentBoardMode=BOARDMODE_ADD_MINUS_MULT_DIV;
					} else {
					  if(g_ascii_strcasecmp(gcomprisBoard->mode, "enumerate")==0){
					    currentMode=MODE_NORMAL;
					    currentUiMode=UIMODE_NORMAL;
					    currentBoardMode=BOARDMODE_ENUMERATE;
					  } else {
					    if(g_ascii_strcasecmp(gcomprisBoard->mode, "enumerate_tux")==0){
					      currentMode=MODE_TUX;
					      currentUiMode=UIMODE_NORMAL;
					      currentBoardMode=BOARDMODE_ENUMERATE;
					    } else {
				              if(g_ascii_strcasecmp(gcomprisBoard->mode, "wordnumber")==0){
						currentMode=MODE_NORMAL;
						currentUiMode=UIMODE_NORMAL;
						currentBoardMode=BOARDMODE_WORDNUMBER;
					      } else {
						if(g_ascii_strcasecmp(gcomprisBoard->mode, "wordnumber_tux")==0){
					          currentMode=MODE_TUX;
						  currentUiMode=UIMODE_NORMAL;
						  currentBoardMode=BOARDMODE_WORDNUMBER;
						} else {
						  currentMode=MODE_NORMAL;
						  currentUiMode=UIMODE_NORMAL;
						  currentBoardMode=BOARDMODE_NORMAL;
						  g_warning("Fallback mode set to images");
						}
					      }
					    }
					  }
					}
				      }
				    }
				  }
				}
			      }
			    }
			  }
			}
		      }
		    }
		  }
		}
	      }
	    }
	  }
	}
      }


      if (currentUiMode == UIMODE_SOUND)
	{
	  GcomprisProperties	*properties = gc_prop_get();

	  gc_sound_bg_pause();

	  /* initial state to restore */
	  sound_policy = gc_sound_policy_get();

	  // Will set the PLAY_AND_INTERRUPT policy on first
	  // user click so that intro sounds is not

	  gc_set_background(goo_canvas_get_root_item(gcomprisBoard->canvas),
			    "memory/gcompris_band.svg");
	  base_x1 = BASE_SOUND_X1;
	  base_y1 = BASE_SOUND_Y1;
	  base_x2 = BASE_SOUND_X2;
	  base_y2 = BASE_SOUND_Y2;
	  base_x1_tux = BASE_SOUND_X1_TUX;

	  if(!properties->fx) {
	    gc_dialog(_("Error: this activity cannot be played with the\n"
			"sound effects disabled.\nGo to the configuration dialog to\n"
			"enable the sound"), gc_board_stop);
	    return;
	  }

	}
      else
	{
        if ((currentBoardMode==BOARDMODE_ENUMERATE)||(currentBoardMode==BOARDMODE_WORDNUMBER))
	    {
             gcomprisBoard->maxlevel = 6;
	    }

	  gc_set_background(goo_canvas_get_root_item(gcomprisBoard->canvas),
			    "memory/scenery_background.png");
	  base_x1 = BASE_CARD_X1;
	  base_y1 = BASE_CARD_Y1;
	  base_x2 = BASE_CARD_X2;
	  base_y2 = BASE_CARD_Y2;
	  base_x1_tux = BASE_CARD_X1_TUX;
	}


      /* TRANSLATORS: Put here the numbers in your language */
      numbers=_("0123456789");
      g_assert(g_utf8_validate(numbers,-1,NULL)); // require by all utf8-functions

      /* TRANSLATORS: Put here the alphabet lowercase in your language */
      alphabet_lowercase=_("abcdefghijklmnopqrstuvwxyz");
      g_assert(g_utf8_validate(alphabet_lowercase,-1,NULL)); // require by all utf8-functions

      g_warning("Using lowercase %s", alphabet_lowercase);

      /* TRANSLATORS: Put here the alphabet uppercase in your language */
      alphabet_uppercase=_("ABCDEFGHIJKLMNOPQRSTUVWXYZ");
      g_assert(g_utf8_validate(alphabet_uppercase,-1,NULL)); // require by all utf8-functions
      g_warning("Using uppercase %s", alphabet_uppercase);

      /* TRANSLATORS: Put here the mathematical operators '+-x/' for  your language. */
      operators=_("+-×÷");
      g_assert(g_utf8_validate(operators,-1,NULL)); // require by all utf8-functions
      g_warning("Using operators %s", operators);

      op_add = g_malloc0(2*sizeof(gunichar));
      g_utf8_strncpy(op_add, g_utf8_offset_to_pointer (operators,0),1);

      op_minus = g_malloc0(2*sizeof(gunichar));
      g_utf8_strncpy(op_minus, g_utf8_offset_to_pointer (operators,1),1);

      op_mult = g_malloc0(2*sizeof(gunichar));
      g_utf8_strncpy(op_mult, g_utf8_offset_to_pointer (operators,2),1);

      op_div = g_malloc0(2*sizeof(gunichar));
      g_utf8_strncpy(op_div, g_utf8_offset_to_pointer (operators,3),1);


      g_warning("Using operators %s %s %s %s", op_add, op_minus,
		                               op_mult, op_div);

      if (currentMode == MODE_TUX){
	tux_memory_size = tux_memory_sizes[gcomprisBoard->level];
	tux_memory = g_queue_new ();
      }

      Paused = FALSE;

      memory_next_level();
    }
}
Exemplo n.º 15
0
/* set initial values for the next level */
static void money_next_level()
{
  guint		   min_price = 0, max_price = 0;
  guint		   paid = 0;
  guint		   number_of_item = 0;
  guint		   i;
  gchar		  *display_format;

  gc_set_background(goo_canvas_get_root_item(gcomprisBoard->canvas),
		    "money/money-bg.png");

  gc_bar_set_level(gcomprisBoard);

  money_destroy_all_items();
  gamewon = FALSE;

  boardRootItem = goo_canvas_group_new (goo_canvas_get_root_item(gcomprisBoard->canvas),
					NULL);


  /* The OK Button */
  GooCanvasItem *item = goo_canvas_svg_new( boardRootItem,
					    gc_skin_rsvg_get(),
					    "svg-id", "#OK",
					    NULL);
  SET_ITEM_LOCATION(item, 725, 230);
  g_signal_connect(item, "button_press_event",
		   (GtkSignalFunc) moneyactivity_process_ok, NULL);
  gc_item_focus_init(item, NULL);

  tux_money = MONEY_WIDGET(money_widget_new());
  money_widget_set_position(tux_money,
			    boardRootItem,
			    100.0, 380.0,
			    700.0, 490.0,
			    5, 2,
			    FALSE);

  /* Select level difficulty */
  switch(currentMode)
    {
    case WITHOUT_CENTS:
      switch(gcomprisBoard->level)
	{
	case 1:
	  number_of_item = 1;
	  min_price      = 3;
	  max_price      = 10;
	  money_widget_add(tux_money, MONEY_EURO_PAPER_5E);
	  money_widget_add(tux_money, MONEY_EURO_COIN_2E);
	  money_widget_add(tux_money, MONEY_EURO_COIN_1E);
	  money_widget_add(tux_money, MONEY_EURO_COIN_2E);
	  money_widget_add(tux_money, MONEY_EURO_PAPER_5E);
	  money_widget_add(tux_money, MONEY_EURO_PAPER_5E);
	  money_widget_add(tux_money, MONEY_EURO_COIN_1E);
	  money_widget_add(tux_money, MONEY_EURO_COIN_1E);
	  break;
	case 2:
	  number_of_item = 1;
	  min_price      = 10;
	  max_price      = 20;
	  money_widget_add(tux_money, MONEY_EURO_PAPER_10E);
	  money_widget_add(tux_money, MONEY_EURO_PAPER_5E);
	  money_widget_add(tux_money, MONEY_EURO_COIN_2E);
	  money_widget_add(tux_money, MONEY_EURO_COIN_1E);
	  money_widget_add(tux_money, MONEY_EURO_COIN_2E);
	  money_widget_add(tux_money, MONEY_EURO_PAPER_5E);
	  money_widget_add(tux_money, MONEY_EURO_PAPER_5E);
	  money_widget_add(tux_money, MONEY_EURO_COIN_1E);
	  money_widget_add(tux_money, MONEY_EURO_COIN_1E);
	  break;
	case 3:
	  number_of_item = 2;
	  min_price      = 20;
	  max_price      = 30;
	  money_widget_add(tux_money, MONEY_EURO_PAPER_10E);
	  money_widget_add(tux_money, MONEY_EURO_PAPER_10E);
	  money_widget_add(tux_money, MONEY_EURO_PAPER_5E);
	  money_widget_add(tux_money, MONEY_EURO_COIN_2E);
	  money_widget_add(tux_money, MONEY_EURO_COIN_1E);
	  money_widget_add(tux_money, MONEY_EURO_COIN_2E);
	  money_widget_add(tux_money, MONEY_EURO_PAPER_5E);
	  money_widget_add(tux_money, MONEY_EURO_PAPER_5E);
	  money_widget_add(tux_money, MONEY_EURO_COIN_1E);
	  money_widget_add(tux_money, MONEY_EURO_COIN_1E);
	  break;
	case 4:
	  number_of_item = 2;
	  min_price      = 30;
	  max_price      = 40;
	  money_widget_add(tux_money, MONEY_EURO_PAPER_10E);
	  money_widget_add(tux_money, MONEY_EURO_PAPER_10E);
	  money_widget_add(tux_money, MONEY_EURO_PAPER_5E);
	  money_widget_add(tux_money, MONEY_EURO_COIN_2E);
	  money_widget_add(tux_money, MONEY_EURO_COIN_1E);
	  money_widget_add(tux_money, MONEY_EURO_COIN_2E);
	  money_widget_add(tux_money, MONEY_EURO_PAPER_10E);
	  money_widget_add(tux_money, MONEY_EURO_PAPER_5E);
	  money_widget_add(tux_money, MONEY_EURO_COIN_1E);
	  money_widget_add(tux_money, MONEY_EURO_COIN_1E);
	  break;
	case 5:
	  number_of_item = 3;
	  min_price      = 40;
	  max_price      = 50;
	  money_widget_add(tux_money, MONEY_EURO_COIN_2E);
	  money_widget_add(tux_money, MONEY_EURO_COIN_1E);
	  money_widget_add(tux_money, MONEY_EURO_PAPER_10E);
	  money_widget_add(tux_money, MONEY_EURO_PAPER_10E);
	  money_widget_add(tux_money, MONEY_EURO_PAPER_5E);
	  money_widget_add(tux_money, MONEY_EURO_COIN_1E);
	  money_widget_add(tux_money, MONEY_EURO_PAPER_5E);
	  money_widget_add(tux_money, MONEY_EURO_COIN_2E);
	  money_widget_add(tux_money, MONEY_EURO_PAPER_20E);
	  money_widget_add(tux_money, MONEY_EURO_COIN_1E);
	  break;
	case 6:
	  number_of_item = 3;
	  min_price      = 50;
	  max_price      = 60;
	  money_widget_add(tux_money, MONEY_EURO_PAPER_10E);
	  money_widget_add(tux_money, MONEY_EURO_PAPER_20E);
	  money_widget_add(tux_money, MONEY_EURO_COIN_2E);
	  money_widget_add(tux_money, MONEY_EURO_PAPER_20E);
	  money_widget_add(tux_money, MONEY_EURO_PAPER_5E);
	  money_widget_add(tux_money, MONEY_EURO_PAPER_5E);
	  money_widget_add(tux_money, MONEY_EURO_COIN_2E);
	  money_widget_add(tux_money, MONEY_EURO_COIN_1E);
	  money_widget_add(tux_money, MONEY_EURO_COIN_1E);
	  money_widget_add(tux_money, MONEY_EURO_COIN_1E);
	  break;
	case 7:
	  number_of_item = 4;
	  min_price      = 60;
	  max_price      = 70;
	  money_widget_add(tux_money, MONEY_EURO_COIN_2E);
	  money_widget_add(tux_money, MONEY_EURO_PAPER_50E);
	  money_widget_add(tux_money, MONEY_EURO_PAPER_5E);
	  money_widget_add(tux_money, MONEY_EURO_COIN_1E);
	  money_widget_add(tux_money, MONEY_EURO_PAPER_10E);
	  money_widget_add(tux_money, MONEY_EURO_PAPER_20E);
	  money_widget_add(tux_money, MONEY_EURO_PAPER_5E);
	  money_widget_add(tux_money, MONEY_EURO_COIN_2E);
	  money_widget_add(tux_money, MONEY_EURO_COIN_1E);
	  money_widget_add(tux_money, MONEY_EURO_COIN_1E);
	  break;
	case 8:
	  number_of_item = 4;
	  min_price      = 70;
	  max_price      = 80;
	  money_widget_add(tux_money, MONEY_EURO_PAPER_50E);
	  money_widget_add(tux_money, MONEY_EURO_PAPER_20E);
	  money_widget_add(tux_money, MONEY_EURO_PAPER_5E);
	  money_widget_add(tux_money, MONEY_EURO_COIN_2E);
	  money_widget_add(tux_money, MONEY_EURO_COIN_1E);
	  money_widget_add(tux_money, MONEY_EURO_COIN_2E);
	  money_widget_add(tux_money, MONEY_EURO_PAPER_10E);
	  money_widget_add(tux_money, MONEY_EURO_PAPER_5E);
	  money_widget_add(tux_money, MONEY_EURO_COIN_1E);
	  money_widget_add(tux_money, MONEY_EURO_COIN_1E);
	  break;
	case 9:
	  number_of_item = 4;
	  min_price      = 50;
	  max_price      = 100;
	  money_widget_add(tux_money, MONEY_EURO_PAPER_10E);
	  money_widget_add(tux_money, MONEY_EURO_COIN_2E);
	  money_widget_add(tux_money, MONEY_EURO_PAPER_5E);
	  money_widget_add(tux_money, MONEY_EURO_COIN_1E);
	  money_widget_add(tux_money, MONEY_EURO_COIN_1E);
	  money_widget_add(tux_money, MONEY_EURO_COIN_2E);
	  money_widget_add(tux_money, MONEY_EURO_PAPER_50E);
	  money_widget_add(tux_money, MONEY_EURO_PAPER_20E);
	  money_widget_add(tux_money, MONEY_EURO_PAPER_5E);
	  money_widget_add(tux_money, MONEY_EURO_PAPER_5E);
	  break;
	}
      break;
    case WITH_CENTS:
      switch(gcomprisBoard->level)
	{
	case 1:
	  number_of_item = 1;
	  min_price      = 1;
	  max_price      = 3;
	  money_widget_add(tux_money, MONEY_EURO_COIN_2E);
	  money_widget_add(tux_money, MONEY_EURO_COIN_1E);
	  money_widget_add(tux_money, MONEY_EURO_COIN_5C);
	  money_widget_add(tux_money, MONEY_EURO_COIN_2C);
	  money_widget_add(tux_money, MONEY_EURO_COIN_20C);
	  money_widget_add(tux_money, MONEY_EURO_COIN_50C);
	  money_widget_add(tux_money, MONEY_EURO_COIN_20C);
	  money_widget_add(tux_money, MONEY_EURO_COIN_10C);
	  money_widget_add(tux_money, MONEY_EURO_COIN_1C);
	  money_widget_add(tux_money, MONEY_EURO_COIN_1C);
	  break;
	case 2:
	  number_of_item = 1;
	  min_price      = 1;
	  max_price      = 3;
	  money_widget_add(tux_money, MONEY_EURO_COIN_2E);
	  money_widget_add(tux_money, MONEY_EURO_COIN_1E);
	  money_widget_add(tux_money, MONEY_EURO_COIN_5C);
	  money_widget_add(tux_money, MONEY_EURO_COIN_2C);
	  money_widget_add(tux_money, MONEY_EURO_COIN_20C);
	  money_widget_add(tux_money, MONEY_EURO_COIN_50C);
	  money_widget_add(tux_money, MONEY_EURO_COIN_20C);
	  money_widget_add(tux_money, MONEY_EURO_COIN_10C);
	  money_widget_add(tux_money, MONEY_EURO_COIN_1C);
	  money_widget_add(tux_money, MONEY_EURO_COIN_1C);
	  break;
	case 3:
	  number_of_item = 2;
	  min_price      = 1;
	  max_price      = 3;
	  money_widget_add(tux_money, MONEY_EURO_COIN_2E);
	  money_widget_add(tux_money, MONEY_EURO_COIN_1E);
	  money_widget_add(tux_money, MONEY_EURO_COIN_5C);
	  money_widget_add(tux_money, MONEY_EURO_COIN_2C);
	  money_widget_add(tux_money, MONEY_EURO_COIN_20C);
	  money_widget_add(tux_money, MONEY_EURO_COIN_50C);
	  money_widget_add(tux_money, MONEY_EURO_COIN_20C);
	  money_widget_add(tux_money, MONEY_EURO_COIN_10C);
	  money_widget_add(tux_money, MONEY_EURO_COIN_1C);
	  money_widget_add(tux_money, MONEY_EURO_COIN_1C);
	  break;
	case 4:
	  number_of_item = 3;
	  min_price      = 1;
	  max_price      = 3;
	  money_widget_add(tux_money, MONEY_EURO_COIN_2E);
	  money_widget_add(tux_money, MONEY_EURO_COIN_1E);
	  money_widget_add(tux_money, MONEY_EURO_COIN_5C);
	  money_widget_add(tux_money, MONEY_EURO_COIN_2C);
	  money_widget_add(tux_money, MONEY_EURO_COIN_20C);
	  money_widget_add(tux_money, MONEY_EURO_COIN_50C);
	  money_widget_add(tux_money, MONEY_EURO_COIN_20C);
	  money_widget_add(tux_money, MONEY_EURO_COIN_10C);
	  money_widget_add(tux_money, MONEY_EURO_COIN_1C);
	  money_widget_add(tux_money, MONEY_EURO_COIN_1C);
	  break;
	case 5:
	  number_of_item = 4;
	  min_price      = 0;
	  max_price      = 4;
	  money_widget_add(tux_money, MONEY_EURO_COIN_2E);
	  money_widget_add(tux_money, MONEY_EURO_COIN_1E);
	  money_widget_add(tux_money, MONEY_EURO_COIN_5C);
	  money_widget_add(tux_money, MONEY_EURO_COIN_2C);
	  money_widget_add(tux_money, MONEY_EURO_COIN_20C);
	  money_widget_add(tux_money, MONEY_EURO_COIN_50C);
	  money_widget_add(tux_money, MONEY_EURO_COIN_20C);
	  money_widget_add(tux_money, MONEY_EURO_COIN_10C);
	  money_widget_add(tux_money, MONEY_EURO_COIN_1C);
	  money_widget_add(tux_money, MONEY_EURO_COIN_1C);
	  break;
	}
      break;
    case BACK_WITHOUT_CENTS:
      switch(gcomprisBoard->level)
	{
	case 1:
	  number_of_item = 1;
	  min_price      = 3;
	  max_price      = 9;
	  paid		 = 10;
	  money_widget_add(tux_money, MONEY_EURO_PAPER_5E);
	  money_widget_add(tux_money, MONEY_EURO_COIN_2E);
	  money_widget_add(tux_money, MONEY_EURO_COIN_1E);
	  money_widget_add(tux_money, MONEY_EURO_COIN_2E);
	  money_widget_add(tux_money, MONEY_EURO_PAPER_5E);
	  money_widget_add(tux_money, MONEY_EURO_PAPER_5E);
	  money_widget_add(tux_money, MONEY_EURO_COIN_1E);
	  money_widget_add(tux_money, MONEY_EURO_COIN_1E);
	  break;
	case 2:
	  number_of_item = 1;
	  min_price      = 1;
	  max_price      = 19;
	  paid		 = 20;
	  money_widget_add(tux_money, MONEY_EURO_PAPER_10E);
	  money_widget_add(tux_money, MONEY_EURO_PAPER_5E);
	  money_widget_add(tux_money, MONEY_EURO_COIN_2E);
	  money_widget_add(tux_money, MONEY_EURO_COIN_1E);
	  money_widget_add(tux_money, MONEY_EURO_COIN_2E);
	  money_widget_add(tux_money, MONEY_EURO_PAPER_5E);
	  money_widget_add(tux_money, MONEY_EURO_PAPER_5E);
	  money_widget_add(tux_money, MONEY_EURO_COIN_1E);
	  money_widget_add(tux_money, MONEY_EURO_COIN_1E);
	  break;
	case 3:
	  number_of_item = 2;
	  min_price      = 2;
	  max_price      = 29;
	  paid		 = 30;
	  money_widget_add(tux_money, MONEY_EURO_PAPER_10E);
	  money_widget_add(tux_money, MONEY_EURO_PAPER_10E);
	  money_widget_add(tux_money, MONEY_EURO_PAPER_5E);
	  money_widget_add(tux_money, MONEY_EURO_COIN_2E);
	  money_widget_add(tux_money, MONEY_EURO_COIN_1E);
	  money_widget_add(tux_money, MONEY_EURO_COIN_2E);
	  money_widget_add(tux_money, MONEY_EURO_PAPER_5E);
	  money_widget_add(tux_money, MONEY_EURO_PAPER_5E);
	  money_widget_add(tux_money, MONEY_EURO_COIN_1E);
	  money_widget_add(tux_money, MONEY_EURO_COIN_1E);
	  break;
	case 4:
	  number_of_item = 2;
	  min_price      = 2;
	  max_price      = 39;
	  paid		 = 40;
	  money_widget_add(tux_money, MONEY_EURO_PAPER_10E);
	  money_widget_add(tux_money, MONEY_EURO_PAPER_10E);
	  money_widget_add(tux_money, MONEY_EURO_PAPER_5E);
	  money_widget_add(tux_money, MONEY_EURO_COIN_2E);
	  money_widget_add(tux_money, MONEY_EURO_COIN_1E);
	  money_widget_add(tux_money, MONEY_EURO_COIN_2E);
	  money_widget_add(tux_money, MONEY_EURO_PAPER_10E);
	  money_widget_add(tux_money, MONEY_EURO_PAPER_5E);
	  money_widget_add(tux_money, MONEY_EURO_COIN_1E);
	  money_widget_add(tux_money, MONEY_EURO_COIN_1E);
	  break;
	case 5:
	  number_of_item = 3;
	  min_price      = 3;
	  max_price      = 49;
	  paid		 = 50;
	  money_widget_add(tux_money, MONEY_EURO_COIN_2E);
	  money_widget_add(tux_money, MONEY_EURO_COIN_1E);
	  money_widget_add(tux_money, MONEY_EURO_PAPER_10E);
	  money_widget_add(tux_money, MONEY_EURO_PAPER_10E);
	  money_widget_add(tux_money, MONEY_EURO_PAPER_5E);
	  money_widget_add(tux_money, MONEY_EURO_COIN_1E);
	  money_widget_add(tux_money, MONEY_EURO_PAPER_5E);
	  money_widget_add(tux_money, MONEY_EURO_COIN_2E);
	  money_widget_add(tux_money, MONEY_EURO_PAPER_20E);
	  money_widget_add(tux_money, MONEY_EURO_COIN_1E);
	  break;
	case 6:
	  number_of_item = 3;
	  min_price      = 3;
	  max_price      = 60;
	  paid		 = 100;
	  money_widget_add(tux_money, MONEY_EURO_PAPER_10E);
	  money_widget_add(tux_money, MONEY_EURO_PAPER_50E);
	  money_widget_add(tux_money, MONEY_EURO_COIN_2E);
	  money_widget_add(tux_money, MONEY_EURO_PAPER_20E);
	  money_widget_add(tux_money, MONEY_EURO_PAPER_20E);
	  money_widget_add(tux_money, MONEY_EURO_PAPER_5E);
	  money_widget_add(tux_money, MONEY_EURO_COIN_2E);
	  money_widget_add(tux_money, MONEY_EURO_COIN_1E);
	  money_widget_add(tux_money, MONEY_EURO_COIN_1E);
	  money_widget_add(tux_money, MONEY_EURO_COIN_1E);
	  break;
	case 7:
	  number_of_item = 4;
	  min_price      = 4;
	  max_price      = 70;
	  paid		 = 100;
	  money_widget_add(tux_money, MONEY_EURO_PAPER_10E);
	  money_widget_add(tux_money, MONEY_EURO_PAPER_50E);
	  money_widget_add(tux_money, MONEY_EURO_PAPER_5E);
	  money_widget_add(tux_money, MONEY_EURO_COIN_1E);
	  money_widget_add(tux_money, MONEY_EURO_PAPER_10E);
	  money_widget_add(tux_money, MONEY_EURO_PAPER_20E);
	  money_widget_add(tux_money, MONEY_EURO_PAPER_5E);
	  money_widget_add(tux_money, MONEY_EURO_COIN_2E);
	  money_widget_add(tux_money, MONEY_EURO_COIN_1E);
	  money_widget_add(tux_money, MONEY_EURO_COIN_1E);
	  break;
	case 8:
	  number_of_item = 4;
	  min_price      = 4;
	  max_price      = 80;
	  paid		 = 100;
	  money_widget_add(tux_money, MONEY_EURO_PAPER_50E);
	  money_widget_add(tux_money, MONEY_EURO_PAPER_20E);
	  money_widget_add(tux_money, MONEY_EURO_PAPER_10E);
	  money_widget_add(tux_money, MONEY_EURO_COIN_2E);
	  money_widget_add(tux_money, MONEY_EURO_COIN_1E);
	  money_widget_add(tux_money, MONEY_EURO_COIN_2E);
	  money_widget_add(tux_money, MONEY_EURO_PAPER_10E);
	  money_widget_add(tux_money, MONEY_EURO_PAPER_5E);
	  money_widget_add(tux_money, MONEY_EURO_COIN_1E);
	  money_widget_add(tux_money, MONEY_EURO_COIN_1E);
	  break;
	case 9:
	  number_of_item = 4;
	  min_price      = 4;
	  max_price      = 99;
	  paid		 = 100;
	  money_widget_add(tux_money, MONEY_EURO_PAPER_10E);
	  money_widget_add(tux_money, MONEY_EURO_COIN_2E);
	  money_widget_add(tux_money, MONEY_EURO_PAPER_5E);
	  money_widget_add(tux_money, MONEY_EURO_COIN_1E);
	  money_widget_add(tux_money, MONEY_EURO_COIN_1E);
	  money_widget_add(tux_money, MONEY_EURO_COIN_2E);
	  money_widget_add(tux_money, MONEY_EURO_PAPER_50E);
	  money_widget_add(tux_money, MONEY_EURO_PAPER_20E);
	  money_widget_add(tux_money, MONEY_EURO_PAPER_5E);
	  money_widget_add(tux_money, MONEY_EURO_PAPER_5E);
	  break;
	}
      break;
    case BACK_WITH_CENTS:
      switch(gcomprisBoard->level)
	{
	case 1:
	  number_of_item = 1;
	  min_price      = 1;
	  max_price      = 3;
	  paid		 = 5;
	  money_widget_add(tux_money, MONEY_EURO_COIN_2E);
	  money_widget_add(tux_money, MONEY_EURO_COIN_1E);
	  money_widget_add(tux_money, MONEY_EURO_COIN_5C);
	  money_widget_add(tux_money, MONEY_EURO_COIN_2C);
	  money_widget_add(tux_money, MONEY_EURO_COIN_20C);
	  money_widget_add(tux_money, MONEY_EURO_COIN_50C);
	  money_widget_add(tux_money, MONEY_EURO_COIN_20C);
	  money_widget_add(tux_money, MONEY_EURO_COIN_10C);
	  money_widget_add(tux_money, MONEY_EURO_COIN_1C);
	  money_widget_add(tux_money, MONEY_EURO_COIN_1C);
	  break;
	case 2:
	  number_of_item = 1;
	  min_price      = 1;
	  max_price      = 3;
	  paid		 = 5;
	  money_widget_add(tux_money, MONEY_EURO_COIN_2E);
	  money_widget_add(tux_money, MONEY_EURO_COIN_1E);
	  money_widget_add(tux_money, MONEY_EURO_COIN_5C);
	  money_widget_add(tux_money, MONEY_EURO_COIN_2C);
	  money_widget_add(tux_money, MONEY_EURO_COIN_20C);
	  money_widget_add(tux_money, MONEY_EURO_COIN_50C);
	  money_widget_add(tux_money, MONEY_EURO_COIN_20C);
	  money_widget_add(tux_money, MONEY_EURO_COIN_10C);
	  money_widget_add(tux_money, MONEY_EURO_COIN_1C);
	  money_widget_add(tux_money, MONEY_EURO_COIN_1C);
	  break;
	case 3:
	  number_of_item = 2;
	  min_price      = 1;
	  max_price      = 3;
	  paid		 = 5;
	  money_widget_add(tux_money, MONEY_EURO_COIN_2E);
	  money_widget_add(tux_money, MONEY_EURO_COIN_1E);
	  money_widget_add(tux_money, MONEY_EURO_COIN_5C);
	  money_widget_add(tux_money, MONEY_EURO_COIN_2C);
	  money_widget_add(tux_money, MONEY_EURO_COIN_20C);
	  money_widget_add(tux_money, MONEY_EURO_COIN_50C);
	  money_widget_add(tux_money, MONEY_EURO_COIN_20C);
	  money_widget_add(tux_money, MONEY_EURO_COIN_10C);
	  money_widget_add(tux_money, MONEY_EURO_COIN_1C);
	  money_widget_add(tux_money, MONEY_EURO_COIN_1C);
	  break;
	case 4:
	  number_of_item = 3;
	  min_price      = 1;
	  max_price      = 3;
	  paid		 = 5;
	  money_widget_add(tux_money, MONEY_EURO_COIN_2E);
	  money_widget_add(tux_money, MONEY_EURO_COIN_1E);
	  money_widget_add(tux_money, MONEY_EURO_COIN_5C);
	  money_widget_add(tux_money, MONEY_EURO_COIN_2C);
	  money_widget_add(tux_money, MONEY_EURO_COIN_20C);
	  money_widget_add(tux_money, MONEY_EURO_COIN_50C);
	  money_widget_add(tux_money, MONEY_EURO_COIN_20C);
	  money_widget_add(tux_money, MONEY_EURO_COIN_10C);
	  money_widget_add(tux_money, MONEY_EURO_COIN_1C);
	  money_widget_add(tux_money, MONEY_EURO_COIN_1C);
	  break;
	case 5:
	  number_of_item = 4;
	  min_price      = 0;
	  max_price      = 4;
	  paid		 = 5;
	  money_widget_add(tux_money, MONEY_EURO_COIN_2E);
	  money_widget_add(tux_money, MONEY_EURO_COIN_1E);
	  money_widget_add(tux_money, MONEY_EURO_COIN_5C);
	  money_widget_add(tux_money, MONEY_EURO_COIN_2C);
	  money_widget_add(tux_money, MONEY_EURO_COIN_20C);
	  money_widget_add(tux_money, MONEY_EURO_COIN_50C);
	  money_widget_add(tux_money, MONEY_EURO_COIN_20C);
	  money_widget_add(tux_money, MONEY_EURO_COIN_10C);
	  money_widget_add(tux_money, MONEY_EURO_COIN_1C);
	  money_widget_add(tux_money, MONEY_EURO_COIN_1C);
	  break;
	}
      break;
    }

  seller_money = MONEY_WIDGET(money_widget_new());
  money_widget_set_position(seller_money,
			    boardRootItem,
			    100.0,  20.0,
			    700.0, 130.0,
			    5, 2,
			    FALSE);

  money_widget_set_target(seller_money, tux_money);
  money_widget_set_target(tux_money, seller_money);

  /* Display what to buy */
  price_target = 0;
  for(i=1; i<=number_of_item; i++)
  {
    gdouble object_price;
    gchar *text;
    GooCanvasItem *item;
    RsvgHandle *svg_handle;
    RsvgDimensionData dimension;
    double xratio, yratio;
    guint offset_x = 50;
    guint boardwidth = BOARDWIDTH - offset_x * 2;

    /* Display the price */
    object_price  = (double) g_random_int_range(min_price/number_of_item,
						max_price/number_of_item);

    {
      /* Select an image list depending on the price */
      gchar **imageList;
      guint number_of_images;
      if ( object_price < 5 )
	{
	  imageList = imageList1;
	  number_of_images = NUMBER_OF_IMAGES1;
	}
      else if ( object_price < 10 )
	{
	  imageList = imageList2;
	  number_of_images = NUMBER_OF_IMAGES2;
	}
      else
	{
	  imageList = imageList3;
	  number_of_images = NUMBER_OF_IMAGES3;
	}

      svg_handle =							\
	gc_rsvg_load(imageList[g_random_int_range(0, number_of_images - 1)]);

      rsvg_handle_get_dimensions(svg_handle, &dimension);

      item = goo_canvas_svg_new ( boardRootItem,
				  svg_handle,
				  NULL);
    }
    xratio =  (gdouble)(boardwidth/(number_of_item+1)) / dimension.width;
    yratio =  100.0 / dimension.height;

    xratio = yratio = MIN(xratio, yratio);
    goo_canvas_item_translate(item,
			      offset_x +
			      (i*boardwidth)/(number_of_item+1)
    			      - dimension.width*xratio/2,
    			      200);

    goo_canvas_item_scale(item, xratio, xratio);

    if( (currentMode == WITH_CENTS) ||
	(currentMode == BACK_WITH_CENTS) )
      {
	/* Set here the way to display money. Change only the money sign, and it's place, always keep %.2f, it will be replaced by 0,34 if decimal is ',' in your locale */
	display_format = _("$ %.2f");
	/* Add random cents */
	if(gcomprisBoard->level == 1)
	  {
	    object_price += (double)((double) g_random_int_range(1, 9))/10.0;
	  }
	else
	  {
	    object_price += (double)((double) g_random_int_range(1, 99))/100.0;
	  }
      }
    else
      {
	/* Set here the way to display money. Change only the money sign, and it's place, always keep %.2f, it will be replaced by 0,34 if decimal is ',' in your locale */
	display_format = _("$ %.0f");
      }

    price_target += object_price;
    text = g_strdup_printf(display_format, object_price);
    goo_canvas_text_new(boardRootItem,
			text,
			offset_x + (i*boardwidth)/(number_of_item+1),
			185,
			-1,
			GTK_ANCHOR_CENTER,
			"font", gc_skin_font_board_big,
			"fill-color", "white",
			NULL);
    g_free(text);
    g_object_unref(svg_handle);
  }

  if (paid)
    {
      // Calc the money back instead of the objects price
      price_target = paid - price_target;
      // Display Tux and his money
      display_paying_tux(paid);
    }
}
Exemplo n.º 16
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);

    }

}