From 3846547707f593d149511cebf36f5fdbae8518d7 Mon Sep 17 00:00:00 2001 From: Mateusz Faderewski Date: Thu, 21 Dec 2023 20:14:01 +0100 Subject: [PATCH] Cleaned up navigation --- src/menu/actions.c | 6 ------ src/menu/menu_state.h | 2 -- src/menu/views/browser.c | 42 ++++++++++++++++++++++++++++++--------- src/menu/views/load_rom.c | 4 ++-- 4 files changed, 35 insertions(+), 19 deletions(-) diff --git a/src/menu/actions.c b/src/menu/actions.c index 79791b4a..8bb58587 100644 --- a/src/menu/actions.c +++ b/src/menu/actions.c @@ -20,9 +20,7 @@ static void actions_clear (menu_t *menu) { menu->actions.enter = false; menu->actions.back = false; menu->actions.options = false; - menu->actions.system_info = false; menu->actions.settings = false; - menu->actions.credits = false; } static void actions_update_direction (menu_t *menu) { @@ -91,11 +89,7 @@ static void actions_update_buttons (menu_t *menu) { menu->actions.back = true; } else if (pressed.r) { menu->actions.options = true; - } else if (pressed.z) { - menu->actions.system_info = true; } else if (pressed.start) { - menu->actions.credits = true; - } else if (pressed.l) { menu->actions.settings = true; } } diff --git a/src/menu/menu_state.h b/src/menu/menu_state.h index 76e37358..7c0c5f10 100644 --- a/src/menu/menu_state.h +++ b/src/menu/menu_state.h @@ -83,9 +83,7 @@ typedef struct { bool enter; bool back; bool options; - bool system_info; bool settings; - bool credits; } actions; struct { diff --git a/src/menu/views/browser.c b/src/menu/views/browser.c index 21dee587..ecc3ac2b 100644 --- a/src/menu/views/browser.c +++ b/src/menu/views/browser.c @@ -228,11 +228,36 @@ static component_context_menu_t entry_context_menu = { } }; +static void edit_settings (menu_t *menu) { + menu->next_mode = MENU_MODE_SETTINGS_EDITOR; +} + +static void show_system_info (menu_t *menu) { + menu->next_mode = MENU_MODE_SYSTEM_INFO; +} + +static void show_credits (menu_t *menu) { + menu->next_mode = MENU_MODE_CREDITS; +} + +static component_context_menu_t settings_context_menu = { + .list = { + { .text = "Edit settings", .action = edit_settings }, + { .text = "Show system info", .action = show_system_info }, + { .text = "Show credits", .action = show_credits }, + COMPONENT_CONTEXT_MENU_LIST_END, + } +}; + static void process (menu_t *menu) { if (component_context_menu_process(menu, &entry_context_menu)) { return; } + if (component_context_menu_process(menu, &settings_context_menu)) { + return; + } + int scroll_speed = menu->actions.go_fast ? 10 : 1; if (menu->browser.entries > 1) { @@ -284,12 +309,8 @@ static void process (menu_t *menu) { } } else if (menu->actions.options && menu->browser.entry) { component_context_menu_show(&entry_context_menu); - } else if (menu->actions.system_info) { - menu->next_mode = MENU_MODE_SYSTEM_INFO; - } else if (menu->actions.credits) { - menu->next_mode = MENU_MODE_CREDITS; } else if (menu->actions.settings) { - menu->next_mode = MENU_MODE_SETTINGS_EDITOR; + component_context_menu_show(&settings_context_menu); } } @@ -326,15 +347,15 @@ static void draw (menu_t *menu, surface_t *d) { component_actions_bar_text_draw( ALIGN_RIGHT, VALIGN_TOP, - "%s\n" - "L: Settings", - menu->browser.entries == 0 ? "" : "R: Options" + "Start: Settings\n" + "^%02XR: Options^00", + menu->browser.entries == 0 ? STL_UNKNOWN : STL_DEFAULT ); if (menu->current_time >= 0) { component_actions_bar_text_draw( ALIGN_CENTER, VALIGN_TOP, - "Z: System Info | Start: Credits\n" + "\n" "%s", ctime(&menu->current_time) ); @@ -342,6 +363,8 @@ static void draw (menu_t *menu, surface_t *d) { component_context_menu_draw(&entry_context_menu); + component_context_menu_draw(&settings_context_menu); + rdpq_detach_show(); } @@ -349,6 +372,7 @@ static void draw (menu_t *menu, surface_t *d) { void view_browser_init (menu_t *menu) { if (!menu->browser.valid) { component_context_menu_init(&entry_context_menu); + component_context_menu_init(&settings_context_menu); if (load_directory(menu)) { path_free(menu->browser.directory); menu->browser.directory = path_init("sd:/", ""); diff --git a/src/menu/views/load_rom.c b/src/menu/views/load_rom.c index f8a23219..6beeaa0f 100644 --- a/src/menu/views/load_rom.c +++ b/src/menu/views/load_rom.c @@ -161,8 +161,8 @@ static component_context_menu_t set_tv_type_context_menu = { .list = { }}; static component_context_menu_t options_context_menu = { .list = { - { .text = "Set Save Type", .submenu = &set_save_type_context_menu }, - { .text = "Set TV Type", .submenu = &set_tv_type_context_menu }, + { .text = "Set save type", .submenu = &set_save_type_context_menu }, + { .text = "Set TV type", .submenu = &set_tv_type_context_menu }, COMPONENT_CONTEXT_MENU_LIST_END, }};