Skip to content

Commit

Permalink
fix indents
Browse files Browse the repository at this point in the history
  • Loading branch information
ipochto committed Dec 5, 2023
1 parent 8376505 commit 4ddc43a
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 40 deletions.
13 changes: 6 additions & 7 deletions src/include/viewport.h
Original file line number Diff line number Diff line change
Expand Up @@ -135,13 +135,12 @@ class CViewport
void Set(const PixelPos &mapPixelPos);
/// Draw the map grid for dubug purposes
void DrawMapGridInViewport() const;
/// Highlight overlays when size of logical and graphical tiles are identical
void HighlightGraphicalTileInViewport(int dx, int dy, uint32_t color = ColorRed, uint8_t transparency = 64) const;
/// Highlight overlays when size of logical and graphical tiles are differ
void HighlightGraphicalTileInViewport(int dx, int dy, int graphicTileOffset, int sx,
const fieldHighlightChecker highlightChecker,
uint32_t color = ColorRed, uint8_t transparency = 64) const;

/// Highlight overlays when size of logical and graphical tiles are identical
void HighlightGraphicalTileInViewport(int dx, int dy, uint32_t color = ColorRed, uint8_t transparency = 64) const;
/// Highlight overlays when size of logical and graphical tiles are differ
void HighlightGraphicalTileInViewport(int dx, int dy, int graphicTileOffset, int sx,
const fieldHighlightChecker highlightChecker,
uint32_t color = ColorRed, uint8_t transparency = 64) const;
/** Draw the map background.
* The template parameter graphicalTileIsLogicalTile selects the specialization.
* Drawing maps where graphical and logical tile sizes differ implies some extra
Expand Down
66 changes: 33 additions & 33 deletions src/map/map_draw.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -260,21 +260,21 @@ void CViewport::DrawMapGridInViewport() const
/// Highlight overlays when size of logical and graphical tiles are identical
void CViewport::HighlightGraphicalTileInViewport(int dx, int dy, uint32_t color /* = ColorRed */, uint8_t transparency /* = 64*/) const
{
Video.FillTransRectangleClip(color, dx, dy, PixelTileSize.x, PixelTileSize.y, transparency);
Video.FillTransRectangleClip(color, dx, dy, PixelTileSize.x, PixelTileSize.y, transparency);
}

/// Highlight overlays when size of logical and graphical tiles are differ
void CViewport::HighlightGraphicalTileInViewport(int dx, int dy, int graphicTileOffset, int sx,
const fieldHighlightChecker highlightChecker,
uint32_t color /* = ColorRed */, uint8_t transparency /* = 64*/) const
const fieldHighlightChecker highlightChecker,
uint32_t color /* = ColorRed */, uint8_t transparency /* = 64*/) const
{
for (int i = 0; i < graphicTileOffset; i++) {
for (int j = 0; j < graphicTileOffset; j++) {
if (highlightChecker(Map.Fields[sx + j + (Map.Info.MapWidth * i)])) {
Video.FillTransRectangleClip(color, dx + j * PixelTileSize.x, dy + i * PixelTileSize.y, PixelTileSize.x, PixelTileSize.y, transparency);
}
}
}
for (int i = 0; i < graphicTileOffset; i++) {
for (int j = 0; j < graphicTileOffset; j++) {
if (highlightChecker(Map.Fields[sx + j + (Map.Info.MapWidth * i)])) {
Video.FillTransRectangleClip(color, dx + j * PixelTileSize.x, dy + i * PixelTileSize.y, PixelTileSize.x, PixelTileSize.y, transparency);
}
}
}
}

template<bool graphicalTileIsLogicalTile>
Expand Down Expand Up @@ -348,30 +348,30 @@ void CViewport::DrawMapBackgroundInViewport(const fieldHighlightChecker highligh
}
Map.TileGraphic->DrawFrameClip(tile, dx, dy);
#ifdef DEBUG
// AStar passability overlay
if (CViewport::isPassabilityHighlighted()) {
HighlightGraphicalTileInViewport(dx, dy, graphicTileOffset, sx,
[](const CMapField &mf) -> bool { return mf.getFlag() & MapFieldUnpassable; },
ColorRed, 32);
HighlightGraphicalTileInViewport(dx, dy, graphicTileOffset, sx,
[](const CMapField &mf) -> bool { return !(mf.getFlag() & MapFieldUnpassable); },
ColorGreen, 32);
HighlightGraphicalTileInViewport(dx, dy, graphicTileOffset, sx,
[](const CMapField &mf) -> bool { return mf.getFlag() & (MapFieldLandUnit | MapFieldBuilding | MapFieldSeaUnit); },
ColorOrange, 32);
}
// AStar passability overlay
if (CViewport::isPassabilityHighlighted()) {
HighlightGraphicalTileInViewport(dx, dy, graphicTileOffset, sx,
[](const CMapField &mf) -> bool { return mf.getFlag() & MapFieldUnpassable; },
ColorRed, 32);
HighlightGraphicalTileInViewport(dx, dy, graphicTileOffset, sx,
[](const CMapField &mf) -> bool { return !(mf.getFlag() & MapFieldUnpassable); },
ColorGreen, 32);
HighlightGraphicalTileInViewport(dx, dy, graphicTileOffset, sx,
[](const CMapField &mf) -> bool { return mf.getFlag() & (MapFieldLandUnit | MapFieldBuilding | MapFieldSeaUnit); },
ColorOrange, 32);
}
#endif
/// Highlight overlay if needed (editor stuff)
if (highlightChecker) {
if constexpr(graphicalTileIsLogicalTile) {
if(highlightChecker(mf)) {
HighlightGraphicalTileInViewport(dx, dy);
}
} else {
HighlightGraphicalTileInViewport(dx, dy, graphicTileOffset, sx, highlightChecker);
}
}
/// Highlight overlay if needed (editor stuff)
if (highlightChecker) {
if constexpr(graphicalTileIsLogicalTile) {
if(highlightChecker(mf)) {
HighlightGraphicalTileInViewport(dx, dy);
}
} else {
HighlightGraphicalTileInViewport(dx, dy, graphicTileOffset, sx, highlightChecker);
}
}
if constexpr(graphicalTileIsLogicalTile) {
++sx;
} else {
Expand Down

0 comments on commit 4ddc43a

Please sign in to comment.