all repos — mgba @ 44736f89be783d41571bb62347f42eeeb43b74a5

mGBA Game Boy Advance Emulator

GUI: Submenus
Jeffrey Pfau jeffrey@endrift.com
Tue, 01 Sep 2015 22:09:12 -0700
commit

44736f89be783d41571bb62347f42eeeb43b74a5

parent

d724d914c89304c339d738d924bed5a929d8a891

2 files changed, 10 insertions(+), 1 deletions(-)

jump to
M src/util/gui/menu.csrc/util/gui/menu.c

@@ -56,7 +56,14 @@ break;

} if (newInput & (1 << GUI_INPUT_SELECT)) { *item = *GUIMenuItemListGetPointer(&menu->items, menu->index); - return GUI_MENU_EXIT_ACCEPT; + if (item->submenu) { + enum GUIMenuExitReason reason = GUIShowMenu(params, item->submenu, item); + if (reason != GUI_MENU_EXIT_BACK) { + return reason; + } + } else { + return GUI_MENU_EXIT_ACCEPT; + } } if (newInput & (1 << GUI_INPUT_BACK)) { return GUI_MENU_EXIT_BACK;
M src/util/gui/menu.hsrc/util/gui/menu.h

@@ -8,9 +8,11 @@ #define GUI_MENU_H

#include "util/vector.h" +struct GUIMenu; struct GUIMenuItem { const char* title; void* data; + struct GUIMenu* submenu; }; DECLARE_VECTOR(GUIMenuItemList, struct GUIMenuItem);