mirror of
https://github.com/cellos51/balatro-gba.git
synced 2026-04-25 07:41:58 -05:00
* Added wrapping to selection grid * Added return value to on_selection_changed to allow aborting on wrap * Extracted button code to button.c/.h * Bounds checking changes for selection_grid_move_selection_horz() --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Co-authored-by: Rickey <ric@rf3.xyz>
30 lines
664 B
C
30 lines
664 B
C
#include "button.h"
|
|
|
|
#include "audio_utils.h"
|
|
#include "soundbank.h"
|
|
|
|
#include <tonc.h>
|
|
|
|
void button_set_highlight(Button* button, bool highlight)
|
|
{
|
|
if (button == NULL)
|
|
return;
|
|
|
|
u16 set_color = highlight ? BTN_HIGHLIGHT_COLOR : pal_bg_mem[button->button_pal_idx];
|
|
|
|
memset16(&pal_bg_mem[button->border_pal_idx], set_color, 1);
|
|
}
|
|
|
|
void button_press(Button* button)
|
|
{
|
|
if (button == NULL || button->on_pressed == NULL ||
|
|
(button->can_be_pressed != NULL && !button->can_be_pressed()))
|
|
{
|
|
return;
|
|
}
|
|
|
|
play_sfx(SFX_BUTTON, MM_BASE_PITCH_RATE, BUTTON_SFX_VOLUME);
|
|
|
|
button->on_pressed();
|
|
}
|