2023-02-20 22:16:50 +02:00
|
|
|
/*
|
|
|
|
* MapViewController.h, part of VCMI engine
|
|
|
|
*
|
|
|
|
* 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
|
|
|
|
|
|
|
|
#include "IMapRendererObserver.h"
|
|
|
|
|
|
|
|
VCMI_LIB_NAMESPACE_BEGIN
|
|
|
|
class Point;
|
2023-02-21 14:38:08 +02:00
|
|
|
struct ObjectPosInfo;
|
2023-02-20 22:16:50 +02:00
|
|
|
VCMI_LIB_NAMESPACE_END
|
2023-02-21 14:38:08 +02:00
|
|
|
|
2023-02-26 18:17:53 +02:00
|
|
|
struct MapRendererContextState;
|
|
|
|
|
|
|
|
class MapViewCache;
|
2023-02-20 22:16:50 +02:00
|
|
|
class MapViewModel;
|
2023-02-21 19:21:50 +02:00
|
|
|
class IMapRendererContext;
|
2023-02-26 18:17:53 +02:00
|
|
|
class MapRendererAdventureContext;
|
|
|
|
class MapRendererAdventureFadingContext;
|
|
|
|
class MapRendererAdventureMovingContext;
|
2023-03-01 19:25:51 +02:00
|
|
|
class MapRendererAdventureTransitionContext;
|
2023-02-26 18:17:53 +02:00
|
|
|
class MapRendererWorldViewContext;
|
|
|
|
class MapRendererSpellViewContext;
|
|
|
|
class MapRendererPuzzleMapContext;
|
2023-02-20 22:16:50 +02:00
|
|
|
|
|
|
|
/// Class responsible for updating view state,
|
|
|
|
/// such as its position and any animations
|
|
|
|
class MapViewController : public IMapObjectObserver
|
|
|
|
{
|
2023-02-26 18:17:53 +02:00
|
|
|
std::shared_ptr<IMapRendererContext> context;
|
|
|
|
std::shared_ptr<MapRendererContextState> state;
|
2023-02-20 22:16:50 +02:00
|
|
|
std::shared_ptr<MapViewModel> model;
|
2023-02-26 18:17:53 +02:00
|
|
|
std::shared_ptr<MapViewCache> view;
|
|
|
|
|
|
|
|
// all potential contexts for view
|
|
|
|
// only some are present at any given moment, rest are nullptr's
|
|
|
|
std::shared_ptr<MapRendererAdventureContext> adventureContext;
|
|
|
|
std::shared_ptr<MapRendererAdventureMovingContext> movementContext;
|
2023-03-01 19:25:51 +02:00
|
|
|
std::shared_ptr<MapRendererAdventureTransitionContext> teleportContext;
|
2023-02-26 18:17:53 +02:00
|
|
|
std::shared_ptr<MapRendererAdventureFadingContext> fadingOutContext;
|
|
|
|
std::shared_ptr<MapRendererAdventureFadingContext> fadingInContext;
|
|
|
|
std::shared_ptr<MapRendererWorldViewContext> worldViewContext;
|
|
|
|
std::shared_ptr<MapRendererSpellViewContext> spellViewContext;
|
|
|
|
std::shared_ptr<MapRendererPuzzleMapContext> puzzleMapContext;
|
2023-02-20 22:16:50 +02:00
|
|
|
|
|
|
|
private:
|
2023-02-26 18:17:53 +02:00
|
|
|
bool isEventVisible(const CGObjectInstance * obj);
|
|
|
|
bool isEventVisible(const CGHeroInstance * obj, const int3 & from, const int3 & dest);
|
|
|
|
|
|
|
|
void fadeOutObject(const CGObjectInstance * obj);
|
|
|
|
void fadeInObject(const CGObjectInstance * obj);
|
|
|
|
|
|
|
|
void removeObject(const CGObjectInstance * obj);
|
|
|
|
void addObject(const CGObjectInstance * obj);
|
|
|
|
|
2023-02-20 22:16:50 +02:00
|
|
|
// IMapObjectObserver impl
|
|
|
|
bool hasOngoingAnimations() override;
|
|
|
|
void onObjectFadeIn(const CGObjectInstance * obj) override;
|
|
|
|
void onObjectFadeOut(const CGObjectInstance * obj) override;
|
|
|
|
void onObjectInstantAdd(const CGObjectInstance * obj) override;
|
|
|
|
void onObjectInstantRemove(const CGObjectInstance * obj) override;
|
2023-02-26 18:17:53 +02:00
|
|
|
void onAfterHeroTeleported(const CGHeroInstance * obj, const int3 & from, const int3 & dest) override;
|
|
|
|
void onBeforeHeroTeleported(const CGHeroInstance * obj, const int3 & from, const int3 & dest) override;
|
2023-02-20 22:16:50 +02:00
|
|
|
void onHeroMoved(const CGHeroInstance * obj, const int3 & from, const int3 & dest) override;
|
2023-02-26 18:17:53 +02:00
|
|
|
void onBeforeHeroEmbark(const CGHeroInstance * obj, const int3 & from, const int3 & dest) override;
|
|
|
|
void onAfterHeroEmbark(const CGHeroInstance * obj, const int3 & from, const int3 & dest) override;
|
|
|
|
void onBeforeHeroDisembark(const CGHeroInstance * obj, const int3 & from, const int3 & dest) override;
|
|
|
|
void onAfterHeroDisembark(const CGHeroInstance * obj, const int3 & from, const int3 & dest) override;
|
|
|
|
|
|
|
|
void resetContext();
|
2023-02-20 22:16:50 +02:00
|
|
|
|
|
|
|
public:
|
2023-02-26 18:17:53 +02:00
|
|
|
MapViewController(std::shared_ptr<MapViewModel> model, std::shared_ptr<MapViewCache> view);
|
2023-02-21 19:21:50 +02:00
|
|
|
|
2023-02-23 19:46:41 +02:00
|
|
|
std::shared_ptr<IMapRendererContext> getContext() const;
|
2023-02-20 22:16:50 +02:00
|
|
|
|
|
|
|
void setViewCenter(const int3 & position);
|
|
|
|
void setViewCenter(const Point & position, int level);
|
|
|
|
void setTileSize(const Point & tileSize);
|
|
|
|
void update(uint32_t timeDelta);
|
2023-02-21 14:38:08 +02:00
|
|
|
|
2023-02-26 18:17:53 +02:00
|
|
|
void activateAdventureContext(uint32_t animationTime);
|
|
|
|
void activateAdventureContext();
|
|
|
|
void activateWorldViewContext();
|
|
|
|
void activateSpellViewContext();
|
|
|
|
void activatePuzzleMapContext(const int3 & grailPosition);
|
|
|
|
|
2023-02-21 14:38:08 +02:00
|
|
|
void setTerrainVisibility(bool showAllTerrain);
|
|
|
|
void setOverlayVisibility(const std::vector<ObjectPosInfo> & objectPositions);
|
2023-02-20 22:16:50 +02:00
|
|
|
};
|