CAdvMapPanel.h 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. /*
  2. * CAdvMapPanel.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 PlayerColor;
  14. VCMI_LIB_NAMESPACE_END
  15. class CAnimation;
  16. class CAnimImage;
  17. class CFilledTexture;
  18. class CButton;
  19. class IImage;
  20. /// simple panel that contains other displayable elements; used to separate groups of controls
  21. class CAdvMapPanel : public CIntObject
  22. {
  23. std::vector<std::shared_ptr<CButton>> colorableButtons;
  24. std::vector<std::shared_ptr<CIntObject>> otherObjects;
  25. /// the surface passed to this obj will be freed in dtor
  26. std::shared_ptr<IImage> background;
  27. public:
  28. CAdvMapPanel(std::shared_ptr<IImage> bg, Point position);
  29. void addChildToPanel(std::shared_ptr<CIntObject> obj, ui8 actions = 0);
  30. void addChildColorableButton(std::shared_ptr<CButton> button);
  31. /// recolors all buttons to given player color
  32. void setPlayerColor(const PlayerColor & clr);
  33. void showAll(SDL_Surface * to) override;
  34. };
  35. /// specialized version of CAdvMapPanel that handles recolorable def-based pictures for world view info panel
  36. class CAdvMapWorldViewPanel : public CAdvMapPanel
  37. {
  38. /// data that allows reconstruction of panel info icons
  39. std::vector<std::pair<int, Point>> iconsData;
  40. /// ptrs to child-pictures constructed from iconsData
  41. std::vector<std::shared_ptr<CAnimImage>> currentIcons;
  42. /// surface drawn below world view panel on higher resolutions (won't be needed when world view panel is configured for extraResolutions mod)
  43. std::shared_ptr<CFilledTexture> backgroundFiller;
  44. std::shared_ptr<CAnimation> icons;
  45. public:
  46. CAdvMapWorldViewPanel(std::shared_ptr<CAnimation> _icons, std::shared_ptr<IImage> bg, Point position, int spaceBottom, const PlayerColor &color);
  47. void addChildIcon(std::pair<int, Point> data, int indexOffset);
  48. /// recreates all pictures from given def to recolor them according to current player color
  49. void recolorIcons(const PlayerColor & color, int indexOffset);
  50. };