CMinimap.h 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. /*
  2. * CMinimap.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. class ColorRGBA;
  14. VCMI_LIB_NAMESPACE_END
  15. class Canvas;
  16. class CMinimap;
  17. class CMinimapInstance : public CIntObject
  18. {
  19. CMinimap * parent;
  20. std::unique_ptr<Canvas> minimap;
  21. int level;
  22. //get color of selected tile on minimap
  23. ColorRGBA getTileColor(const int3 & pos) const;
  24. void redrawMinimap();
  25. public:
  26. CMinimapInstance(CMinimap * parent, int level);
  27. void showAll(Canvas & to) override;
  28. void refreshTile(const int3 & pos);
  29. };
  30. /// Minimap which is displayed at the right upper corner of adventure map
  31. class CMinimap : public CIntObject
  32. {
  33. std::shared_ptr<CPicture> aiShield; //the graphic displayed during AI turn
  34. std::shared_ptr<CMinimapInstance> minimap;
  35. Rect screenArea;
  36. int level;
  37. void gesturePanning(const Point & initialPosition, const Point & currentPosition, const Point & lastUpdateDistance) override;
  38. void clickLeft(tribool down, bool previousState) override;
  39. void clickRight(tribool down, bool previousState) override;
  40. void hover (bool on) override;
  41. void mouseMoved (const Point & cursorPosition) override;
  42. /// relocates center of adventure map screen to currently hovered tile
  43. void moveAdvMapSelection(const Point & positionGlobal);
  44. protected:
  45. /// computes coordinates of tile below cursor pos
  46. int3 pixelToTile(const Point & cursorPos) const;
  47. /// computes position of tile within minimap instance
  48. Point tileToPixels(const int3 & position) const;
  49. public:
  50. explicit CMinimap(const Rect & position);
  51. void onMapViewMoved(const Rect & visibleArea, int mapLevel);
  52. void update();
  53. void setAIRadar(bool on);
  54. void showAll(Canvas & to) override;
  55. void updateTiles(std::unordered_set<int3> positions);
  56. };