Commit 89c3c40f authored by Bruno Coudoin's avatar Bruno Coudoin

fixed crane to work again

now menu set back the back to its original position so
that activities don't have to manage this.


svn path=/branches/gcomprixogoo/; revision=3506
parent b6a93a6c
......@@ -221,6 +221,10 @@ static void menu_start (GcomprisBoard *agcomprisBoard)
gc_bar_set(GC_BAR_CONFIG|GC_BAR_ABOUT);
gc_bar_set_level(gcomprisBoard);
/* Set back the bar to it's original location */
gc_bar_location (-1, -1, -1);
menuitems = g_new(MenuItems, 1);
img = gc_skin_image_get("gcompris-menu2bg.png");
......
......@@ -408,7 +408,8 @@ static void game_won()
listColors = g_list_remove(listColors, g_list_nth_data(listColors,0));
if( g_list_length(listColors) <= 0 ) { // the current board is finished : bail out
if( g_list_length(listColors) <= 0 )
{ // the current board is finished : restart it
gc_bonus_end_display(GC_BOARD_FINISHED_TUXLOCO);
return;
}
......
......@@ -102,7 +102,6 @@ static GooCanvasItem *selected_item = NULL;
static GooCanvasItem *red_hands = NULL;
static GooCanvasItem *crane_rope_item = NULL;
static gint timer_id = 0;
static gint nb_move = 0;
static gboolean moving = FALSE;
static move_object my_move;
static int list_answer[CRANE_FRAME_LINE * CRANE_FRAME_COLUMN];
......@@ -199,7 +198,6 @@ static void start_board (GcomprisBoard *agcomprisBoard)
{
if (agcomprisBoard != NULL) {
gchar *img;
gcomprisBoard = agcomprisBoard;
gcomprisBoard->level = 1;
......@@ -207,11 +205,10 @@ static void start_board (GcomprisBoard *agcomprisBoard)
gcomprisBoard->sublevel = 1;
gcomprisBoard->number_of_sublevel = 1; /* Go to next level after this number of 'play' */
gc_bar_set(GC_BAR_LEVEL);
gc_bar_location (BOARDWIDTH-BARWIDTH/2, -1, 0.5);
img = gc_skin_image_get("gcompris-bg.jpg");
gc_set_background(goo_canvas_get_root_item(gcomprisBoard->canvas),
img);
g_free(img);
"crane/crane-bg.svgz");
/* disable im_context */
......@@ -342,20 +339,11 @@ static GooCanvasItem *crane_create_item()
{
int i;
int nb_element;
GdkPixbuf *pixmap;
boardRootItem = \
goo_canvas_group_new (goo_canvas_get_root_item(gcomprisBoard->canvas),
NULL);
pixmap = gc_pixmap_load("crane/crane-bg.png");
goo_canvas_image_new (boardRootItem,
pixmap,
0.0,
0.0,
NULL);
gdk_pixbuf_unref(pixmap);
// The four arrows on the crane
draw_arrow();
......@@ -698,10 +686,13 @@ static void place_item(int x, int y, int active) {
}
static guint smooth_move(move_object *move) {
static guint smooth_move(move_object *move)
{
static gint nb_move = 0;
GooCanvasBounds bounds;
int speed = 4;
if (nb_move == 0) {
if (nb_move <= 0) {
moving = TRUE;
nb_move = move->nb;
}
......@@ -716,11 +707,13 @@ static guint smooth_move(move_object *move) {
"points", crane_rope,
NULL);
goo_canvas_item_translate(selected_item, move->x, move->y);
goo_canvas_item_translate(red_hands, move->x, move->y);
nb_move--;
goo_canvas_item_translate(selected_item,
move->x * speed, move->y * speed);
goo_canvas_item_translate(red_hands,
move->x * speed, move->y * speed);
nb_move -= speed;
if (nb_move == 0) {
if (nb_move <= 0) {
moving = FALSE;
return FALSE;
}
......
......@@ -9,7 +9,7 @@ img_DATA = \
arrow_u.png \
arrow_up.png \
bulb.png \
crane-bg.png \
crane-bg.svgz \
letter-a.png \
letter-b.png \
rectangle1.png \
......
......@@ -74,6 +74,10 @@ static gboolean _barup; /* The state of the bar */
static gboolean _click_mode; /* Need to click on the bar to
bring it up or just enter it */
/* Default position for the bar */
static int _default_x;
static int _default_y;
static int _default_zoom;
static void confirm_quit(gboolean answer);
......@@ -92,23 +96,26 @@ void gc_bar_start (GooCanvas *theCanvas)
{
GcomprisProperties *properties = gc_prop_get();
GdkPixbuf *pixmap = NULL;
gint16 width, height, startx;
gint16 width, height;
gint16 buttony;
double zoom;
width = BOARDWIDTH/2;
width = BARWIDTH;
height = BARHEIGHT-2;
startx = width / 2;
_default_x = width / 2;
_default_y = BOARDHEIGHT - BARHEIGHT;
_default_zoom = 1.0;
bar_reset_sound_id();
rootitem = goo_canvas_group_new (goo_canvas_get_root_item(theCanvas), NULL);
goo_canvas_item_translate(rootitem, 0, BOARDHEIGHT - BARHEIGHT);
goo_canvas_item_translate(rootitem, _default_x, _default_y);
pixmap = gc_skin_pixmap_load("bar_bg.png");
bar_item = goo_canvas_image_new (rootitem,
pixmap,
startx,
0,
0,
NULL);
setup_item_signals(bar_item, "bar");
......@@ -123,7 +130,7 @@ void gc_bar_start (GooCanvas *theCanvas)
pixmap = gc_skin_pixmap_load("button_exit.png");
exit_item = goo_canvas_image_new (rootitem,
pixmap,
startx + (width/NUMBER_OF_ITEMS) * 0,
(width/NUMBER_OF_ITEMS) * 0,
buttony,
NULL);
gdk_pixbuf_unref(pixmap);
......@@ -136,7 +143,7 @@ void gc_bar_start (GooCanvas *theCanvas)
zoom = (double)(height-BAR_GAP)/(double)gdk_pixbuf_get_height(pixmap);
home_item = goo_canvas_image_new (rootitem,
pixmap,
startx + (width/NUMBER_OF_ITEMS) * 4,
(width/NUMBER_OF_ITEMS) * 4,
buttony,
NULL);
gdk_pixbuf_unref(pixmap);
......@@ -149,7 +156,7 @@ void gc_bar_start (GooCanvas *theCanvas)
zoom = (double)(height-BAR_GAP)/(double)gdk_pixbuf_get_height(pixmap);
level_item = goo_canvas_image_new (rootitem,
pixmap,
startx + (width/NUMBER_OF_ITEMS) * 3,
(width/NUMBER_OF_ITEMS) * 3,
buttony,
NULL);
gdk_pixbuf_unref(pixmap);
......@@ -163,7 +170,7 @@ void gc_bar_start (GooCanvas *theCanvas)
zoom = (double)(height-BAR_GAP)/(double)gdk_pixbuf_get_height(pixmap);
repeat_item = goo_canvas_image_new (rootitem,
pixmap,
startx + (width/NUMBER_OF_ITEMS) * 0,
(width/NUMBER_OF_ITEMS) * 0,
buttony,
NULL);
gdk_pixbuf_unref(pixmap);
......@@ -176,7 +183,7 @@ void gc_bar_start (GooCanvas *theCanvas)
zoom = (double)(height-BAR_GAP)/(double)gdk_pixbuf_get_height(pixmap);
help_item = goo_canvas_image_new (rootitem,
pixmap,
startx + (width/NUMBER_OF_ITEMS) * 1,
(width/NUMBER_OF_ITEMS) * 1,
buttony,
NULL);
gdk_pixbuf_unref(pixmap);
......@@ -190,7 +197,7 @@ void gc_bar_start (GooCanvas *theCanvas)
zoom = (double)(height-BAR_GAP)/(double)gdk_pixbuf_get_height(pixmap);
config_item = goo_canvas_image_new (rootitem,
pixmap,
startx + (width/NUMBER_OF_ITEMS) * 2,
(width/NUMBER_OF_ITEMS) * 2,
buttony,
NULL);
gdk_pixbuf_unref(pixmap);
......@@ -203,7 +210,7 @@ void gc_bar_start (GooCanvas *theCanvas)
zoom = (double)(height-BAR_GAP)/(double)gdk_pixbuf_get_height(pixmap);
about_item = goo_canvas_image_new (rootitem,
pixmap,
startx + (width/NUMBER_OF_ITEMS) * 3,
(width/NUMBER_OF_ITEMS) * 3,
buttony,
NULL);
gdk_pixbuf_unref(pixmap);
......@@ -293,6 +300,24 @@ gc_bar_set_repeat_icon (GdkPixbuf *pixmap)
NULL);
}
/** Setting the bar location
* @param[in] x the bar x coordinate, -1 to set the default
* @param[in] y the bar x coordinate, -1 to set the default
* @param[in] zoom the bar zoom factor, -1 to set the default
*/
void
gc_bar_location (int x, int y, double zoom)
{
goo_canvas_item_set_transform(rootitem, NULL);
goo_canvas_item_translate(rootitem,
(x == -1 ? _default_x : x),
(y == -1 ? _default_y : y));
goo_canvas_item_scale(rootitem,
(zoom == -1 ? _default_zoom : zoom),
(zoom == -1 ? _default_zoom : zoom));
}
/* Setting list of available icons in the control bar */
void
gc_bar_set (const GComprisBarFlags flags)
......
......@@ -65,6 +65,7 @@
#define BOARDWIDTH 800
#define BOARDHEIGHT 520
#define BARHEIGHT 40
#define BARWIDTH (BOARDWIDTH/2)
#define DEFAULT_SKIN "gartoon"
......@@ -108,6 +109,7 @@ typedef enum {
void gc_bar_set (const GComprisBarFlags flags);
void gc_bar_hide (gboolean hide);
void gc_bar_location (int x, int y, double zoom);
/* General */
GooCanvas *gc_get_canvas(void);
......
imgdir = $(pkgdatadir)/@PACKAGE_DATA_DIR@/superbrain
img_DATA = \
superbrain_background.jpg
superbrain_background.svgz
EXTRA_DIST = $(img_DATA)
......@@ -165,6 +165,7 @@ static void start_board (GcomprisBoard *agcomprisBoard)
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");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment