From 73d25744fb01844cc28402dfc4b48a030d270579 Mon Sep 17 00:00:00 2001 From: Johannes Schwarz Date: Fri, 26 Jun 2009 17:59:33 +0000 Subject: 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 --- apps/plugins/chopper.c | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) (limited to 'apps/plugins/chopper.c') 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); -- cgit v1.1