Index: apps/plugins/mazezam.c =================================================================== --- apps/plugins/mazezam.c (Revision 21285) +++ apps/plugins/mazezam.c (Arbeitskopie) @@ -838,31 +838,16 @@ } /***************************************************************************** -* Offer a main menu with no continue option +* Manages the main menu ******************************************************************************/ -static int main_menu_without_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_PLAY_GAME, - MAZEZAM_TEXT_QUIT); - return rb->do_menu(&menu, start_selection, NULL, false); + if(action == ACTION_REQUEST_MENUITEM && + !have_continue && this_item==0) + return ACTION_EXIT_MENUITEM; + return action; } - -/***************************************************************************** -* Offer a main menu with a continue option -******************************************************************************/ -static int main_menu_with_continue(int* start_selection) -{ - 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); -} - -/***************************************************************************** -* Manages the main menu -******************************************************************************/ static void main_menu(void) { /* The initial option is "play game" */ @@ -873,11 +858,14 @@ /* Load data */ resume_load_data(&r_data, &old_data); + have_continue = (r_data.level != 0); + 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); + choice = rb->do_menu(&menu, &start_selection, NULL, false); switch(choice) { case 0: /* Continue */ @@ -885,14 +873,10 @@ 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: Index: apps/plugins/xobox.c =================================================================== --- apps/plugins/xobox.c (Revision 21285) +++ apps/plugins/xobox.c (Arbeitskopie) @@ -307,9 +307,6 @@ #define PIC_QIX 0 #define PIC_PLAYER 1 -#define MENU_START 0 -#define MENU_QUIT 1 - /* The time (in ms) for one iteration through the game loop - decrease this to speed up the game - note that current_tick is (currently) only accurate to 10ms. @@ -923,79 +920,50 @@ } /* 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 && 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", - "Difficult", - "Playback Control", - "Quit"); + int selection = 0; + _ingame = ingame; + MENUITEM_STRINGLIST(main_menu, "Xobox Menu", xobox_menu_cb, + "Resume Game", "Start New Game", + "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; - } + 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; } } - 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; - } - } - } } /* general keypad handler loop */ @@ -1005,7 +973,7 @@ bool pause = false; int end; - if (xobox_menu(false)==1) { + if (xobox_menu(false)) { return PLUGIN_OK; } @@ -1014,8 +982,8 @@ #ifdef HAS_BUTTON_HOLD if (rb->button_hold()) { - pause = true; - rb->splash (HZ, "PAUSED"); + pause = true; + rb->splash (HZ, "Paused"); } #endif @@ -1043,8 +1011,10 @@ rb->splash (HZ, "Paused"); break; case QUIT: - if (xobox_menu(true)==1) { - quit = true; + if (!pause) { + if (xobox_menu(true)) { + quit = true; + } } break; default: @@ -1058,7 +1028,7 @@ } if (player.gameover) { rb->splash (HZ, "Game Over!"); - if (xobox_menu(false)==1) { + if (xobox_menu(false)) { quit = true; } } Index: apps/plugins/keybox.c =================================================================== --- apps/plugins/keybox.c (Revision 21285) +++ apps/plugins/keybox.c (Arbeitskopie) @@ -71,7 +71,6 @@ 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 @@ 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) + && 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) { Index: apps/plugins/calendar.c =================================================================== --- apps/plugins/calendar.c (Revision 21285) +++ apps/plugins/calendar.c (Arbeitskopie) @@ -627,8 +627,8 @@ 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) + if (action == ACTION_REQUEST_MENUITEM + && memos_in_shown_memory <= 0 && this_item==0) return ACTION_EXIT_MENUITEM; return action; } @@ -638,25 +638,11 @@ 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); + MENUITEM_STRINGLIST(edit_menu, "Edit menu", edit_menu_cb, + "Remove", "Edit", + "New Weekly", "New Monthly", + "New Yearly", "New One off"); - 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); - while (!exit) { switch (rb->do_menu(&edit_menu, &selected, NULL, false)) Index: apps/plugins/chopper.c =================================================================== --- apps/plugins/chopper.c (Revision 21285) +++ apps/plugins/chopper.c (Arbeitskopie) @@ -700,9 +700,17 @@ rb->lcd_update(); } +static bool _ingame; +static int chopMenuCb(int action, const struct menu_item_ex *this_item) +{ + if(action == ACTION_REQUEST_MENUITEM + && !_ingame && 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,9 +719,10 @@ { "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); rb->lcd_set_background(LCD_BLACK); @@ -727,19 +736,15 @@ while (!menu_quit) { switch(rb->do_menu(&menu, &result, NULL, false)) { - case 0: /* Start New Game */ + case 0: menu_quit=true; + res = -1; + break; + case 1: + 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"); - } - break; case 2: rb->set_option("Level", &iLevelMode, INT, levels, 2, NULL); break; Index: apps/menu.c =================================================================== --- apps/menu.c (Revision 21285) +++ apps/menu.c (Arbeitskopie) @@ -81,7 +81,8 @@ 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