From d618b7d159dfc2f027fac15ab6ab253dc0dc8fa0 Mon Sep 17 00:00:00 2001 From: Robin Jones Date: Sat, 16 Nov 2024 00:49:59 +0000 Subject: [PATCH] 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 c0252341..ac9fd698 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 81e62db5..dc36c1e7 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;