[gcompris/gcomprixogoo] Added an 'i am ready button'.
- From: Bruno Coudoin <bcoudoin src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [gcompris/gcomprixogoo] Added an 'i am ready button'.
- Date: Sun, 3 Jan 2010 15:01:42 +0000 (UTC)
commit 0a30dd32118705f04984145ed78f6a27476fca10
Author: Bruno Coudoin <bruno coudoin free fr>
Date: Sun Jan 3 16:00:36 2010 +0100
Added an 'i am ready button'.
Now in single activity mode it is possible to restart it
uppon loas without restarting the whole activity.
src/algebra_by-activity/algebra.c | 43 +++++++++++++++++++++++++++++++-----
1 files changed, 37 insertions(+), 6 deletions(-)
---
diff --git a/src/algebra_by-activity/algebra.c b/src/algebra_by-activity/algebra.c
index e6c23b2..294995d 100644
--- a/src/algebra_by-activity/algebra.c
+++ b/src/algebra_by-activity/algebra.c
@@ -81,6 +81,10 @@ 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 gboolean item_event_ready (GooCanvasItem *item,
+ GooCanvasItem *target,
+ GdkEventButton *event,
+ gchar *data);
static GooCanvasItem *algebra_create_item(GooCanvasItem *parent);
static void algebra_destroy_item(GooCanvasItem *item);
@@ -92,6 +96,7 @@ static void display_operand(GooCanvasItem *parent,
gboolean masked);
static void get_random_number(guint *first_operand, guint *second_operand);
static void algebra_next_level(void);
+static void ask_for_ready(void);
static gboolean item_event (GooCanvasItem *item,
GooCanvasItem *target,
GdkEventButton *event,
@@ -144,8 +149,8 @@ static void pause_board (gboolean pause)
/* Make the timer follow our pause status */
gc_timer_pause(pause);
- if(gamewon == TRUE && pause == FALSE) /* the game is won */
- algebra_next_level();
+ if(pause == FALSE)
+ ask_for_ready();
board_paused = pause;
}
@@ -225,7 +230,7 @@ static void start_board (GcomprisBoard *agcomprisBoard)
currentOperation[1]='\0';
init_operation();
- algebra_next_level();
+ ask_for_ready();
gamewon = FALSE;
pause_board(FALSE);
@@ -259,7 +264,7 @@ set_level (guint level)
{
gcomprisBoard->level=level;
gcomprisBoard->sublevel=1;
- algebra_next_level();
+ ask_for_ready();
}
}
@@ -387,6 +392,34 @@ static void timer_end()
gc_bonus_display(gamewon, GC_BONUS_SMILEY);
}
+static void ask_for_ready()
+{
+
+ algebra_destroy_all_items();
+
+ boardRootItem = \
+ goo_canvas_group_new (goo_canvas_get_root_item(gcomprisBoard->canvas),
+ NULL);
+
+ gc_util_button_text_svg(boardRootItem,
+ BOARDWIDTH * 0.5,
+ BOARDHEIGHT * 0.5,
+ "#BUTTON_TEXT",
+ _("I am Ready"),
+ (GtkSignalFunc) item_event_ready,
+ "ready");
+}
+
+static gboolean item_event_ready (GooCanvasItem *item,
+ GooCanvasItem *target,
+ GdkEventButton *event,
+ gchar *data)
+{
+ if(!strcmp((char *)data, "ready"))
+ algebra_next_level();
+
+ return TRUE;
+}
/* set initial values for the next level */
static void algebra_next_level()
@@ -398,7 +431,6 @@ static void algebra_next_level()
goo_canvas_group_new (goo_canvas_get_root_item(gcomprisBoard->canvas),
NULL);
-
maxtime = 20;
gc_timer_display(TIMER_X, TIMER_Y,
GCOMPRIS_TIMER_BALLOON, maxtime, timer_end);
@@ -411,7 +443,6 @@ static void algebra_next_level()
}
-
static void algebra_destroy_item(GooCanvasItem *item)
{
item_list = g_list_remove (item_list, item);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]