From 0019e5e4455c1675e93199ac117bb30a5cff3d2e Mon Sep 17 00:00:00 2001 From: Robin Jones Date: Fri, 15 Nov 2024 19:44:59 +0000 Subject: [PATCH] split action bar text lines --- Makefile | 1 + src/menu/ui_components.h | 32 ++++++++++++++++++++++++- src/menu/ui_components/common.c | 2 +- src/menu/ui_components/joypad_buttons.c | 12 ++++++++++ src/menu/views/browser.c | 20 +++++++++++----- src/menu/views/credits.c | 2 +- src/menu/views/file_info.c | 2 +- src/menu/views/flashcart_info.c | 2 +- src/menu/views/load_disk.c | 10 +++++--- src/menu/views/load_emulator.c | 8 +++++-- src/menu/views/load_rom.c | 16 +++++++++---- src/menu/views/music_player.c | 10 +++++--- src/menu/views/rtc.c | 26 ++++++++++++++------ src/menu/views/settings_editor.c | 9 +++++-- src/menu/views/system_info.c | 2 +- src/menu/views/text_viewer.c | 11 ++++++--- 16 files changed, 129 insertions(+), 36 deletions(-) create mode 100644 src/menu/ui_components/joypad_buttons.c diff --git a/Makefile b/Makefile index 052b3c44..d63f0e7d 100644 --- a/Makefile +++ b/Makefile @@ -56,6 +56,7 @@ SRCS = \ menu/ui_components/common.c \ menu/ui_components/context_menu.c \ menu/ui_components/file_list.c \ + menu/ui_components/joypad_buttons.c \ menu/usb_comm.c \ menu/views/browser.c \ menu/views/credits.c \ diff --git a/src/menu/ui_components.h b/src/menu/ui_components.h index f0dc6060..50f6463e 100644 --- a/src/menu/ui_components.h +++ b/src/menu/ui_components.h @@ -29,6 +29,36 @@ typedef enum { IMAGE_TYPE_END /**< List end marker */ } file_image_type_t; +/** + * @brief joypad button sprite Enumeration. + * + * Enumeration for different types of joypad button sprites used in the user interface. + */ +typedef enum { + SPRITE_JOYPAD_BUTTON_A, + SPRITE_JOYPAD_BUTTON_B, + SPRITE_JOYPAD_BUTTON_C_DOWN, + SPRITE_JOYPAD_BUTTON_C_LEFT, + SPRITE_JOYPAD_BUTTON_C_RIGHT, + SPRITE_JOYPAD_BUTTON_C_UP, + SPRITE_JOYPAD_BUTTON_D_DOWN, + SPRITE_JOYPAD_BUTTON_D_LEFT, + SPRITE_JOYPAD_BUTTON_D_RIGHT, + SPRITE_JOYPAD_BUTTON_D_UP, + SPRITE_JOYPAD_BUTTON_L, + SPRITE_JOYPAD_BUTTON_R, + SPRITE_JOYPAD_BUTTON_Z, + SPRITE_JOYPAD_BUTTON_TYPE_END /**< List end marker */ +} sprite_joypad_button_type_t; + + +typedef enum { + ACTION_BAR_LINE_ONE, + ACTION_BAR_LINE_TWO, + ACTION_BAR_LINE_END +} action_bar_line_t; + + /** * @brief Draw a box component. * @@ -136,7 +166,7 @@ void ui_components_main_text_draw(rdpq_align_t align, rdpq_valign_t valign, char * @param fmt Format string for the text. * @param ... Additional arguments for the format string. */ -void ui_components_actions_bar_text_draw(rdpq_align_t align, rdpq_valign_t valign, char *fmt, ...); +void ui_components_actions_bar_text_draw(rdpq_align_t align, rdpq_valign_t valign, action_bar_line_t line, char *fmt, ...); /** * @brief Initialize the background component. diff --git a/src/menu/ui_components/common.c b/src/menu/ui_components/common.c index dec31885..1d45a80b 100644 --- a/src/menu/ui_components/common.c +++ b/src/menu/ui_components/common.c @@ -166,7 +166,7 @@ void ui_components_main_text_draw (rdpq_align_t align, rdpq_valign_t valign, cha } } -void ui_components_actions_bar_text_draw (rdpq_align_t align, rdpq_valign_t valign, char *fmt, ...) { +void ui_components_actions_bar_text_draw (rdpq_align_t align, rdpq_valign_t valign, action_bar_line_t line, char *fmt, ...) { char buffer[256]; size_t nbytes = sizeof(buffer); diff --git a/src/menu/ui_components/joypad_buttons.c b/src/menu/ui_components/joypad_buttons.c new file mode 100644 index 00000000..eb768581 --- /dev/null +++ b/src/menu/ui_components/joypad_buttons.c @@ -0,0 +1,12 @@ +#include +#include + +#include "../ui_components.h" + +void ui_components_joypad_buttons_init(void) { + +} + +void ui_components_joypad_buttons_draw (void) { + +} diff --git a/src/menu/views/browser.c b/src/menu/views/browser.c index abe86b59..2e546661 100644 --- a/src/menu/views/browser.c +++ b/src/menu/views/browser.c @@ -386,23 +386,31 @@ static void draw (menu_t *menu, surface_t *d) { } ui_components_actions_bar_text_draw( - ALIGN_LEFT, VALIGN_TOP, - "%s\n" + ALIGN_LEFT, VALIGN_TOP, ACTION_BAR_LINE_ONE, + "%s", + menu->browser.entries == 0 ? "" : action + ); + ui_components_actions_bar_text_draw( + ALIGN_LEFT, VALIGN_TOP, ACTION_BAR_LINE_TWO, + "\n" "^%02XB: Back^00", - menu->browser.entries == 0 ? "" : action, path_is_root(menu->browser.directory) ? STL_GRAY : STL_DEFAULT ); ui_components_actions_bar_text_draw( - ALIGN_RIGHT, VALIGN_TOP, - "Start: Settings\n" + ALIGN_RIGHT, VALIGN_TOP, ACTION_BAR_LINE_ONE, + "Start: Settings" + ); + ui_components_actions_bar_text_draw( + ALIGN_RIGHT, VALIGN_TOP, ACTION_BAR_LINE_TWO, + "\n" "^%02XR: Options^00", menu->browser.entries == 0 ? STL_GRAY : STL_DEFAULT ); if (menu->current_time >= 0) { ui_components_actions_bar_text_draw( - ALIGN_CENTER, VALIGN_TOP, + ALIGN_CENTER, VALIGN_TOP, ACTION_BAR_LINE_TWO, "\n" "%s", ctime(&menu->current_time) diff --git a/src/menu/views/credits.c b/src/menu/views/credits.c index 3595b30c..034b29f4 100644 --- a/src/menu/views/credits.c +++ b/src/menu/views/credits.c @@ -55,7 +55,7 @@ static void draw (menu_t *menu, surface_t *d) { ); ui_components_actions_bar_text_draw( - ALIGN_LEFT, VALIGN_TOP, + ALIGN_LEFT, VALIGN_TOP, ACTION_BAR_LINE_TWO, "\n" "B: Exit" ); diff --git a/src/menu/views/file_info.c b/src/menu/views/file_info.c index be204e5f..0ae04237 100644 --- a/src/menu/views/file_info.c +++ b/src/menu/views/file_info.c @@ -88,7 +88,7 @@ static void draw (menu_t *menu, surface_t *d) { ); ui_components_actions_bar_text_draw( - ALIGN_LEFT, VALIGN_TOP, + ALIGN_LEFT, VALIGN_TOP, ACTION_BAR_LINE_TWO, "\n" "B: Exit" ); diff --git a/src/menu/views/flashcart_info.c b/src/menu/views/flashcart_info.c index abf99991..8bd8c585 100644 --- a/src/menu/views/flashcart_info.c +++ b/src/menu/views/flashcart_info.c @@ -79,7 +79,7 @@ static void draw (menu_t *menu, surface_t *d) { ); ui_components_actions_bar_text_draw( - ALIGN_LEFT, VALIGN_TOP, + ALIGN_LEFT, VALIGN_TOP, ACTION_BAR_LINE_TWO, "\n" "B: Back" ); diff --git a/src/menu/views/load_disk.c b/src/menu/views/load_disk.c index c1e24a79..97d60926 100644 --- a/src/menu/views/load_disk.c +++ b/src/menu/views/load_disk.c @@ -81,14 +81,18 @@ static void draw (menu_t *menu, surface_t *d) { ); ui_components_actions_bar_text_draw( - ALIGN_LEFT, VALIGN_TOP, - "A: Load and run 64DD disk\n" + ALIGN_LEFT, VALIGN_TOP, ACTION_BAR_LINE_ONE, + "A: Load and run 64DD disk" + ); + ui_components_actions_bar_text_draw( + ALIGN_LEFT, VALIGN_TOP, ACTION_BAR_LINE_TWO, + "\n" "B: Exit" ); if (menu->load.rom_path) { ui_components_actions_bar_text_draw( - ALIGN_RIGHT, VALIGN_TOP, + ALIGN_RIGHT, VALIGN_TOP, ACTION_BAR_LINE_ONE, "R: Load with ROM" ); } diff --git a/src/menu/views/load_emulator.c b/src/menu/views/load_emulator.c index ad923145..7b4958b5 100644 --- a/src/menu/views/load_emulator.c +++ b/src/menu/views/load_emulator.c @@ -66,8 +66,12 @@ static void draw (menu_t *menu, surface_t *d) { ); ui_components_actions_bar_text_draw( - ALIGN_LEFT, VALIGN_TOP, - "A: Load and run Emulated ROM\n" + ALIGN_LEFT, VALIGN_TOP, ACTION_BAR_LINE_ONE, + "A: Load and run Emulated ROM" + ); + ui_components_actions_bar_text_draw( + ALIGN_LEFT, VALIGN_TOP, ACTION_BAR_LINE_TWO, + "\n" "B: Exit" ); } diff --git a/src/menu/views/load_rom.c b/src/menu/views/load_rom.c index fb95003f..d7bb7d24 100644 --- a/src/menu/views/load_rom.c +++ b/src/menu/views/load_rom.c @@ -263,14 +263,22 @@ static void draw (menu_t *menu, surface_t *d) { ); ui_components_actions_bar_text_draw( - ALIGN_LEFT, VALIGN_TOP, - "A: Load and run ROM\n" + ALIGN_LEFT, VALIGN_TOP, ACTION_BAR_LINE_ONE, + "A: Load and run ROM" + ); + ui_components_actions_bar_text_draw( + ALIGN_LEFT, VALIGN_TOP, ACTION_BAR_LINE_TWO, + "\n" "B: Back" ); ui_components_actions_bar_text_draw( - ALIGN_RIGHT, VALIGN_TOP, - "L|Z: Extra Info\n" + ALIGN_RIGHT, VALIGN_TOP, ACTION_BAR_LINE_ONE, + "L|Z: Extra Info" + ); + ui_components_actions_bar_text_draw( + ALIGN_RIGHT, VALIGN_TOP, ACTION_BAR_LINE_TWO, + "\n" "R: Options" ); diff --git a/src/menu/views/music_player.c b/src/menu/views/music_player.c index b2dde597..217fadc1 100644 --- a/src/menu/views/music_player.c +++ b/src/menu/views/music_player.c @@ -103,11 +103,15 @@ static void draw (menu_t *menu, surface_t *d) { ); ui_components_actions_bar_text_draw( - ALIGN_LEFT, VALIGN_TOP, - "A: %s\n" - "B: Exit | Left / Right: Rewind / Fast forward", + ALIGN_LEFT, VALIGN_TOP, ACTION_BAR_LINE_ONE, + "A: %s", mp3player_is_playing() ? "Pause" : mp3player_is_finished() ? "Play again" : "Play" ); + ui_components_actions_bar_text_draw( + ALIGN_LEFT, VALIGN_TOP, ACTION_BAR_LINE_TWO, + "\n" + "B: Exit | Left / Right: Rewind / Fast forward" + ); rdpq_detach_show(); } diff --git a/src/menu/views/rtc.c b/src/menu/views/rtc.c index f7e93dad..1aab2541 100644 --- a/src/menu/views/rtc.c +++ b/src/menu/views/rtc.c @@ -187,8 +187,12 @@ static void draw (menu_t *menu, surface_t *d) { ); ui_components_actions_bar_text_draw( - ALIGN_LEFT, VALIGN_TOP, - "A: Change\n" + ALIGN_LEFT, VALIGN_TOP, ACTION_BAR_LINE_ONE, + "A: Change" + ); + ui_components_actions_bar_text_draw( + ALIGN_LEFT, VALIGN_TOP, ACTION_BAR_LINE_TWO, + "\n" "B: Back" ); } @@ -207,7 +211,7 @@ static void draw (menu_t *menu, surface_t *d) { ); ui_components_actions_bar_text_draw( - ALIGN_LEFT, VALIGN_TOP, + ALIGN_LEFT, VALIGN_TOP, ACTION_BAR_LINE_TWO, "\n" "B: Back" ); @@ -215,13 +219,21 @@ static void draw (menu_t *menu, surface_t *d) { } else { ui_components_actions_bar_text_draw( - ALIGN_RIGHT, VALIGN_TOP, - "Up/Down: Adjust Field\n" + ALIGN_RIGHT, VALIGN_TOP, ACTION_BAR_LINE_ONE, + "Up/Down: Adjust Field" + ); + ui_components_actions_bar_text_draw( + ALIGN_RIGHT, VALIGN_TOP, ACTION_BAR_LINE_TWO, + "\n" "Left/Right: Switch Field" ); ui_components_actions_bar_text_draw( - ALIGN_LEFT, VALIGN_TOP, - "R: Save\n" + ALIGN_LEFT, VALIGN_TOP, ACTION_BAR_LINE_ONE, + "R: Save" + ); + ui_components_actions_bar_text_draw( + ALIGN_LEFT, VALIGN_TOP, ACTION_BAR_LINE_TWO, + "\n" "B: Back" ); } diff --git a/src/menu/views/settings_editor.c b/src/menu/views/settings_editor.c index 4b2467d1..bb092bbc 100644 --- a/src/menu/views/settings_editor.c +++ b/src/menu/views/settings_editor.c @@ -164,8 +164,13 @@ static void draw (menu_t *menu, surface_t *d) { ui_components_actions_bar_text_draw( - ALIGN_LEFT, VALIGN_TOP, - "A: Change\n" + ALIGN_LEFT, VALIGN_TOP, ACTION_BAR_LINE_ONE, + "A: Change" + ); + + ui_components_actions_bar_text_draw( + ALIGN_LEFT, VALIGN_TOP, ACTION_BAR_LINE_TWO, + "\n" "B: Back" ); diff --git a/src/menu/views/system_info.c b/src/menu/views/system_info.c index 653ee0b0..b21e779b 100644 --- a/src/menu/views/system_info.c +++ b/src/menu/views/system_info.c @@ -66,7 +66,7 @@ static void draw (menu_t *menu, surface_t *d) { ); ui_components_actions_bar_text_draw( - ALIGN_LEFT, VALIGN_TOP, + ALIGN_LEFT, VALIGN_TOP, ACTION_BAR_LINE_TWO, "\n" "B: Exit" ); diff --git a/src/menu/views/text_viewer.c b/src/menu/views/text_viewer.c index b3cdb559..d41b014c 100644 --- a/src/menu/views/text_viewer.c +++ b/src/menu/views/text_viewer.c @@ -82,12 +82,17 @@ static void draw (menu_t *menu, surface_t *d) { ui_components_list_scrollbar_draw(text->current_line, text->lines, LIST_ENTRIES); ui_components_actions_bar_text_draw( - ALIGN_LEFT, VALIGN_TOP, - "^%02XUp / Down: Scroll^00\n" - "B: Back", + ALIGN_LEFT, VALIGN_TOP, ACTION_BAR_LINE_ONE, + "^%02XUp / Down: Scroll^00", text->vertical_scroll_possible ? STL_DEFAULT : STL_GRAY ); + ui_components_actions_bar_text_draw( + ALIGN_LEFT, VALIGN_TOP, ACTION_BAR_LINE_TWO, + "\n" + "B: Back" + ); + rdpq_detach_show(); }