1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-11-23 22:37:55 +02:00

show invisible

This commit is contained in:
Laserlicht
2025-10-12 16:26:44 +02:00
parent e81d5bc973
commit 5a64fbd89c
8 changed files with 47 additions and 5 deletions

View File

@@ -99,6 +99,7 @@ public:
virtual bool showGrid() const = 0; virtual bool showGrid() const = 0;
virtual bool showVisitable() const = 0; virtual bool showVisitable() const = 0;
virtual bool showBlocked() const = 0; virtual bool showBlocked() const = 0;
virtual bool showInvisible() const = 0;
/// if true, spell range for teleport / scuttle boat will be visible /// if true, spell range for teleport / scuttle boat will be visible
virtual bool showSpellRange(const int3 & position) const = 0; virtual bool showSpellRange(const int3 & position) const = 0;

View File

@@ -14,6 +14,9 @@
#include "IMapRendererContext.h" #include "IMapRendererContext.h"
#include "mapHandler.h" #include "mapHandler.h"
#include "../CServerHandler.h"
#include "../GameInstance.h"
#include "../Client.h"
#include "../GameEngine.h" #include "../GameEngine.h"
#include "../render/CAnimation.h" #include "../render/CAnimation.h"
#include "../render/Canvas.h" #include "../render/Canvas.h"
@@ -23,12 +26,14 @@
#include "../render/Graphics.h" #include "../render/Graphics.h"
#include "../../lib/CConfigHandler.h" #include "../../lib/CConfigHandler.h"
#include "../../lib/gameState/CGameState.h"
#include "../../lib/RiverHandler.h" #include "../../lib/RiverHandler.h"
#include "../../lib/RoadHandler.h" #include "../../lib/RoadHandler.h"
#include "../../lib/TerrainHandler.h" #include "../../lib/TerrainHandler.h"
#include "../../lib/mapObjects/CGHeroInstance.h" #include "../../lib/mapObjects/CGHeroInstance.h"
#include "../../lib/mapObjects/MiscObjects.h" #include "../../lib/mapObjects/MiscObjects.h"
#include "../../lib/mapObjects/ObjectTemplate.h" #include "../../lib/mapObjects/ObjectTemplate.h"
#include "../../lib/mapping/CMap.h"
#include "../../lib/mapping/TerrainTile.h" #include "../../lib/mapping/TerrainTile.h"
#include "../../lib/pathfinder/CGPathNode.h" #include "../../lib/pathfinder/CGPathNode.h"
@@ -592,8 +597,15 @@ MapRendererOverlay::MapRendererOverlay()
, imageBlocked(ENGINE->renderHandler().loadImage(ImagePath::builtin("debug/blocked"), EImageBlitMode::COLORKEY)) , imageBlocked(ENGINE->renderHandler().loadImage(ImagePath::builtin("debug/blocked"), EImageBlitMode::COLORKEY))
, imageVisitable(ENGINE->renderHandler().loadImage(ImagePath::builtin("debug/visitable"), EImageBlitMode::COLORKEY)) , imageVisitable(ENGINE->renderHandler().loadImage(ImagePath::builtin("debug/visitable"), EImageBlitMode::COLORKEY))
, imageSpellRange(ENGINE->renderHandler().loadImage(ImagePath::builtin("debug/spellRange"), 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) void MapRendererOverlay::renderTile(IMapRendererContext & context, Canvas & target, const int3 & coordinates)
@@ -601,7 +613,7 @@ void MapRendererOverlay::renderTile(IMapRendererContext & context, Canvas & targ
if(context.showGrid()) if(context.showGrid())
target.draw(imageGrid, Point(0,0)); target.draw(imageGrid, Point(0,0));
if(context.showVisitable() || context.showBlocked()) if(context.showVisitable() || context.showBlocked() || context.showInvisible())
{ {
bool blocking = false; bool blocking = false;
bool visitable = false; bool visitable = false;
@@ -610,6 +622,12 @@ void MapRendererOverlay::renderTile(IMapRendererContext & context, Canvas & targ
{ {
const auto * object = context.getObject(objectID); 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)) if(context.objectTransparency(objectID, coordinates) > 0 && !context.isActiveHero(object))
{ {
visitable |= object->visitableAt(coordinates); visitable |= object->visitableAt(coordinates);
@@ -643,6 +661,9 @@ uint8_t MapRendererOverlay::checksum(IMapRendererContext & context, const int3 &
if (context.showSpellRange(coordinates)) if (context.showSpellRange(coordinates))
result += 8; result += 8;
if (context.showInvisible())
result += 16;
return result; return result;
} }

View File

@@ -9,11 +9,11 @@
*/ */
#pragma once #pragma once
#include "../../lib/int3.h"
#include "../../lib/filesystem/ResourcePath.h" #include "../../lib/filesystem/ResourcePath.h"
VCMI_LIB_NAMESPACE_BEGIN VCMI_LIB_NAMESPACE_BEGIN
class int3;
class ObjectInstanceID; class ObjectInstanceID;
class CGObjectInstance; class CGObjectInstance;
@@ -139,6 +139,11 @@ class MapRendererOverlay
std::shared_ptr<IImage> imageVisitable; std::shared_ptr<IImage> imageVisitable;
std::shared_ptr<IImage> imageBlocked; std::shared_ptr<IImage> imageBlocked;
std::shared_ptr<IImage> imageSpellRange; std::shared_ptr<IImage> imageSpellRange;
std::shared_ptr<IImage> imageEvent;
std::shared_ptr<IImage> imageGrail;
bool isSinglePlayer;
int3 grailPos;
public: public:
MapRendererOverlay(); MapRendererOverlay();

View File

@@ -232,6 +232,11 @@ bool MapRendererBaseContext::showBlocked() const
return false; return false;
} }
bool MapRendererBaseContext::showInvisible() const
{
return false;
}
bool MapRendererBaseContext::showSpellRange(const int3 & position) const bool MapRendererBaseContext::showSpellRange(const int3 & position) const
{ {
return false; return false;
@@ -362,6 +367,11 @@ bool MapRendererAdventureContext::showBlocked() const
return settingShowBlocked; return settingShowBlocked;
} }
bool MapRendererAdventureContext::showInvisible() const
{
return settingShowInvisible;
}
bool MapRendererAdventureContext::showTextOverlay() const bool MapRendererAdventureContext::showTextOverlay() const
{ {
return settingTextOverlay; return settingTextOverlay;

View File

@@ -62,6 +62,7 @@ public:
bool showGrid() const override; bool showGrid() const override;
bool showVisitable() const override; bool showVisitable() const override;
bool showBlocked() const override; bool showBlocked() const override;
bool showInvisible() const override;
bool showSpellRange(const int3 & position) const override; bool showSpellRange(const int3 & position) const override;
}; };
@@ -72,6 +73,7 @@ public:
bool settingShowGrid = false; bool settingShowGrid = false;
bool settingShowVisitable = false; bool settingShowVisitable = false;
bool settingShowBlocked = false; bool settingShowBlocked = false;
bool settingShowInvisible = false;
bool settingTextOverlay = false; bool settingTextOverlay = false;
bool settingsAdventureObjectAnimation = true; bool settingsAdventureObjectAnimation = true;
bool settingsAdventureTerrainAnimation = true; bool settingsAdventureTerrainAnimation = true;
@@ -88,6 +90,7 @@ public:
bool showGrid() const override; bool showGrid() const override;
bool showVisitable() const override; bool showVisitable() const override;
bool showBlocked() const override; bool showBlocked() const override;
bool showInvisible() const override;
bool showTextOverlay() const override; bool showTextOverlay() const override;
bool showSpellRange(const int3 & position) const override; bool showSpellRange(const int3 & position) const override;

View File

@@ -233,6 +233,7 @@ void MapViewController::updateState()
adventureContext->settingShowGrid = settings["gameTweaks"]["showGrid"].Bool(); adventureContext->settingShowGrid = settings["gameTweaks"]["showGrid"].Bool();
adventureContext->settingShowVisitable = settings["session"]["showVisitable"].Bool(); adventureContext->settingShowVisitable = settings["session"]["showVisitable"].Bool();
adventureContext->settingShowBlocked = settings["session"]["showBlocked"].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(); adventureContext->settingTextOverlay = (ENGINE->isKeyboardAltDown() || ENGINE->input().getNumTouchFingers() == 2) && settings["general"]["enableOverlay"].Bool();
} }
} }

View File

@@ -169,6 +169,7 @@ Below a list of supported commands, with their arguments wrapped in `<>`
- `showGrid` - display a square grid overlay on top of adventure map - `showGrid` - display a square grid overlay on top of adventure map
- `showBlocked` - show blocked tiles on 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 - `hideSystemMessages` - suppress server messages in chat
- `antilag` - toggles network lag compensation in multiplayer on or off - `antilag` - toggles network lag compensation in multiplayer on or off

View File

@@ -66,7 +66,7 @@ void ObjectTemplate::afterLoadFixup()
if(id == Obj::EVENT) if(id == Obj::EVENT)
{ {
setSize(1,1); setSize(1,1);
usedTiles[0][0] = VISITABLE; usedTiles[0][0] = VISITABLE | VISIBLE;
visitDir = 0xFF; visitDir = 0xFF;
} }
} }