From 0019e5e4455c1675e93199ac117bb30a5cff3d2e Mon Sep 17 00:00:00 2001 From: Robin Jones Date: Fri, 15 Nov 2024 19:44:59 +0000 Subject: [PATCH 1/9] 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 052b3c44e..d63f0e7d6 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 f0dc6060b..50f6463e8 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 dec318852..1d45a80b4 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 000000000..eb7685813 --- /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 abe86b598..2e5466615 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 3595b30c4..034b29f4d 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 be204e5f1..0ae04237f 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 abf99991d..8bd8c5856 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 c1e24a792..97d609268 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 ad9231454..7b4958b56 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 fb95003fe..d7bb7d244 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 b2dde5975..217fadc15 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 f7e93dad0..1aab25410 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 4b2467d1e..bb092bbc9 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 653ee0b07..b21e779b8 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 b3cdb5591..d41b014c2 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(); } From 868f450ebfbe23f815dc0e96e33d678a9adc8796 Mon Sep 17 00:00:00 2001 From: Robin Jones Date: Fri, 15 Nov 2024 20:14:43 +0000 Subject: [PATCH 2/9] Add context button enumeration --- src/menu/ui_components.h | 4 +++- src/menu/ui_components/common.c | 2 +- src/menu/views/browser.c | 10 +++++----- 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 | 6 +++--- src/menu/views/load_emulator.c | 4 ++-- src/menu/views/load_rom.c | 8 ++++---- src/menu/views/music_player.c | 4 ++-- src/menu/views/rtc.c | 14 +++++++------- src/menu/views/settings_editor.c | 4 ++-- src/menu/views/system_info.c | 2 +- src/menu/views/text_viewer.c | 4 ++-- 14 files changed, 35 insertions(+), 33 deletions(-) diff --git a/src/menu/ui_components.h b/src/menu/ui_components.h index 50f6463e8..86e313f6f 100644 --- a/src/menu/ui_components.h +++ b/src/menu/ui_components.h @@ -35,6 +35,7 @@ typedef enum { * Enumeration for different types of joypad button sprites used in the user interface. */ typedef enum { + SPRITE_JOYPAD_BUTTON_NONE, SPRITE_JOYPAD_BUTTON_A, SPRITE_JOYPAD_BUTTON_B, SPRITE_JOYPAD_BUTTON_C_DOWN, @@ -47,6 +48,7 @@ typedef enum { SPRITE_JOYPAD_BUTTON_D_UP, SPRITE_JOYPAD_BUTTON_L, SPRITE_JOYPAD_BUTTON_R, + SPRITE_JOYPAD_BUTTON_START, SPRITE_JOYPAD_BUTTON_Z, SPRITE_JOYPAD_BUTTON_TYPE_END /**< List end marker */ } sprite_joypad_button_type_t; @@ -166,7 +168,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, action_bar_line_t line, char *fmt, ...); +void ui_components_actions_bar_text_draw(rdpq_align_t align, rdpq_valign_t valign, action_bar_line_t line, sprite_joypad_button_type_t context_button, char *fmt, ...); /** * @brief Initialize the background component. diff --git a/src/menu/ui_components/common.c b/src/menu/ui_components/common.c index 1d45a80b4..9f5e307b0 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, action_bar_line_t line, char *fmt, ...) { +void ui_components_actions_bar_text_draw (rdpq_align_t align, rdpq_valign_t valign, action_bar_line_t line, sprite_joypad_button_type_t context_button, char *fmt, ...) { char buffer[256]; size_t nbytes = sizeof(buffer); diff --git a/src/menu/views/browser.c b/src/menu/views/browser.c index 2e5466615..b7ddf6729 100644 --- a/src/menu/views/browser.c +++ b/src/menu/views/browser.c @@ -386,23 +386,23 @@ static void draw (menu_t *menu, surface_t *d) { } ui_components_actions_bar_text_draw( - ALIGN_LEFT, VALIGN_TOP, ACTION_BAR_LINE_ONE, + ALIGN_LEFT, VALIGN_TOP, ACTION_BAR_LINE_ONE, SPRITE_JOYPAD_BUTTON_NONE, "%s", menu->browser.entries == 0 ? "" : action ); ui_components_actions_bar_text_draw( - ALIGN_LEFT, VALIGN_TOP, ACTION_BAR_LINE_TWO, + ALIGN_LEFT, VALIGN_TOP, ACTION_BAR_LINE_TWO, SPRITE_JOYPAD_BUTTON_B, "\n" "^%02XB: Back^00", path_is_root(menu->browser.directory) ? STL_GRAY : STL_DEFAULT ); ui_components_actions_bar_text_draw( - ALIGN_RIGHT, VALIGN_TOP, ACTION_BAR_LINE_ONE, + ALIGN_RIGHT, VALIGN_TOP, ACTION_BAR_LINE_ONE, SPRITE_JOYPAD_BUTTON_START, "Start: Settings" ); ui_components_actions_bar_text_draw( - ALIGN_RIGHT, VALIGN_TOP, ACTION_BAR_LINE_TWO, + ALIGN_RIGHT, VALIGN_TOP, ACTION_BAR_LINE_TWO, SPRITE_JOYPAD_BUTTON_R, "\n" "^%02XR: Options^00", menu->browser.entries == 0 ? STL_GRAY : STL_DEFAULT @@ -410,7 +410,7 @@ static void draw (menu_t *menu, surface_t *d) { if (menu->current_time >= 0) { ui_components_actions_bar_text_draw( - ALIGN_CENTER, VALIGN_TOP, ACTION_BAR_LINE_TWO, + ALIGN_CENTER, VALIGN_TOP, ACTION_BAR_LINE_TWO, SPRITE_JOYPAD_BUTTON_NONE, "\n" "%s", ctime(&menu->current_time) diff --git a/src/menu/views/credits.c b/src/menu/views/credits.c index 034b29f4d..1d0cf15d2 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, ACTION_BAR_LINE_TWO, + ALIGN_LEFT, VALIGN_TOP, ACTION_BAR_LINE_TWO, SPRITE_JOYPAD_BUTTON_B, "\n" "B: Exit" ); diff --git a/src/menu/views/file_info.c b/src/menu/views/file_info.c index 0ae04237f..2998faa66 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, ACTION_BAR_LINE_TWO, + ALIGN_LEFT, VALIGN_TOP, ACTION_BAR_LINE_TWO, SPRITE_JOYPAD_BUTTON_B, "\n" "B: Exit" ); diff --git a/src/menu/views/flashcart_info.c b/src/menu/views/flashcart_info.c index 8bd8c5856..a67119f90 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, ACTION_BAR_LINE_TWO, + ALIGN_LEFT, VALIGN_TOP, ACTION_BAR_LINE_TWO, SPRITE_JOYPAD_BUTTON_B, "\n" "B: Back" ); diff --git a/src/menu/views/load_disk.c b/src/menu/views/load_disk.c index 97d609268..4e6957e92 100644 --- a/src/menu/views/load_disk.c +++ b/src/menu/views/load_disk.c @@ -81,18 +81,18 @@ static void draw (menu_t *menu, surface_t *d) { ); ui_components_actions_bar_text_draw( - ALIGN_LEFT, VALIGN_TOP, ACTION_BAR_LINE_ONE, + ALIGN_LEFT, VALIGN_TOP, ACTION_BAR_LINE_ONE, SPRITE_JOYPAD_BUTTON_A, "A: Load and run 64DD disk" ); ui_components_actions_bar_text_draw( - ALIGN_LEFT, VALIGN_TOP, ACTION_BAR_LINE_TWO, + ALIGN_LEFT, VALIGN_TOP, ACTION_BAR_LINE_TWO, SPRITE_JOYPAD_BUTTON_B, "\n" "B: Exit" ); if (menu->load.rom_path) { ui_components_actions_bar_text_draw( - ALIGN_RIGHT, VALIGN_TOP, ACTION_BAR_LINE_ONE, + ALIGN_RIGHT, VALIGN_TOP, ACTION_BAR_LINE_ONE, SPRITE_JOYPAD_BUTTON_R, "R: Load with ROM" ); } diff --git a/src/menu/views/load_emulator.c b/src/menu/views/load_emulator.c index 7b4958b56..5c07c0916 100644 --- a/src/menu/views/load_emulator.c +++ b/src/menu/views/load_emulator.c @@ -66,11 +66,11 @@ static void draw (menu_t *menu, surface_t *d) { ); ui_components_actions_bar_text_draw( - ALIGN_LEFT, VALIGN_TOP, ACTION_BAR_LINE_ONE, + ALIGN_LEFT, VALIGN_TOP, ACTION_BAR_LINE_ONE, SPRITE_JOYPAD_BUTTON_A, "A: Load and run Emulated ROM" ); ui_components_actions_bar_text_draw( - ALIGN_LEFT, VALIGN_TOP, ACTION_BAR_LINE_TWO, + ALIGN_LEFT, VALIGN_TOP, ACTION_BAR_LINE_TWO, SPRITE_JOYPAD_BUTTON_B, "\n" "B: Exit" ); diff --git a/src/menu/views/load_rom.c b/src/menu/views/load_rom.c index d7bb7d244..d457feac7 100644 --- a/src/menu/views/load_rom.c +++ b/src/menu/views/load_rom.c @@ -263,21 +263,21 @@ static void draw (menu_t *menu, surface_t *d) { ); ui_components_actions_bar_text_draw( - ALIGN_LEFT, VALIGN_TOP, ACTION_BAR_LINE_ONE, + ALIGN_LEFT, VALIGN_TOP, ACTION_BAR_LINE_ONE, SPRITE_JOYPAD_BUTTON_A, "A: Load and run ROM" ); ui_components_actions_bar_text_draw( - ALIGN_LEFT, VALIGN_TOP, ACTION_BAR_LINE_TWO, + ALIGN_LEFT, VALIGN_TOP, ACTION_BAR_LINE_TWO, SPRITE_JOYPAD_BUTTON_B, "\n" "B: Back" ); ui_components_actions_bar_text_draw( - ALIGN_RIGHT, VALIGN_TOP, ACTION_BAR_LINE_ONE, + ALIGN_RIGHT, VALIGN_TOP, ACTION_BAR_LINE_ONE, SPRITE_JOYPAD_BUTTON_L, "L|Z: Extra Info" ); ui_components_actions_bar_text_draw( - ALIGN_RIGHT, VALIGN_TOP, ACTION_BAR_LINE_TWO, + ALIGN_RIGHT, VALIGN_TOP, ACTION_BAR_LINE_TWO, SPRITE_JOYPAD_BUTTON_R, "\n" "R: Options" ); diff --git a/src/menu/views/music_player.c b/src/menu/views/music_player.c index 217fadc15..8e9c5af74 100644 --- a/src/menu/views/music_player.c +++ b/src/menu/views/music_player.c @@ -103,12 +103,12 @@ static void draw (menu_t *menu, surface_t *d) { ); ui_components_actions_bar_text_draw( - ALIGN_LEFT, VALIGN_TOP, ACTION_BAR_LINE_ONE, + ALIGN_LEFT, VALIGN_TOP, ACTION_BAR_LINE_ONE, SPRITE_JOYPAD_BUTTON_A, "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, + ALIGN_LEFT, VALIGN_TOP, ACTION_BAR_LINE_TWO, SPRITE_JOYPAD_BUTTON_B, "\n" "B: Exit | Left / Right: Rewind / Fast forward" ); diff --git a/src/menu/views/rtc.c b/src/menu/views/rtc.c index 1aab25410..0bab4cdf8 100644 --- a/src/menu/views/rtc.c +++ b/src/menu/views/rtc.c @@ -187,11 +187,11 @@ static void draw (menu_t *menu, surface_t *d) { ); ui_components_actions_bar_text_draw( - ALIGN_LEFT, VALIGN_TOP, ACTION_BAR_LINE_ONE, + ALIGN_LEFT, VALIGN_TOP, ACTION_BAR_LINE_ONE, SPRITE_JOYPAD_BUTTON_A, "A: Change" ); ui_components_actions_bar_text_draw( - ALIGN_LEFT, VALIGN_TOP, ACTION_BAR_LINE_TWO, + ALIGN_LEFT, VALIGN_TOP, ACTION_BAR_LINE_TWO, SPRITE_JOYPAD_BUTTON_B, "\n" "B: Back" ); @@ -211,7 +211,7 @@ static void draw (menu_t *menu, surface_t *d) { ); ui_components_actions_bar_text_draw( - ALIGN_LEFT, VALIGN_TOP, ACTION_BAR_LINE_TWO, + ALIGN_LEFT, VALIGN_TOP, ACTION_BAR_LINE_TWO, SPRITE_JOYPAD_BUTTON_B, "\n" "B: Back" ); @@ -219,20 +219,20 @@ static void draw (menu_t *menu, surface_t *d) { } else { ui_components_actions_bar_text_draw( - ALIGN_RIGHT, VALIGN_TOP, ACTION_BAR_LINE_ONE, + ALIGN_RIGHT, VALIGN_TOP, ACTION_BAR_LINE_ONE, SPRITE_JOYPAD_BUTTON_NONE, "Up/Down: Adjust Field" ); ui_components_actions_bar_text_draw( - ALIGN_RIGHT, VALIGN_TOP, ACTION_BAR_LINE_TWO, + ALIGN_RIGHT, VALIGN_TOP, ACTION_BAR_LINE_TWO, SPRITE_JOYPAD_BUTTON_NONE, "\n" "Left/Right: Switch Field" ); ui_components_actions_bar_text_draw( - ALIGN_LEFT, VALIGN_TOP, ACTION_BAR_LINE_ONE, + ALIGN_LEFT, VALIGN_TOP, ACTION_BAR_LINE_ONE, SPRITE_JOYPAD_BUTTON_R, "R: Save" ); ui_components_actions_bar_text_draw( - ALIGN_LEFT, VALIGN_TOP, ACTION_BAR_LINE_TWO, + ALIGN_LEFT, VALIGN_TOP, ACTION_BAR_LINE_TWO, SPRITE_JOYPAD_BUTTON_B, "\n" "B: Back" ); diff --git a/src/menu/views/settings_editor.c b/src/menu/views/settings_editor.c index bb092bbc9..4bbaf0769 100644 --- a/src/menu/views/settings_editor.c +++ b/src/menu/views/settings_editor.c @@ -164,12 +164,12 @@ static void draw (menu_t *menu, surface_t *d) { ui_components_actions_bar_text_draw( - ALIGN_LEFT, VALIGN_TOP, ACTION_BAR_LINE_ONE, + ALIGN_LEFT, VALIGN_TOP, ACTION_BAR_LINE_ONE, SPRITE_JOYPAD_BUTTON_A, "A: Change" ); ui_components_actions_bar_text_draw( - ALIGN_LEFT, VALIGN_TOP, ACTION_BAR_LINE_TWO, + ALIGN_LEFT, VALIGN_TOP, ACTION_BAR_LINE_TWO, SPRITE_JOYPAD_BUTTON_B, "\n" "B: Back" ); diff --git a/src/menu/views/system_info.c b/src/menu/views/system_info.c index b21e779b8..b1550b854 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, ACTION_BAR_LINE_TWO, + ALIGN_LEFT, VALIGN_TOP, ACTION_BAR_LINE_TWO, SPRITE_JOYPAD_BUTTON_B, "\n" "B: Exit" ); diff --git a/src/menu/views/text_viewer.c b/src/menu/views/text_viewer.c index d41b014c2..f9249c4f5 100644 --- a/src/menu/views/text_viewer.c +++ b/src/menu/views/text_viewer.c @@ -82,13 +82,13 @@ 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, ACTION_BAR_LINE_ONE, + ALIGN_LEFT, VALIGN_TOP, ACTION_BAR_LINE_ONE, SPRITE_JOYPAD_BUTTON_NONE, "^%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, + ALIGN_LEFT, VALIGN_TOP, ACTION_BAR_LINE_TWO, SPRITE_JOYPAD_BUTTON_B, "\n" "B: Back" ); From 98a633056306cb711317e740dacb1e1fa166fdfd Mon Sep 17 00:00:00 2001 From: Robin Jones Date: Fri, 15 Nov 2024 20:28:13 +0000 Subject: [PATCH 3/9] Improve comments --- src/menu/ui_components/common.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/menu/ui_components/common.c b/src/menu/ui_components/common.c index 9f5e307b0..14f99a320 100644 --- a/src/menu/ui_components/common.c +++ b/src/menu/ui_components/common.c @@ -175,6 +175,9 @@ void ui_components_actions_bar_text_draw (rdpq_align_t align, rdpq_valign_t vali char *formatted = vasnprintf(buffer, &nbytes, fmt, va); va_end(va); + // FIXME: if there is a button to draw, we should add it! + // FIXME: take into account action bar line + rdpq_text_printn( &(rdpq_textparms_t) { .width = VISIBLE_AREA_WIDTH - (TEXT_MARGIN_HORIZONTAL * 2), From 8f393b50d77a2e6d89c5ee536c939068b5d2495f Mon Sep 17 00:00:00 2001 From: Robin Jones Date: Fri, 15 Nov 2024 20:47:12 +0000 Subject: [PATCH 4/9] minor improvements --- src/menu/ui_components.h | 4 ++-- src/menu/ui_components/common.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/menu/ui_components.h b/src/menu/ui_components.h index 86e313f6f..0fa7b3b2d 100644 --- a/src/menu/ui_components.h +++ b/src/menu/ui_components.h @@ -57,7 +57,7 @@ typedef enum { typedef enum { ACTION_BAR_LINE_ONE, ACTION_BAR_LINE_TWO, - ACTION_BAR_LINE_END + ACTION_BAR_LINE_END /**< List end marker */ } action_bar_line_t; @@ -168,7 +168,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, action_bar_line_t line, sprite_joypad_button_type_t context_button, char *fmt, ...); +void ui_components_actions_bar_text_draw(rdpq_align_t align, rdpq_valign_t valign, action_bar_line_t line, sprite_joypad_button_type_t action_button, char *fmt, ...); /** * @brief Initialize the background component. diff --git a/src/menu/ui_components/common.c b/src/menu/ui_components/common.c index 14f99a320..c284f252c 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, action_bar_line_t line, sprite_joypad_button_type_t context_button, char *fmt, ...) { +void ui_components_actions_bar_text_draw (rdpq_align_t align, rdpq_valign_t valign, action_bar_line_t line, sprite_joypad_button_type_t action_button, char *fmt, ...) { char buffer[256]; size_t nbytes = sizeof(buffer); @@ -175,7 +175,7 @@ void ui_components_actions_bar_text_draw (rdpq_align_t align, rdpq_valign_t vali char *formatted = vasnprintf(buffer, &nbytes, fmt, va); va_end(va); - // FIXME: if there is a button to draw, we should add it! + // FIXME: if there is an action button to draw, we should add it! // FIXME: take into account action bar line rdpq_text_printn( From ee610dcd8a5d2c80a5f8a04a93f3289a96d57b10 Mon Sep 17 00:00:00 2001 From: Robin Jones Date: Fri, 15 Nov 2024 23:09:34 +0000 Subject: [PATCH 5/9] loads a button at correct place. --- Makefile | 2 +- src/menu/menu.c | 2 ++ src/menu/ui_components.h | 6 ++++ src/menu/ui_components/common.c | 5 ++- src/menu/ui_components/joypad_buttons.c | 12 ------- src/menu/ui_components/sprites.c | 44 +++++++++++++++++++++++++ 6 files changed, 57 insertions(+), 14 deletions(-) delete mode 100644 src/menu/ui_components/joypad_buttons.c create mode 100644 src/menu/ui_components/sprites.c diff --git a/Makefile b/Makefile index d63f0e7d6..37de58b7a 100644 --- a/Makefile +++ b/Makefile @@ -56,7 +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/ui_components/sprites.c \ menu/usb_comm.c \ menu/views/browser.c \ menu/views/credits.c \ diff --git a/src/menu/menu.c b/src/menu/menu.c index 91a51a09f..359cb4cf7 100644 --- a/src/menu/menu.c +++ b/src/menu/menu.c @@ -55,6 +55,8 @@ static void menu_init (boot_params_t *boot_params) { rdpq_init(); dfs_init(DFS_DEFAULT_LOCATION); + ui_components_sprites_init(); + actions_init(); sound_init_default(); sound_init_sfx(); diff --git a/src/menu/ui_components.h b/src/menu/ui_components.h index 0fa7b3b2d..d066405a9 100644 --- a/src/menu/ui_components.h +++ b/src/menu/ui_components.h @@ -284,4 +284,10 @@ void ui_components_boxart_free(component_boxart_t *b); */ void ui_components_boxart_draw(component_boxart_t *b); + +void ui_components_sprites_init(void); + +void ui_components_joypad_buttons_draw (sprite_joypad_button_type_t button, float pos_x, float pos_y); + + #endif /* UI_COMPONENTS_H__ */ diff --git a/src/menu/ui_components/common.c b/src/menu/ui_components/common.c index c284f252c..499bb08c9 100644 --- a/src/menu/ui_components/common.c +++ b/src/menu/ui_components/common.c @@ -175,9 +175,12 @@ void ui_components_actions_bar_text_draw (rdpq_align_t align, rdpq_valign_t vali char *formatted = vasnprintf(buffer, &nbytes, fmt, va); va_end(va); - // FIXME: if there is an action button to draw, we should add it! // FIXME: take into account action bar line + if(action_button != SPRITE_JOYPAD_BUTTON_NONE) { + ui_components_joypad_buttons_draw(action_button, VISIBLE_AREA_X0 + TEXT_MARGIN_HORIZONTAL, LAYOUT_ACTIONS_SEPARATOR_Y + BORDER_THICKNESS + TEXT_MARGIN_VERTICAL + TEXT_OFFSET_VERTICAL); + } + rdpq_text_printn( &(rdpq_textparms_t) { .width = VISIBLE_AREA_WIDTH - (TEXT_MARGIN_HORIZONTAL * 2), diff --git a/src/menu/ui_components/joypad_buttons.c b/src/menu/ui_components/joypad_buttons.c deleted file mode 100644 index eb7685813..000000000 --- a/src/menu/ui_components/joypad_buttons.c +++ /dev/null @@ -1,12 +0,0 @@ -#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/ui_components/sprites.c b/src/menu/ui_components/sprites.c new file mode 100644 index 000000000..cea054b31 --- /dev/null +++ b/src/menu/ui_components/sprites.c @@ -0,0 +1,44 @@ +#include +#include + +#include "../ui_components.h" + +sprite_t *sprite_joypad_a; +sprite_t *sprite_joypad_b; +sprite_t *sprite_joypad_c_down; +sprite_t *sprite_joypad_c_left; +sprite_t *sprite_joypad_c_right; +sprite_t *sprite_joypad_c_up; +sprite_t *sprite_joypad_d_down; +sprite_t *sprite_joypad_d_left; +sprite_t *sprite_joypad_d_right; +sprite_t *sprite_joypad_d_up; +sprite_t *sprite_joypad_l; +sprite_t *sprite_joypad_r; +sprite_t *sprite_joypad_start; +sprite_t *sprite_joypad_z; + +void ui_components_sprites_init(void) { + sprite_joypad_a = sprite_load("rom:/joypad_a.sprite"); + sprite_joypad_b = sprite_load("rom:/joypad_b.sprite"); + sprite_joypad_c_down = sprite_load("rom:/joypad_c_down.sprite"); + sprite_joypad_c_left = sprite_load("rom:/joypad_c_left.sprite"); + sprite_joypad_c_right = sprite_load("rom:/joypad_c_right.sprite"); + sprite_joypad_c_up = sprite_load("rom:/joypad_c_up.sprite"); + sprite_joypad_d_down = sprite_load("rom:/joypad_d_down.sprite"); + sprite_joypad_d_left = sprite_load("rom:/joypad_d_left.sprite"); + sprite_joypad_d_right = sprite_load("rom:/joypad_d_right.sprite"); + sprite_joypad_d_up = sprite_load("rom:/joypad_d_up.sprite"); + sprite_joypad_l = sprite_load("rom:/joypad_l.sprite"); + sprite_joypad_r = sprite_load("rom:/joypad_r.sprite"); + sprite_joypad_start = sprite_load("rom:/joypad_start.sprite"); + sprite_joypad_z = sprite_load("rom:/joypad_z.sprite"); +} + +void ui_components_joypad_buttons_draw (sprite_joypad_button_type_t button, float pos_x, float pos_y) { + rdpq_set_mode_standard(); + rdpq_mode_blender(RDPQ_BLENDER_MULTIPLY); + rdpq_sprite_blit(sprite_joypad_a, pos_x, pos_y, &(rdpq_blitparms_t){ + .scale_x = 1, .scale_y = 1, + }); +} From c70ef3dfcc37ffca98e8e8ad9a81c0ce2e7e147f Mon Sep 17 00:00:00 2001 From: Robin Jones Date: Fri, 15 Nov 2024 23:31:31 +0000 Subject: [PATCH 6/9] Add sprite map kinda --- src/menu/ui_components/sprites.c | 51 +++++++++++++++++++++++++++++++- 1 file changed, 50 insertions(+), 1 deletion(-) diff --git a/src/menu/ui_components/sprites.c b/src/menu/ui_components/sprites.c index cea054b31..81e62db51 100644 --- a/src/menu/ui_components/sprites.c +++ b/src/menu/ui_components/sprites.c @@ -36,9 +36,58 @@ void ui_components_sprites_init(void) { } void ui_components_joypad_buttons_draw (sprite_joypad_button_type_t button, float pos_x, float pos_y) { + sprite_t *current_button; + + switch (button) { + case SPRITE_JOYPAD_BUTTON_A: + current_button = sprite_joypad_a; + break; + case SPRITE_JOYPAD_BUTTON_B: + current_button = sprite_joypad_b; + break; + case SPRITE_JOYPAD_BUTTON_C_DOWN: + current_button = sprite_joypad_c_down; + break; + case SPRITE_JOYPAD_BUTTON_C_LEFT: + current_button = sprite_joypad_c_left; + break; + case SPRITE_JOYPAD_BUTTON_C_RIGHT: + current_button = sprite_joypad_c_right; + break; + case SPRITE_JOYPAD_BUTTON_C_UP: + current_button = sprite_joypad_c_up; + break; + case SPRITE_JOYPAD_BUTTON_D_DOWN: + current_button = sprite_joypad_d_down; + break; + case SPRITE_JOYPAD_BUTTON_D_LEFT: + current_button = sprite_joypad_d_left; + break; + case SPRITE_JOYPAD_BUTTON_D_RIGHT: + current_button = sprite_joypad_d_right; + break; + case SPRITE_JOYPAD_BUTTON_D_UP: + current_button = sprite_joypad_d_up; + break; + case SPRITE_JOYPAD_BUTTON_L: + current_button = sprite_joypad_l; + break; + case SPRITE_JOYPAD_BUTTON_R: + current_button = sprite_joypad_r; + break; + case SPRITE_JOYPAD_BUTTON_START: + current_button = sprite_joypad_z; + break; + case SPRITE_JOYPAD_BUTTON_Z: + current_button = sprite_joypad_z; + break; + default: + return; + } + rdpq_set_mode_standard(); rdpq_mode_blender(RDPQ_BLENDER_MULTIPLY); - rdpq_sprite_blit(sprite_joypad_a, pos_x, pos_y, &(rdpq_blitparms_t){ + rdpq_sprite_blit(current_button, pos_x, pos_y, &(rdpq_blitparms_t){ .scale_x = 1, .scale_y = 1, }); } From 6f6339ab154ec85c4df8c89b7390e51b084dff14 Mon Sep 17 00:00:00 2001 From: Robin Jones Date: Fri, 15 Nov 2024 23:49:16 +0000 Subject: [PATCH 7/9] Improve buttton sprite positions --- src/menu/ui_components/common.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/src/menu/ui_components/common.c b/src/menu/ui_components/common.c index 499bb08c9..c02523415 100644 --- a/src/menu/ui_components/common.c +++ b/src/menu/ui_components/common.c @@ -175,10 +175,19 @@ void ui_components_actions_bar_text_draw (rdpq_align_t align, rdpq_valign_t vali char *formatted = vasnprintf(buffer, &nbytes, fmt, va); va_end(va); - // FIXME: take into account action bar line - - if(action_button != SPRITE_JOYPAD_BUTTON_NONE) { - ui_components_joypad_buttons_draw(action_button, VISIBLE_AREA_X0 + TEXT_MARGIN_HORIZONTAL, LAYOUT_ACTIONS_SEPARATOR_Y + BORDER_THICKNESS + TEXT_MARGIN_VERTICAL + TEXT_OFFSET_VERTICAL); + // FIXME: take into account action bar align + if(action_button != SPRITE_JOYPAD_BUTTON_NONE && align == ALIGN_LEFT) { + switch (line) + { + case ACTION_BAR_LINE_ONE: + ui_components_joypad_buttons_draw(action_button, VISIBLE_AREA_X0 + TEXT_MARGIN_HORIZONTAL, LAYOUT_ACTIONS_SEPARATOR_Y + BORDER_THICKNESS + TEXT_MARGIN_VERTICAL + TEXT_OFFSET_VERTICAL); + break; + case ACTION_BAR_LINE_TWO: + ui_components_joypad_buttons_draw(action_button, VISIBLE_AREA_X0 + TEXT_MARGIN_HORIZONTAL, LAYOUT_ACTIONS_SEPARATOR_Y + BORDER_THICKNESS + TEXT_MARGIN_VERTICAL + TEXT_OFFSET_VERTICAL + 18); + break; + default: + break; + } } rdpq_text_printn( From 619e1658fd7989b11c8c583f3a26747a47cdbd27 Mon Sep 17 00:00:00 2001 From: Robin Jones Date: Sat, 16 Nov 2024 00:00:44 +0000 Subject: [PATCH 8/9] Fix for browser actions --- src/menu/views/browser.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/menu/views/browser.c b/src/menu/views/browser.c index b7ddf6729..5d6005651 100644 --- a/src/menu/views/browser.c +++ b/src/menu/views/browser.c @@ -386,7 +386,7 @@ static void draw (menu_t *menu, surface_t *d) { } ui_components_actions_bar_text_draw( - ALIGN_LEFT, VALIGN_TOP, ACTION_BAR_LINE_ONE, SPRITE_JOYPAD_BUTTON_NONE, + ALIGN_LEFT, VALIGN_TOP, ACTION_BAR_LINE_ONE, SPRITE_JOYPAD_BUTTON_A, "%s", menu->browser.entries == 0 ? "" : action ); From d618b7d159dfc2f027fac15ab6ab253dc0dc8fa0 Mon Sep 17 00:00:00 2001 From: Robin Jones Date: Sat, 16 Nov 2024 00:49:59 +0000 Subject: [PATCH 9/9] Improve sprite alignment Handle both sides of the action bar Fix start button. --- src/menu/ui_components/common.c | 28 +++++++++++++++------------- src/menu/ui_components/sprites.c | 2 +- 2 files changed, 16 insertions(+), 14 deletions(-) diff --git a/src/menu/ui_components/common.c b/src/menu/ui_components/common.c index c02523415..ac9fd6985 100644 --- a/src/menu/ui_components/common.c +++ b/src/menu/ui_components/common.c @@ -175,19 +175,21 @@ void ui_components_actions_bar_text_draw (rdpq_align_t align, rdpq_valign_t vali char *formatted = vasnprintf(buffer, &nbytes, fmt, va); va_end(va); - // FIXME: take into account action bar align - if(action_button != SPRITE_JOYPAD_BUTTON_NONE && align == ALIGN_LEFT) { - switch (line) - { - case ACTION_BAR_LINE_ONE: - ui_components_joypad_buttons_draw(action_button, VISIBLE_AREA_X0 + TEXT_MARGIN_HORIZONTAL, LAYOUT_ACTIONS_SEPARATOR_Y + BORDER_THICKNESS + TEXT_MARGIN_VERTICAL + TEXT_OFFSET_VERTICAL); - break; - case ACTION_BAR_LINE_TWO: - ui_components_joypad_buttons_draw(action_button, VISIBLE_AREA_X0 + TEXT_MARGIN_HORIZONTAL, LAYOUT_ACTIONS_SEPARATOR_Y + BORDER_THICKNESS + TEXT_MARGIN_VERTICAL + TEXT_OFFSET_VERTICAL + 18); - break; - default: - break; - } + uint16_t btn_offset_x = 0; + uint16_t btn_offset_y = 0; + + + // FIXME: improve bar align and line offsets. Currently they are just best guesses! + if (line == ACTION_BAR_LINE_TWO) { + btn_offset_y = 18; + } + + if (align == ALIGN_RIGHT) { + btn_offset_x = 450; + } + + if(action_button != SPRITE_JOYPAD_BUTTON_NONE) { + ui_components_joypad_buttons_draw(action_button, VISIBLE_AREA_X0 + TEXT_MARGIN_HORIZONTAL + btn_offset_x, LAYOUT_ACTIONS_SEPARATOR_Y + BORDER_THICKNESS + TEXT_MARGIN_VERTICAL + TEXT_OFFSET_VERTICAL + btn_offset_y); } rdpq_text_printn( diff --git a/src/menu/ui_components/sprites.c b/src/menu/ui_components/sprites.c index 81e62db51..dc36c1e7e 100644 --- a/src/menu/ui_components/sprites.c +++ b/src/menu/ui_components/sprites.c @@ -76,7 +76,7 @@ void ui_components_joypad_buttons_draw (sprite_joypad_button_type_t button, floa current_button = sprite_joypad_r; break; case SPRITE_JOYPAD_BUTTON_START: - current_button = sprite_joypad_z; + current_button = sprite_joypad_start; break; case SPRITE_JOYPAD_BUTTON_Z: current_button = sprite_joypad_z;