Add option to enable a more readable deck, suggestion by @Turro75 (#495) (#511)

* Options menu revamp

* Implement readable card sprites

* redraw characters to fix the original style

* clang format

* remove usage of UNDEFINED (-1) for unsigned values

* typo

* change save fix for something cleaner

* remove dependency to game_variables.h from card.c

* Make the palette look less silly ^^'

* Address @ricfehr3's comments

* clang format

* quick rename

* clang format

---------

Co-authored-by: Geralt <84459734+MathisMartin31@users.noreply.github.com>
Co-authored-by: MathisMartin31 <mathis.martin31@gmail.com>
Co-authored-by: Turro75 <valerio.turrini@gmail.com>
This commit is contained in:
Rickey
2026-05-25 11:11:33 -07:00
committed by GitHub
co-authored by Geralt MathisMartin31 Turro75
parent cebdebbfd0
commit 221b6d77c0
10 changed files with 172 additions and 110 deletions
+90 -58
View File
@@ -4,6 +4,7 @@
#include "audio_utils.h"
#include "background_options_menu_gfx.h"
#include "button.h"
#include "card.h"
#include "game.h"
#include "game/common_ui.h"
#include "game_variables.h"
@@ -39,23 +40,26 @@ enum OptionSpeedButtons
#define MENU_BUTTON_MAIN_COLOR_PAL_IDX 1
#define SAVE_BUTTON_MAIN_COLOR_PAL_IDX 3
#define BACK_BUTTON_MAIN_COLOR_PAL_IDX 4
#define SPEED_DOWN_BUTTON_OUTLINE_COLOR_PAL_IDX 5
#define SPEED_BUTTON_OUTLINE_COLOR_PAL_IDX 6
#define SPEED_UP_BUTTON_OUTLINE_COLOR_PAL_IDX 7
#define CONTRAST_BUTTON_OUTLINE_COLOR_PAL_IDX 8
#define MUSIC_BUTTON_OUTLINE_COLOR_PAL_IDX 9
#define SOUND_BUTTON_OUTLINE_COLOR_PAL_IDX 10
#define SAVE_BUTTON_OUTLINE_COLOR_PAL_IDX 11
#define BACK_BUTTON_OUTLINE_COLOR_PAL_IDX 12
#define SPEED_DOWN_BUTTON_OUTLINE_COLOR_PAL_IDX 16
#define SPEED_BUTTON_OUTLINE_COLOR_PAL_IDX 17
#define SPEED_UP_BUTTON_OUTLINE_COLOR_PAL_IDX 18
#define CONTRAST_BUTTON_OUTLINE_COLOR_PAL_IDX 19
#define READABLE_BUTTON_OUTLINE_COLOR_PAL_IDX 20
#define MUSIC_BUTTON_OUTLINE_COLOR_PAL_IDX 21
#define SOUND_BUTTON_OUTLINE_COLOR_PAL_IDX 22
#define SAVE_BUTTON_OUTLINE_COLOR_PAL_IDX 23
#define BACK_BUTTON_OUTLINE_COLOR_PAL_IDX 24
// Define selection grid for the menu buttons
static void game_speed_down_on_pressed(void);
static void game_speed_up_on_pressed(void);
static void high_contrast_on_pressed(void);
static void more_readable_on_pressed(void);
static void save_on_pressed(void);
static void back_on_pressed(void);
static int options_menu_return_upper_rows_size(void);
static int options_menu_return_card_sprites_row_size(void);
static int options_menu_return_bottom_row_size(void);
static void options_menu_row_on_key_transit(SelectionGrid* selection_grid, Selection* selection);
static bool game_speed_row_on_selection_changed(
@@ -95,7 +99,7 @@ static SelectionGridRow options_menu_selection_rows[] = {
},
{
HIGH_CONTRAST_ROW_IDX,
options_menu_return_upper_rows_size,
options_menu_return_card_sprites_row_size,
regular_button_row_on_selection_changed,
options_menu_row_on_key_transit,
{.wrap = false}
@@ -125,7 +129,10 @@ static SelectionGridRow options_menu_selection_rows[] = {
static Button options_menu_buttons[NB_OPTIONS_ROWS][2] = {
{{SPEED_BUTTON_OUTLINE_COLOR_PAL_IDX, MENU_BUTTON_MAIN_COLOR_PAL_IDX, NULL, NULL}},
{{CONTRAST_BUTTON_OUTLINE_COLOR_PAL_IDX, MENU_BUTTON_MAIN_COLOR_PAL_IDX, high_contrast_on_pressed, NULL}},
{
{CONTRAST_BUTTON_OUTLINE_COLOR_PAL_IDX, MENU_BUTTON_MAIN_COLOR_PAL_IDX, high_contrast_on_pressed, NULL},
{READABLE_BUTTON_OUTLINE_COLOR_PAL_IDX, MENU_BUTTON_MAIN_COLOR_PAL_IDX, more_readable_on_pressed, NULL}
},
{{MUSIC_BUTTON_OUTLINE_COLOR_PAL_IDX, MENU_BUTTON_MAIN_COLOR_PAL_IDX, NULL, NULL}},
{{SOUND_BUTTON_OUTLINE_COLOR_PAL_IDX, MENU_BUTTON_MAIN_COLOR_PAL_IDX, NULL, NULL}},
{
@@ -164,9 +171,12 @@ static const Rect OPTIONS_SPEED_VALUES[GAME_SPEED_MAX] = { { 3, 20, 4, 21
{ 4, 22, 5, 23} };
static const BG_POINT OPTIONS_SPEED_VALUE_DEST_POS = {14, 3};
static const Rect OPTIONS_CONTRAST_VALUE_YES_SRC_RECT = { 1, 24, 4, 25};
static const Rect OPTIONS_CONTRAST_VALUE_NO_SRC_RECT = { 6, 24, 9, 25};
static const BG_POINT OPTIONS_CONTRAST_VALUE_DEST_POS = {13, 7};
static const Rect OPTIONS_CONTRAST_CHECK_NO_SRC_RECT = { 0, 24, 1, 25};
static const Rect OPTIONS_CONTRAST_CHECK_YES_SRC_RECT = { 2, 24, 3, 25};
static const BG_POINT OPTIONS_CONTRAST_CHECK_DEST_POS = {14, 7};
static const Rect OPTIONS_READABLE_CHECK_NO_SRC_RECT = { 4, 24, 5, 25};
static const Rect OPTIONS_READABLE_CHECK_YES_SRC_RECT = { 6, 24, 7, 25};
static const BG_POINT OPTIONS_READABLE_CHECK_DEST_POS = {21, 7};
static const Rect OPTIONS_MUSIC_SLIDER_FULL_SRC = { 9, 20, 9, 20};
static const Rect OPTIONS_MUSIC_SLIDER_MID_SRC = {10, 20, 10, 20};
@@ -184,13 +194,13 @@ static const u8 OPTIONS_SOUND_SLIDER_SEGMENT_LENGTH = (OPTIONS_SOUND_
/ VOLUME_OPTION_MAX;
// Values in pixels
static const BG_POINT OPTIONS_GAME_SPEED_TEXT_POS = { 82, 16};
static const BG_POINT OPTIONS_HIGH_CONTRAST_TEXT_POS = { 40, 48};
static const BG_POINT OPTIONS_MUSIC_VOLUME_TEXT_POS = { 56, 80};
static const BG_POINT OPTIONS_MUSIC_VALUE_TEXT_POS = {160, 80};
static const BG_POINT OPTIONS_SOUND_VOLUME_TEXT_POS = { 56, 104};
static const BG_POINT OPTIONS_SOUND_VALUE_TEXT_POS = {160, 104};
static const BG_POINT OPTIONS_BACK_SAVE_TEXT_POS = { 64, 136};
static const BG_POINT OPTIONS_GAME_SPEED_TEXT_POS = { 82, 16};
static const BG_POINT OPTIONS_CARD_SPRITES_TEXT_POS = { 72, 48};
static const BG_POINT OPTIONS_MUSIC_VOLUME_TEXT_POS = { 56, 80};
static const BG_POINT OPTIONS_MUSIC_VALUE_TEXT_POS = {160, 80};
static const BG_POINT OPTIONS_SOUND_VOLUME_TEXT_POS = { 56, 104};
static const BG_POINT OPTIONS_SOUND_VALUE_TEXT_POS = {160, 104};
static const BG_POINT OPTIONS_BACK_SAVE_TEXT_POS = { 64, 136};
// clang-format on
#define GAME_SPEED_ARROW_HIGHLIGHT_DURATION 10
@@ -212,8 +222,21 @@ static void disable_all_outlines_except_self(Selection sel_btn)
for (int j = 0; j < NB_OPTIONS_ROWS; j++)
{
int nb_buttons_in_row = (j == SAVE_BACK_ROW_IDX) ? options_menu_return_bottom_row_size()
: options_menu_return_upper_rows_size();
int nb_buttons_in_row;
switch (j)
{
case HIGH_CONTRAST_ROW_IDX:
nb_buttons_in_row = options_menu_return_card_sprites_row_size();
break;
case SAVE_BACK_ROW_IDX:
nb_buttons_in_row = options_menu_return_bottom_row_size();
break;
default:
nb_buttons_in_row = options_menu_return_upper_rows_size();
break;
}
for (int i = 0; i < nb_buttons_in_row; i++)
{
button_set_highlight(&options_menu_buttons[j][i], i == sel_btn.x && j == sel_btn.y);
@@ -224,29 +247,16 @@ static void disable_all_outlines_except_self(Selection sel_btn)
static void update_game_speed_button_graphics()
{
// check if need to disable game speed arrows
if (g_game_vars.game_speed == GAME_SPEED_MIN)
{
main_bg_se_copy_rect(
OPTIONS_SPEED_DOWN_DISABLED_BTN_SRC_RECT,
OPTIONS_SPEED_DOWN_BTN_DEST_POS
);
}
else
{
main_bg_se_copy_rect(
OPTIONS_SPEED_DOWN_ACTIVE_BTN_SRC_RECT,
OPTIONS_SPEED_DOWN_BTN_DEST_POS
);
}
if (g_game_vars.game_speed == GAME_SPEED_MAX)
{
main_bg_se_copy_rect(OPTIONS_SPEED_UP_DISABLED_BTN_SRC_RECT, OPTIONS_SPEED_UP_BTN_DEST_POS);
}
else
{
main_bg_se_copy_rect(OPTIONS_SPEED_UP_ACTIVE_BTN_SRC_RECT, OPTIONS_SPEED_UP_BTN_DEST_POS);
}
Rect speed_down_btn_tiles = (g_game_vars.game_speed == GAME_SPEED_MIN)
? OPTIONS_SPEED_DOWN_DISABLED_BTN_SRC_RECT
: OPTIONS_SPEED_DOWN_ACTIVE_BTN_SRC_RECT;
main_bg_se_copy_rect(speed_down_btn_tiles, OPTIONS_SPEED_DOWN_BTN_DEST_POS);
Rect speed_up_btn_tiles = (g_game_vars.game_speed == GAME_SPEED_MAX)
? OPTIONS_SPEED_UP_DISABLED_BTN_SRC_RECT
: OPTIONS_SPEED_UP_ACTIVE_BTN_SRC_RECT;
main_bg_se_copy_rect(speed_up_btn_tiles, OPTIONS_SPEED_UP_BTN_DEST_POS);
main_bg_se_copy_rect(
OPTIONS_SPEED_VALUES[g_game_vars.game_speed - 1],
@@ -254,16 +264,18 @@ static void update_game_speed_button_graphics()
);
}
static void update_high_contrast_button_graphics()
static void update_high_contrast_button_graphics(void)
{
if (g_game_vars.high_contrast)
{
main_bg_se_copy_rect(OPTIONS_CONTRAST_VALUE_YES_SRC_RECT, OPTIONS_CONTRAST_VALUE_DEST_POS);
}
else
{
main_bg_se_copy_rect(OPTIONS_CONTRAST_VALUE_NO_SRC_RECT, OPTIONS_CONTRAST_VALUE_DEST_POS);
}
Rect contrast_btn_tiles = (get_cards_high_contrast()) ? OPTIONS_CONTRAST_CHECK_YES_SRC_RECT
: OPTIONS_CONTRAST_CHECK_NO_SRC_RECT;
main_bg_se_copy_rect(contrast_btn_tiles, OPTIONS_CONTRAST_CHECK_DEST_POS);
}
static void update_more_readable_button_graphics(void)
{
Rect readable_btn_tiles = (get_cards_more_readable()) ? OPTIONS_READABLE_CHECK_YES_SRC_RECT
: OPTIONS_READABLE_CHECK_NO_SRC_RECT;
main_bg_se_copy_rect(readable_btn_tiles, OPTIONS_READABLE_CHECK_DEST_POS);
}
static void update_volume_slider_graphics(enum OptionButtonRows sel_row)
@@ -360,9 +372,9 @@ void game_options_menu_change_background(void)
TTE_WHITE_PB
);
tte_printf(
"#{P:%d,%d; cx:0x%X000}High Contrast Cards",
OPTIONS_HIGH_CONTRAST_TEXT_POS.x,
OPTIONS_HIGH_CONTRAST_TEXT_POS.y,
"#{P:%d,%d; cx:0x%X000}Card Sprites",
OPTIONS_CARD_SPRITES_TEXT_POS.x,
OPTIONS_CARD_SPRITES_TEXT_POS.y,
TTE_WHITE_PB
);
tte_printf(
@@ -396,6 +408,7 @@ void game_options_menu_on_init(void)
// Do an update on the first frame
update_game_speed_button_graphics();
update_high_contrast_button_graphics();
update_more_readable_button_graphics();
update_volume_slider_graphics(MUSIC_VOLUME_ROW_IDX);
update_volume_slider_graphics(SOUND_VOLUME_ROW_IDX);
}
@@ -442,10 +455,19 @@ static void game_speed_up_on_pressed(void)
*/
static void high_contrast_on_pressed(void)
{
g_game_vars.high_contrast = (g_game_vars.high_contrast == 1) ? false : true;
set_cards_high_contrast(!get_cards_high_contrast());
update_high_contrast_button_graphics();
}
/**
* @brief Handles input for the more readable card toggle button and nothing more.
*/
static void more_readable_on_pressed(void)
{
set_cards_more_readable(!get_cards_more_readable());
update_more_readable_button_graphics();
}
/**
* @brief Handles input for the Save button.
*/
@@ -465,7 +487,7 @@ static void back_on_pressed(void)
}
/**
* @brief Gives the width of upper options menu rows in selection grid.
* @brief Gives the width of normal options rows in selection grid.
*
* @returns 1
*/
@@ -474,6 +496,16 @@ static int options_menu_return_upper_rows_size(void)
return 1;
}
/**
* @brief Gives the width of Card Sprites options row in selection grid.
*
* @returns 2
*/
static int options_menu_return_card_sprites_row_size(void)
{
return 2;
}
/**
* @brief Gives the width of the Save and Back buttons' row.
*