balatro-gba/source/button.c
MeirGavish 5300846f73
Refactored to use selection grid during round (#348)
* 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>
2026-01-15 20:32:09 +02:00

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();
}