mirror of
https://github.com/vcmi/vcmi.git
synced 2025-03-29 21:56:54 +02:00
Added debug rendering
This commit is contained in:
parent
685cc91029
commit
16e7f860ff
Mods/vcmi/Data/debug
client/adventureMap
BIN
Mods/vcmi/Data/debug/blocked.png
Normal file
BIN
Mods/vcmi/Data/debug/blocked.png
Normal file
Binary file not shown.
After ![]() (image error) 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 ![]() (image error) 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 ![]() (image error) 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())
|
||||
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});
|
||||
target.drawLine(Point(0, 0), Point(31, 0), {128, 128, 128, 128}, {128, 128, 128, 128});
|
||||
bool blockable = false;
|
||||
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);
|
||||
rendererObjects.renderTile(context, target, coordinates);
|
||||
rendererPath.renderTile(context, target, coordinates);
|
||||
rendererDebug.renderTile(context, target, coordinates);
|
||||
|
||||
if(!context.isVisible(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);
|
||||
};
|
||||
|
||||
class MapRendererDebugGrid
|
||||
class MapRendererDebug
|
||||
{
|
||||
std::shared_ptr<IImage> imageGrid;
|
||||
std::shared_ptr<IImage> imageVisitable;
|
||||
std::shared_ptr<IImage> imageBlockable;
|
||||
public:
|
||||
MapRendererDebug();
|
||||
|
||||
void renderTile(const IMapRendererContext & context, Canvas & target, const int3 & coordinates);
|
||||
};
|
||||
|
||||
@ -140,7 +145,7 @@ class MapRenderer
|
||||
MapRendererFow rendererFow;
|
||||
MapRendererObjects rendererObjects;
|
||||
MapRendererPath rendererPath;
|
||||
MapRendererDebugGrid rendererDebugGrid;
|
||||
MapRendererDebug rendererDebug;
|
||||
|
||||
public:
|
||||
void renderTile(const IMapRendererContext & context, Canvas & target, const int3 & coordinates);
|
||||
|
@ -69,6 +69,8 @@ public:
|
||||
|
||||
/// if true, map grid should be visible on map
|
||||
virtual bool showGrid() const = 0;
|
||||
virtual bool showVisitable() const = 0;
|
||||
virtual bool showBlockable() const = 0;
|
||||
};
|
||||
|
||||
class IMapObjectObserver
|
||||
|
@ -190,6 +190,16 @@ bool MapRendererContext::showGrid() const
|
||||
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)
|
||||
{
|
||||
assert(context->isInMap(position));
|
||||
|
@ -70,6 +70,8 @@ public:
|
||||
size_t terrainImageIndex(size_t groupSize) const override;
|
||||
Point getTileSize() const override;
|
||||
bool showGrid() const override;
|
||||
bool showVisitable() const override;
|
||||
bool showBlockable() const override;
|
||||
};
|
||||
|
||||
class MapViewModel
|
||||
|
Loading…
x
Reference in New Issue
Block a user