CWindowWithArtifacts.h 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  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 "CArtifactHolder.h"
  12. #include "CArtifactsOfHeroMain.h"
  13. #include "CArtifactsOfHeroKingdom.h"
  14. #include "CArtifactsOfHeroAltar.h"
  15. #include "CArtifactsOfHeroMarket.h"
  16. #include "CArtifactsOfHeroBackpack.h"
  17. class CWindowWithArtifacts : public CArtifactHolder
  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. explicit CWindowWithArtifacts(const std::vector<CArtifactsOfHeroPtr> * artSets = nullptr);
  29. void addSet(CArtifactsOfHeroPtr artSet);
  30. void addSetAndCallbacks(CArtifactsOfHeroPtr artSet);
  31. void addCloseCallback(CloseCallback callback);
  32. const CGHeroInstance * getHeroPickedArtifact();
  33. const CArtifactInstance * getPickedArtifact();
  34. void clickPressedArtPlaceHero(CArtifactsOfHeroBase & artsInst, CArtPlace & artPlace, const Point & cursorPosition);
  35. void showPopupArtPlaceHero(CArtifactsOfHeroBase & artsInst, CArtPlace & artPlace, const Point & cursorPosition);
  36. void gestureArtPlaceHero(CArtifactsOfHeroBase & artsInst, CArtPlace & artPlace, const Point & cursorPosition);
  37. void artifactRemoved(const ArtifactLocation & artLoc) override;
  38. void artifactMoved(const ArtifactLocation & srcLoc, const ArtifactLocation & destLoc, bool withRedraw) override;
  39. void artifactDisassembled(const ArtifactLocation & artLoc) override;
  40. void artifactAssembled(const ArtifactLocation & artLoc) override;
  41. protected:
  42. std::vector<CArtifactsOfHeroPtr> artSets;
  43. CloseCallback closeCallback;
  44. void updateSlots();
  45. std::optional<std::tuple<const CGHeroInstance*, const CArtifactInstance*>> getState();
  46. std::optional<CArtifactsOfHeroPtr> findAOHbyRef(CArtifactsOfHeroBase & artsInst);
  47. void markPossibleSlots();
  48. bool checkSpecialArts(const CArtifactInstance & artInst, const CGHeroInstance * hero, bool isTrade);
  49. void setCursorAnimation(const CArtifactInstance & artInst);
  50. };