Index: apps/menu.c =================================================================== --- apps/menu.c (revision 21505) +++ apps/menu.c (working copy) @@ -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_itemdo_menu(&menu, start_selection, NULL, false); + if(action == ACTION_REQUEST_MENUITEM + && !have_continue && ((intptr_t)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 +859,14 @@ /* 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 +874,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 21505) +++ apps/plugins/xobox.c (working copy) @@ -923,79 +923,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 && ((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", - "Difficult", - "Playback Control", - "Quit"); + 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) { - 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 */ Index: apps/plugins/chopper.c =================================================================== --- apps/plugins/chopper.c (revision 21505) +++ apps/plugins/chopper.c (working copy) @@ -5,7 +5,7 @@ * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ * \/ \/ \/ \/ \/ - * $Id: $ + * $Id$ * * Originally by Joshua Oreman, improved by Prashant Varanasi * Ported to Rockbox by Ben Basha (Paprica) @@ -700,9 +676,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 && ((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 +695,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); @@ -727,19 +713,15 @@ while (!menu_quit) { switch(rb->do_menu(&menu, &result, NULL, false)) { - case 0: /* Start New Game */ + case 0: /* Resume Game */ menu_quit=true; + res = -1; + break; + case 1: /* Start New 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"); - } - break; case 2: rb->set_option("Level", &iLevelMode, INT, levels, 2, NULL); break;