Allow to exit the options menu without saving changes made (#484)

* Allow exiting options menu without saving

* Change "Back" button text to "Cancel" to be more explicit

* clang format

* fix load_game

* use proper existing defines for options default values

* fix buttons' array sizes

---------

Co-authored-by: MathisMartin31 <mathis.martin31@gmail.com>
This commit is contained in:
Geralt
2026-05-19 18:10:49 -07:00
committed by GitHub
co-authored by MathisMartin31
parent 9b85329669
commit 69403f059f
3 changed files with 120 additions and 132 deletions
+9 -9
View File
@@ -155,10 +155,10 @@ static const SaveHeader SaveHeader_default = {
*/
static const SaveOptions SaveOptions_default = {
.tag_options = "- OPTIONS DATA -",
.game_speed = 0,
.high_contrast = false,
.music_volume = 0,
.sound_volume = 0,
.game_speed = GAME_SPEED_MIN,
.high_contrast = DEFAULT_HIGH_CONTRAST,
.music_volume = VOLUME_OPTION_MAX,
.sound_volume = VOLUME_OPTION_MAX,
.padding = {UNDEFINED, UNDEFINED, UNDEFINED},
};
@@ -306,12 +306,12 @@ void save_options(void)
void load_options(void)
{
SaveHeader header;
if (!get_save_header(&header) || !(header.valid_sections & SAVE_SECTION_FLAG_OPTIONS))
return;
SaveOptions options = SaveOptions_default;
read_sram(OPTIONS_ADDRESS, (u8*)&options, sizeof(options));
// If options data doesn't exist or is invalid, just don't read from
// SRAM and apply the default values
if (get_save_header(&header) && (header.valid_sections & SAVE_SECTION_FLAG_OPTIONS))
read_sram(OPTIONS_ADDRESS, (u8*)&options, sizeof(options));
g_game_vars.game_speed = options.game_speed;
g_game_vars.high_contrast = options.high_contrast;
@@ -362,11 +362,11 @@ void save_game(void)
void load_game(void)
{
SaveHeader header;
if (!get_save_header(&header) || !(header.valid_sections & SAVE_SECTION_FLAG_GAME))
return;
SaveGame game = SaveGame_default;
read_sram(GAME_ADDRESS, (u8*)&game, sizeof(game));
g_game_vars.timer = game.timer;