Ver Fonte

show invisible

Laserlicht há 2 semanas atrás
pai
commit
5a64fbd89c

+ 1 - 0
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;

+ 23 - 2
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;
 }
 

+ 6 - 1
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<IImage> imageVisitable;
 	std::shared_ptr<IImage> imageBlocked;
 	std::shared_ptr<IImage> imageSpellRange;
+	std::shared_ptr<IImage> imageEvent;
+	std::shared_ptr<IImage> imageGrail;
+
+	bool isSinglePlayer;
+	int3 grailPos;
 public:
 	MapRendererOverlay();
 

+ 10 - 0
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;

+ 3 - 0
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;

+ 1 - 0
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();
 	}
 }

+ 2 - 1
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
 

+ 1 - 1
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;
 	}
 }