Skip to content

Commit 648a9c7

Browse files
committed
Borderless Minimap and Automap type save
1 parent 1d0a52f commit 648a9c7

5 files changed

Lines changed: 40 additions & 12 deletions

File tree

Source/automap.cpp

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1257,7 +1257,7 @@ Displacement GetAutomapScreen()
12571257
{
12581258
Displacement screen = {};
12591259

1260-
if (GetAutomapType() == AutomapType::Minimap) {
1260+
if (IsMinimapAutomapType()) {
12611261
screen = {
12621262
MinimapRect.position.x + MinimapRect.size.width / 2,
12631263
MinimapRect.position.y + MinimapRect.size.height / 2
@@ -1291,7 +1291,7 @@ void SearchAutomapItem(const Surface &out, const Displacement &myPlayerOffset, i
12911291
const int endY = std::clamp(tile.y + searchRadius, 0, MAXDUNY);
12921292

12931293
const AutomapType mapType = GetAutomapType();
1294-
const int scale = (mapType == AutomapType::Minimap) ? MinimapScale : AutoMapScale;
1294+
const int scale = IsMinimapAutomapType(mapType) ? MinimapScale : AutoMapScale;
12951295

12961296
for (int i = startX; i < endX; i++) {
12971297
for (int j = startY; j < endY; j++) {
@@ -1308,7 +1308,7 @@ void SearchAutomapItem(const Surface &out, const Displacement &myPlayerOffset, i
13081308

13091309
screen += GetAutomapScreen();
13101310

1311-
if (mapType != AutomapType::Minimap && CanPanelsCoverView()) {
1311+
if (!IsMinimapAutomapType(mapType) && CanPanelsCoverView()) {
13121312
if (IsRightPanelOpen())
13131313
screen.x -= gnScreenWidth / 4;
13141314
if (IsLeftPanelOpen())
@@ -1352,7 +1352,7 @@ void DrawAutomapPlr(const Surface &out, const Displacement &myPlayerOffset, cons
13521352
if (player.isWalking())
13531353
playerOffset = GetOffsetForWalking(player.AnimInfo, player._pdir);
13541354

1355-
const int scale = (GetAutomapType() == AutomapType::Minimap) ? MinimapScale : AutoMapScale;
1355+
const int scale = IsMinimapAutomapType() ? MinimapScale : AutoMapScale;
13561356

13571357
Point base = {
13581358
((playerOffset.deltaX + myPlayerOffset.deltaX) * scale / 100 / 2) + (px - py) * AmLine(AmLineLength::DoubleTile),
@@ -1732,7 +1732,7 @@ void AutomapRight()
17321732

17331733
void AutomapZoomIn()
17341734
{
1735-
int &scale = (GetAutomapType() == AutomapType::Minimap) ? MinimapScale : AutoMapScale;
1735+
int &scale = IsMinimapAutomapType() ? MinimapScale : AutoMapScale;
17361736

17371737
if (scale >= 200)
17381738
return;
@@ -1742,7 +1742,7 @@ void AutomapZoomIn()
17421742

17431743
void AutomapZoomOut()
17441744
{
1745-
int &scale = (GetAutomapType() == AutomapType::Minimap) ? MinimapScale : AutoMapScale;
1745+
int &scale = IsMinimapAutomapType() ? MinimapScale : AutoMapScale;
17461746

17471747
if (scale <= 25)
17481748
return;
@@ -1773,7 +1773,7 @@ void DrawAutomap(const Surface &out)
17731773
if (myPlayer.isWalking())
17741774
myPlayerOffset = GetOffsetForWalking(myPlayer.AnimInfo, myPlayer._pdir, true);
17751775

1776-
const int scale = (GetAutomapType() == AutomapType::Minimap) ? MinimapScale : AutoMapScale;
1776+
const int scale = IsMinimapAutomapType() ? MinimapScale : AutoMapScale;
17771777
const int d = (scale * 64) / 100;
17781778
int cells = 2 * (gnScreenWidth / 2 / d) + 1;
17791779
if (((gnScreenWidth / 2) % d) != 0)
@@ -1801,6 +1801,12 @@ void DrawAutomap(const Surface &out)
18011801
DrawVerticalLine(out, MinimapRect.position + Displacement { -2, -1 }, MinimapRect.size.height + 1, MapColorsDim);
18021802
DrawVerticalLine(out, MinimapRect.position + Displacement { MinimapRect.size.width, -1 }, MinimapRect.size.height + 1, MapColorsDim);
18031803

1804+
if (AutoMapShowItems)
1805+
SearchAutomapItem(out, myPlayerOffset, 8, [](Point position) {
1806+
return dItem[position.x][position.y] != 0;
1807+
});
1808+
} else if (GetAutomapType() == AutomapType::MinimapBorderless) {
1809+
18041810
if (AutoMapShowItems)
18051811
SearchAutomapItem(out, myPlayerOffset, 8, [](Point position) {
18061812
return dItem[position.x][position.y] != 0;

Source/automap.h

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,8 @@ enum class AutomapType : uint8_t {
8585
FIRST = Opaque,
8686
Transparent,
8787
Minimap,
88-
LAST = Minimap
88+
MinimapBorderless,
89+
LAST = MinimapBorderless
8990
};
9091

9192
extern DVL_API_FOR_TEST AutomapType CurrentAutomapType;
@@ -106,16 +107,26 @@ inline AutomapType GetAutomapType()
106107
return CurrentAutomapType;
107108
}
108109

110+
inline bool IsMinimapAutomapType(AutomapType type)
111+
{
112+
return type == AutomapType::Minimap || type == AutomapType::MinimapBorderless;
113+
}
114+
115+
inline bool IsMinimapAutomapType()
116+
{
117+
return IsMinimapAutomapType(GetAutomapType());
118+
}
119+
109120
inline Displacement AmOffset(AmWidthOffset x, AmHeightOffset y)
110121
{
111-
int scale = (GetAutomapType() == AutomapType::Minimap) ? MinimapScale : AutoMapScale;
122+
int scale = IsMinimapAutomapType() ? MinimapScale : AutoMapScale;
112123

113124
return { scale * static_cast<int>(x) / 100, scale * static_cast<int>(y) / 100 };
114125
}
115126

116127
inline int AmLine(AmLineLength l)
117128
{
118-
int scale = (GetAutomapType() == AutomapType::Minimap) ? MinimapScale : AutoMapScale;
129+
int scale = IsMinimapAutomapType() ? MinimapScale : AutoMapScale;
119130

120131
return scale * static_cast<int>(l) / 100;
121132
}

Source/diablo.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1937,7 +1937,7 @@ void InitKeymapActions()
19371937
options.Keymapper.AddAction(
19381938
"CycleAutomapType",
19391939
N_("Cycle map type"),
1940-
N_("Opaque -> Transparent -> Minimap -> None"),
1940+
N_("Opaque -> Transparent -> Minimap -> Borderless Minimap -> None"),
19411941
SDLK_M,
19421942
CycleAutomapType,
19431943
nullptr,

Source/engine/render/automap_render.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ void DrawMapFreeLine(const Surface &out, Point from, Point to, uint8_t colorInde
165165

166166
void SetMapPixel(const Surface &out, Point position, uint8_t color)
167167
{
168-
if (GetAutomapType() == AutomapType::Minimap && !MinimapRect.contains(position))
168+
if (IsMinimapAutomapType() && !MinimapRect.contains(position))
169169
return;
170170

171171
if (GetAutomapType() == AutomapType::Transparent) {

Source/loadsave.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2658,6 +2658,16 @@ tl::expected<void, std::string> LoadGame(bool firstflag)
26582658

26592659
AutomapActive = file.NextBool8();
26602660
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+
}
26612671
AutomapZoomReset();
26622672
ResyncQuests();
26632673

@@ -2921,6 +2931,7 @@ void SaveGameData(SaveWriter &saveWriter)
29212931

29222932
file.WriteLE<uint8_t>(AutomapActive ? 1 : 0);
29232933
file.WriteBE<int32_t>(AutoMapScale);
2934+
file.WriteLE<uint8_t>(static_cast<uint8_t>(GetAutomapType()));
29242935

29252936
SaveAdditionalMissiles(saveWriter);
29262937
SaveLevelSeeds(saveWriter);

0 commit comments

Comments
 (0)