summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--apps/menu.c3
-rw-r--r--apps/plugins/calendar.c27
-rw-r--r--apps/plugins/chopper.c28
-rw-r--r--apps/plugins/keybox.c26
-rw-r--r--apps/plugins/mazezam.c59
-rw-r--r--apps/plugins/solitaire.c57
-rw-r--r--apps/plugins/xobox.c108
7 files changed, 124 insertions, 184 deletions
diff --git a/apps/menu.c b/apps/menu.c
index c49650d941..653dc09aec 100644
--- a/apps/menu.c
+++ b/apps/menu.c
@@ -81,7 +81,8 @@ static void get_menu_callback(const struct menu_item_ex *m,
static int get_menu_selection(int selected_item, const struct menu_item_ex *menu)
{
int type = (menu->flags&MENU_TYPE_MASK);
- if (type == MT_MENU && (selected_item<current_subitems_count))
+ if ((type == MT_MENU || type == MT_RETURN_ID)
+ && (selected_item<current_subitems_count))
return current_subitems[selected_item];
return selected_item;
}
diff --git a/apps/plugins/calendar.c b/apps/plugins/calendar.c
index 72b572e7eb..873a09b970 100644
--- a/apps/plugins/calendar.c
+++ b/apps/plugins/calendar.c
@@ -627,8 +627,9 @@ static void add_memo(struct shown *shown, int type)
static int edit_menu_cb(int action, const struct menu_item_ex *this_item)
{
- (void) this_item;
- if (action == ACTION_REQUEST_MENUITEM && memos_in_shown_memory <= 0)
+ int i = (intptr_t)this_item;
+ if (action == ACTION_REQUEST_MENUITEM
+ && memos_in_shown_memory <= 0 && (i==0 || i==1))
return ACTION_EXIT_MENUITEM;
return action;
}
@@ -638,24 +639,10 @@ static bool edit_memo(int change, struct shown *shown)
bool exit = false;
int selected = 0;
- MENUITEM_RETURNVALUE(edit_menu_remove, "Remove", 0,
- edit_menu_cb, Icon_NOICON);
- MENUITEM_RETURNVALUE(edit_menu_edit, "Edit", 1,
- edit_menu_cb, Icon_NOICON);
- MENUITEM_RETURNVALUE(edit_menu_weekly, "New Weekly", 2,
- NULL, Icon_NOICON);
- MENUITEM_RETURNVALUE(edit_menu_monthly, "New Monthly", 3,
- NULL, Icon_NOICON);
- MENUITEM_RETURNVALUE(edit_menu_yearly, "New Yearly", 4,
- NULL, Icon_NOICON);
- MENUITEM_RETURNVALUE(edit_menu_oneoff, "New One off", 5,
- NULL, Icon_NOICON);
-
- MAKE_MENU(edit_menu, "Edit menu",
- NULL, Icon_NOICON,
- &edit_menu_remove, &edit_menu_edit,
- &edit_menu_weekly, &edit_menu_monthly,
- &edit_menu_yearly, &edit_menu_oneoff);
+ MENUITEM_STRINGLIST(edit_menu, "Edit menu", edit_menu_cb,
+ "Remove", "Edit",
+ "New Weekly", "New Monthly",
+ "New Yearly", "New One off");
while (!exit)
{
diff --git a/apps/plugins/chopper.c b/apps/plugins/chopper.c
index 2c1ee477eb..54a1ae0bfe 100644
--- a/apps/plugins/chopper.c
+++ b/apps/plugins/chopper.c
@@ -700,9 +700,17 @@ static void chopDrawScene(void)
rb->lcd_update();
}
+static bool _ingame;
+static int chopMenuCb(int action, const struct menu_item_ex *this_item)
+{
+ if(action == ACTION_REQUEST_MENUITEM
+ && !_ingame && ((intptr_t)this_item)==0)
+ return ACTION_EXIT_MENUITEM;
+ return action;
+}
static int chopMenu(int menunum)
{
- int result = (menunum==0)?0:1;
+ int result = 0;
int res = 0;
bool menu_quit = false;
@@ -711,8 +719,10 @@ static int chopMenu(int menunum)
{ "Steep", -1 },
};
- MENUITEM_STRINGLIST(menu,"Chopper Menu",NULL,"Start New Game","Resume Game",
+ MENUITEM_STRINGLIST(menu,"Chopper Menu",chopMenuCb,
+ "Resume Game","Start New Game",
"Level","Playback Control","Quit");
+ _ingame = (menunum!=0);
#ifdef HAVE_LCD_COLOR
rb->lcd_set_foreground(LCD_WHITE);
@@ -727,18 +737,14 @@ static int chopMenu(int menunum)
while (!menu_quit) {
switch(rb->do_menu(&menu, &result, NULL, false))
{
- case 0: /* Start New Game */
+ case 0: /* Resume Game */
menu_quit=true;
- chopper_load(true);
res = -1;
break;
- case 1: /* Resume Game */
- if(menunum==1) {
- menu_quit=true;
- res = -1;
- } else if(menunum==0){
- rb->splash(HZ, "No game to resume");
- }
+ case 1: /* Start New Game */
+ menu_quit=true;
+ chopper_load(true);
+ res = -1;
break;
case 2:
rb->set_option("Level", &iLevelMode, INT, levels, 2, NULL);
diff --git a/apps/plugins/keybox.c b/apps/plugins/keybox.c
index 5d625a33a2..08d5131eff 100644
--- a/apps/plugins/keybox.c
+++ b/apps/plugins/keybox.c
@@ -71,7 +71,6 @@ static uint32_t salt;
static union hash pwhash;
static bool data_changed = false;
-static int context_item_cb(int action, const struct menu_item_ex *this_item);
static void encrypt_buffer(char *buf, size_t size, uint32_t *key);
static void decrypt_buffer(char *buf, size_t size, uint32_t *key);
@@ -105,35 +104,22 @@ static void decrypt(uint32_t* v, uint32_t* k)
v[0]=v0; v[1]=v1;
}
-MENUITEM_RETURNVALUE(context_add_entry, "Add entry", 0,
- NULL, Icon_NOICON);
-MENUITEM_RETURNVALUE(context_edit_title, "Edit title", 1,
- &context_item_cb, Icon_NOICON);
-MENUITEM_RETURNVALUE(context_edit_name, "Edit user name", 2,
- &context_item_cb, Icon_NOICON);
-MENUITEM_RETURNVALUE(context_edit_password, "Edit password", 3,
- &context_item_cb, Icon_NOICON);
-MENUITEM_RETURNVALUE(context_delete_entry, "Delete entry", 4,
- &context_item_cb, Icon_NOICON);
-MENUITEM_RETURNVALUE(context_debug, "debug", 5,
- &context_item_cb, Icon_NOICON);
-
-MAKE_MENU(context_m, "Context menu",
- context_item_cb, Icon_NOICON,
- &context_add_entry, &context_edit_title, &context_edit_name,
- &context_edit_password, &context_delete_entry);
-
static int context_item_cb(int action, const struct menu_item_ex *this_item)
{
if (action == ACTION_REQUEST_MENUITEM
&& pw_list.num_entries == 0
- && this_item != &context_add_entry)
+ && ((intptr_t)this_item) != 0)
{
return ACTION_EXIT_MENUITEM;
}
return action;
}
+MENUITEM_STRINGLIST(context_m, "Context menu", context_item_cb,
+ "Add entry",
+ "Edit title", "Edit user name", "Edit password",
+ "Delete entry")
+
static char * kb_list_cb(int selected_item, void *data,
char *buffer, size_t buffer_len)
{
diff --git a/apps/plugins/mazezam.c b/apps/plugins/mazezam.c
index 2e79567740..ac7e651fbc 100644
--- a/apps/plugins/mazezam.c
+++ b/apps/plugins/mazezam.c
@@ -52,13 +52,12 @@ const struct button_mapping *plugin_contexts[]
#define MAZEZAM_TEXT_WELLDONE_OPTION "Goodbye"
#define MAZEZAM_TEXT_MAZEZAM_MENU "MazezaM Menu"
#define MAZEZAM_TEXT_RETRY_LEVEL "Retry level"
-#define MAZEZAM_TEXT_AUDIO_PLAYBACK "Audio playback"
+#define MAZEZAM_TEXT_AUDIO_PLAYBACK "Playback Control"
#define MAZEZAM_TEXT_QUIT "Quit"
-#define MAZEZAM_TEXT_BACK "Return"
+#define MAZEZAM_TEXT_BACK "Resume Game"
#define MAZEZAM_TEXT_MAIN_MENU "MazezaM"
#define MAZEZAM_TEXT_CONTINUE "Play from checkpoint"
-#define MAZEZAM_TEXT_PLAY_GAME "Play game"
-#define MAZEZAM_TEXT_PLAY_NEW_GAME "Play new game"
+#define MAZEZAM_TEXT_PLAY_NEW_GAME "Start New Game"
#define MAZEZAM_START_LIVES 3 /* how many lives at game start */
#define MAZEZAM_FIRST_CHECKPOINT 3 /* The level at the first checkpoint */
@@ -838,31 +837,16 @@ static void resume_save_data (struct resume_data *r, struct resume_data *old)
}
/*****************************************************************************
-* Offer a main menu with no continue option
-******************************************************************************/
-static int main_menu_without_continue(int* start_selection)
-{
- MENUITEM_STRINGLIST(menu,MAZEZAM_TEXT_MAIN_MENU,NULL,
- MAZEZAM_TEXT_PLAY_GAME,
- MAZEZAM_TEXT_QUIT);
- return rb->do_menu(&menu, start_selection, NULL, false);
-}
-
-/*****************************************************************************
-* Offer a main menu with a continue option
+* Manages the main menu
******************************************************************************/
-static int main_menu_with_continue(int* start_selection)
+static bool have_continue;
+static int main_menu_cb(int action, const struct menu_item_ex *this_item)
{
- MENUITEM_STRINGLIST(menu,MAZEZAM_TEXT_MAIN_MENU,NULL,
- MAZEZAM_TEXT_CONTINUE,
- MAZEZAM_TEXT_PLAY_NEW_GAME,
- MAZEZAM_TEXT_QUIT);
- return rb->do_menu(&menu, start_selection, NULL, false);
+ if(action == ACTION_REQUEST_MENUITEM
+ && !have_continue && ((intptr_t)this_item)==0)
+ return ACTION_EXIT_MENUITEM;
+ return action;
}
-
-/*****************************************************************************
-* Manages the main menu
-******************************************************************************/
static void main_menu(void)
{
/* The initial option is "play game" */
@@ -873,11 +857,14 @@ static void main_menu(void)
/* Load data */
resume_load_data(&r_data, &old_data);
+ MENUITEM_STRINGLIST(menu,MAZEZAM_TEXT_MAIN_MENU,main_menu_cb,
+ MAZEZAM_TEXT_CONTINUE,
+ MAZEZAM_TEXT_PLAY_NEW_GAME,
+ MAZEZAM_TEXT_QUIT);
+
while (state >= STATE_IN_APPLICATION) {
- if (r_data.level == 0)
- choice = main_menu_without_continue(&start_selection);
- else
- choice = main_menu_with_continue(&start_selection);
+ have_continue = (r_data.level != 0);
+ choice = rb->do_menu(&menu, &start_selection, NULL, false);
switch(choice) {
case 0: /* Continue */
@@ -885,14 +872,10 @@ static void main_menu(void)
game_loop(&r_data);
break;
- case 1: /* Quit or Play new game */
- if (r_data.level == 0)
- state = STATE_QUIT;
- else { /* Play new game */
- r_data.level = 0;
- state = STATE_IN_GAME;
- game_loop(&r_data);
- }
+ case 1: /* Play new game */
+ r_data.level = 0;
+ state = STATE_IN_GAME;
+ game_loop(&r_data);
break;
case MENU_ATTACHED_USB:
diff --git a/apps/plugins/solitaire.c b/apps/plugins/solitaire.c
index a8beb58719..f4a04fe086 100644
--- a/apps/plugins/solitaire.c
+++ b/apps/plugins/solitaire.c
@@ -782,22 +782,33 @@ void solitaire_init(void);
/* menu return codes */
enum { MENU_RESUME, MENU_SAVE_AND_QUIT, MENU_QUIT, MENU_USB };
+static bool _ingame;
+int solitaire_menu_cb(int action, const struct menu_item_ex *this_item)
+{
+ int i = (intptr_t)this_item;
+ if( action == ACTION_REQUEST_MENUITEM )
+ {
+ if((!_ingame && (i==0 || i==5)) || ( _ingame && i==2 ))
+ return ACTION_EXIT_MENUITEM;
+ }
+ return action;
+}
+
int solitaire_menu(bool in_game)
{
int selected = 0;
int result = -1;
- MENUITEM_STRINGLIST(menu, "Solitaire Menu", NULL,
- "Start Game", "Draw Cards Option",
- "Help", "Audio Playback", "Quit");
- MENUITEM_STRINGLIST(menu_in_game, "Solitaire Menu", NULL,
- "Resume Game", "Restart Game", "Help",
- "Audio Playback", "Save and Quit", "Quit");
+ MENUITEM_STRINGLIST(menu, "Solitaire Menu", solitaire_menu_cb,
+ "Resume Game", "Start New Game",
+ "Draw Cards Option",
+ "Help", "Playback Control",
+ "Save and Quit", "Quit");
+ _ingame = in_game;
while (result < 0)
{
- switch (rb->do_menu(in_game? &menu_in_game: &menu,
- &selected, NULL, false))
+ switch (rb->do_menu(&menu, &selected, NULL, false))
{
default:
result = MENU_RESUME;
@@ -812,36 +823,30 @@ int solitaire_menu(bool in_game)
break;
case 1:
- if (in_game)
- {
- solitaire_init();
- result = MENU_RESUME;
- }
- else
- {
- if (rb->set_option("Draw Cards Option", &sol.draw_type,
- INT, drawcards, 2, NULL))
- result = MENU_USB;
- }
+ solitaire_init();
+ result = MENU_RESUME;
break;
case 2:
- if (solitaire_help() == HELP_USB)
+ if (rb->set_option("Draw Cards Option", &sol.draw_type,
+ INT, drawcards, 2, NULL))
result = MENU_USB;
break;
case 3:
+ if (solitaire_help() == HELP_USB)
+ result = MENU_USB;
+ break;
+
+ case 4:
playback_control(NULL);
break;
- case 4:
- if( in_game )
- result = MENU_SAVE_AND_QUIT;
- else
- result = MENU_QUIT;
+ case 5:
+ result = MENU_SAVE_AND_QUIT;
break;
- case 5:
+ case 6:
result = MENU_QUIT;
break;
}
diff --git a/apps/plugins/xobox.c b/apps/plugins/xobox.c
index 82e1511f70..b26c16eabf 100644
--- a/apps/plugins/xobox.c
+++ b/apps/plugins/xobox.c
@@ -920,77 +920,49 @@ static void init_game (void)
}
/* the main menu */
+static bool _ingame;
+static int xobox_menu_cb(int action, const struct menu_item_ex *this_item)
+{
+ if(action == ACTION_REQUEST_MENUITEM
+ && !_ingame && ((intptr_t)this_item)==0)
+ return ACTION_EXIT_MENUITEM;
+ return action;
+}
+
static int xobox_menu(bool ingame)
{
rb->button_clear_queue();
- int choice = 0;
- if (ingame) {
- MENUITEM_STRINGLIST (main_menu, "Xobox Menu", NULL,
- "Resume Game",
- "Restart Level",
- "Speed",
- "Difficulty",
- "Playback Control",
- "Quit");
-
- while (true) {
- choice = rb->do_menu(&main_menu, &choice, NULL, false);
- switch (choice) {
- case 0:
- return 0;
- case 1:
- init_game ();
- return 0;
- case 2:
- rb->set_int ("Speed", "", UNIT_INT, &speed, NULL, 1, 1, 10, NULL);
- break;
- case 3:
- rb->set_int ("Difficulty", "", UNIT_INT, &difficulty, NULL,
- 5, 50, 95, NULL);
- break;
- case 4:
- playback_control(NULL);
- break;
- case 5:
- return 1;
- case MENU_ATTACHED_USB:
- return 1;
- default:
- break;
- }
- }
- }
- else {
- MENUITEM_STRINGLIST (main_menu, "Xobox Menu", NULL,
- "Start Game",
- "Speed",
- "Difficulty",
- "Playback Control",
- "Quit");
-
- while (true) {
- choice = rb->do_menu(&main_menu, &choice, NULL, false);
- switch (choice) {
- case 0:
- init_game ();
- return 0;
- case 1:
- rb->set_int ("Speed", "", UNIT_INT, &speed, NULL, 1, 1, 10, NULL);
- break;
- case 2:
- rb->set_int ("Difficulty", "", UNIT_INT, &difficulty, NULL,
- 5, 50, 95, NULL);
- break;
- case 3:
- playback_control(NULL);
- break;
- case 4:
- return 1;
- case MENU_ATTACHED_USB:
- return 1;
- default:
- break;
- }
+
+ int selection = 0;
+ MENUITEM_STRINGLIST(main_menu, "Xobox Menu", xobox_menu_cb,
+ "Resume Game", "Start New Game",
+ "Speed", "Difficulty",
+ "Playback Control", "Quit");
+ _ingame = ingame;
+
+ while (true) {
+ switch (rb->do_menu(&main_menu, &selection, NULL, false)) {
+ case 0:
+ return 0;
+ case 1:
+ init_game ();
+ return 0;
+ case 2:
+ rb->set_int ("Speed", "", UNIT_INT, &speed, NULL, 1, 1, 10, NULL);
+ break;
+ case 3:
+ rb->set_int ("Difficulty", "", UNIT_INT, &difficulty, NULL,
+ 5, 50, 95, NULL);
+ break;
+ case 4:
+ playback_control(NULL);
+ break;
+ case 5:
+ return 1;
+ case MENU_ATTACHED_USB:
+ return 1;
+ default:
+ break;
}
}
}