CArtPlace.h 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. /*
  2. * CArtPlace.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 "MiscWidgets.h"
  12. class CAnimImage;
  13. class CArtPlace : public SelectableSlot
  14. {
  15. public:
  16. using ClickFunctor = std::function<void(CArtPlace&, const Point&)>;
  17. ArtifactPosition slot;
  18. CArtPlace(Point position, const CArtifactInstance * art = nullptr);
  19. const CArtifactInstance * getArt();
  20. void lockSlot(bool on);
  21. bool isLocked() const;
  22. void setArtifact(const CArtifactInstance * art);
  23. void setClickPressedCallback(ClickFunctor callback);
  24. void setShowPopupCallback(ClickFunctor callback);
  25. void setGestureCallback(ClickFunctor callback);
  26. void clickPressed(const Point & cursorPosition) override;
  27. void showPopupWindow(const Point & cursorPosition) override;
  28. void gesture(bool on, const Point & initialPosition, const Point & finalPosition) override;
  29. protected:
  30. std::shared_ptr<CAnimImage> image;
  31. const CArtifactInstance * ourArt;
  32. int imageIndex;
  33. bool locked;
  34. ClickFunctor clickPressedCallback;
  35. ClickFunctor showPopupCallback;
  36. ClickFunctor gestureCallback;
  37. void setInternals(const CArtifactInstance * artInst);
  38. };
  39. class CCommanderArtPlace : public CArtPlace
  40. {
  41. protected:
  42. const CGHeroInstance * commanderOwner;
  43. ArtifactPosition commanderSlotID;
  44. void returnArtToHeroCallback();
  45. public:
  46. CCommanderArtPlace(Point position, const CGHeroInstance * commanderOwner, ArtifactPosition artSlot, const CArtifactInstance * art = nullptr);
  47. void clickPressed(const Point & cursorPosition) override;
  48. void showPopupWindow(const Point & cursorPosition) override;
  49. };
  50. class CHeroArtPlace: public CArtPlace
  51. {
  52. public:
  53. CHeroArtPlace(Point position, const CArtifactInstance * art = nullptr);
  54. void addCombinedArtInfo(std::map<const CArtifact*, int> & arts);
  55. };
  56. namespace ArtifactUtilsClient
  57. {
  58. bool askToAssemble(const CGHeroInstance * hero, const ArtifactPosition & slot);
  59. bool askToDisassemble(const CGHeroInstance * hero, const ArtifactPosition & slot);
  60. }