2023-02-14 23:49:12 +02:00
|
|
|
/*
|
2023-02-20 22:16:50 +02:00
|
|
|
* MapRendererContext.h, part of VCMI engine
|
2023-02-14 23:49:12 +02:00
|
|
|
*
|
|
|
|
* Authors: listed in file AUTHORS in main folder
|
|
|
|
*
|
|
|
|
* License: GNU General Public License v2.0 or later
|
|
|
|
* Full text of license available in license.txt file, in main folder
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
|
2023-02-20 22:16:50 +02:00
|
|
|
#include "IMapRendererContext.h"
|
2023-02-14 23:49:12 +02:00
|
|
|
|
2023-02-20 22:16:50 +02:00
|
|
|
#include "../lib/GameConstants.h"
|
2023-02-26 18:17:53 +02:00
|
|
|
#include "../lib/int3.h"
|
2023-02-14 23:49:12 +02:00
|
|
|
|
2023-02-21 14:38:08 +02:00
|
|
|
VCMI_LIB_NAMESPACE_BEGIN
|
|
|
|
struct ObjectPosInfo;
|
|
|
|
VCMI_LIB_NAMESPACE_END
|
|
|
|
|
2023-02-26 18:17:53 +02:00
|
|
|
struct MapRendererContextState;
|
|
|
|
|
|
|
|
class MapRendererBaseContext : public IMapRendererContext
|
2023-02-14 23:49:12 +02:00
|
|
|
{
|
2023-02-26 18:17:53 +02:00
|
|
|
public:
|
|
|
|
const MapRendererContextState & viewState;
|
|
|
|
bool settingsSessionSpectate = false;
|
|
|
|
|
|
|
|
explicit MapRendererBaseContext(const MapRendererContextState & viewState);
|
|
|
|
|
|
|
|
uint32_t getObjectRotation(ObjectInstanceID objectID) const;
|
2023-02-18 17:37:09 +02:00
|
|
|
|
2023-02-26 18:17:53 +02:00
|
|
|
int3 getMapSize() const override;
|
|
|
|
bool isInMap(const int3 & coordinates) const override;
|
|
|
|
bool isVisible(const int3 & coordinates) const override;
|
|
|
|
bool tileAnimated(const int3 & coordinates) const override;
|
|
|
|
|
2023-03-08 22:43:52 +02:00
|
|
|
bool isActiveHero(const CGObjectInstance* obj) const override;
|
|
|
|
|
2023-02-26 18:17:53 +02:00
|
|
|
const TerrainTile & getMapTile(const int3 & coordinates) const override;
|
|
|
|
const MapObjectsList & getObjects(const int3 & coordinates) const override;
|
|
|
|
const CGObjectInstance * getObject(ObjectInstanceID objectID) const override;
|
|
|
|
const CGPath * currentPath() const override;
|
|
|
|
|
|
|
|
size_t objectGroupIndex(ObjectInstanceID objectID) const override;
|
|
|
|
Point objectImageOffset(ObjectInstanceID objectID, const int3 & coordinates) const override;
|
|
|
|
double objectTransparency(ObjectInstanceID objectID, const int3 & coordinates) const override;
|
|
|
|
size_t objectImageIndex(ObjectInstanceID objectID, size_t groupSize) const override;
|
|
|
|
size_t terrainImageIndex(size_t groupSize) const override;
|
|
|
|
size_t overlayImageIndex(const int3 & coordinates) const override;
|
|
|
|
|
2023-03-01 19:25:51 +02:00
|
|
|
double viewTransitionProgress() const override;
|
2023-02-26 18:17:53 +02:00
|
|
|
bool filterGrayscale() const override;
|
|
|
|
bool showRoads() const override;
|
|
|
|
bool showRivers() const override;
|
|
|
|
bool showBorder() const override;
|
|
|
|
bool showOverlay() const override;
|
|
|
|
bool showGrid() const override;
|
|
|
|
bool showVisitable() const override;
|
2023-03-08 01:19:26 +02:00
|
|
|
bool showBlocked() const override;
|
2023-02-26 18:17:53 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
class MapRendererAdventureContext : public MapRendererBaseContext
|
|
|
|
{
|
2023-02-20 22:16:50 +02:00
|
|
|
public:
|
2023-02-26 18:17:53 +02:00
|
|
|
uint32_t animationTime = 0;
|
|
|
|
bool settingShowGrid = false;
|
|
|
|
bool settingShowVisitable = false;
|
2023-03-08 01:19:26 +02:00
|
|
|
bool settingShowBlocked = false;
|
2023-02-26 18:17:53 +02:00
|
|
|
bool settingsAdventureObjectAnimation = true;
|
|
|
|
bool settingsAdventureTerrainAnimation = true;
|
|
|
|
|
|
|
|
explicit MapRendererAdventureContext(const MapRendererContextState & viewState);
|
|
|
|
|
|
|
|
const CGPath * currentPath() const override;
|
|
|
|
size_t objectImageIndex(ObjectInstanceID objectID, size_t groupSize) const override;
|
|
|
|
size_t terrainImageIndex(size_t groupSize) const override;
|
2023-02-20 19:56:35 +02:00
|
|
|
|
2023-02-26 18:17:53 +02:00
|
|
|
bool showBorder() const override;
|
|
|
|
bool showGrid() const override;
|
|
|
|
bool showVisitable() const override;
|
2023-03-08 01:19:26 +02:00
|
|
|
bool showBlocked() const override;
|
2023-02-14 23:49:12 +02:00
|
|
|
};
|
2023-02-16 21:35:15 +02:00
|
|
|
|
2023-03-01 19:25:51 +02:00
|
|
|
class MapRendererAdventureTransitionContext : public MapRendererAdventureContext
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
double progress = 0;
|
|
|
|
|
|
|
|
explicit MapRendererAdventureTransitionContext(const MapRendererContextState & viewState);
|
|
|
|
|
|
|
|
double viewTransitionProgress() const override;
|
|
|
|
};
|
|
|
|
|
2023-02-26 18:17:53 +02:00
|
|
|
class MapRendererAdventureFadingContext : public MapRendererAdventureContext
|
2023-02-16 21:35:15 +02:00
|
|
|
{
|
2023-02-26 18:17:53 +02:00
|
|
|
public:
|
2023-02-20 22:16:50 +02:00
|
|
|
ObjectInstanceID target;
|
|
|
|
double progress;
|
2023-02-26 18:17:53 +02:00
|
|
|
|
|
|
|
explicit MapRendererAdventureFadingContext(const MapRendererContextState & viewState);
|
|
|
|
|
|
|
|
bool tileAnimated(const int3 & coordinates) const override;
|
|
|
|
double objectTransparency(ObjectInstanceID objectID, const int3 & coordinates) const override;
|
2023-02-20 22:16:50 +02:00
|
|
|
};
|
2023-02-16 21:35:15 +02:00
|
|
|
|
2023-02-26 18:17:53 +02:00
|
|
|
class MapRendererAdventureMovingContext : public MapRendererAdventureContext
|
2023-02-20 22:16:50 +02:00
|
|
|
{
|
2023-02-26 18:17:53 +02:00
|
|
|
public:
|
2023-02-20 22:16:50 +02:00
|
|
|
ObjectInstanceID target;
|
2023-02-26 18:17:53 +02:00
|
|
|
int3 tileFrom;
|
|
|
|
int3 tileDest;
|
2023-02-20 22:16:50 +02:00
|
|
|
double progress;
|
2023-02-18 17:37:09 +02:00
|
|
|
|
2023-02-26 18:17:53 +02:00
|
|
|
explicit MapRendererAdventureMovingContext(const MapRendererContextState & viewState);
|
|
|
|
|
|
|
|
bool tileAnimated(const int3 & coordinates) const override;
|
|
|
|
size_t objectGroupIndex(ObjectInstanceID objectID) const override;
|
|
|
|
Point objectImageOffset(ObjectInstanceID objectID, const int3 & coordinates) const override;
|
|
|
|
size_t objectImageIndex(ObjectInstanceID objectID, size_t groupSize) const override;
|
2023-02-21 14:38:08 +02:00
|
|
|
};
|
|
|
|
|
2023-02-26 18:17:53 +02:00
|
|
|
class MapRendererWorldViewContext : public MapRendererBaseContext
|
2023-02-20 22:16:50 +02:00
|
|
|
{
|
2023-02-26 18:17:53 +02:00
|
|
|
protected:
|
|
|
|
size_t selectOverlayImageForObject(const ObjectPosInfo & object) const;
|
2023-02-16 21:35:15 +02:00
|
|
|
|
2023-02-26 18:17:53 +02:00
|
|
|
public:
|
|
|
|
explicit MapRendererWorldViewContext(const MapRendererContextState & viewState);
|
2023-02-16 21:35:15 +02:00
|
|
|
|
2023-02-26 18:17:53 +02:00
|
|
|
size_t overlayImageIndex(const int3 & coordinates) const override;
|
|
|
|
bool showOverlay() const override;
|
|
|
|
};
|
2023-02-16 21:35:15 +02:00
|
|
|
|
2023-02-26 18:17:53 +02:00
|
|
|
class MapRendererSpellViewContext : public MapRendererWorldViewContext
|
|
|
|
{
|
|
|
|
public:
|
2023-02-21 14:38:08 +02:00
|
|
|
std::vector<ObjectPosInfo> additionalOverlayIcons;
|
|
|
|
bool showAllTerrain = false;
|
|
|
|
|
2023-02-26 18:17:53 +02:00
|
|
|
explicit MapRendererSpellViewContext(const MapRendererContextState & viewState);
|
2023-02-16 21:35:15 +02:00
|
|
|
|
2023-02-20 22:16:50 +02:00
|
|
|
bool isVisible(const int3 & coordinates) const override;
|
2023-02-26 18:17:53 +02:00
|
|
|
double objectTransparency(ObjectInstanceID objectID, const int3 & coordinates) const override;
|
|
|
|
size_t overlayImageIndex(const int3 & coordinates) const override;
|
|
|
|
};
|
2023-02-20 22:16:50 +02:00
|
|
|
|
2023-02-26 18:17:53 +02:00
|
|
|
class MapRendererPuzzleMapContext : public MapRendererBaseContext
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
std::unique_ptr<CGPath> grailPos;
|
2023-02-20 22:16:50 +02:00
|
|
|
|
2023-02-26 18:17:53 +02:00
|
|
|
explicit MapRendererPuzzleMapContext(const MapRendererContextState & viewState);
|
|
|
|
~MapRendererPuzzleMapContext();
|
2023-02-20 22:16:50 +02:00
|
|
|
|
2023-02-26 18:17:53 +02:00
|
|
|
const CGPath * currentPath() const override;
|
|
|
|
double objectTransparency(ObjectInstanceID objectID, const int3 & coordinates) const override;
|
|
|
|
bool isVisible(const int3 & coordinates) const override;
|
2023-02-22 17:25:10 +02:00
|
|
|
bool filterGrayscale() const override;
|
2023-02-23 19:46:41 +02:00
|
|
|
bool showRoads() const override;
|
|
|
|
bool showRivers() const override;
|
2023-02-16 21:35:15 +02:00
|
|
|
};
|