Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Automap: Grates #6601

Closed
wants to merge 2 commits into from
Closed
Changes from all 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
71 changes: 57 additions & 14 deletions Source/automap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@
MapColorsBright = PAL8_YELLOW,
/** color for dim map lines/dots */
MapColorsDim = (PAL16_YELLOW + 8),
/** color for grates */
MapColorsGrate = (PAL16_YELLOW + 4),
/** color for items on automap */
MapColorsItem = (PAL8_BLUE + 1),
/** color for activated pentragram on automap */
Expand Down Expand Up @@ -621,10 +623,44 @@
}
}

/**
* @brief Draws a dotted line to represent a wall grate.
*/
void DrawMapVerticalGrate(const Surface &out, Point center, uint8_t colorDim)
{
Point pos1 = center + AmOffset(AmWidthOffset::HalfTileLeft, AmHeightOffset::None) + AmOffset(AmWidthOffset::EighthTileRight, AmHeightOffset::EighthTileUp);
Point pos2 = center + AmOffset(AmWidthOffset::HalfTileLeft, AmHeightOffset::None);
Point pos3 = center + AmOffset(AmWidthOffset::HalfTileLeft, AmHeightOffset::None) + AmOffset(AmWidthOffset::EighthTileLeft, AmHeightOffset::EighthTileDown);

out.SetPixel(pos1 + Displacement { 0, 1 }, 0);
out.SetPixel(pos2 + Displacement { 0, 1 }, 0);
out.SetPixel(pos3 + Displacement { 0, 1 }, 0);
out.SetPixel(pos1, colorDim);
out.SetPixel(pos2, colorDim);
out.SetPixel(pos3, colorDim);
}

/**
* @brief Draws a dotted line to represent a wall grate.
*/
void DrawMapHorizontalGrate(const Surface &out, Point center, uint8_t colorDim)
{
Point pos1 = center + AmOffset(AmWidthOffset::HalfTileRight, AmHeightOffset::None) + AmOffset(AmWidthOffset::EighthTileLeft, AmHeightOffset::EighthTileUp);
Point pos2 = center + AmOffset(AmWidthOffset::HalfTileRight, AmHeightOffset::None);
Point pos3 = center + AmOffset(AmWidthOffset::HalfTileRight, AmHeightOffset::None) + AmOffset(AmWidthOffset::EighthTileRight, AmHeightOffset::EighthTileDown);

out.SetPixel(pos1 + Displacement { 0, 1 }, 0);
out.SetPixel(pos2 + Displacement { 0, 1 }, 0);
out.SetPixel(pos3 + Displacement { 0, 1 }, 0);
out.SetPixel(pos1, colorDim);
out.SetPixel(pos2, colorDim);
out.SetPixel(pos3, colorDim);
}

/**
* Left-facing obstacle
*/
void DrawHorizontal(const Surface &out, Point center, AutomapTile tile, AutomapTile nwTile, AutomapTile neTile, AutomapTile seTile, uint8_t colorBright, uint8_t colorDim)
void DrawHorizontal(const Surface &out, Point center, AutomapTile tile, AutomapTile nwTile, AutomapTile neTile, AutomapTile seTile, uint8_t colorBright, uint8_t colorDim, uint8_t colorGrate)
{
AmWidthOffset w = AmWidthOffset::None;
AmHeightOffset h = AmHeightOffset::HalfTileUp;
Expand All @@ -648,20 +684,22 @@
l = AmLineLength::FullTile;
}
// Draw the wall line if the wall is solid
if (!tile.hasAnyFlag(AutomapTile::Flags::HorizontalDoor, AutomapTile::Flags::HorizontalArch)) {
if (!tile.HasFlag(AutomapTile::Flags::HorizontalPassage)) {

Check failure on line 687 in Source/automap.cpp

View workflow job for this annotation

GitHub Actions / build

'HasFlag': is not a member of 'devilution::`anonymous-namespace'::AutomapTile'
DrawMapLineSE(out, center + AmOffset(w, h), AmLine(l), colorDim);
return;
}
// Draw door
if (tile.hasFlag(AutomapTile::Flags::HorizontalDoor)) {
// Draw door or grate
if (tile.HasFlag(AutomapTile::Flags::HorizontalDoor)) {

Check failure on line 692 in Source/automap.cpp

View workflow job for this annotation

GitHub Actions / build

'HasFlag': is not a member of 'devilution::`anonymous-namespace'::AutomapTile'
DrawMapHorizontalDoor(out, center, nwTile, colorBright, colorDim);
} else if (tile.HasFlag(AutomapTile::Flags::HorizontalGrate)) {

Check failure on line 694 in Source/automap.cpp

View workflow job for this annotation

GitHub Actions / build

'HasFlag': is not a member of 'devilution::`anonymous-namespace'::AutomapTile'
DrawMapHorizontalGrate(out, center, colorGrate);
}
}

/**
* Right-facing obstacle
*/
void DrawVertical(const Surface &out, Point center, AutomapTile tile, AutomapTile nwTile, AutomapTile neTile, AutomapTile swTile, uint8_t colorBright, uint8_t colorDim)
void DrawVertical(const Surface &out, Point center, AutomapTile tile, AutomapTile nwTile, AutomapTile neTile, AutomapTile swTile, uint8_t colorBright, uint8_t colorDim, uint8_t colorGrate)
{
AmWidthOffset w = AmWidthOffset::ThreeQuartersTileLeft;
AmHeightOffset h = AmHeightOffset::QuarterTileDown;
Expand All @@ -685,13 +723,15 @@
l = AmLineLength::FullTile;
}
// Draw the wall line if the wall is solid
if (!tile.hasAnyFlag(AutomapTile::Flags::VerticalDoor, AutomapTile::Flags::VerticalArch)) {
if (!tile.HasFlag(AutomapTile::Flags::VerticalPassage)) {

Check failure on line 726 in Source/automap.cpp

View workflow job for this annotation

GitHub Actions / build

'HasFlag': is not a member of 'devilution::`anonymous-namespace'::AutomapTile'
DrawMapLineNE(out, center + AmOffset(w, h), AmLine(l), colorDim);
return;
}
// Draw door
if (tile.hasFlag(AutomapTile::Flags::VerticalDoor)) {
// Draw door or grate
if (tile.HasFlag(AutomapTile::Flags::VerticalDoor)) {

Check failure on line 731 in Source/automap.cpp

View workflow job for this annotation

GitHub Actions / build

'HasFlag': is not a member of 'devilution::`anonymous-namespace'::AutomapTile'
DrawMapVerticalDoor(out, center, neTile, colorBright, colorDim);
} else if (tile.HasFlag(AutomapTile::Flags::VerticalGrate)) {

Check failure on line 733 in Source/automap.cpp

View workflow job for this annotation

GitHub Actions / build

'HasFlag': is not a member of 'devilution::`anonymous-namespace'::AutomapTile'
DrawMapVerticalGrate(out, center, colorGrate);
}
}

Expand Down Expand Up @@ -940,16 +980,19 @@
{
uint8_t colorBright = MapColorsBright;
uint8_t colorDim = MapColorsDim;
uint8_t colorGrate = MapColorsGrate;
MapExplorationType explorationType = static_cast<MapExplorationType>(AutomapView[std::clamp(map.x, 0, DMAXX - 1)][std::clamp(map.y, 0, DMAXY - 1)]);

switch (explorationType) {
case MAP_EXP_SHRINE:
colorDim = PAL16_GRAY + 11;
colorBright = PAL16_GRAY + 3;
colorGrate = PAL16_GRAY + 7;
break;
case MAP_EXP_OTHERS:
colorDim = PAL16_BEIGE + 10;
colorBright = PAL16_BEIGE + 2;
colorGrate = PAL16_BEIGE + 6;
break;
case MAP_EXP_SELF:
case MAP_EXP_NONE:
Expand Down Expand Up @@ -1024,25 +1067,25 @@
case AutomapTile::Types::Vertical:
case AutomapTile::Types::FenceVertical:
case AutomapTile::Types::VerticalDiamond:
DrawVertical(out, center, tile, nwTile, neTile, swTile, colorBright, colorDim);
DrawVertical(out, center, tile, nwTile, neTile, swTile, colorBright, colorDim, colorGrate);
break;
case AutomapTile::Types::Horizontal:
case AutomapTile::Types::FenceHorizontal:
case AutomapTile::Types::HorizontalDiamond:
DrawHorizontal(out, center, tile, nwTile, neTile, seTile, colorBright, colorDim);
DrawHorizontal(out, center, tile, nwTile, neTile, seTile, colorBright, colorDim, colorGrate);
break;
case AutomapTile::Types::Cross:
DrawVertical(out, center, tile, nwTile, neTile, swTile, colorBright, colorDim);
DrawHorizontal(out, center, tile, nwTile, neTile, seTile, colorBright, colorDim);
DrawVertical(out, center, tile, nwTile, neTile, swTile, colorBright, colorDim, colorGrate);
DrawHorizontal(out, center, tile, nwTile, neTile, seTile, colorBright, colorDim, colorGrate);
break;
case AutomapTile::Types::CaveHorizontalCross:
case AutomapTile::Types::CaveHorizontalWoodCross:
DrawVertical(out, center, tile, nwTile, neTile, swTile, colorBright, colorDim);
DrawVertical(out, center, tile, nwTile, neTile, swTile, colorBright, colorDim, colorGrate);
DrawCaveHorizontal(out, center, tile, nwTile, swTile, colorBright, colorDim);
break;
case AutomapTile::Types::CaveVerticalCross:
case AutomapTile::Types::CaveVerticalWoodCross:
DrawHorizontal(out, center, tile, nwTile, neTile, seTile, colorBright, colorDim);
DrawHorizontal(out, center, tile, nwTile, neTile, seTile, colorBright, colorDim, colorGrate);
DrawCaveVertical(out, center, tile, neTile, seTile, colorBright, colorDim);
break;
case AutomapTile::Types::CaveHorizontal:
Expand Down Expand Up @@ -1134,11 +1177,11 @@
DrawLavaRiver<Direction::NorthWest, Direction::NorthEast>(out, center, lavaColor, false);
break;
case AutomapTile::Types::VerticalWallLava:
DrawVertical(out, center, tile, nwTile, neTile, swTile, colorBright, colorDim);

Check failure on line 1180 in Source/automap.cpp

View workflow job for this annotation

GitHub Actions / build

'devilution::`anonymous-namespace'::DrawVertical': function does not take 8 arguments
DrawLavaRiver<Direction::SouthEast, Direction::NoDirection>(out, center, lavaColor, false);
break;
case AutomapTile::Types::HorizontalWallLava:
DrawHorizontal(out, center, tile, nwTile, neTile, swTile, colorBright, colorDim);

Check failure on line 1184 in Source/automap.cpp

View workflow job for this annotation

GitHub Actions / build

'devilution::`anonymous-namespace'::DrawHorizontal': function does not take 8 arguments
DrawLavaRiver<Direction::SouthWest, Direction::NoDirection>(out, center, lavaColor, false);
break;
case AutomapTile::Types::SELava:
Expand Down
Loading