Improve sprite alignment

Handle both sides of the action bar
Fix start button.
This commit is contained in:
Robin Jones 2024-11-16 00:49:59 +00:00
parent 619e1658fd
commit d618b7d159
2 changed files with 16 additions and 14 deletions

View File

@ -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); char *formatted = vasnprintf(buffer, &nbytes, fmt, va);
va_end(va); va_end(va);
// FIXME: take into account action bar align uint16_t btn_offset_x = 0;
if(action_button != SPRITE_JOYPAD_BUTTON_NONE && align == ALIGN_LEFT) { uint16_t btn_offset_y = 0;
switch (line)
{
case ACTION_BAR_LINE_ONE: // FIXME: improve bar align and line offsets. Currently they are just best guesses!
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); if (line == ACTION_BAR_LINE_TWO) {
break; btn_offset_y = 18;
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; if (align == ALIGN_RIGHT) {
default: btn_offset_x = 450;
break; }
}
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( rdpq_text_printn(

View File

@ -76,7 +76,7 @@ void ui_components_joypad_buttons_draw (sprite_joypad_button_type_t button, floa
current_button = sprite_joypad_r; current_button = sprite_joypad_r;
break; break;
case SPRITE_JOYPAD_BUTTON_START: case SPRITE_JOYPAD_BUTTON_START:
current_button = sprite_joypad_z; current_button = sprite_joypad_start;
break; break;
case SPRITE_JOYPAD_BUTTON_Z: case SPRITE_JOYPAD_BUTTON_Z:
current_button = sprite_joypad_z; current_button = sprite_joypad_z;