loads a button at correct place.

This commit is contained in:
Robin Jones 2024-11-15 23:09:34 +00:00
parent 8f393b50d7
commit ee610dcd8a
6 changed files with 57 additions and 14 deletions

View File

@ -56,7 +56,7 @@ SRCS = \
menu/ui_components/common.c \ menu/ui_components/common.c \
menu/ui_components/context_menu.c \ menu/ui_components/context_menu.c \
menu/ui_components/file_list.c \ menu/ui_components/file_list.c \
menu/ui_components/joypad_buttons.c \ menu/ui_components/sprites.c \
menu/usb_comm.c \ menu/usb_comm.c \
menu/views/browser.c \ menu/views/browser.c \
menu/views/credits.c \ menu/views/credits.c \

View File

@ -55,6 +55,8 @@ static void menu_init (boot_params_t *boot_params) {
rdpq_init(); rdpq_init();
dfs_init(DFS_DEFAULT_LOCATION); dfs_init(DFS_DEFAULT_LOCATION);
ui_components_sprites_init();
actions_init(); actions_init();
sound_init_default(); sound_init_default();
sound_init_sfx(); sound_init_sfx();

View File

@ -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_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__ */ #endif /* UI_COMPONENTS_H__ */

View File

@ -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); char *formatted = vasnprintf(buffer, &nbytes, fmt, va);
va_end(va); va_end(va);
// FIXME: if there is an action button to draw, we should add it!
// FIXME: take into account action bar line // 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_text_printn(
&(rdpq_textparms_t) { &(rdpq_textparms_t) {
.width = VISIBLE_AREA_WIDTH - (TEXT_MARGIN_HORIZONTAL * 2), .width = VISIBLE_AREA_WIDTH - (TEXT_MARGIN_HORIZONTAL * 2),

View File

@ -1,12 +0,0 @@
#include <stdio.h>
#include <stdlib.h>
#include "../ui_components.h"
void ui_components_joypad_buttons_init(void) {
}
void ui_components_joypad_buttons_draw (void) {
}

View File

@ -0,0 +1,44 @@
#include <stdio.h>
#include <stdlib.h>
#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,
});
}