gcompris r3478 - in branches/gcomprixogoo: boards/dataset boards/skins/babytoy boards/skins/gartoon src/algebra_by-activity src/anim-activity src/enumerate-activity src/gcompris src/magic_hat_minus-activity src/money-activity src/reversecount-activity src/superbrain-activity src/target-activity
- From: bcoudoin svn gnome org
- To: svn-commits-list gnome org
- Subject: gcompris r3478 - in branches/gcomprixogoo: boards/dataset boards/skins/babytoy boards/skins/gartoon src/algebra_by-activity src/anim-activity src/enumerate-activity src/gcompris src/magic_hat_minus-activity src/money-activity src/reversecount-activity src/superbrain-activity src/target-activity
- Date: Sun, 3 Aug 2008 22:17:00 +0000 (UTC)
Author: bcoudoin
Date: Sun Aug 3 22:17:00 2008
New Revision: 3478
URL: http://svn.gnome.org/viewvc/gcompris?rev=3478&view=rev
Log:
now the control bar is shorter. The ok button is deprecated.
Each activity mist either detect the sucess case itself automatically
of include it's own ok button.
Ported some activities, but there are seaveral left.
Modified:
branches/gcomprixogoo/boards/dataset/misc.xml
branches/gcomprixogoo/boards/skins/babytoy/bar_bg.png
branches/gcomprixogoo/boards/skins/gartoon/bar_bg.png
branches/gcomprixogoo/src/algebra_by-activity/algebra.c
branches/gcomprixogoo/src/anim-activity/AnimItem.py
branches/gcomprixogoo/src/anim-activity/anim.py
branches/gcomprixogoo/src/enumerate-activity/enumerate.c
branches/gcomprixogoo/src/gcompris/bar.c
branches/gcomprixogoo/src/gcompris/gameutil.c
branches/gcomprixogoo/src/gcompris/gameutil.h
branches/gcomprixogoo/src/magic_hat_minus-activity/magic_hat.c
branches/gcomprixogoo/src/money-activity/money.c
branches/gcomprixogoo/src/money-activity/money_widget.c
branches/gcomprixogoo/src/reversecount-activity/reversecount.c
branches/gcomprixogoo/src/superbrain-activity/superbrain.c
branches/gcomprixogoo/src/target-activity/target.c
Modified: branches/gcomprixogoo/boards/dataset/misc.xml
==============================================================================
--- branches/gcomprixogoo/boards/dataset/misc.xml (original)
+++ branches/gcomprixogoo/boards/dataset/misc.xml Sun Aug 3 22:17:00 2008
@@ -11,8 +11,8 @@
<Image filename="babymatch/sailingboat.png"/>
<Image filename="babymatch/fusee.png"/>
<Image filename="babymatch/tuxhelico.png"/>
- <Image filename="babymatch/tuxballoon.png"/>
- <Image filename="babymatch/tuxloco.png"/>
+ <Image filename="skins/gartoon/timers/tuxballoon.png"/>
+ <Image filename="skins/gartoon/tuxloco.png"/>
<Image filename="babymatch/tuxplane.png"/>
<Image filename="imageid/avion.png"/>
<Image filename="railroad/loco5.png"/>
@@ -38,8 +38,8 @@
<Image filename="railroad/loco4.png"/>
<Image filename="railroad/wagon13.png"/>
<Image filename="railroad/wagon6.png"/>
- <Image filename="images/wagon-green.png"/>
- <Image filename="images/wagon-yellow.png"/>
+ <Image filename="click_on_letter/wagon-green.png"/>
+ <Image filename="click_on_letter/wagon-yellow.png"/>
<Image filename="chronos/helico_cornu.png"/>
<Image filename="chronos/wright_flyer.png"/>
<Image filename="chronos/lindbergh.png"/>
@@ -82,16 +82,16 @@
<Image filename="imageid/bottle.png"/>
</ImageSet>
<ImageSet filename="babymatch/tree.png">
- <Image filename="babymatch/cocotier.png"/>
- <Image filename="babymatch/cloud.png"/>
+ <Image filename="imagename/cocotier.png"/>
+ <Image filename="watercycle/cloud.png"/>
<Image filename="babymatch/star.png"/>
<Image filename="babymatch/egg.png"/>
<Image filename="babymatch/flower.png"/>
- <Image filename="babymatch/sapin.png"/>
+ <Image filename="imagename/sapin.png"/>
<Image filename="babymatch/tree.png"/>
<Image filename="imageid/chien.png"/>
<Image filename="imageid/fish.png"/>
- <Image filename="images/water_spot.png"/>
+ <Image filename="followline/water_spot.png"/>
</ImageSet>
<ImageSet filename="gcompris/food/grapefruit.png">
<Image filename="babymatch/apple.png"/>
@@ -124,16 +124,16 @@
<Image filename="babymatch/tuxboat.png"/>
<Image filename="babymatch/sailingboat.png"/>
<Image filename="babymatch/tuxhelico.png"/>
- <Image filename="babymatch/tuxballoon.png"/>
+ <Image filename="skins/gartoon/timers/tuxballoon.png"/>
<Image filename="babymatch/tuxloco.png"/>
<Image filename="babymatch/tuxplane.png"/>
<Image filename="babymatch/Tux_mute.png"/>
<Image filename="babymatch/Tux_play.png"/>
<Image filename="babymatch/tux_top_north.png"/>
<Image filename="babymatch/tux_top_south.png"/>
- <Image filename="images/tux_albert.png"/>
- <Image filename="images/tux_graduate.png"/>
- <Image filename="images/tux-teacher.png"/>
- <Image filename="images/tux_teen.png"/>
+ <Image filename="bargame/tux_albert.png"/>
+ <Image filename="bargame/tux_graduate.png"/>
+ <Image filename="bargame/tux-teacher.png"/>
+ <Image filename="bargame/tux_teen.png"/>
</ImageSet>
</ImageSetRoot>
Modified: branches/gcomprixogoo/boards/skins/babytoy/bar_bg.png
==============================================================================
Binary files. No diff available.
Modified: branches/gcomprixogoo/boards/skins/gartoon/bar_bg.png
==============================================================================
Binary files. No diff available.
Modified: branches/gcomprixogoo/src/algebra_by-activity/algebra.c
==============================================================================
--- branches/gcomprixogoo/src/algebra_by-activity/algebra.c (original)
+++ branches/gcomprixogoo/src/algebra_by-activity/algebra.c Sun Aug 3 22:17:00 2008
@@ -80,6 +80,7 @@
static gboolean is_our_board (GcomprisBoard *gcomprisBoard);
static void set_level (guint level);
static gint key_press(guint keyval, gchar *commit_str, gchar *preedit_str);
+static gboolean solution_found();
static void process_ok(void);
static GooCanvasItem *algebra_create_item(GooCanvasItem *parent);
@@ -116,7 +117,7 @@
end_board,
is_our_board,
key_press,
- process_ok,
+ NULL,
set_level,
NULL,
NULL,
@@ -177,7 +178,7 @@
BOARDWIDTH - 220,
BOARDHEIGHT - 50,
gcomprisBoard->number_of_sublevel);
- gc_bar_set(GC_BAR_LEVEL|GC_BAR_OK);
+ gc_bar_set(GC_BAR_LEVEL);
/* TRANSLATORS: Put here the mathematical operators '+-x/' for your language. */
operators=_("+-ÃÃ");
@@ -352,6 +353,9 @@
}
set_focus_item(currentToBeFoundItem, TRUE);
+
+ if(solution_found())
+ game_won();
}
return TRUE;
}
@@ -676,13 +680,36 @@
}
}
+static gboolean solution_found()
+{
+ ToBeFoundItem *firstToBeFoundItem = currentToBeFoundItem;
+ ToBeFoundItem *toBeFoundItem;
+
+ /* Go to the leftmost digit */
+ while(firstToBeFoundItem->previous!=NULL)
+ firstToBeFoundItem = firstToBeFoundItem->previous;
+
+ toBeFoundItem = firstToBeFoundItem;
+
+ /* Check the numbers one by one */
+ while(firstToBeFoundItem != NULL)
+ {
+ if(firstToBeFoundItem->value != expected_result[firstToBeFoundItem->index])
+ return FALSE;
+
+ firstToBeFoundItem = firstToBeFoundItem->next;
+ }
+
+ return TRUE;
+}
+
static void process_ok()
{
ToBeFoundItem *toBeFoundItem;
ToBeFoundItem *hasfail=NULL;
set_focus_item(currentToBeFoundItem, FALSE);
- /* Go to the rightmost digit */
+ /* Go to the leftmost digit */
while(currentToBeFoundItem->previous!=NULL)
{
currentToBeFoundItem=(ToBeFoundItem *)currentToBeFoundItem->previous;
Modified: branches/gcomprixogoo/src/anim-activity/AnimItem.py
==============================================================================
--- branches/gcomprixogoo/src/anim-activity/AnimItem.py (original)
+++ branches/gcomprixogoo/src/anim-activity/AnimItem.py Sun Aug 3 22:17:00 2008
@@ -248,16 +248,15 @@
self.anchor.hide()
- def create_item_event(self, item, target, event):
+ def create_item_event(self, item, target):
- if (event.type == gtk.gdk.BUTTON_RELEASE
- or event.type == gtk.gdk.BUTTON_PRESS):
- self.refpoint = None
- self.save_at_time(self.anim.timeline.get_time())
- # By default, an object is displayed till the timeline end
- self.set_visible_to_end(self.anim.timeline.get_time())
+ self.refpoint = None
+ self.save_at_time(self.anim.timeline.get_time())
+ # By default, an object is displayed till the timeline end
+ self.set_visible_to_end(self.anim.timeline.get_time())
- elif (event.type == gtk.gdk.MOTION_NOTIFY
+ def create_item_drag_event(self, item, target, event):
+ if (event.type == gtk.gdk.MOTION_NOTIFY
and event.state & gtk.gdk.BUTTON1_MASK):
if not self.refpoint:
@@ -779,3 +778,72 @@
gcompris.sound.play_ogg("sounds/paint1.wav")
self.item.set_properties(stroke_color_rgba = stroke)
+#
+# The Pixmap
+#
+class AnimItemPixmap(AnimItem):
+
+
+ def __init__(self, anim, x, y, pixbuf):
+ AnimItem.__init__(self, anim)
+ x, y = self.snap_to_grid(x, y)
+
+ self.item = \
+ goocanvas.Image(
+ parent = self.rootitem,
+ pixbuf = pixbuf,
+ x = x,
+ y = y)
+
+ self.item.set_data("AnimItem", self)
+ self.item.connect("button_press_event", anim.item_event)
+ self.item.connect("button_release_event", anim.item_event)
+ self.item.connect("motion_notify_event", anim.item_event)
+
+ self.sx = self.sy = 1.0
+
+ def set_bounds(self, p1, p2):
+ (x1, y1, x2, y2) = self.snap_obj_to_grid(p1, p2)
+ bounds = self.item.get_bounds()
+ self.item.set_properties(x = x1,
+ y = y1,
+ width = abs(x2-x1),
+ height = abs(y2-y1) )
+# sx = (x2 - x1) / (bounds.x2 - bounds.x1)
+# sy = (y2 - y1) / (bounds.y2 - bounds.y1)
+# print "sx=%f sy=%f" %(self.sx * sx, self.sy * sy)
+# self.item.scale(2.0, 2.0)
+
+
+ def get_x1y1(self):
+ x = self.item.get_property("x")
+ y = self.item.get_property("y")
+ return(x, y)
+
+ def get_x2y1(self):
+ x = self.item.get_property("x") + self.item.get_property("width")
+ y = self.item.get_property("y")
+ return(x, y)
+
+ def get_x2y2(self):
+ x = self.item.get_property("x") + self.item.get_property("width")
+ y = self.item.get_property("y") + self.item.get_property("height")
+ return(x, y)
+
+ def get_x1y2(self):
+ x = self.item.get_property("x")
+ y = self.item.get_property("y") + self.item.get_property("height")
+ return(x, y)
+
+ # Return the list of properties that have to be saved for
+ # this object
+ def get_properties(self):
+ return('x',
+ 'y',
+ 'width',
+ 'height')
+
+ def fill(self, fill, stroke):
+ # Unsupported
+ pass
+
Modified: branches/gcomprixogoo/src/anim-activity/anim.py
==============================================================================
--- branches/gcomprixogoo/src/anim-activity/anim.py (original)
+++ branches/gcomprixogoo/src/anim-activity/anim.py Sun Aug 3 22:17:00 2008
@@ -194,7 +194,7 @@
self.gcomprisBoard.sublevel=0
self.gcomprisBoard.number_of_sublevel=0
- gcompris.bar_set(0)
+ gcompris.bar_set(255)
gcompris.set_background(self.gcomprisBoard.canvas.get_root_item(),
gcompris.skin.image_to_skin("gcompris-bg.jpg"))
@@ -717,8 +717,7 @@
if self.created_object:
self.created_object.create_item_event(item,
- target,
- event)
+ target)
# We keep all object in a unique list
self.animlist.append(self.created_object)
@@ -729,9 +728,9 @@
elif (event.type == gtk.gdk.MOTION_NOTIFY
and event.state & gtk.gdk.BUTTON1_MASK
and self.created_object):
- self.created_object.create_item_event(item,
- target,
- event)
+ self.created_object.create_item_drag_event(item,
+ target,
+ event)
elif (event.type == gtk.gdk.MOTION_NOTIFY
and event.state & gtk.gdk.BUTTON1_MASK
@@ -746,9 +745,9 @@
# ---------------
elif (event.type == gtk.gdk.BUTTON_RELEASE):
if self.created_object:
- self.created_object.create_item_event(item,
- target,
- event)
+ self.created_object.create_item_drag_event(item,
+ target,
+ event)
self.created_object = None
return True
else:
@@ -837,5 +836,18 @@
def image_selected(image):
#fles is used because self is not passed through callback
global fles
- print "image selected"
+ print "image selected %s" %(image,)
pixmap = gcompris.utils.load_pixmap(image)
+
+ # Always display the image at the center of the drawing area
+ cx = (fles.drawing_area[2] - fles.drawing_area[0]) / 2
+ cy = (fles.drawing_area[3] - fles.drawing_area[1]) / 2
+
+ fles.created_object = AnimItemPixmap(fles, cx, cy, pixmap)
+
+ if fles.created_object:
+ fles.created_object.create_item_event(fles.root_drawingitem,
+ fles.root_drawingitem)
+
+ # We keep all object in a unique list
+ fles.animlist.append(fles.created_object)
Modified: branches/gcomprixogoo/src/enumerate-activity/enumerate.c
==============================================================================
--- branches/gcomprixogoo/src/enumerate-activity/enumerate.c (original)
+++ branches/gcomprixogoo/src/enumerate-activity/enumerate.c Sun Aug 3 22:17:00 2008
@@ -33,6 +33,7 @@
static void pause_board (gboolean pause);
static void end_board (void);
static void process_ok(void);
+static gboolean solution_found();
static gboolean is_our_board (GcomprisBoard *gcomprisBoard);
static void set_level (guint level);
static int gamewon;
@@ -118,7 +119,7 @@
end_board,
is_our_board,
key_press,
- process_ok,
+ NULL,
set_level,
NULL,
NULL,
@@ -167,7 +168,7 @@
gcomprisBoard->maxlevel=9;
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_OK);
+ gc_bar_set(GC_BAR_LEVEL);
gc_set_background(goo_canvas_get_root_item(gcomprisBoard->canvas),
"enumerate/enumerate_background.png");
@@ -275,6 +276,12 @@
NULL);
g_free(oldtext);
+
+ if(solution_found())
+ {
+ gamewon = TRUE;
+ gc_bonus_display(gamewon, GC_BONUS_SMILEY);
+ }
}
return TRUE;
@@ -525,6 +532,17 @@
return FALSE;
}
+static gboolean solution_found()
+{
+ guint i;
+ for(i=0; i<number_of_item_type; i++)
+ {
+ if(answer[i] != answer_to_find[i])
+ return FALSE;
+ }
+ return TRUE;
+}
+
static void process_ok()
{
guint i;
Modified: branches/gcomprixogoo/src/gcompris/bar.c
==============================================================================
--- branches/gcomprixogoo/src/gcompris/bar.c (original)
+++ branches/gcomprixogoo/src/gcompris/bar.c Sun Aug 3 22:17:00 2008
@@ -30,8 +30,8 @@
#define SOUNDLISTFILE PACKAGE
-#define BAR_GAP 15 /* Value used to fill space above and under icons in the bar */
-#define NUMBER_OF_ITEMS 10 /* Number of buttons in the bar */
+#define BAR_GAP 10 /* Value used to fill space above and under icons in the bar */
+#define NUMBER_OF_ITEMS 5 /* Max Number of buttons in the bar */
#define HIDE_BAR_TIMOUT 3000 /* The time before we hide the bar in ms */
static void update_exit_button();
@@ -52,6 +52,8 @@
static gboolean _bar_down(void *ignore);
static void _bar_up(void);
static void _force_bar_down(void);
+static void _force_bar_up(char *data);
+static gint bar_play_sound (gchar *sound);
static gint current_level = -1;
static gint current_flags = -1;
@@ -68,11 +70,16 @@
static gint sound_play_id = 0;
static gint bar_down_id = 0;
-static gboolean _hidden;
+static gboolean _hidden; /* Dialog boxes request a bar hide */
+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 */
+
static void confirm_quit(gboolean answer);
/*
+
* Main entry point
* ----------------
*
@@ -86,11 +93,13 @@
{
GcomprisProperties *properties = gc_prop_get();
GdkPixbuf *pixmap = NULL;
- gint16 width, height;
- double zoom;
+ gint16 width, height, startx;
+ gint16 buttony;
+ double zoom;
- width = BOARDWIDTH;
+ width = BOARDWIDTH/2;
height = BARHEIGHT-2;
+ startx = width / 2;
bar_reset_sound_id();
@@ -100,23 +109,24 @@
pixmap = gc_skin_pixmap_load("bar_bg.png");
bar_item = goo_canvas_image_new (rootitem,
pixmap,
- 0,
+ startx,
0,
NULL);
setup_item_signals(bar_item, "bar");
gdk_pixbuf_unref(pixmap);
+ zoom = (double)(height-BAR_GAP)/(double)gdk_pixbuf_get_height(pixmap);
+ buttony = (height-gdk_pixbuf_get_height(pixmap)*zoom)/2;
+
// EXIT
if(properties->disable_quit == 0)
{
pixmap = gc_skin_pixmap_load("button_exit.png");
- zoom = (double)(height-BAR_GAP)/(double)gdk_pixbuf_get_height(pixmap);
exit_item = goo_canvas_image_new (rootitem,
pixmap,
- (width/NUMBER_OF_ITEMS) * 1 -
- gdk_pixbuf_get_width(pixmap)/2,
- (height-gdk_pixbuf_get_height(pixmap)*zoom)/2,
- NULL);
+ startx + (width/NUMBER_OF_ITEMS) * 0,
+ buttony,
+ NULL);
gdk_pixbuf_unref(pixmap);
setup_item_signals(exit_item, "quit");
@@ -127,9 +137,8 @@
zoom = (double)(height-BAR_GAP)/(double)gdk_pixbuf_get_height(pixmap);
home_item = goo_canvas_image_new (rootitem,
pixmap,
- (double) (width/NUMBER_OF_ITEMS) * 9 -
- gdk_pixbuf_get_width(pixmap)/2,
- (double) (height-gdk_pixbuf_get_height(pixmap)*zoom)/2,
+ startx + (width/NUMBER_OF_ITEMS) * 4,
+ buttony,
NULL);
gdk_pixbuf_unref(pixmap);
@@ -141,10 +150,9 @@
zoom = (double)(height-BAR_GAP)/(double)gdk_pixbuf_get_height(pixmap);
ok_item = goo_canvas_image_new (rootitem,
pixmap,
- (double) (width/NUMBER_OF_ITEMS) * 7 -
- gdk_pixbuf_get_width(pixmap)/2,
- (double) (height-gdk_pixbuf_get_height(pixmap)*zoom)/2,
- NULL);
+ startx + (width/NUMBER_OF_ITEMS) * 5,
+ buttony,
+ NULL);
gdk_pixbuf_unref(pixmap);
setup_item_signals(ok_item, "ok");
@@ -154,10 +162,9 @@
zoom = (double)(height-BAR_GAP)/(double)gdk_pixbuf_get_height(pixmap);
level_item = goo_canvas_image_new (rootitem,
pixmap,
- (double) (width/NUMBER_OF_ITEMS) * 5 -
- gdk_pixbuf_get_width(pixmap)/2,
- (double) (height-gdk_pixbuf_get_height(pixmap)*zoom)/2,
- NULL);
+ startx + (width/NUMBER_OF_ITEMS) * 3,
+ buttony,
+ NULL);
gdk_pixbuf_unref(pixmap);
current_level = 1;
@@ -169,9 +176,8 @@
zoom = (double)(height-BAR_GAP)/(double)gdk_pixbuf_get_height(pixmap);
repeat_item = goo_canvas_image_new (rootitem,
pixmap,
- (double) (width/NUMBER_OF_ITEMS) * 6 -
- gdk_pixbuf_get_width(pixmap)/2,
- (double) (height-gdk_pixbuf_get_height(pixmap)*zoom)/2,
+ startx + (width/NUMBER_OF_ITEMS) * 0,
+ buttony,
NULL);
gdk_pixbuf_unref(pixmap);
@@ -183,10 +189,9 @@
zoom = (double)(height-BAR_GAP)/(double)gdk_pixbuf_get_height(pixmap);
help_item = goo_canvas_image_new (rootitem,
pixmap,
- (double) (width/NUMBER_OF_ITEMS) * 4 -
- gdk_pixbuf_get_width(pixmap)/2,
- (double) (height-gdk_pixbuf_get_height(pixmap)*zoom)/2,
- NULL);
+ startx + (width/NUMBER_OF_ITEMS) * 1,
+ buttony,
+ NULL);
gdk_pixbuf_unref(pixmap);
setup_item_signals(help_item, "help");
@@ -198,10 +203,9 @@
zoom = (double)(height-BAR_GAP)/(double)gdk_pixbuf_get_height(pixmap);
config_item = goo_canvas_image_new (rootitem,
pixmap,
- (double) (width/NUMBER_OF_ITEMS) * 3 -
- gdk_pixbuf_get_width(pixmap)/2,
- (double) (height-gdk_pixbuf_get_height(pixmap)*zoom)/2,
- NULL);
+ startx + (width/NUMBER_OF_ITEMS) * 2,
+ buttony,
+ NULL);
gdk_pixbuf_unref(pixmap);
setup_item_signals(config_item, "configuration");
@@ -212,9 +216,8 @@
zoom = (double)(height-BAR_GAP)/(double)gdk_pixbuf_get_height(pixmap);
about_item = goo_canvas_image_new (rootitem,
pixmap,
- (double) (width/NUMBER_OF_ITEMS) * 2 -
- gdk_pixbuf_get_width(pixmap)/2,
- (double) (height-gdk_pixbuf_get_height(pixmap)*zoom)/2,
+ startx + (width/NUMBER_OF_ITEMS) * 3,
+ buttony,
NULL);
gdk_pixbuf_unref(pixmap);
@@ -242,6 +245,8 @@
NULL);
_hidden = FALSE;
+ _click_mode = TRUE;
+ _barup = TRUE;
_force_bar_down();
}
@@ -390,15 +395,16 @@
else
g_object_set(about_item,
"visibility", GOO_CANVAS_ITEM_INVISIBLE, NULL);
-
- /* FIXME : Workaround for bugged canvas */
- // goo_canvas_update_now(gc_board_get_current()->canvas);
-
}
static gboolean
_bar_down(void *ignore)
{
+ if(_barup == FALSE)
+ return TRUE;
+
+ _barup = FALSE;
+
bar_down_id = 0;
goo_canvas_item_animate(rootitem,
0,
@@ -416,6 +422,11 @@
static void
_force_bar_down(void)
{
+ if(_barup == FALSE)
+ return;
+
+ _barup = FALSE;
+
if(bar_down_id)
g_source_remove (bar_down_id);
@@ -433,9 +444,26 @@
GOO_CANVAS_ANIMATE_FREEZE);
}
+static void _force_bar_up(char *data)
+{
+ bar_reset_sound_id();
+ sound_play_id = g_timeout_add (1000, (GtkFunction) bar_play_sound, data);
+ _bar_up();
+
+ if(bar_down_id)
+ g_source_remove (bar_down_id);
+
+ bar_down_id=0;
+}
+
static void
_bar_up(void)
{
+ if(_barup == TRUE)
+ return;
+
+ _barup = TRUE;
+
goo_canvas_item_raise(rootitem, NULL);
goo_canvas_item_animate(rootitem,
0,
@@ -449,7 +477,7 @@
}
/* Hide all icons in the control bar
- * or retore the icons to the previous value
+ * or restore the icons to the previous value
*/
void
gc_bar_hide (gboolean hide)
@@ -557,17 +585,10 @@
GdkEventCrossing *event,
char *data)
{
- if(_hidden)
+ if(_hidden || _click_mode)
return FALSE;
- bar_reset_sound_id();
- sound_play_id = g_timeout_add (1000, (GtkFunction) bar_play_sound, data);
- _bar_up();
-
- if(bar_down_id)
- g_source_remove (bar_down_id);
-
- bar_down_id=0;
+ _force_bar_up(data);
return FALSE;
}
@@ -598,6 +619,9 @@
if(_hidden)
return(FALSE);
+ if(!_barup)
+ _force_bar_up(data);
+
bar_reset_sound_id();
gc_sound_play_ogg ("sounds/bleep.wav", NULL);
@@ -697,7 +721,7 @@
}
else if(!strcmp((char *)data, "bar"))
{
- _force_bar_down();
+ _force_bar_up(data);
}
return TRUE;
Modified: branches/gcomprixogoo/src/gcompris/gameutil.c
==============================================================================
--- branches/gcomprixogoo/src/gcompris/gameutil.c (original)
+++ branches/gcomprixogoo/src/gcompris/gameutil.c Sun Aug 3 22:17:00 2008
@@ -683,3 +683,56 @@
gc_sound_play_ogg(str, NULL);
g_free(str);
}
+
+/** Display a button with the given text
+ *
+ * \param x the x coordinate of the button
+ * \param y the y coordinate of the button
+ * \param button_file the image file to use as the button
+ * \param text is the text to display in the button
+ * \param process is the callback function
+ * \param data is the user data passed to the callback function
+ *
+ * \return void
+ */
+void
+gc_util_button_text(GooCanvasItem *rootitem,
+ guint x, guint y,
+ char *button_file,
+ char *text,
+ GtkSignalFunc process,
+ gpointer data)
+{
+ GdkPixbuf *pixmap;
+ GooCanvasItem *item;
+ GooCanvasItem *item_text;
+
+ /* The Button */
+ pixmap = gc_skin_pixmap_load(button_file);
+ item = goo_canvas_image_new (rootitem,
+ pixmap,
+ x,
+ y,
+ NULL);
+ gdk_pixbuf_unref(pixmap);
+ g_signal_connect(item,
+ "button_press_event",
+ (GtkSignalFunc) process, data);
+ gc_item_focus_init(item, NULL);
+
+ /* The Text */
+ item_text =
+ goo_canvas_text_new (rootitem,
+ text,
+ x + (double)gdk_pixbuf_get_width(pixmap)/2,
+ y + 24,
+ -1,
+ GTK_ANCHOR_CENTER,
+ "font", gc_skin_font_board_small,
+ "fill_color_rgba", gc_skin_color_text_button,
+ NULL);
+ g_signal_connect(item_text,
+ "button_press_event",
+ process, data);
+ gc_item_focus_init(item_text, item);
+}
Modified: branches/gcomprixogoo/src/gcompris/gameutil.h
==============================================================================
--- branches/gcomprixogoo/src/gcompris/gameutil.h (original)
+++ branches/gcomprixogoo/src/gcompris/gameutil.h Sun Aug 3 22:17:00 2008
@@ -63,4 +63,10 @@
int gc_util_create_rootdir (gchar *rootdir);
void gc_activity_intro_play (GcomprisBoard *gcomprisBoard);
+void gc_util_button_text(GooCanvasItem *rootitem,
+ guint x, guint y,
+ char *button_file,
+ char *text,
+ GtkSignalFunc process,
+ gpointer data);
#endif
Modified: branches/gcomprixogoo/src/magic_hat_minus-activity/magic_hat.c
==============================================================================
--- branches/gcomprixogoo/src/magic_hat_minus-activity/magic_hat.c (original)
+++ branches/gcomprixogoo/src/magic_hat_minus-activity/magic_hat.c Sun Aug 3 22:17:00 2008
@@ -132,7 +132,7 @@
end_board,
is_our_board,
NULL,
- process_ok,
+ NULL,
set_level,
NULL,
NULL,
@@ -176,7 +176,7 @@
gcomprisBoard->maxlevel = 9;
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_OK);
+ gc_bar_set(GC_BAR_LEVEL);
if (strcmp(gcomprisBoard->mode, "minus") == 0)
board_mode = MODE_MINUS;
@@ -232,10 +232,9 @@
if (ok) {
gamewon = TRUE;
gc_sound_play_ogg ("sounds/bonus.wav", NULL);
+ gc_bonus_display(gamewon, GC_BONUS_FLOWER);
}
- gc_bonus_display(gamewon, GC_BONUS_FLOWER);
-
}
/* ======================================= */
@@ -664,6 +663,8 @@
g_object_unref(pixmap);
}
gc_sound_play_ogg ("sounds/bleep.wav", NULL);
+
+ process_ok();
}
return FALSE;
Modified: branches/gcomprixogoo/src/money-activity/money.c
==============================================================================
--- branches/gcomprixogoo/src/money-activity/money.c (original)
+++ branches/gcomprixogoo/src/money-activity/money.c Sun Aug 3 22:17:00 2008
@@ -29,7 +29,6 @@
static void end_board (void);
static gboolean is_our_board (GcomprisBoard *gcomprisBoard);
static void set_level (guint level);
-static void process_ok(void);
static int gamewon;
static void game_won(void);
@@ -41,7 +40,7 @@
Money_Widget *tux_money = NULL;
Money_Widget *seller_money = NULL;
-static double price_target = 0;
+static float price_target = 0;
typedef struct {
char *image;
@@ -91,7 +90,7 @@
end_board,
is_our_board,
NULL,
- process_ok,
+ NULL,
set_level,
NULL,
NULL,
@@ -135,7 +134,7 @@
gcomprisBoard->level=1;
gcomprisBoard->sublevel=1;
gcomprisBoard->number_of_sublevel=10; /* Go to next level after this number of 'play' */
- gc_bar_set(GC_BAR_LEVEL|GC_BAR_OK);
+ gc_bar_set(GC_BAR_LEVEL);
/* Default mode */
if(!gcomprisBoard->mode)
@@ -562,20 +561,15 @@
}
/* ==================================== */
-static void process_ok()
+void moneyactivity_process_ok()
{
if(board_paused)
/*return FALSE*/;
- /* FIXME: Why do I need this trick !! */
- if(price_target >= money_widget_get_total(seller_money) - 0.001 &&
- price_target <= money_widget_get_total(seller_money) + 0.001 )
+ if(price_target == money_widget_get_total(seller_money))
{
gamewon = TRUE;
- money_destroy_all_items();
gc_bonus_display(gamewon, GC_BONUS_SMILEY);
}
- else
- gc_bonus_display(gamewon, GC_BONUS_SMILEY);
}
Modified: branches/gcomprixogoo/src/money-activity/money_widget.c
==============================================================================
--- branches/gcomprixogoo/src/money-activity/money_widget.c (original)
+++ branches/gcomprixogoo/src/money-activity/money_widget.c Sun Aug 3 22:17:00 2008
@@ -24,6 +24,9 @@
#include <string.h>
#include "money_widget.h"
+/* From money.c */
+void moneyactivity_process_ok(void);
+
struct _Money_WidgetPrivate {
GooCanvasItem *rootItem; /* The canvas to display our euros in */
double x1; /* Coordinate of the widget */
@@ -369,6 +372,7 @@
money_widget_add(moneyItem->moneyWidget->priv->targetWidget,
moneyItem->value);
+ moneyactivity_process_ok();
break;
default:
break;
Modified: branches/gcomprixogoo/src/reversecount-activity/reversecount.c
==============================================================================
--- branches/gcomprixogoo/src/reversecount-activity/reversecount.c (original)
+++ branches/gcomprixogoo/src/reversecount-activity/reversecount.c Sun Aug 3 22:17:00 2008
@@ -328,7 +328,8 @@
}
if(!animate_id) {
- animate_id = gtk_timeout_add (animate_speed, (GtkFunction) animate_tux, NULL);
+ animate_id = gtk_timeout_add (animate_speed,
+ (GtkFunction) animate_tux, NULL);
}
}
Modified: branches/gcomprixogoo/src/superbrain-activity/superbrain.c
==============================================================================
--- branches/gcomprixogoo/src/superbrain-activity/superbrain.c (original)
+++ branches/gcomprixogoo/src/superbrain-activity/superbrain.c Sun Aug 3 22:17:00 2008
@@ -117,7 +117,7 @@
end_board,
is_our_board,
NULL,
- process_ok,
+ NULL,
set_level,
NULL,
NULL,
@@ -162,7 +162,10 @@
gcomprisBoard->maxlevel=6;
gcomprisBoard->sublevel=1;
gcomprisBoard->number_of_sublevel=1; /* Go to next level after this number of 'play' */
- gc_bar_set(GC_BAR_OK|GC_BAR_LEVEL);
+ gc_bar_set(GC_BAR_LEVEL);
+
+ gc_set_background(goo_canvas_get_root_item(gcomprisBoard->canvas),
+ "superbrain/superbrain_background.jpg");
superbrain_next_level();
@@ -225,9 +228,6 @@
guint i;
gboolean selected_color[MAX_COLORS];
- gc_set_background(goo_canvas_get_root_item(gcomprisBoard->canvas),
- "superbrain/superbrain_background.jpg");
-
gc_bar_set_level(gcomprisBoard);
superbrain_destroy_all_items();
@@ -277,6 +277,13 @@
boardLogoItem = goo_canvas_group_new (goo_canvas_get_root_item(gcomprisBoard->canvas),
NULL);
+ /* The OK Button */
+ gc_util_button_text(boardRootItem,
+ 270, 360,
+ "button_large.png",
+ _("OK"),
+ (GtkSignalFunc) process_ok, NULL);
+
/* The list of the pieces */
for(i=0; i<number_of_color; i++)
{
@@ -413,6 +420,7 @@
"stroke-color", "white",
"line-width", (double)1,
NULL);
+ gc_item_focus_init(item, NULL);
g_object_set (item, "visibility", GOO_CANVAS_ITEM_INVISIBLE, NULL);
piece->listitem = g_list_append(piece->listitem, item);
Modified: branches/gcomprixogoo/src/target-activity/target.c
==============================================================================
--- branches/gcomprixogoo/src/target-activity/target.c (original)
+++ branches/gcomprixogoo/src/target-activity/target.c Sun Aug 3 22:17:00 2008
@@ -36,6 +36,7 @@
#define TEXT_COLOR "white"
static GooCanvasItem *boardRootItem = NULL;
+static GooCanvasItem *valueRootItem = NULL;
static GooCanvasItem *speedRootItem = NULL;
static double wind_speed;
@@ -132,7 +133,7 @@
end_board,
is_our_board,
key_press,
- process_ok,
+ NULL,
set_level,
NULL,
NULL,
@@ -288,6 +289,7 @@
"text", tmpstr,
NULL);
g_free(tmpstr);
+ process_ok();
}
return TRUE;
@@ -425,6 +427,7 @@
GooCanvasItem *item = NULL;
boardRootItem = goo_canvas_group_new (parent, NULL);
+ valueRootItem = goo_canvas_group_new (boardRootItem, NULL);
goo_canvas_item_translate(boardRootItem,
TARGET_CENTER_X,
TARGET_CENTER_Y);
@@ -450,7 +453,7 @@
/* Display the value for this target */
tmpstr = g_strdup_printf("%d",
targetDefinition[gcomprisBoard->level-1].target_width_value[i*2+1]);
- item = goo_canvas_text_new (boardRootItem,
+ item = goo_canvas_text_new (valueRootItem,
tmpstr,
(double) 0,
(double) targetDefinition[gcomprisBoard->level-1].target_width_value[i*2] - 10,
@@ -502,6 +505,12 @@
target_next_level();
}
+static void bonus()
+{
+ gc_bonus_display(gamewon, GC_BONUS_SMILEY);
+ animate_id = 0;
+}
+
static void process_ok()
{
guint answer_points = atoi(answer_string);
@@ -511,13 +520,7 @@
if(answer_points == user_points)
{
gamewon = TRUE;
- target_destroy_all_items();
- gc_bonus_display(gamewon, GC_BONUS_SMILEY);
- }
- else
- {
- gamewon = FALSE;
- gc_bonus_display(gamewon, GC_BONUS_SMILEY);
+ animate_id = gtk_timeout_add (200, (GtkFunction) bonus, NULL);
}
}
@@ -534,7 +537,7 @@
double x_offset = 245;
gchar *tmpstr;
- gc_bar_set(GC_BAR_LEVEL|GC_BAR_OK);
+ gc_bar_set(GC_BAR_LEVEL);
button_pixmap = gc_skin_pixmap_load("button_large2.png");
goo_canvas_image_new (boardRootItem,
button_pixmap,
@@ -642,7 +645,8 @@
"stroke-color", "white",
"line-width", (double)1,
NULL);
-
+ /* Make sure the target values stay on top */
+ goo_canvas_item_lower(animate_item, valueRootItem);
animate_id = gtk_timeout_add (200, (GtkFunction) animate_items, NULL);
if(--number_of_arrow == 0)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]