Save settings before leaving the settings menu
This commit is contained in:
parent
32d397eb2a
commit
df830f6495
8 changed files with 23 additions and 10 deletions
|
|
@ -436,6 +436,7 @@ void UiHandleEvents(SDL_Event *event)
|
|||
const Uint8 *state = SDLC_GetKeyState();
|
||||
if (state[SDLC_KEYSTATE_LALT] != 0 || state[SDLC_KEYSTATE_RALT] != 0) {
|
||||
sgOptions.Graphics.fullscreen.SetValue(!IsFullScreen());
|
||||
SaveOptions();
|
||||
if (gfnFullscreen != nullptr)
|
||||
gfnFullscreen();
|
||||
return;
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@ void ItemSelected(int value)
|
|||
{
|
||||
auto option = static_cast<StartUpGameMode>(vecDialogItems[value]->m_value);
|
||||
sgOptions.StartUp.gameMode.SetValue(option);
|
||||
SaveOptions();
|
||||
endMenu = true;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -354,6 +354,8 @@ void UiSettingsMenu()
|
|||
|
||||
CleanUpSettingsUI();
|
||||
} while (!backToMain);
|
||||
|
||||
SaveOptions();
|
||||
}
|
||||
|
||||
} // namespace devilution
|
||||
|
|
|
|||
|
|
@ -437,10 +437,12 @@ void PressKey(int vkey)
|
|||
}
|
||||
sgOptions.Keymapper.KeyPressed(vkey);
|
||||
if (vkey == DVL_VK_RETURN) {
|
||||
if (GetAsyncKeyState(DVL_VK_MENU))
|
||||
if (GetAsyncKeyState(DVL_VK_MENU)) {
|
||||
sgOptions.Graphics.fullscreen.SetValue(!IsFullScreen());
|
||||
else
|
||||
SaveOptions();
|
||||
} else {
|
||||
control_type_message();
|
||||
}
|
||||
}
|
||||
if (vkey != DVL_VK_ESCAPE) {
|
||||
return;
|
||||
|
|
@ -461,14 +463,17 @@ void PressKey(int vkey)
|
|||
sgOptions.Keymapper.KeyPressed(vkey);
|
||||
|
||||
if (PauseMode == 2) {
|
||||
if (vkey == DVL_VK_RETURN && GetAsyncKeyState(DVL_VK_MENU))
|
||||
if (vkey == DVL_VK_RETURN && GetAsyncKeyState(DVL_VK_MENU)) {
|
||||
sgOptions.Graphics.fullscreen.SetValue(!IsFullScreen());
|
||||
SaveOptions();
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (vkey == DVL_VK_RETURN) {
|
||||
if (GetAsyncKeyState(DVL_VK_MENU)) {
|
||||
sgOptions.Graphics.fullscreen.SetValue(!IsFullScreen());
|
||||
SaveOptions();
|
||||
} else if (stextflag != STORE_NONE) {
|
||||
StoreEnter();
|
||||
} else if (QuestLogIsOpen) {
|
||||
|
|
@ -995,8 +1000,10 @@ void DiabloSplash()
|
|||
play_movie("gendata\\Hellfire.smk", true);
|
||||
else
|
||||
play_movie("gendata\\diablo1.smk", true);
|
||||
if (*intro == StartUpIntro::Once)
|
||||
if (*intro == StartUpIntro::Once) {
|
||||
intro.SetValue(StartUpIntro::Off);
|
||||
SaveOptions();
|
||||
}
|
||||
}
|
||||
|
||||
if (IsAnyOf(*sgOptions.StartUp.splash, StartUpSplash::TitleDialog, StartUpSplash::LogoAndTitleDialog))
|
||||
|
|
@ -1007,8 +1014,6 @@ void DiabloDeinit()
|
|||
{
|
||||
FreeItemGFX();
|
||||
|
||||
if (sbWasOptionsLoaded && !demo::IsRunning())
|
||||
SaveOptions();
|
||||
if (was_snd_init)
|
||||
effects_cleanup_sfx();
|
||||
snd_deinit();
|
||||
|
|
@ -1726,6 +1731,7 @@ int DiabloMain(int argc, char **argv)
|
|||
// Finally load game data
|
||||
LoadGameArchives();
|
||||
|
||||
SaveOptions();
|
||||
DiabloInit();
|
||||
|
||||
#ifdef __UWP__
|
||||
|
|
|
|||
|
|
@ -341,6 +341,7 @@ void gamemenu_save_game(bool /*bActivate*/)
|
|||
NewCursor(CURSOR_HAND);
|
||||
if (CornerStone.activated) {
|
||||
CornerstoneSave();
|
||||
SaveOptions();
|
||||
}
|
||||
interface_msg_pump();
|
||||
SetWindowProc(saveProc);
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@
|
|||
#include "engine/load_cel.hpp"
|
||||
#include "engine/render/cel_render.hpp"
|
||||
#include "engine/render/text_render.hpp"
|
||||
#include "options.h"
|
||||
#include "stores.h"
|
||||
#include "utils/language.h"
|
||||
#include "utils/stdcompat/optional.hpp"
|
||||
|
|
@ -216,6 +217,8 @@ void gmenu_set_items(TMenuItem *pItem, void (*gmFunc)())
|
|||
// BUGFIX: OOB access when sgCurrentMenuIdx is 0; should be set to NULL instead. (fixed)
|
||||
sgpCurrItem = sgCurrentMenuIdx > 0 ? &sgpCurrentMenu[sgCurrentMenuIdx - 1] : nullptr;
|
||||
GmenuUpDown(true);
|
||||
if (sgpCurrentMenu == nullptr)
|
||||
SaveOptions();
|
||||
}
|
||||
|
||||
void gmenu_draw(const Surface &out)
|
||||
|
|
|
|||
|
|
@ -302,7 +302,6 @@ void OptionAudioChanged()
|
|||
|
||||
/** Game options */
|
||||
Options sgOptions;
|
||||
bool sbWasOptionsLoaded = false;
|
||||
|
||||
#if SDL_VERSION_ATLEAST(2, 0, 0)
|
||||
bool HardwareCursorSupported()
|
||||
|
|
@ -354,12 +353,13 @@ void LoadOptions()
|
|||
|
||||
if (demo::IsRunning())
|
||||
demo::OverrideOptions();
|
||||
|
||||
sbWasOptionsLoaded = true;
|
||||
}
|
||||
|
||||
void SaveOptions()
|
||||
{
|
||||
if (demo::IsRunning())
|
||||
return;
|
||||
|
||||
for (OptionCategoryBase *pCategory : sgOptions.GetCategories()) {
|
||||
for (OptionEntryBase *pEntry : pCategory->GetEntries()) {
|
||||
pEntry->SaveToIni(pCategory->GetKey());
|
||||
|
|
|
|||
|
|
@ -605,7 +605,6 @@ struct Options {
|
|||
};
|
||||
|
||||
extern DVL_API_FOR_TEST Options sgOptions;
|
||||
extern bool sbWasOptionsLoaded;
|
||||
|
||||
bool HardwareCursorSupported();
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue