From 16e7f860ffab9e85c5aa474672128a5ff2219770 Mon Sep 17 00:00:00 2001 From: Ivan Savenko Date: Sun, 19 Feb 2023 23:42:45 +0200 Subject: [PATCH] Added debug rendering --- Mods/vcmi/Data/debug/blocked.png | Bin 0 -> 111 bytes Mods/vcmi/Data/debug/grid.png | Bin 0 -> 102 bytes Mods/vcmi/Data/debug/visitable.png | Bin 0 -> 112 bytes client/adventureMap/MapRenderer.cpp | 36 ++++++++++++++++++++--- client/adventureMap/MapRenderer.h | 9 ++++-- client/adventureMap/MapRendererContext.h | 2 ++ client/adventureMap/MapView.cpp | 10 +++++++ client/adventureMap/MapView.h | 2 ++ 8 files changed, 53 insertions(+), 6 deletions(-) create mode 100644 Mods/vcmi/Data/debug/blocked.png create mode 100644 Mods/vcmi/Data/debug/grid.png create mode 100644 Mods/vcmi/Data/debug/visitable.png diff --git a/Mods/vcmi/Data/debug/blocked.png b/Mods/vcmi/Data/debug/blocked.png new file mode 100644 index 0000000000000000000000000000000000000000..640b5cffcf15e2cc15b13f372b4d985aa08e1a49 GIT binary patch literal 111 zcmeAS@N?(olHy`uVBq!ia0vp^3LwnE1|*BCs=fdzGfx-CkP61P=M)7Q40u=$iiiK7 y7Bs`6V$*{(zC1O}ZN_W$9*8ml6(T@{!)ks;vtSGTM{^&6L_J;oT-G@yGywo&)*AN! literal 0 HcmV?d00001 diff --git a/Mods/vcmi/Data/debug/grid.png b/Mods/vcmi/Data/debug/grid.png new file mode 100644 index 0000000000000000000000000000000000000000..72de533b6fe27f8907c38e3e81ff7bb2358df243 GIT binary patch literal 102 zcmeAS@N?(olHy`uVBq!ia0vp^3LwnE1|*BCs=fdzT~8OskP61P=M)(k7&s1Wa9?hD owcYk$tKmiXJ-dvfLv6}gHE>I(br>mdKI;Vst037iiVgLXD literal 0 HcmV?d00001 diff --git a/Mods/vcmi/Data/debug/visitable.png b/Mods/vcmi/Data/debug/visitable.png new file mode 100644 index 0000000000000000000000000000000000000000..3182015e876519164cb6fc85aaf60d06d5128cfa GIT binary patch literal 112 zcmeAS@N?(olHy`uVBq!ia0vp^3LwnE1|*BCs=fdzb59q?kP61P=NefV3 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); + } diff --git a/client/adventureMap/MapRenderer.h b/client/adventureMap/MapRenderer.h index c2acb6280..40f640b8b 100644 --- a/client/adventureMap/MapRenderer.h +++ b/client/adventureMap/MapRenderer.h @@ -125,9 +125,14 @@ public: void renderTile(const IMapRendererContext & context, Canvas & target, const int3 & coordinates); }; -class MapRendererDebugGrid +class MapRendererDebug { + std::shared_ptr imageGrid; + std::shared_ptr imageVisitable; + std::shared_ptr 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); diff --git a/client/adventureMap/MapRendererContext.h b/client/adventureMap/MapRendererContext.h index 36d1e08b9..32554a177 100644 --- a/client/adventureMap/MapRendererContext.h +++ b/client/adventureMap/MapRendererContext.h @@ -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 diff --git a/client/adventureMap/MapView.cpp b/client/adventureMap/MapView.cpp index 0a1e56c3e..8885e8b44 100644 --- a/client/adventureMap/MapView.cpp +++ b/client/adventureMap/MapView.cpp @@ -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)); diff --git a/client/adventureMap/MapView.h b/client/adventureMap/MapView.h index bf29f8b72..37c3992b8 100644 --- a/client/adventureMap/MapView.h +++ b/client/adventureMap/MapView.h @@ -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