MapView.h 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  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. /// Main class that represents visible section of adventure map
  21. /// Contains all public interface of view and translates calls to internal model
  22. class MapView : public CIntObject
  23. {
  24. std::shared_ptr<MapViewModel> model;
  25. std::shared_ptr<MapViewCache> tilesCache;
  26. std::shared_ptr<MapViewController> controller;
  27. std::shared_ptr<MapViewActions> actions;
  28. bool isSwiping;
  29. std::shared_ptr<MapViewModel> createModel(const Point & dimensions) const;
  30. void render(Canvas & target, bool fullUpdate);
  31. public:
  32. MapView(const Point & offset, const Point & dimensions);
  33. ~MapView() override;
  34. /// Moves current view to another level, preserving position
  35. void onMapLevelSwitched();
  36. /// Moves current view by specified distance in pixels
  37. void onMapScrolled(const Point & distance);
  38. /// Moves current view to specified position, in pixels
  39. void onMapSwiped(const Point & viewPosition);
  40. /// Ends swiping mode and allows normal map scrolling once again
  41. void onMapSwipeEnded();
  42. /// Moves current view to specified tile
  43. void onCenteredTile(const int3 & tile);
  44. /// Centers view on object and starts "tracking" it
  45. /// Whenever object changes position, so will the object
  46. /// Tracking will be disabled on any call that moves view
  47. void onCenteredObject(const CGObjectInstance * target);
  48. /// Switches view to "View Earth" / "View Air" mode, displaying downscaled map with overlay
  49. void onViewSpellActivated( uint32_t tileSize, const std::vector<ObjectPosInfo>& objectPositions, bool showTerrain);
  50. /// Switches view to downscaled View World
  51. void onViewWorldActivated( uint32_t tileSize);
  52. /// Switches view from View World mode back to standard view
  53. void onViewMapActivated();
  54. void show(SDL_Surface * to) override;
  55. void showAll(SDL_Surface * to) override;
  56. };