Skip to content
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 24 additions & 8 deletions Source/automap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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++) {
Expand All @@ -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())
Expand Down Expand Up @@ -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),
Expand Down Expand Up @@ -1547,7 +1547,6 @@ std::unique_ptr<AutomapTile[]> LoadAutomapData(size_t &tileCount)
} // namespace

bool AutomapActive;
AutomapType CurrentAutomapType = AutomapType::Opaque;
uint8_t AutomapView[DMAXX][DMAXY];
int AutoMapScale;
int MinimapScale;
Expand All @@ -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
Expand All @@ -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;
Expand Down Expand Up @@ -1732,7 +1742,7 @@ void AutomapRight()

void AutomapZoomIn()
{
int &scale = (GetAutomapType() == AutomapType::Minimap) ? MinimapScale : AutoMapScale;
int &scale = IsMinimapAutomapType() ? MinimapScale : AutoMapScale;

if (scale >= 200)
return;
Expand All @@ -1742,7 +1752,7 @@ void AutomapZoomIn()

void AutomapZoomOut()
{
int &scale = (GetAutomapType() == AutomapType::Minimap) ? MinimapScale : AutoMapScale;
int &scale = IsMinimapAutomapType() ? MinimapScale : AutoMapScale;

if (scale <= 25)
return;
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -1801,6 +1811,12 @@ void DrawAutomap(const Surface &out)
DrawVerticalLine(out, MinimapRect.position + Displacement { -2, -1 }, MinimapRect.size.height + 1, MapColorsDim);
DrawVerticalLine(out, MinimapRect.position + Displacement { MinimapRect.size.width, -1 }, MinimapRect.size.height + 1, MapColorsDim);

if (AutoMapShowItems)
SearchAutomapItem(out, myPlayerOffset, 8, [](Point position) {
return dItem[position.x][position.y] != 0;
});
} else if (GetAutomapType() == AutomapType::MinimapBorderless) {

if (AutoMapShowItems)
SearchAutomapItem(out, myPlayerOffset, 8, [](Point position) {
return dItem[position.x][position.y] != 0;
Expand Down
24 changes: 10 additions & 14 deletions Source/automap.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#include "engine/surface.hpp"
#include "levels/gendung.h"
#include "utils/attributes.h"
#include "utils/is_of.hpp"

namespace devilution {

Expand Down Expand Up @@ -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<int>(x) / 100, scale * static_cast<int>(y) / 100 };
}

inline int AmLine(AmLineLength l)
{
int scale = (GetAutomapType() == AutomapType::Minimap) ? MinimapScale : AutoMapScale;
int scale = IsMinimapAutomapType() ? MinimapScale : AutoMapScale;

return scale * static_cast<int>(l) / 100;
}
Expand Down
2 changes: 1 addition & 1 deletion Source/control/control_panel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -532,7 +532,7 @@ void CycleAutomapType()
}
const AutomapType newType { static_cast<std::underlying_type_t<AutomapType>>(
(static_cast<unsigned>(GetAutomapType()) + 1) % enum_size<AutomapType>::value) };
SetAutomapType(newType);
GetOptions().Gameplay.automapType.SetValue(newType);
if (newType == AutomapType::FIRST) {
AutomapActive = false;
}
Expand Down
2 changes: 1 addition & 1 deletion Source/diablo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion Source/engine/render/automap_render.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 2 additions & 0 deletions Source/loadsave.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
#include "monster.h"
#include "monsters/validation.hpp"
#include "mpq/mpq_common.hpp"
#include "options.h"
#include "pfile.h"
#include "plrmsg.h"
#include "qol/stash.h"
Expand Down Expand Up @@ -2658,6 +2659,7 @@ tl::expected<void, std::string> LoadGame(bool firstflag)

AutomapActive = file.NextBool8();
AutoMapScale = file.NextBE<int32_t>();
SetAutomapType(*GetOptions().Gameplay.automapType);
AutomapZoomReset();
ResyncQuests();

Expand Down
8 changes: 8 additions & 0 deletions Source/options.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 })
Expand Down Expand Up @@ -916,6 +923,7 @@ std::vector<OptionEntryBase *> GameplayOptions::GetEntries()
&disableCripplingShrines,
&grabInput,
&pauseOnFocusLoss,
&automapType,
&skipLoadingScreenThresholdMs,
};
}
Expand Down
3 changes: 3 additions & 0 deletions Source/options.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#include <ankerl/unordered_dense.h>
#include <function_ref.hpp>

#include "automap.h"
#include "appfat.h"
#include "controls/controller_buttons.h"
#include "engine/size.hpp"
Expand Down Expand Up @@ -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> automapType;
/** @brief Number of Healing potions to pick up automatically */
OptionEntryInt<int> numHealPotionPickup;
/** @brief Number of Full Healing potions to pick up automatically */
Expand Down