CMinimap.h 1.7 KB

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