MapViewController.h 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. /*
  2. * MapViewController.h, part of VCMI engine
  3. *
  4. * Authors: listed in file AUTHORS in main folder
  5. *
  6. * License: GNU General Public License v2.0 or later
  7. * Full text of license available in license.txt file, in main folder
  8. *
  9. */
  10. #pragma once
  11. #include "IMapRendererObserver.h"
  12. VCMI_LIB_NAMESPACE_BEGIN
  13. class Point;
  14. struct ObjectPosInfo;
  15. VCMI_LIB_NAMESPACE_END
  16. class MapViewModel;
  17. class IMapRendererContext;
  18. class MapRendererContext;
  19. /// Class responsible for updating view state,
  20. /// such as its position and any animations
  21. class MapViewController : public IMapObjectObserver
  22. {
  23. std::shared_ptr<MapRendererContext> context;
  24. std::shared_ptr<MapViewModel> model;
  25. private:
  26. // IMapObjectObserver impl
  27. bool hasOngoingAnimations() override;
  28. void onObjectFadeIn(const CGObjectInstance * obj) override;
  29. void onObjectFadeOut(const CGObjectInstance * obj) override;
  30. void onObjectInstantAdd(const CGObjectInstance * obj) override;
  31. void onObjectInstantRemove(const CGObjectInstance * obj) override;
  32. void onHeroTeleported(const CGHeroInstance * obj, const int3 & from, const int3 & dest) override;
  33. void onHeroMoved(const CGHeroInstance * obj, const int3 & from, const int3 & dest) override;
  34. void onHeroRotated(const CGHeroInstance * obj, const int3 & from, const int3 & dest) override;
  35. void moveFocusToSelection();
  36. public:
  37. explicit MapViewController(std::shared_ptr<MapViewModel> model);
  38. std::shared_ptr<IMapRendererContext> getContext() const;
  39. void setViewCenter(const int3 & position);
  40. void setViewCenter(const Point & position, int level);
  41. void setTileSize(const Point & tileSize);
  42. void update(uint32_t timeDelta);
  43. void setTerrainVisibility(bool showAllTerrain);
  44. void setOverlayVisibility(const std::vector<ObjectPosInfo> & objectPositions);
  45. };