You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
85 lines
2.5 KiB
85 lines
2.5 KiB
|
5 years ago
|
#include "engine/render/automap_render.hpp"
|
||
|
5 years ago
|
|
||
|
|
namespace devilution {
|
||
|
|
namespace {
|
||
|
|
|
||
|
|
enum class DirectionX {
|
||
|
|
EAST = 1,
|
||
|
|
WEST = -1,
|
||
|
|
};
|
||
|
|
|
||
|
|
enum class DirectionY {
|
||
|
|
SOUTH = 1,
|
||
|
|
NORTH = -1,
|
||
|
|
};
|
||
|
|
|
||
|
|
template <DirectionX DirX, DirectionY DirY>
|
||
|
|
void DrawMapLine(const CelOutputBuffer &out, Point from, int height, std::uint8_t colorIndex)
|
||
|
|
{
|
||
|
5 years ago
|
while (height-- > 0) {
|
||
|
|
SetPixel(out, from, colorIndex);
|
||
|
|
from.x += static_cast<int>(DirX);
|
||
|
|
SetPixel(out, from, colorIndex);
|
||
|
|
from.x += static_cast<int>(DirX);
|
||
|
|
from.y += static_cast<int>(DirY);
|
||
|
5 years ago
|
}
|
||
|
5 years ago
|
SetPixel(out, from, colorIndex);
|
||
|
5 years ago
|
}
|
||
|
|
|
||
|
|
template <DirectionX DirX, DirectionY DirY>
|
||
|
5 years ago
|
void DrawMapLineSteep(const CelOutputBuffer &out, Point from, int width, std::uint8_t colorIndex)
|
||
|
5 years ago
|
{
|
||
|
|
while (width-- > 0) {
|
||
|
|
SetPixel(out, from, colorIndex);
|
||
|
|
from.y += static_cast<int>(DirY);
|
||
|
|
SetPixel(out, from, colorIndex);
|
||
|
|
from.y += static_cast<int>(DirY);
|
||
|
|
from.x += static_cast<int>(DirX);
|
||
|
|
}
|
||
|
|
SetPixel(out, from, colorIndex);
|
||
|
|
}
|
||
|
|
|
||
|
|
} // namespace
|
||
|
|
|
||
|
|
void DrawMapLineNE(const CelOutputBuffer &out, Point from, int height, std::uint8_t colorIndex)
|
||
|
|
{
|
||
|
|
DrawMapLine<DirectionX::EAST, DirectionY::NORTH>(out, from, height, colorIndex);
|
||
|
|
}
|
||
|
|
|
||
|
|
void DrawMapLineSE(const CelOutputBuffer &out, Point from, int height, std::uint8_t colorIndex)
|
||
|
|
{
|
||
|
|
DrawMapLine<DirectionX::EAST, DirectionY::SOUTH>(out, from, height, colorIndex);
|
||
|
|
}
|
||
|
|
|
||
|
|
void DrawMapLineNW(const CelOutputBuffer &out, Point from, int height, std::uint8_t colorIndex)
|
||
|
|
{
|
||
|
|
DrawMapLine<DirectionX::WEST, DirectionY::NORTH>(out, from, height, colorIndex);
|
||
|
|
}
|
||
|
|
|
||
|
|
void DrawMapLineSW(const CelOutputBuffer &out, Point from, int height, std::uint8_t colorIndex)
|
||
|
|
{
|
||
|
|
DrawMapLine<DirectionX::WEST, DirectionY::SOUTH>(out, from, height, colorIndex);
|
||
|
|
}
|
||
|
|
|
||
|
5 years ago
|
void DrawMapLineSteepNE(const CelOutputBuffer &out, Point from, int width, std::uint8_t colorIndex)
|
||
|
5 years ago
|
{
|
||
|
5 years ago
|
DrawMapLineSteep<DirectionX::EAST, DirectionY::NORTH>(out, from, width, colorIndex);
|
||
|
5 years ago
|
}
|
||
|
|
|
||
|
5 years ago
|
void DrawMapLineSteepSE(const CelOutputBuffer &out, Point from, int width, std::uint8_t colorIndex)
|
||
|
5 years ago
|
{
|
||
|
5 years ago
|
DrawMapLineSteep<DirectionX::EAST, DirectionY::SOUTH>(out, from, width, colorIndex);
|
||
|
5 years ago
|
}
|
||
|
|
|
||
|
5 years ago
|
void DrawMapLineSteepNW(const CelOutputBuffer &out, Point from, int width, std::uint8_t colorIndex)
|
||
|
5 years ago
|
{
|
||
|
5 years ago
|
DrawMapLineSteep<DirectionX::WEST, DirectionY::NORTH>(out, from, width, colorIndex);
|
||
|
5 years ago
|
}
|
||
|
|
|
||
|
5 years ago
|
void DrawMapLineSteepSW(const CelOutputBuffer &out, Point from, int width, std::uint8_t colorIndex)
|
||
|
5 years ago
|
{
|
||
|
5 years ago
|
DrawMapLineSteep<DirectionX::WEST, DirectionY::SOUTH>(out, from, width, colorIndex);
|
||
|
5 years ago
|
}
|
||
|
|
|
||
|
|
} // namespace devilution
|