Browse Source

Options: Remove dependency on demomode

pull/7670/head
Gleb Mazovetskiy 1 year ago
parent
commit
9492456dcd
  1. 14
      Source/diablo.cpp
  2. 3
      Source/gamemenu.cpp
  3. 4
      Source/gmenu.cpp
  4. 7
      Source/options.cpp
  5. 1
      test/timedemo_test.cpp

14
Source/diablo.cpp

@ -495,7 +495,7 @@ void PressKey(SDL_Keycode vkey, uint16_t modState)
if (vkey == SDLK_RETURN || vkey == SDLK_KP_ENTER) {
if ((modState & KMOD_ALT) != 0) {
options.Graphics.fullscreen.SetValue(!IsFullScreen());
SaveOptions();
if (!demo::IsRunning()) SaveOptions();
} else {
TypeChatMessage();
}
@ -530,7 +530,7 @@ void PressKey(SDL_Keycode vkey, uint16_t modState)
if (PauseMode == 2) {
if ((vkey == SDLK_RETURN || vkey == SDLK_KP_ENTER) && (modState & KMOD_ALT) != 0) {
options.Graphics.fullscreen.SetValue(!IsFullScreen());
SaveOptions();
if (!demo::IsRunning()) SaveOptions();
}
return;
}
@ -568,7 +568,7 @@ void PressKey(SDL_Keycode vkey, uint16_t modState)
case SDLK_KP_ENTER:
if ((modState & KMOD_ALT) != 0) {
options.Graphics.fullscreen.SetValue(!IsFullScreen());
SaveOptions();
if (!demo::IsRunning()) SaveOptions();
} else if (ActiveStore != TalkID::None) {
StoreEnter();
} else if (QuestLogIsOpen) {
@ -1234,7 +1234,7 @@ void DiabloSplash()
play_movie("gendata\\diablo1.smk", true);
if (*intro == StartUpIntro::Once) {
intro.SetValue(StartUpIntro::Off);
SaveOptions();
if (!demo::IsRunning()) SaveOptions();
}
}
@ -2565,12 +2565,14 @@ int DiabloMain(int argc, char **argv)
// Read settings including translation next. This will use the presence of fonts.mpq and look for assets in devilutionx.mpq
LoadOptions();
if (demo::IsRunning()) demo::OverrideOptions();
// Then look for a voice pack file based on the selected translation
LoadLanguageArchive();
ApplicationInit();
LuaInitialize();
SaveOptions();
if (!demo::IsRunning()) SaveOptions();
// Finally load game data
LoadGameArchives();
@ -2589,7 +2591,7 @@ int DiabloMain(int argc, char **argv)
#ifdef __UWP__
onInitialized();
#endif
SaveOptions();
if (!demo::IsRunning()) SaveOptions();
DiabloSplash();
mainmenu_loop();

3
Source/gamemenu.cpp

@ -8,6 +8,7 @@
#include "cursor.h"
#include "diablo_msg.hpp"
#include "engine/backbuffer_state.hpp"
#include "engine/demomode.h"
#include "engine/events.hpp"
#include "engine/sound.h"
#include "engine/sound_defs.hpp"
@ -358,7 +359,7 @@ void gamemenu_save_game(bool /*bActivate*/)
NewCursor(CURSOR_HAND);
if (CornerStone.activated) {
CornerstoneSave();
SaveOptions();
if (!demo::IsRunning()) SaveOptions();
}
interface_msg_pump();
SetEventHandler(saveProc);

4
Source/gmenu.cpp

@ -14,6 +14,7 @@
#include "controls/axis_direction.h"
#include "controls/controller_motion.h"
#include "engine/clx_sprite.hpp"
#include "engine/demomode.h"
#include "engine/load_cel.hpp"
#include "engine/render/clx_render.hpp"
#include "engine/render/primitive_render.hpp"
@ -232,8 +233,9 @@ 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)
if (sgpCurrentMenu == nullptr && !demo::IsRunning()) {
SaveOptions();
}
}
void gmenu_draw(const Surface &out)

7
Source/options.cpp

@ -27,7 +27,6 @@
#include "controls/game_controls.h"
#include "controls/plrctrls.h"
#include "engine/assets.hpp"
#include "engine/demomode.h"
#include "engine/sound_defs.hpp"
#include "platform/locale.hpp"
#include "quick_messages.hpp"
@ -193,16 +192,10 @@ void LoadOptions()
#ifdef __vita__
options.Controller.bRearTouch = ini->getBool("Controller", "Enable Rear Touchpad", true);
#endif
if (demo::IsRunning())
demo::OverrideOptions();
}
void SaveOptions()
{
if (demo::IsRunning())
return;
Options &options = GetOptions();
for (OptionCategoryBase *pCategory : options.GetCategories()) {
for (const OptionEntryBase *pEntry : pCategory->GetEntries()) {

1
test/timedemo_test.cpp

@ -50,6 +50,7 @@ void RunTimedemo(std::string timedemoFolderName)
InitKeymapActions();
LoadOptions();
demo::OverrideOptions();
LuaInitialize();
const int demoNumber = 0;

Loading…
Cancel
Save