diff options
Diffstat (limited to 'apps')
-rw-r--r-- | apps/menu.c | 32 | ||||
-rw-r--r-- | apps/menu.h | 2 | ||||
-rw-r--r-- | apps/plugins/xobox.c | 62 |
3 files changed, 31 insertions, 65 deletions
diff --git a/apps/menu.c b/apps/menu.c index 32b50d4912..a519c1a857 100644 --- a/apps/menu.c +++ b/apps/menu.c @@ -142,6 +142,11 @@ static void menu_get_icon(int selected_item, void * data, ICON * icon) int menu_icon = Icon_NOICON; selected_item = get_menu_selection(selected_item, menu); + if ((menu->flags&MENU_TYPE_MASK) == MT_RETURN_ID) + { + *icon = bitmap_icons_6x8[Icon_Menu_functioncall]; + return; + } menu = menu->submenus[selected_item]; if (menu->flags&MENU_HAS_DESC) menu_icon = menu->callback_and_desc->icon_id; @@ -177,22 +182,27 @@ static void init_menu_lists(const struct menu_item_ex *menu, struct gui_synclist *lists, int selected, bool callback) { int i, count = MENU_GET_COUNT(menu->flags); + int type = (menu->flags&MENU_TYPE_MASK); menu_callback_type menu_callback = NULL; ICON icon = NOICON; current_subitems_count = 0; - if ((menu->flags&MENU_TYPE_MASK) == MT_OLD_MENU) + if (type == MT_OLD_MENU) { init_oldmenu(menu, lists, selected, callback); return; } - + if (type == MT_RETURN_ID) + get_menu_callback(menu, &menu_callback); + for (i=0; i<count; i++) { - get_menu_callback(menu->submenus[i],&menu_callback); + if (type != MT_RETURN_ID) + get_menu_callback(menu->submenus[i],&menu_callback); if (menu_callback) { - if (menu_callback(ACTION_REQUEST_MENUITEM,menu->submenus[i]) + if (menu_callback(ACTION_REQUEST_MENUITEM, + type==MT_RETURN_ID ? (void*)(intptr_t)i: menu->submenus[i]) != ACTION_EXIT_MENUITEM) { current_subitems[current_subitems_count] = i; @@ -524,13 +534,15 @@ int do_menu(const struct menu_item_ex *start_menu, int *start_selected) if (in_stringlist) type = (menu->flags&MENU_TYPE_MASK); else - type = (temp->flags&MENU_TYPE_MASK); - get_menu_callback(temp, &menu_callback); - if (menu_callback) { - action = menu_callback(ACTION_ENTER_MENUITEM,temp); - if (action == ACTION_EXIT_MENUITEM) - break; + type = (temp->flags&MENU_TYPE_MASK); + get_menu_callback(temp, &menu_callback); + if (menu_callback) + { + action = menu_callback(ACTION_ENTER_MENUITEM,temp); + if (action == ACTION_EXIT_MENUITEM) + break; + } } switch (type) { diff --git a/apps/menu.h b/apps/menu.h index 3a7a2de42f..aab2365a14 100644 --- a/apps/menu.h +++ b/apps/menu.h @@ -130,7 +130,7 @@ bool do_setting_from_menu(const struct menu_item_ex *temp); static const struct menu_item_ex name = \ {MT_RETURN_ID|MENU_HAS_DESC| \ MENU_ITEM_COUNT(sizeof( name##_)/sizeof(*name##_)), \ - { .submenus = name##_},{.callback_and_desc = & name##__}}; + { .strings = name##_},{.callback_and_desc = & name##__}}; /* returns a value associated with the item */ diff --git a/apps/plugins/xobox.c b/apps/plugins/xobox.c index df7a65b2eb..a2a8d4e50f 100644 --- a/apps/plugins/xobox.c +++ b/apps/plugins/xobox.c @@ -716,60 +716,14 @@ static inline void move_board (void) #define MENU_QUIT 1 static int game_menu (void) { - static char menu[MAIN_MENU_SIZE][15] = { - "Start New Game", - "Quit" - }; - - int button, selection = 0, sw, sh, i; - bool quit = false; - - rb->lcd_setfont(FONT_UI); - rb->lcd_getstringsize("A", &sw, &sh); - if(sw*20 > LCD_WIDTH || sh*4 > LCD_HEIGHT) - rb->lcd_setfont(FONT_SYSFIXED); - - rb->lcd_getstringsize ("XOBOX", &sw, &sh); - sh++; - rb->lcd_set_background (LCD_WHITE); - rb->lcd_set_foreground (LCD_BLACK); - rb->lcd_clear_display (); - rb->lcd_putsxy (LCD_WIDTH / 2 - sw / 2, 2, "XOBOX"); - while (!quit) { - for (i = 0; i < MAIN_MENU_SIZE; i++) { - rb->lcd_set_foreground ((i == selection ? LCD_WHITE : LCD_BLACK)); - rb->lcd_set_background ((i == selection ? CLR_BLUE : LCD_WHITE)); - rb->lcd_putsxy (10, sh + 4 + i * sh, menu[i]); - } - rb->lcd_update (); - button = rb->button_get (true); - switch (button) { -#ifdef MENU_UP - case MENU_UP: -#else - case UP: -#endif - selection = (selection + MAIN_MENU_SIZE - 1) % MAIN_MENU_SIZE; - break; -#ifdef MENU_UP - case MENU_DOWN: -#else - case DOWN: -#endif - selection = (selection + 1) % MAIN_MENU_SIZE; - break; - case SELECT: - case RIGHT: - quit = true; - break; -#ifdef RC_QUIT - case RC_QUIT: -#endif - case QUIT: - selection = MENU_QUIT; - quit = true; - break; - } + MENUITEM_STRINGLIST(menu, "XOBOX Menu", NULL, "Start New Game", "Quit"); + int selection = 0; + rb->lcd_set_foreground (rb->global_settings->fg_color); + rb->lcd_set_background (rb->global_settings->bg_color); + selection = rb->do_menu(&menu, NULL); + if (selection < 0) + { + selection = MENU_QUIT; } return selection; } |