MapView.h 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. /*
  2. * MapView.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 "../gui/CIntObject.h"
  12. VCMI_LIB_NAMESPACE_BEGIN
  13. struct ObjectPosInfo;
  14. VCMI_LIB_NAMESPACE_END
  15. class Canvas;
  16. class MapViewActions;
  17. class MapViewController;
  18. class MapViewModel;
  19. class MapViewCache;
  20. /// Internal class that contains logic shared between all map views
  21. class BasicMapView : public CIntObject
  22. {
  23. protected:
  24. std::shared_ptr<MapViewModel> model;
  25. std::shared_ptr<MapViewCache> tilesCache;
  26. std::shared_ptr<MapViewController> controller;
  27. std::shared_ptr<MapViewModel> createModel(const Point & dimensions) const;
  28. void render(Canvas & target, bool fullUpdate);
  29. public:
  30. BasicMapView(const Point & offset, const Point & dimensions);
  31. ~BasicMapView() override;
  32. void tick(uint32_t msPassed) override;
  33. void show(SDL_Surface * to) override;
  34. void showAll(SDL_Surface * to) override;
  35. };
  36. /// Main class that represents visible section of adventure map
  37. /// Contains all public interface of view and translates calls to internal model
  38. class MapView : public BasicMapView
  39. {
  40. std::shared_ptr<MapViewActions> actions;
  41. bool isSwiping;
  42. public:
  43. void show(SDL_Surface * to) override;
  44. MapView(const Point & offset, const Point & dimensions);
  45. /// Moves current view to another level, preserving position
  46. void onMapLevelSwitched();
  47. /// Moves current view by specified distance in pixels
  48. void onMapScrolled(const Point & distance);
  49. /// Moves current view to specified position, in pixels
  50. void onMapSwiped(const Point & viewPosition);
  51. /// Ends swiping mode and allows normal map scrolling once again
  52. void onMapSwipeEnded();
  53. /// Moves current view to specified tile
  54. void onCenteredTile(const int3 & tile);
  55. /// Moves current view to specified object
  56. void onCenteredObject(const CGObjectInstance * target);
  57. /// Switches view to "View Earth" / "View Air" mode, displaying downscaled map with overlay
  58. void onViewSpellActivated(uint32_t tileSize, const std::vector<ObjectPosInfo> & objectPositions, bool showTerrain);
  59. /// Switches view to downscaled View World
  60. void onViewWorldActivated(uint32_t tileSize);
  61. /// Switches view from View World mode back to standard view
  62. void onViewMapActivated();
  63. };
  64. /// Main class that represents map view for puzzle map
  65. class PuzzleMapView : public BasicMapView
  66. {
  67. public:
  68. PuzzleMapView(const Point & offset, const Point & dimensions, const int3 & tileToCenter);
  69. };