From: Holger Schemel Date: Tue, 12 Nov 2024 19:52:02 +0000 (+0100) Subject: added setup option to save setup without "save and exit" menu entry X-Git-Tag: 4.4.0.0-test-4~60 X-Git-Url: https://git.artsoft.org/?a=commitdiff_plain;h=8732560371e058bf8181868cdd2507a1bab459d7;p=rocksndiamonds.git added setup option to save setup without "save and exit" menu entry --- diff --git a/src/events.c b/src/events.c index 3603e32c..b25bce3e 100644 --- a/src/events.c +++ b/src/events.c @@ -666,6 +666,9 @@ void HandleWindowEvent(WindowEvent *event) UpdateMousePosition(); SetWindowTitle(); + + // required if executed from outside setup menu + SaveSetupIfNeeded(); } } #if defined(PLATFORM_ANDROID) diff --git a/src/files.c b/src/files.c index 9496b89e..43f8f5c0 100644 --- a/src/files.c +++ b/src/files.c @@ -11015,6 +11015,10 @@ static struct TokenInfo global_setup_tokens[] = TYPE_SWITCH, &setup.show_undo_redo_buttons, "show_undo_redo_buttons" }, + { + TYPE_SWITCH, + &setup.show_menu_to_save_setup, "show_menu_to_save_setup" + }, { TYPE_STRING, &setup.scores_in_highscore_list, "scores_in_highscore_list" @@ -11867,6 +11871,7 @@ static void setSetupInfoToDefaults(struct SetupInfo *si) si->small_game_graphics = FALSE; si->show_load_save_buttons = FALSE; si->show_undo_redo_buttons = FALSE; + si->show_menu_to_save_setup = FALSE; si->scores_in_highscore_list = getStringCopy(STR_SCORES_TYPE_DEFAULT); si->graphics_set = getStringCopy(GFX_CLASSIC_SUBDIR); @@ -12776,6 +12781,13 @@ void SaveSetup(void) SaveSetup_EditorCascade(); } +void SaveSetupIfNeeded(void) +{ + // save changed setup value if "save and exit" menu disabled + if (!setup.show_menu_to_save_setup) + SaveSetup(); +} + static void SaveSetup_WriteGameControllerMappings(SetupFileHash *mappings_hash, char *filename) { diff --git a/src/files.h b/src/files.h index c122716b..cf379db6 100644 --- a/src/files.h +++ b/src/files.h @@ -94,6 +94,7 @@ void SaveSetup_EditorCascade(void); void LoadSetup(void); void SaveSetup(void); +void SaveSetupIfNeeded(void); void SaveSetup_AddGameControllerMapping(char *); diff --git a/src/libgame/system.h b/src/libgame/system.h index 16a00b6c..84d401ce 100644 --- a/src/libgame/system.h +++ b/src/libgame/system.h @@ -1546,6 +1546,7 @@ struct SetupInfo boolean small_game_graphics; boolean show_load_save_buttons; boolean show_undo_redo_buttons; + boolean show_menu_to_save_setup; char *scores_in_highscore_list; char *graphics_set; diff --git a/src/screens.c b/src/screens.c index 27ef88a6..a26d2d11 100644 --- a/src/screens.c +++ b/src/screens.c @@ -356,6 +356,7 @@ static void AdjustScoreInfoButtons_PlayTape(int, int, boolean); static boolean OfferUploadTapes(void); static void execOfferUploadTapes(void); +static void execSaveAndExitSetup(void); static void DrawHallOfFame_setScoreEntries(void); static void HandleHallOfFame_SelectLevel(int, int); @@ -5731,6 +5732,8 @@ static void HandleChooseTree(int mx, int my, int dx, int dy, int button, execSetupTouch(); else execSetupArtwork(); + + SaveSetupIfNeeded(); } else { @@ -8339,6 +8342,7 @@ static struct TokenInfo setup_info_game[] = { TYPE_STRING, &snapshot_mode_text, "" }, { TYPE_SWITCH, &setup.show_load_save_buttons, "Show Load/Save Buttons:" }, { TYPE_SWITCH, &setup.show_undo_redo_buttons, "Show Undo/Redo Buttons:" }, + { TYPE_SWITCH, &setup.show_menu_to_save_setup, "Show Menu to Save Setup:" }, { TYPE_EMPTY, NULL, "" }, { TYPE_LEAVE_MENU, execSetupMain, "Back" }, @@ -8987,6 +8991,8 @@ static void changeSetupValue(int screen_pos, int setup_info_pos_raw, int dx) // update old setup options from new setup options if (si->value == &setup.allow_skipping_levels) UpdateHandicapAndSkipLevels(); + + SaveSetupIfNeeded(); } static struct TokenInfo *getSetupInfoFinal(struct TokenInfo *setup_info_orig) @@ -9055,6 +9061,11 @@ static void DrawSetupScreen_Generic(void) { setup_info = setup_info_main; title_string = STR_SETUP_MAIN; + + if (!setup.show_menu_to_save_setup) + setHideSetupEntry(execSaveAndExitSetup); + else + removeHideSetupEntry(execSaveAndExitSetup); } else if (setup_mode == SETUP_MODE_GAME) { diff --git a/src/tools.c b/src/tools.c index a6d5aa47..8416aae1 100644 --- a/src/tools.c +++ b/src/tools.c @@ -14,6 +14,7 @@ #include "libgame/libgame.h" #include "tools.h" +#include "files.h" #include "init.h" #include "game.h" #include "events.h" @@ -11886,6 +11887,9 @@ void ToggleFullscreenIfNeeded(void) // set setup value according to successfully changed fullscreen mode setup.fullscreen = video.fullscreen_enabled; + + // required if executed from outside setup menu + SaveSetupIfNeeded(); } void ChangeWindowScalingIfNeeded(void) @@ -11899,6 +11903,9 @@ void ChangeWindowScalingIfNeeded(void) // set setup value according to successfully changed window scaling setup.window_scaling_percent = video.window_scaling_percent; + + // required if executed from outside setup menu + SaveSetupIfNeeded(); } void ChangeVsyncModeIfNeeded(void)