aboutsummaryrefslogtreecommitdiff
path: root/src/menu
diff options
context:
space:
mode:
authorXavier Del Campo Romero <xavi.dcr@tutanota.com>2022-07-06 23:46:59 +0200
committerXavier Del Campo Romero <xavi.dcr@tutanota.com>2022-07-07 02:37:25 +0200
commit251bd41c4499521baa2c810155f85a7fcb528116 (patch)
treeb7abb43109eb85369cec0c804de17507eca3f5b4 /src/menu
parenta0363cef8578c098de48e8863db98a35750fbaac (diff)
downloadrts-251bd41c4499521baa2c810155f85a7fcb528116.tar.gz
Allow multiple button types
Diffstat (limited to 'src/menu')
-rw-r--r--src/menu/src/menu.c37
1 files changed, 28 insertions, 9 deletions
diff --git a/src/menu/src/menu.c b/src/menu/src/menu.c
index 38f8632..c2f1e96 100644
--- a/src/menu/src/menu.c
+++ b/src/menu/src/menu.c
@@ -29,18 +29,19 @@ int menu(void)
cnt.mode = GUI_CONTAINER_MODE_V;
cnt.common.hcentered = true;
cnt.common.vcentered = true;
- gui_button_init(&play);
- gui_button_init(&exit_btn);
+ cnt.spacing = 4;
+ gui_button_init(&play, GUI_BUTTON_TYPE_1);
+ gui_button_init(&exit_btn, GUI_BUTTON_TYPE_1);
play.on_pressed = on_pressed;
play.arg = &start;
- play.w = 140;
+ play.u.type1.w = 140;
play.common.hcentered = true;
- play.label.text = "Play";
+ play.u.type1.label.text = "Play";
exit_btn.arg = &exit;
- exit_btn.w = 140;
+ exit_btn.u.type1.w = 140;
exit_btn.common.hcentered = true;
- exit_btn.label.text = "Exit";
+ exit_btn.u.type1.label.text = "Exit";
exit_btn.on_pressed = on_pressed;
gui_add_child(&cnt.common, &play.common);
gui_add_child(&cnt.common, &exit_btn.common);
@@ -72,9 +73,27 @@ int menu(void)
if (p.common.exit || exit)
return 0;
- if (gui_render(&cnt.common)
- || cursor_render(&cam.cursor)
- || gfx_draw())
+ if (gui_render(&cnt.common))
+ return -1;
+
+ switch (p.common.type)
+ {
+ case PERIPHERAL_TYPE_PAD:
+ /* Fall through. */
+ case PERIPHERAL_TYPE_KEYBOARD_MOUSE:
+ if (cursor_render(&cam.cursor))
+ return -1;
+
+ break;
+
+ case PERIPHERAL_TYPE_TOUCH:
+ break;
+
+ default:
+ return -1;
+ }
+
+ if (gfx_draw())
return -1;
}