diff --git a/client/mapView/IMapRendererContext.h b/client/mapView/IMapRendererContext.h index c1ff9bfc6..52ee6af51 100644 --- a/client/mapView/IMapRendererContext.h +++ b/client/mapView/IMapRendererContext.h @@ -99,6 +99,7 @@ public: virtual bool showGrid() const = 0; virtual bool showVisitable() const = 0; virtual bool showBlocked() const = 0; + virtual bool showInvisible() const = 0; /// if true, spell range for teleport / scuttle boat will be visible virtual bool showSpellRange(const int3 & position) const = 0; diff --git a/client/mapView/MapRenderer.cpp b/client/mapView/MapRenderer.cpp index cddaadec7..d85b5ae53 100644 --- a/client/mapView/MapRenderer.cpp +++ b/client/mapView/MapRenderer.cpp @@ -14,6 +14,9 @@ #include "IMapRendererContext.h" #include "mapHandler.h" +#include "../CServerHandler.h" +#include "../GameInstance.h" +#include "../Client.h" #include "../GameEngine.h" #include "../render/CAnimation.h" #include "../render/Canvas.h" @@ -23,12 +26,14 @@ #include "../render/Graphics.h" #include "../../lib/CConfigHandler.h" +#include "../../lib/gameState/CGameState.h" #include "../../lib/RiverHandler.h" #include "../../lib/RoadHandler.h" #include "../../lib/TerrainHandler.h" #include "../../lib/mapObjects/CGHeroInstance.h" #include "../../lib/mapObjects/MiscObjects.h" #include "../../lib/mapObjects/ObjectTemplate.h" +#include "../../lib/mapping/CMap.h" #include "../../lib/mapping/TerrainTile.h" #include "../../lib/pathfinder/CGPathNode.h" @@ -592,8 +597,15 @@ MapRendererOverlay::MapRendererOverlay() , imageBlocked(ENGINE->renderHandler().loadImage(ImagePath::builtin("debug/blocked"), EImageBlitMode::COLORKEY)) , imageVisitable(ENGINE->renderHandler().loadImage(ImagePath::builtin("debug/visitable"), EImageBlitMode::COLORKEY)) , imageSpellRange(ENGINE->renderHandler().loadImage(ImagePath::builtin("debug/spellRange"), EImageBlitMode::COLORKEY)) + , imageEvent(ENGINE->renderHandler().loadAnimation(AnimationPath::builtin("AVZevnt0"), EImageBlitMode::COLORKEY)->getImage(0)) + , imageGrail(ENGINE->renderHandler().loadAnimation(AnimationPath::builtin("AVZgrail"), EImageBlitMode::COLORKEY)->getImage(0)) + , grailPos(GAME->server().client->gameState().getMap().grailPos) { - + int humanPlayer = 0; + for (const auto & pi : GAME->server().client->gameState().getStartInfo()->playerInfos) + if(pi.second.isControlledByHuman()) + humanPlayer++; + isSinglePlayer = humanPlayer < 2; } void MapRendererOverlay::renderTile(IMapRendererContext & context, Canvas & target, const int3 & coordinates) @@ -601,7 +613,7 @@ void MapRendererOverlay::renderTile(IMapRendererContext & context, Canvas & targ if(context.showGrid()) target.draw(imageGrid, Point(0,0)); - if(context.showVisitable() || context.showBlocked()) + if(context.showVisitable() || context.showBlocked() || context.showInvisible()) { bool blocking = false; bool visitable = false; @@ -610,6 +622,12 @@ void MapRendererOverlay::renderTile(IMapRendererContext & context, Canvas & targ { const auto * object = context.getObject(objectID); + if(object->ID == Obj::EVENT && context.showInvisible() && isSinglePlayer) + target.draw(imageEvent, Point(0,0)); + + if(grailPos == coordinates && context.showInvisible() && isSinglePlayer) + target.draw(imageGrail, Point(0,0)); + if(context.objectTransparency(objectID, coordinates) > 0 && !context.isActiveHero(object)) { visitable |= object->visitableAt(coordinates); @@ -643,6 +661,9 @@ uint8_t MapRendererOverlay::checksum(IMapRendererContext & context, const int3 & if (context.showSpellRange(coordinates)) result += 8; + if (context.showInvisible()) + result += 16; + return result; } diff --git a/client/mapView/MapRenderer.h b/client/mapView/MapRenderer.h index e72160a1c..c6e014fc1 100644 --- a/client/mapView/MapRenderer.h +++ b/client/mapView/MapRenderer.h @@ -9,11 +9,11 @@ */ #pragma once +#include "../../lib/int3.h" #include "../../lib/filesystem/ResourcePath.h" VCMI_LIB_NAMESPACE_BEGIN -class int3; class ObjectInstanceID; class CGObjectInstance; @@ -139,6 +139,11 @@ class MapRendererOverlay std::shared_ptr imageVisitable; std::shared_ptr imageBlocked; std::shared_ptr imageSpellRange; + std::shared_ptr imageEvent; + std::shared_ptr imageGrail; + + bool isSinglePlayer; + int3 grailPos; public: MapRendererOverlay(); diff --git a/client/mapView/MapRendererContext.cpp b/client/mapView/MapRendererContext.cpp index 5da7cd5c6..7c248a22d 100644 --- a/client/mapView/MapRendererContext.cpp +++ b/client/mapView/MapRendererContext.cpp @@ -232,6 +232,11 @@ bool MapRendererBaseContext::showBlocked() const return false; } +bool MapRendererBaseContext::showInvisible() const +{ + return false; +} + bool MapRendererBaseContext::showSpellRange(const int3 & position) const { return false; @@ -362,6 +367,11 @@ bool MapRendererAdventureContext::showBlocked() const return settingShowBlocked; } +bool MapRendererAdventureContext::showInvisible() const +{ + return settingShowInvisible; +} + bool MapRendererAdventureContext::showTextOverlay() const { return settingTextOverlay; diff --git a/client/mapView/MapRendererContext.h b/client/mapView/MapRendererContext.h index ece349d22..f9054ad42 100644 --- a/client/mapView/MapRendererContext.h +++ b/client/mapView/MapRendererContext.h @@ -62,6 +62,7 @@ public: bool showGrid() const override; bool showVisitable() const override; bool showBlocked() const override; + bool showInvisible() const override; bool showSpellRange(const int3 & position) const override; }; @@ -72,6 +73,7 @@ public: bool settingShowGrid = false; bool settingShowVisitable = false; bool settingShowBlocked = false; + bool settingShowInvisible = false; bool settingTextOverlay = false; bool settingsAdventureObjectAnimation = true; bool settingsAdventureTerrainAnimation = true; @@ -88,6 +90,7 @@ public: bool showGrid() const override; bool showVisitable() const override; bool showBlocked() const override; + bool showInvisible() const override; bool showTextOverlay() const override; bool showSpellRange(const int3 & position) const override; diff --git a/client/mapView/MapViewController.cpp b/client/mapView/MapViewController.cpp index b0ece0265..c5ac99e09 100644 --- a/client/mapView/MapViewController.cpp +++ b/client/mapView/MapViewController.cpp @@ -233,6 +233,7 @@ void MapViewController::updateState() adventureContext->settingShowGrid = settings["gameTweaks"]["showGrid"].Bool(); adventureContext->settingShowVisitable = settings["session"]["showVisitable"].Bool(); adventureContext->settingShowBlocked = settings["session"]["showBlocked"].Bool(); + adventureContext->settingShowInvisible = settings["session"]["showInvisible"].Bool(); adventureContext->settingTextOverlay = (ENGINE->isKeyboardAltDown() || ENGINE->input().getNumTouchFingers() == 2) && settings["general"]["enableOverlay"].Bool(); } } diff --git a/docs/players/Cheat_Codes.md b/docs/players/Cheat_Codes.md index ba65eae71..5b33792f9 100644 --- a/docs/players/Cheat_Codes.md +++ b/docs/players/Cheat_Codes.md @@ -168,7 +168,8 @@ Below a list of supported commands, with their arguments wrapped in `<>` - `headless` - run without GUI, implies `onlyAI` is set - `showGrid` - display a square grid overlay on top of adventure map - `showBlocked` - show blocked tiles on map -- `showVisitable` - show visitable tiles on map +- `showVisitable` - show visitable tiles on map +- `showInvisible` - show invisible tiles (events, grail) on map (only singleplayer) - `hideSystemMessages` - suppress server messages in chat - `antilag` - toggles network lag compensation in multiplayer on or off diff --git a/lib/mapObjects/ObjectTemplate.cpp b/lib/mapObjects/ObjectTemplate.cpp index a14481420..bf15d1ff3 100644 --- a/lib/mapObjects/ObjectTemplate.cpp +++ b/lib/mapObjects/ObjectTemplate.cpp @@ -66,7 +66,7 @@ void ObjectTemplate::afterLoadFixup() if(id == Obj::EVENT) { setSize(1,1); - usedTiles[0][0] = VISITABLE; + usedTiles[0][0] = VISITABLE | VISIBLE; visitDir = 0xFF; } }