mirror of
https://github.com/cellos51/balatro-gba.git
synced 2026-05-26 15:28:41 -05:00
* background * Implement Options button * Update main menu artwork * add options menu tiles * prepare options menu handling * incorporate main menu refactor * toto * add all menu interactions * do not reset selection_x in main_menu * options struct * fix rebase from ricfehr3's repo * Implement high contrast cards * Save/Load options values to SRAM * load options on game_init and validate data within the load_options function * Get changes from ricfehr3's PR * recover fix for glitched ace * clang format * clang format * clang format * Save 500B of image data by using only minimal set of tiles instead of keeping final window in source file * clang format * clang format * Implement Options button * Update main menu artwork * progress, leaving it alone for now until discussion * make game_vars an extern * Move options vars into their own struct * rollback previous commit * Implement save validation. Version check to come * implement data validity + version check for game saves * clang format * Save position in rng sequence for consistent run after load * fix rebase issues * fix rebase issue * remove unused/duplicate define * Oops, made a mistake when testing PR #424 * encode high contrast palette into an image, and load it at game_start * document save.c/h and correct typos * correct alignment * game speed and high contrast buttons working * small cleanup * sliders also work again now * clang format * Moved balatro_version extern declaration to version.h file * removed unsused variable * make showing ROM version a toggle * move ante, round and money to the GameVariables struct * Rename SaveCheckInfo struct to SaveHeader for clarity * Add SaveHeader struct explanation * clang format * Revert unnecessary tileset optimization * SFX now follows the sound volume slider * clang format * Music now follows volume slider * Changed volume slider increment from 5 to 20 to avoid having the music sound too rough under 20% volume * refactor main_menu.c to use SelectionGrid and Button structs * clang format * make a "new" save button so we don't save during the state transition * clang format * Reduced state transition flicker by only changing affine background to a different one * Fix loading game too late in game init sequence * First batch of suggestions from @MeirGavish * Remove unnecessary intermediary buffers for high contrast palette swapping * comment row warp hack for button input * Add some of Copilot's suggestions * rename balatro_version into gbalatro_version for rebranding reasons + version display erase screen fix * remove unnecessary NULL check on `on_selection_changed` method * implement small game speed arrow buttons animation * factorize some code * remove unnecessary data validation in load_game(), since we already checked the header * Implement @MeirGavish 's suggestion regarding splitting the huge `on_update` function * clang format * implement @ricfehr3 's suggestion about keeping last selected button instead of using an obscure `on_boot` boolean * Apply @ricfehr3's suggestions * fix clang-format flags --------- Co-authored-by: MathisMartin31 <mathis.martin31@gmail.com>
76 lines
2.0 KiB
C
76 lines
2.0 KiB
C
/**
|
|
* @file button.h
|
|
*
|
|
* @brief A button structure containing the common button functionalities
|
|
*/
|
|
|
|
#ifndef BUTTON_H
|
|
#define BUTTON_H
|
|
|
|
#include <tonc_types.h>
|
|
|
|
#define BTN_HIGHLIGHT_COLOR 0xFFFF
|
|
|
|
#define BUTTON_SFX_VOLUME 154 // 60% of MM_SFX_FULL_VOLUME
|
|
|
|
/**
|
|
* @brief The function to be called when the button is pressed
|
|
*/
|
|
typedef void (*ButtonOnPressedFunc)(void);
|
|
|
|
/**
|
|
* @brief Returns true if the button should be activated when pressed.
|
|
*/
|
|
typedef bool (*ButtonCanBePressedFunc)(void);
|
|
|
|
/**
|
|
* @brief A button representation
|
|
*/
|
|
typedef struct
|
|
{
|
|
// Using u8 for the palette indices to make sure they don't overflow pal_bg_mem
|
|
|
|
/**
|
|
* @brief Palette index of the button border whose color is updated depending on highlight.
|
|
*/
|
|
u8 border_pal_idx;
|
|
|
|
/**
|
|
* @brief Palette index of the color of the button itself, used for the border when not
|
|
* highlighted.
|
|
*/
|
|
u8 button_pal_idx;
|
|
|
|
/**
|
|
* @brief Called when the button is pressed if @ref can_be_pressed, don't call this directly,
|
|
* call @ref button_press() instead.
|
|
* Should not be set to NULL.
|
|
*/
|
|
ButtonOnPressedFunc on_pressed;
|
|
|
|
/**
|
|
* @brief Returns true if the button should be activated when pressed.
|
|
* Can be NULL if button can always be pressed.
|
|
*/
|
|
ButtonCanBePressedFunc can_be_pressed;
|
|
} Button;
|
|
|
|
/**
|
|
* @brief Set the button highlight on or off.
|
|
* @param button The button to modify. No-op on NULL.
|
|
* @param highlight true to highlight, false to unhighlight.
|
|
*/
|
|
void button_set_highlight(Button* button, bool highlight);
|
|
|
|
/**
|
|
* @brief Execute a button press, by calling the button's @ref on_pressed function.
|
|
* This checks the button's @ref can_be_pressed function and will do nothing if
|
|
* returns false.
|
|
*
|
|
* Button presses should go through this function rather than directly call @ref on_pressed.
|
|
*
|
|
* @param button The button being pressed. No-op on NULL.
|
|
*/
|
|
void button_press(Button* button);
|
|
|
|
#endif // BUTTON_H
|