mirror of
https://github.com/vcmi/vcmi.git
synced 2025-07-17 01:32:21 +02:00
Added debug rendering
This commit is contained in:
BIN
Mods/vcmi/Data/debug/blocked.png
Normal file
BIN
Mods/vcmi/Data/debug/blocked.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 111 B |
BIN
Mods/vcmi/Data/debug/grid.png
Normal file
BIN
Mods/vcmi/Data/debug/grid.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 102 B |
BIN
Mods/vcmi/Data/debug/visitable.png
Normal file
BIN
Mods/vcmi/Data/debug/visitable.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 112 B |
@ -500,12 +500,39 @@ void MapRendererObjects::renderTile(const IMapRendererContext & context, Canvas
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MapRendererDebugGrid::renderTile(const IMapRendererContext & context, Canvas & target, const int3 & coordinates)
|
MapRendererDebug::MapRendererDebug()
|
||||||
|
: imageGrid(IImage::createFromFile("debug/grid"))
|
||||||
|
, imageBlockable(IImage::createFromFile("debug/blocked"))
|
||||||
|
, imageVisitable(IImage::createFromFile("debug/visitable"))
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void MapRendererDebug::renderTile(const IMapRendererContext & context, Canvas & target, const int3 & coordinates)
|
||||||
{
|
{
|
||||||
if(context.showGrid())
|
if(context.showGrid())
|
||||||
|
target.draw(imageGrid, Point(0,0));
|
||||||
|
|
||||||
|
if(context.showVisitable() || context.showBlockable())
|
||||||
{
|
{
|
||||||
target.drawLine(Point(0, 0), Point(0, 31), {128, 128, 128, 128}, {128, 128, 128, 128});
|
bool blockable = false;
|
||||||
target.drawLine(Point(0, 0), Point(31, 0), {128, 128, 128, 128}, {128, 128, 128, 128});
|
bool visitable = false;
|
||||||
|
|
||||||
|
for (auto const & objectID: context.getObjects(coordinates))
|
||||||
|
{
|
||||||
|
auto const * object = context.getObject(objectID);
|
||||||
|
|
||||||
|
if (context.objectTransparency(objectID) > 0)
|
||||||
|
{
|
||||||
|
visitable |= object->visitableAt(coordinates.x, coordinates.y);
|
||||||
|
blockable |= object->blockingAt(coordinates.x, coordinates.y);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (context.showBlockable() && blockable)
|
||||||
|
target.draw(imageBlockable, Point(0,0));
|
||||||
|
if (context.showVisitable() && visitable)
|
||||||
|
target.draw(imageVisitable, Point(0,0));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -619,9 +646,10 @@ void MapRenderer::renderTile(const IMapRendererContext & context, Canvas & targe
|
|||||||
rendererRoad.renderTile(context, target, coordinates);
|
rendererRoad.renderTile(context, target, coordinates);
|
||||||
rendererObjects.renderTile(context, target, coordinates);
|
rendererObjects.renderTile(context, target, coordinates);
|
||||||
rendererPath.renderTile(context, target, coordinates);
|
rendererPath.renderTile(context, target, coordinates);
|
||||||
|
rendererDebug.renderTile(context, target, coordinates);
|
||||||
|
|
||||||
if(!context.isVisible(coordinates))
|
if(!context.isVisible(coordinates))
|
||||||
rendererFow.renderTile(context, target, coordinates);
|
rendererFow.renderTile(context, target, coordinates);
|
||||||
}
|
}
|
||||||
rendererDebugGrid.renderTile(context, target, coordinates);
|
|
||||||
}
|
}
|
||||||
|
@ -125,9 +125,14 @@ public:
|
|||||||
void renderTile(const IMapRendererContext & context, Canvas & target, const int3 & coordinates);
|
void renderTile(const IMapRendererContext & context, Canvas & target, const int3 & coordinates);
|
||||||
};
|
};
|
||||||
|
|
||||||
class MapRendererDebugGrid
|
class MapRendererDebug
|
||||||
{
|
{
|
||||||
|
std::shared_ptr<IImage> imageGrid;
|
||||||
|
std::shared_ptr<IImage> imageVisitable;
|
||||||
|
std::shared_ptr<IImage> imageBlockable;
|
||||||
public:
|
public:
|
||||||
|
MapRendererDebug();
|
||||||
|
|
||||||
void renderTile(const IMapRendererContext & context, Canvas & target, const int3 & coordinates);
|
void renderTile(const IMapRendererContext & context, Canvas & target, const int3 & coordinates);
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -140,7 +145,7 @@ class MapRenderer
|
|||||||
MapRendererFow rendererFow;
|
MapRendererFow rendererFow;
|
||||||
MapRendererObjects rendererObjects;
|
MapRendererObjects rendererObjects;
|
||||||
MapRendererPath rendererPath;
|
MapRendererPath rendererPath;
|
||||||
MapRendererDebugGrid rendererDebugGrid;
|
MapRendererDebug rendererDebug;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
void renderTile(const IMapRendererContext & context, Canvas & target, const int3 & coordinates);
|
void renderTile(const IMapRendererContext & context, Canvas & target, const int3 & coordinates);
|
||||||
|
@ -69,6 +69,8 @@ public:
|
|||||||
|
|
||||||
/// if true, map grid should be visible on map
|
/// if true, map grid should be visible on map
|
||||||
virtual bool showGrid() const = 0;
|
virtual bool showGrid() const = 0;
|
||||||
|
virtual bool showVisitable() const = 0;
|
||||||
|
virtual bool showBlockable() const = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
class IMapObjectObserver
|
class IMapObjectObserver
|
||||||
|
@ -190,6 +190,16 @@ bool MapRendererContext::showGrid() const
|
|||||||
return true; // settings["gameTweaks"]["showGrid"].Bool();
|
return true; // settings["gameTweaks"]["showGrid"].Bool();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool MapRendererContext::showVisitable() const
|
||||||
|
{
|
||||||
|
return settings["session"]["showVisitable"].Bool();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool MapRendererContext::showBlockable() const
|
||||||
|
{
|
||||||
|
return settings["session"]["showBlockable"].Bool();
|
||||||
|
}
|
||||||
|
|
||||||
void MapViewController::setViewCenter(const int3 & position)
|
void MapViewController::setViewCenter(const int3 & position)
|
||||||
{
|
{
|
||||||
assert(context->isInMap(position));
|
assert(context->isInMap(position));
|
||||||
|
@ -70,6 +70,8 @@ public:
|
|||||||
size_t terrainImageIndex(size_t groupSize) const override;
|
size_t terrainImageIndex(size_t groupSize) const override;
|
||||||
Point getTileSize() const override;
|
Point getTileSize() const override;
|
||||||
bool showGrid() const override;
|
bool showGrid() const override;
|
||||||
|
bool showVisitable() const override;
|
||||||
|
bool showBlockable() const override;
|
||||||
};
|
};
|
||||||
|
|
||||||
class MapViewModel
|
class MapViewModel
|
||||||
|
Reference in New Issue
Block a user