diff options
| author | Johannes Schwarz <ubuntuxer@rockbox.org> | 2009-06-26 17:59:33 +0000 |
|---|---|---|
| committer | Johannes Schwarz <ubuntuxer@rockbox.org> | 2009-06-26 17:59:33 +0000 |
| commit | 73d25744fb01844cc28402dfc4b48a030d270579 (patch) | |
| tree | 34a3e43d7160f263178928553644cf3392a6341b /apps/plugins/xobox.c | |
| parent | c2565c9bcf02b8b9fe0311a15a731dde449c1552 (diff) | |
| download | rockbox-73d25744fb01844cc28402dfc4b48a030d270579.zip rockbox-73d25744fb01844cc28402dfc4b48a030d270579.tar.gz rockbox-73d25744fb01844cc28402dfc4b48a030d270579.tar.bz2 rockbox-73d25744fb01844cc28402dfc4b48a030d270579.tar.xz | |
FS#10283 simplify plugins' menus by using stringlist with callback (by Teruaki Kawashima - some minor changes by myself)
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@21523 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/plugins/xobox.c')
| -rw-r--r-- | apps/plugins/xobox.c | 108 |
1 files changed, 40 insertions, 68 deletions
diff --git a/apps/plugins/xobox.c b/apps/plugins/xobox.c index 82e1511..b26c16e 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; } } } |