MapViewController.h 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  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. public:
  36. explicit MapViewController(std::shared_ptr<MapViewModel> model);
  37. std::shared_ptr<const IMapRendererContext> getContext() const;
  38. void setViewCenter(const int3 & position);
  39. void setViewCenter(const Point & position, int level);
  40. void setTileSize(const Point & tileSize);
  41. void update(uint32_t timeDelta);
  42. void setTerrainVisibility(bool showAllTerrain);
  43. void setOverlayVisibility(const std::vector<ObjectPosInfo> & objectPositions);
  44. };