~ubuntu-branches/ubuntu/trusty/gcompris/trusty

« back to all changes in this revision

Viewing changes to src/boards/money.c

  • Committer: Bazaar Package Importer
  • Author(s): Yann Dirson
  • Date: 2006-12-15 23:08:17 UTC
  • mfrom: (1.1.4 upstream)
  • Revision ID: james.westby@ubuntu.com-20061215230817-exr5ks1hd73s3tlk
Tags: 8.2.2-1
* New upstream bugfix release, fixes among other things the support for
  the version of gnucap shipped in etch.
* Add missing dependency on python-gtk2 (Closes: #396523).
* Removed reference to non-existent sound file from memory.c (upstream
  fix - impacts 8.2 as well).  
* Now suggests gnuchess, gnucap, and tuxpaint.
* Updated extended description for the main package.

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
 *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
18
18
 */
19
19
 
20
 
#include <ctype.h>
21
 
#include <math.h>
22
 
#include <assert.h>
23
 
 
24
20
#include "gcompris/gcompris.h"
25
21
#include "money_widget.h"
26
22
 
84
80
  {
85
81
    NULL,
86
82
    NULL,
87
 
    N_("Money"),
88
 
    N_("Pratice money usage"),
 
83
    "Money",
 
84
    "Pratise money usage",
89
85
    "Bruno Coudoin <bruno.coudoin@free.fr>",
90
86
    NULL,
91
87
    NULL,
99
95
    process_ok,
100
96
    set_level,
101
97
    NULL,
 
98
    NULL,
 
99
    NULL,
102
100
    NULL
103
101
  };
104
102
 
108
106
 *
109
107
 */
110
108
 
111
 
BoardPlugin
112
 
*get_bplugin_info(void)
113
 
{
114
 
  return &menu_bp;
115
 
}
 
109
GET_BPLUGIN_INFO(money)
116
110
 
117
111
/*
118
112
 * in : boolean TRUE = PAUSE : FALSE = CONTINUE
142
136
      gcomprisBoard->level=1;
143
137
      gcomprisBoard->sublevel=1;
144
138
      gcomprisBoard->number_of_sublevel=10; /* Go to next level after this number of 'play' */
145
 
      gcompris_bar_set(GCOMPRIS_BAR_LEVEL|GCOMPRIS_BAR_OK);
 
139
      gc_bar_set(GC_BAR_LEVEL|GC_BAR_OK);
146
140
 
147
141
      /* Default mode */
148
142
      if(!gcomprisBoard->mode)
204
198
/* set initial values for the next level */
205
199
static void money_next_level()
206
200
{
207
 
  GnomeCanvasItem *item = NULL;
208
201
  GdkPixbuf       *pixmap = NULL;
209
 
  guint            min_price, max_price;
210
 
  guint            number_of_item;
 
202
  guint            min_price = 0, max_price = 0;
 
203
  guint            number_of_item = 0;
211
204
  guint            i;
212
205
  gchar           *display_format;
213
 
 
214
 
  gcompris_set_background(gnome_canvas_root(gcomprisBoard->canvas),
215
 
                          "money/money-bg.png");
216
 
 
217
 
  gcompris_bar_set_level(gcomprisBoard);
 
206
  gchar           *img;
 
207
 
 
208
  img = gc_skin_image_get("money-bg.png");
 
209
  gc_set_background(gnome_canvas_root(gcomprisBoard->canvas),
 
210
                          img);
 
211
  g_free(img);
 
212
 
 
213
  gc_bar_set_level(gcomprisBoard);
218
214
 
219
215
  money_destroy_all_items();
220
216
  gamewon = FALSE;
266
262
          money_widget_add(tux_money, MONEY_EURO_COIN_1E);
267
263
          money_widget_add(tux_money, MONEY_EURO_COIN_1E);
268
264
          break;
269
 
        case 3: 
 
265
        case 3:
270
266
          number_of_item = 2;
271
267
          min_price      = 20;
272
268
          max_price      = 30;
471
467
  for(i=1; i<=number_of_item; i++)
472
468
  {
473
469
    double object_price;
 
470
    gchar *text;
474
471
 
475
 
    pixmap = gcompris_load_pixmap(imageList[RAND(0, NUMBER_OF_IMAGES-1)]);
 
472
    pixmap = gc_pixmap_load(imageList[RAND(0, NUMBER_OF_IMAGES-1)]);
476
473
 
477
474
    gnome_canvas_item_new ( boardRootItem,
478
475
                            gnome_canvas_pixbuf_get_type (),
479
476
                            "pixbuf", pixmap,
480
 
                            "x", (double) (i*BOARDWIDTH)/(number_of_item+1) 
 
477
                            "x", (double) (i*BOARDWIDTH)/(number_of_item+1)
481
478
                            - gdk_pixbuf_get_width(pixmap)/2,
482
479
                            "y", (double) 200,
483
480
                            NULL);
484
 
    
 
481
 
485
482
    /* Diplay the price */
486
483
    object_price  = (double) RAND(min_price/number_of_item, max_price/number_of_item);
487
484
 
488
485
    if(currentMode==WITH_CENTS)
489
486
      {
490
 
        display_format = "%.2f €";
 
487
        /* 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 */
 
488
        display_format = _("$ %.2f");
491
489
        /* Add random cents */
492
490
        if(gcomprisBoard->level == 1)
493
491
          {
500
498
      }
501
499
    else
502
500
      {
503
 
        display_format = "%.0f €";
 
501
        display_format = _("$ %.0f");
504
502
      }
505
503
 
506
504
    price_target += object_price;
 
505
    text = g_strdup_printf(display_format, object_price);
507
506
    gnome_canvas_item_new(boardRootItem,
508
507
                          gnome_canvas_text_get_type (),
509
 
                          "text", g_strdup_printf(display_format, object_price),
510
 
                          "font", gcompris_skin_font_board_big,
 
508
                          "text", text,
 
509
                          "font", gc_skin_font_board_big,
511
510
                          "x", (double) (i*BOARDWIDTH)/(number_of_item+1),
512
511
                          "y", (double) 180,
513
512
                          "anchor", GTK_ANCHOR_CENTER,
514
513
                          "fill_color", "white",
515
514
                          NULL);
516
 
    
 
515
    g_free(text);
517
516
    gdk_pixbuf_unref(pixmap);
518
517
  }
519
518
 
546
545
    gcomprisBoard->sublevel=1;
547
546
    gcomprisBoard->level++;
548
547
    if(gcomprisBoard->level>gcomprisBoard->maxlevel) { // the current board is finished : bail out
549
 
      board_finished(BOARD_FINISHED_RANDOM);
 
548
      gc_bonus_end_display(BOARD_FINISHED_RANDOM);
550
549
      return;
551
550
    }
552
 
    gcompris_play_ogg ("bonus", NULL);
 
551
    gc_sound_play_ogg ("sounds/bonus.ogg", NULL);
553
552
  }
554
553
  money_next_level();
555
554
}
567
566
    {
568
567
      gamewon = TRUE;
569
568
      money_destroy_all_items();
570
 
      gcompris_display_bonus(gamewon, BONUS_SMILEY);
 
569
      gc_bonus_display(gamewon, BONUS_SMILEY);
571
570
    }
572
571
  else
573
 
    gcompris_display_bonus(gamewon, BONUS_SMILEY);
 
572
    gc_bonus_display(gamewon, BONUS_SMILEY);
574
573
}