CWindowWithArtifacts.h 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. /*
  2. * CWindowWithArtifacts.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 "../widgets/CArtifactsOfHeroMain.h"
  12. #include "../widgets/CArtifactsOfHeroKingdom.h"
  13. #include "../widgets/CArtifactsOfHeroAltar.h"
  14. #include "../widgets/CArtifactsOfHeroMarket.h"
  15. #include "../widgets/CArtifactsOfHeroBackpack.h"
  16. #include "CWindowObject.h"
  17. class CWindowWithArtifacts : virtual public CWindowObject
  18. {
  19. public:
  20. using CArtifactsOfHeroPtr = std::variant<
  21. std::weak_ptr<CArtifactsOfHeroMarket>,
  22. std::weak_ptr<CArtifactsOfHeroAltar>,
  23. std::weak_ptr<CArtifactsOfHeroKingdom>,
  24. std::weak_ptr<CArtifactsOfHeroMain>,
  25. std::weak_ptr<CArtifactsOfHeroBackpack>,
  26. std::weak_ptr<CArtifactsOfHeroQuickBackpack>>;
  27. using CloseCallback = std::function<void()>;
  28. std::vector<CArtifactsOfHeroPtr> artSets;
  29. CloseCallback closeCallback;
  30. explicit CWindowWithArtifacts(const std::vector<CArtifactsOfHeroPtr> * artSets = nullptr);
  31. void addSet(CArtifactsOfHeroPtr newArtSet);
  32. void addSetAndCallbacks(CArtifactsOfHeroPtr newArtSet);
  33. void addCloseCallback(const CloseCallback & callback);
  34. const CGHeroInstance * getHeroPickedArtifact();
  35. const CArtifactInstance * getPickedArtifact();
  36. void clickPressedArtPlaceHero(const CArtifactsOfHeroBase & artsInst, CArtPlace & artPlace, const Point & cursorPosition);
  37. void showPopupArtPlaceHero(const CArtifactsOfHeroBase & artsInst, CArtPlace & artPlace, const Point & cursorPosition);
  38. void gestureArtPlaceHero(const CArtifactsOfHeroBase & artsInst, CArtPlace & artPlace, const Point & cursorPosition);
  39. void activate() override;
  40. void deactivate() override;
  41. void enableArtifactsCostumeSwitcher() const;
  42. virtual void artifactRemoved(const ArtifactLocation & artLoc);
  43. virtual void artifactMoved(const ArtifactLocation & srcLoc, const ArtifactLocation & destLoc, bool withRedraw);
  44. virtual void artifactDisassembled(const ArtifactLocation & artLoc);
  45. virtual void artifactAssembled(const ArtifactLocation & artLoc);
  46. protected:
  47. void update() const;
  48. std::optional<std::tuple<const CGHeroInstance*, const CArtifactInstance*>> getState();
  49. std::optional<CArtifactsOfHeroPtr> findAOHbyRef(const CArtifactsOfHeroBase & artsInst);
  50. void markPossibleSlots();
  51. bool checkSpecialArts(const CArtifactInstance & artInst, const CGHeroInstance * hero, bool isTrade) const;
  52. void setCursorAnimation(const CArtifactInstance & artInst);
  53. };