CMinimap.h 2.1 KB

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