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/chopper.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/chopper.c')
| -rw-r--r-- | apps/plugins/chopper.c | 28 |
1 files changed, 17 insertions, 11 deletions
diff --git a/apps/plugins/chopper.c b/apps/plugins/chopper.c index 2c1ee47..54a1ae0 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); |