CMinimap.h 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  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(SDL_Surface * 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 clickLeft(tribool down, bool previousState) override;
  38. void clickRight(tribool down, bool previousState) override;
  39. void hover (bool on) override;
  40. void mouseMoved (const Point & cursorPosition) override;
  41. /// relocates center of adventure map screen to currently hovered tile
  42. void moveAdvMapSelection();
  43. protected:
  44. /// computes coordinates of tile below cursor pos
  45. int3 pixelToTile(const Point & cursorPos) const;
  46. /// computes position of tile within minimap instance
  47. Point tileToPixels(const int3 & position) const;
  48. public:
  49. explicit CMinimap(const Rect & position);
  50. void onMapViewMoved(const Rect & visibleArea, int mapLevel);
  51. void update();
  52. void setAIRadar(bool on);
  53. void showAll(SDL_Surface * to) override;
  54. void updateTiles(std::unordered_set<int3> positions);
  55. };