CMinimap.h 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. /*
  2. * AdventureMapClasses.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 "ObjectLists.h"
  12. #include "../../lib/FunctionList.h"
  13. VCMI_LIB_NAMESPACE_BEGIN
  14. class CArmedInstance;
  15. class CGGarrison;
  16. class CGObjectInstance;
  17. class CGHeroInstance;
  18. class CGTownInstance;
  19. struct Component;
  20. struct InfoAboutArmy;
  21. struct InfoAboutHero;
  22. struct InfoAboutTown;
  23. VCMI_LIB_NAMESPACE_END
  24. class CAnimation;
  25. class CAnimImage;
  26. class CShowableAnim;
  27. class CFilledTexture;
  28. class CButton;
  29. class CComponent;
  30. class CHeroTooltip;
  31. class CTownTooltip;
  32. class CTextBox;
  33. class IImage;
  34. class CMinimap;
  35. class CMinimapInstance : public CIntObject
  36. {
  37. CMinimap * parent;
  38. SDL_Surface * minimap;
  39. int level;
  40. //get color of selected tile on minimap
  41. const SDL_Color & getTileColor(const int3 & pos);
  42. void blitTileWithColor(const SDL_Color & color, const int3 & pos, SDL_Surface * to, int x, int y);
  43. //draw minimap already scaled.
  44. //result is not antialiased. Will result in "missing" pixels on huge maps (>144)
  45. void drawScaled(int level);
  46. public:
  47. CMinimapInstance(CMinimap * parent, int level);
  48. ~CMinimapInstance();
  49. void showAll(SDL_Surface * to) override;
  50. void tileToPixels (const int3 & tile, int & x, int & y, int toX = 0, int toY = 0);
  51. void refreshTile(const int3 & pos);
  52. };
  53. /// Minimap which is displayed at the right upper corner of adventure map
  54. class CMinimap : public CIntObject
  55. {
  56. protected:
  57. std::shared_ptr<CPicture> aiShield; //the graphic displayed during AI turn
  58. std::shared_ptr<CMinimapInstance> minimap;
  59. int level;
  60. //to initialize colors
  61. std::map<TerrainId, std::pair<SDL_Color, SDL_Color> > loadColors();
  62. void clickLeft(tribool down, bool previousState) override;
  63. void clickRight(tribool down, bool previousState) override;
  64. void hover (bool on) override;
  65. void mouseMoved (const SDL_MouseMotionEvent & sEvent) override;
  66. void moveAdvMapSelection();
  67. public:
  68. // terrainID -> (normal color, blocked color)
  69. const std::map<TerrainId, std::pair<SDL_Color, SDL_Color> > colors;
  70. CMinimap(const Rect & position);
  71. //should be called to invalidate whole map - different player or level
  72. int3 translateMousePosition();
  73. void update();
  74. void setLevel(int level);
  75. void setAIRadar(bool on);
  76. void showAll(SDL_Surface * to) override;
  77. void hideTile(const int3 &pos); //puts FoW
  78. void showTile(const int3 &pos); //removes FoW
  79. };