diff --git a/Source/automap.cpp b/Source/automap.cpp index 96b54e36d25..0722eadc00e 100644 --- a/Source/automap.cpp +++ b/Source/automap.cpp @@ -1257,7 +1257,7 @@ Displacement GetAutomapScreen() { Displacement screen = {}; - if (GetAutomapType() == AutomapType::Minimap) { + if (IsMinimapAutomapType()) { screen = { MinimapRect.position.x + MinimapRect.size.width / 2, MinimapRect.position.y + MinimapRect.size.height / 2 @@ -1291,7 +1291,7 @@ void SearchAutomapItem(const Surface &out, const Displacement &myPlayerOffset, i const int endY = std::clamp(tile.y + searchRadius, 0, MAXDUNY); const AutomapType mapType = GetAutomapType(); - const int scale = (mapType == AutomapType::Minimap) ? MinimapScale : AutoMapScale; + const int scale = IsMinimapAutomapType(mapType) ? MinimapScale : AutoMapScale; for (int i = startX; i < endX; i++) { for (int j = startY; j < endY; j++) { @@ -1308,7 +1308,7 @@ void SearchAutomapItem(const Surface &out, const Displacement &myPlayerOffset, i screen += GetAutomapScreen(); - if (mapType != AutomapType::Minimap && CanPanelsCoverView()) { + if (!IsMinimapAutomapType(mapType) && CanPanelsCoverView()) { if (IsRightPanelOpen()) screen.x -= gnScreenWidth / 4; if (IsLeftPanelOpen()) @@ -1352,7 +1352,7 @@ void DrawAutomapPlr(const Surface &out, const Displacement &myPlayerOffset, cons if (player.isWalking()) playerOffset = GetOffsetForWalking(player.AnimInfo, player._pdir); - const int scale = (GetAutomapType() == AutomapType::Minimap) ? MinimapScale : AutoMapScale; + const int scale = IsMinimapAutomapType() ? MinimapScale : AutoMapScale; Point base = { ((playerOffset.deltaX + myPlayerOffset.deltaX) * scale / 100 / 2) + (px - py) * AmLine(AmLineLength::DoubleTile), @@ -1547,7 +1547,6 @@ std::unique_ptr LoadAutomapData(size_t &tileCount) } // namespace bool AutomapActive; -AutomapType CurrentAutomapType = AutomapType::Opaque; uint8_t AutomapView[DMAXX][DMAXY]; int AutoMapScale; int MinimapScale; @@ -1557,6 +1556,7 @@ Rectangle MinimapRect {}; void InitAutomapOnce() { AutomapActive = false; + SetAutomapType(*GetOptions().Gameplay.automapType); AutoMapScale = 50; // Set the dimensions and screen position of the minimap relative to the screen dimensions @@ -1577,6 +1577,16 @@ void InitAutomapOnce() } } +void SetAutomapType(AutomapType type) +{ + GetOptions().Gameplay.automapType.SetValue(type); +} + +AutomapType GetAutomapType() +{ + return *GetOptions().Gameplay.automapType; +} + void InitAutomap() { size_t tileCount = 0; @@ -1732,7 +1742,7 @@ void AutomapRight() void AutomapZoomIn() { - int &scale = (GetAutomapType() == AutomapType::Minimap) ? MinimapScale : AutoMapScale; + int &scale = IsMinimapAutomapType() ? MinimapScale : AutoMapScale; if (scale >= 200) return; @@ -1742,7 +1752,7 @@ void AutomapZoomIn() void AutomapZoomOut() { - int &scale = (GetAutomapType() == AutomapType::Minimap) ? MinimapScale : AutoMapScale; + int &scale = IsMinimapAutomapType() ? MinimapScale : AutoMapScale; if (scale <= 25) return; @@ -1773,7 +1783,7 @@ void DrawAutomap(const Surface &out) if (myPlayer.isWalking()) myPlayerOffset = GetOffsetForWalking(myPlayer.AnimInfo, myPlayer._pdir, true); - const int scale = (GetAutomapType() == AutomapType::Minimap) ? MinimapScale : AutoMapScale; + const int scale = IsMinimapAutomapType() ? MinimapScale : AutoMapScale; const int d = (scale * 64) / 100; int cells = 2 * (gnScreenWidth / 2 / d) + 1; if (((gnScreenWidth / 2) % d) != 0) diff --git a/Source/automap.h b/Source/automap.h index e12d752ed4c..aafab3bfd9c 100644 --- a/Source/automap.h +++ b/Source/automap.h @@ -12,6 +12,7 @@ #include "engine/surface.hpp" #include "levels/gendung.h" #include "utils/attributes.h" +#include "utils/is_of.hpp" namespace devilution { @@ -85,37 +86,32 @@ enum class AutomapType : uint8_t { FIRST = Opaque, Transparent, Minimap, - LAST = Minimap + MinimapBorderless, + LAST = MinimapBorderless }; -extern DVL_API_FOR_TEST AutomapType CurrentAutomapType; +AutomapType GetAutomapType(); -/** - * @brief Sets the map type. Does not change `AutomapActive`. - */ -inline void SetAutomapType(AutomapType type) +inline bool IsMinimapAutomapType(AutomapType type) { - CurrentAutomapType = type; + return IsAnyOf(type, AutomapType::Minimap, AutomapType::MinimapBorderless); } -/** - * @brief Sets the map type. Does not change `AutomapActive`. - */ -inline AutomapType GetAutomapType() +inline bool IsMinimapAutomapType() { - return CurrentAutomapType; + return IsMinimapAutomapType(GetAutomapType()); } inline Displacement AmOffset(AmWidthOffset x, AmHeightOffset y) { - int scale = (GetAutomapType() == AutomapType::Minimap) ? MinimapScale : AutoMapScale; + int scale = IsMinimapAutomapType() ? MinimapScale : AutoMapScale; return { scale * static_cast(x) / 100, scale * static_cast(y) / 100 }; } inline int AmLine(AmLineLength l) { - int scale = (GetAutomapType() == AutomapType::Minimap) ? MinimapScale : AutoMapScale; + int scale = IsMinimapAutomapType() ? MinimapScale : AutoMapScale; return scale * static_cast(l) / 100; } diff --git a/Source/control/control_panel.cpp b/Source/control/control_panel.cpp index dd33e61601a..d94b3d0d8ab 100644 --- a/Source/control/control_panel.cpp +++ b/Source/control/control_panel.cpp @@ -532,7 +532,7 @@ void CycleAutomapType() } const AutomapType newType { static_cast>( (static_cast(GetAutomapType()) + 1) % enum_size::value) }; - SetAutomapType(newType); + GetOptions().Gameplay.automapType.SetValue(newType); if (newType == AutomapType::FIRST) { AutomapActive = false; } diff --git a/Source/diablo.cpp b/Source/diablo.cpp index 0339a904373..906d2278392 100644 --- a/Source/diablo.cpp +++ b/Source/diablo.cpp @@ -1937,7 +1937,7 @@ void InitKeymapActions() options.Keymapper.AddAction( "CycleAutomapType", N_("Cycle map type"), - N_("Opaque -> Transparent -> Minimap -> None"), + N_("Opaque -> Transparent -> Minimap -> Borderless Minimap -> None"), SDLK_M, CycleAutomapType, nullptr, diff --git a/Source/engine/render/automap_render.cpp b/Source/engine/render/automap_render.cpp index 9f3c3191150..d1bc8008ede 100644 --- a/Source/engine/render/automap_render.cpp +++ b/Source/engine/render/automap_render.cpp @@ -165,7 +165,7 @@ void DrawMapFreeLine(const Surface &out, Point from, Point to, uint8_t colorInde void SetMapPixel(const Surface &out, Point position, uint8_t color) { - if (GetAutomapType() == AutomapType::Minimap && !MinimapRect.contains(position)) + if (IsMinimapAutomapType() && !MinimapRect.contains(position)) return; if (GetAutomapType() == AutomapType::Transparent) { diff --git a/Source/options.cpp b/Source/options.cpp index 52e2730ed3f..8f7d09d2658 100644 --- a/Source/options.cpp +++ b/Source/options.cpp @@ -865,6 +865,13 @@ GameplayOptions::GameplayOptions() , autoRefillBelt("Auto Refill Belt", OptionEntryFlags::None, N_("Auto Refill Belt"), N_("Refill belt from inventory when belt item is consumed."), false) , 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) , quickCast("Quick Cast", OptionEntryFlags::None, N_("Quick Cast"), N_("Spell hotkeys instantly cast the spell, rather than switching the readied spell."), false) + , automapType("Automap Type", OptionEntryFlags::None, N_("Automap Type"), N_("Default automap type used when loading a game."), AutomapType::Opaque, + { + { AutomapType::Opaque, N_("Opaque") }, + { AutomapType::Transparent, N_("Transparent") }, + { AutomapType::Minimap, N_("Minimap") }, + { AutomapType::MinimapBorderless, N_("Minimap Borderless") }, + }) , 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 }) , 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 }) , 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 GameplayOptions::GetEntries() &disableCripplingShrines, &grabInput, &pauseOnFocusLoss, + &automapType, &skipLoadingScreenThresholdMs, }; } diff --git a/Source/options.h b/Source/options.h index 58954f55f28..a78127b6a05 100644 --- a/Source/options.h +++ b/Source/options.h @@ -25,6 +25,7 @@ #include #include +#include "automap.h" #include "appfat.h" #include "controls/controller_buttons.h" #include "engine/size.hpp" @@ -623,6 +624,8 @@ struct GameplayOptions : OptionCategoryBase { OptionEntryBoolean disableCripplingShrines; /** @brief Spell hotkeys instantly cast the spell. */ OptionEntryBoolean quickCast; + /** @brief Default automap type to use when loading a game. */ + OptionEntryEnum automapType; /** @brief Number of Healing potions to pick up automatically */ OptionEntryInt numHealPotionPickup; /** @brief Number of Full Healing potions to pick up automatically */