Index: apps/plugins/xobox.c =================================================================== --- apps/plugins/xobox.c (revision 21197) +++ apps/plugins/xobox.c (working copy) @@ -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,58 @@ } /* the main menu */ +static bool _ingame; +static int xobox_menu_cb(int action, const struct menu_item_ex *this_item); +MENUITEM_RETURNVALUE (menu_resumegame, "Resume Game", 0, + xobox_menu_cb, Icon_NOICON); +MENUITEM_RETURNVALUE (menu_startgame, "Start New Game", 1, NULL, Icon_NOICON); +MENUITEM_RETURNVALUE (menu_speed, "Speed", 2, NULL, Icon_NOICON); +MENUITEM_RETURNVALUE (menu_difficulty, "Difficulty", 3, NULL, Icon_NOICON); +MENUITEM_RETURNVALUE (menu_playback, "Playback Control", 4, NULL, Icon_NOICON); +MENUITEM_RETURNVALUE (menu_quit, "Quit", 5, NULL, Icon_NOICON); +MAKE_MENU (main_menu, "Xobox Menu", NULL, Icon_NOICON, + &menu_resumegame, &menu_startgame, + &menu_speed, &menu_difficulty, + &menu_playback, &menu_quit); +static int xobox_menu_cb(int action, const struct menu_item_ex *this_item) +{ + if (action == ACTION_REQUEST_MENUITEM && + this_item==&menu_resumegame && !_ingame) + 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; - 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 +981,7 @@ bool pause = false; int end; - if (xobox_menu(false)==1) { + if (xobox_menu(false)) { return PLUGIN_OK; } @@ -1014,8 +990,8 @@ #ifdef HAS_BUTTON_HOLD if (rb->button_hold()) { - pause = true; - rb->splash (HZ, "PAUSED"); + pause = true; + rb->splash (HZ, "Paused"); } #endif @@ -1043,8 +1019,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 +1036,7 @@ } if (player.gameover) { rb->splash (HZ, "Game Over!"); - if (xobox_menu(false)==1) { + if (xobox_menu(false)) { quit = true; } }