Skip to content

Commit 9da1e21

Browse files
committed
Change persistence from save file to gameplay option/INI file
1 parent 648a9c7 commit 9da1e21

4 files changed

Lines changed: 16 additions & 11 deletions

File tree

Source/automap.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1557,6 +1557,7 @@ Rectangle MinimapRect {};
15571557
void InitAutomapOnce()
15581558
{
15591559
AutomapActive = false;
1560+
SetAutomapType(*GetOptions().Gameplay.automapType);
15601561
AutoMapScale = 50;
15611562

15621563
// Set the dimensions and screen position of the minimap relative to the screen dimensions

Source/loadsave.cpp

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
#include "monster.h"
3333
#include "monsters/validation.hpp"
3434
#include "mpq/mpq_common.hpp"
35+
#include "options.h"
3536
#include "pfile.h"
3637
#include "plrmsg.h"
3738
#include "qol/stash.h"
@@ -2658,16 +2659,7 @@ tl::expected<void, std::string> LoadGame(bool firstflag)
26582659

26592660
AutomapActive = file.NextBool8();
26602661
AutoMapScale = file.NextBE<int32_t>();
2661-
if (file.IsValid(sizeof(uint8_t))) {
2662-
const auto automapType = file.NextLE<uint8_t>();
2663-
if (automapType <= static_cast<uint8_t>(AutomapType::LAST)) {
2664-
SetAutomapType(static_cast<AutomapType>(automapType));
2665-
} else {
2666-
SetAutomapType(AutomapType::Opaque);
2667-
}
2668-
} else {
2669-
SetAutomapType(AutomapType::Opaque);
2670-
}
2662+
SetAutomapType(*GetOptions().Gameplay.automapType);
26712663
AutomapZoomReset();
26722664
ResyncQuests();
26732665

@@ -2931,14 +2923,15 @@ void SaveGameData(SaveWriter &saveWriter)
29312923

29322924
file.WriteLE<uint8_t>(AutomapActive ? 1 : 0);
29332925
file.WriteBE<int32_t>(AutoMapScale);
2934-
file.WriteLE<uint8_t>(static_cast<uint8_t>(GetAutomapType()));
29352926

29362927
SaveAdditionalMissiles(saveWriter);
29372928
SaveLevelSeeds(saveWriter);
29382929
}
29392930

29402931
void SaveGame()
29412932
{
2933+
GetOptions().Gameplay.automapType.SetValue(GetAutomapType());
2934+
SaveOptions();
29422935
gbValidSaveFile = true;
29432936
pfile_write_hero(/*writeGameData=*/true);
29442937
sfile_write_stash();

Source/options.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -865,6 +865,13 @@ GameplayOptions::GameplayOptions()
865865
, autoRefillBelt("Auto Refill Belt", OptionEntryFlags::None, N_("Auto Refill Belt"), N_("Refill belt from inventory when belt item is consumed."), false)
866866
, disableCripplingShrines("Disable Crippling Shrines", OptionEntryFlags::None, N_("Disable Crippling Shrines"), N_("When enabled Cauldrons, Fascinating Shrines, Goat Shrines, Ornate Shrines, Sacred Shrines and Murphy's Shrines are not able to be clicked on and labeled as disabled."), false)
867867
, quickCast("Quick Cast", OptionEntryFlags::None, N_("Quick Cast"), N_("Spell hotkeys instantly cast the spell, rather than switching the readied spell."), false)
868+
, automapType("Automap Type", OptionEntryFlags::None, N_("Automap Type"), N_("Default automap type used when loading a game."), AutomapType::Opaque,
869+
{
870+
{ AutomapType::Opaque, N_("Opaque") },
871+
{ AutomapType::Transparent, N_("Transparent") },
872+
{ AutomapType::Minimap, N_("Minimap") },
873+
{ AutomapType::MinimapBorderless, N_("Minimap Borderless") },
874+
})
868875
, numHealPotionPickup("Heal Potion Pickup", OptionEntryFlags::None, N_("Heal Potion Pickup"), N_("Number of Healing potions to pick up automatically."), 0, { 0, 1, 2, 4, 8, 16 })
869876
, numFullHealPotionPickup("Full Heal Potion Pickup", OptionEntryFlags::None, N_("Full Heal Potion Pickup"), N_("Number of Full Healing potions to pick up automatically."), 0, { 0, 1, 2, 4, 8, 16 })
870877
, numManaPotionPickup("Mana Potion Pickup", OptionEntryFlags::None, N_("Mana Potion Pickup"), N_("Number of Mana potions to pick up automatically."), 0, { 0, 1, 2, 4, 8, 16 })
@@ -916,6 +923,7 @@ std::vector<OptionEntryBase *> GameplayOptions::GetEntries()
916923
&disableCripplingShrines,
917924
&grabInput,
918925
&pauseOnFocusLoss,
926+
&automapType,
919927
&skipLoadingScreenThresholdMs,
920928
};
921929
}

Source/options.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
#include <ankerl/unordered_dense.h>
2626
#include <function_ref.hpp>
2727

28+
#include "automap.h"
2829
#include "appfat.h"
2930
#include "controls/controller_buttons.h"
3031
#include "engine/size.hpp"
@@ -623,6 +624,8 @@ struct GameplayOptions : OptionCategoryBase {
623624
OptionEntryBoolean disableCripplingShrines;
624625
/** @brief Spell hotkeys instantly cast the spell. */
625626
OptionEntryBoolean quickCast;
627+
/** @brief Default automap type to use when loading a game. */
628+
OptionEntryEnum<AutomapType> automapType;
626629
/** @brief Number of Healing potions to pick up automatically */
627630
OptionEntryInt<int> numHealPotionPickup;
628631
/** @brief Number of Full Healing potions to pick up automatically */

0 commit comments

Comments
 (0)