2
0

CWindowWithArtifacts.h 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  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. void addSet(CArtifactsOfHeroPtr artSet);
  29. void addSetAndCallbacks(CArtifactsOfHeroPtr artSet);
  30. void addCloseCallback(CloseCallback callback);
  31. const CGHeroInstance * getHeroPickedArtifact();
  32. const CArtifactInstance * getPickedArtifact();
  33. void clickPressedArtPlaceHero(CArtifactsOfHeroBase & artsInst, CArtPlace & artPlace, const Point & cursorPosition);
  34. void showPopupArtPlaceHero(CArtifactsOfHeroBase & artsInst, CArtPlace & artPlace, const Point & cursorPosition);
  35. void gestureArtPlaceHero(CArtifactsOfHeroBase & artsInst, CArtPlace & artPlace, const Point & cursorPosition);
  36. void artifactRemoved(const ArtifactLocation & artLoc) override;
  37. void artifactMoved(const ArtifactLocation & srcLoc, const ArtifactLocation & destLoc, bool withRedraw) override;
  38. void artifactDisassembled(const ArtifactLocation & artLoc) override;
  39. void artifactAssembled(const ArtifactLocation & artLoc) override;
  40. protected:
  41. std::vector<CArtifactsOfHeroPtr> artSets;
  42. CloseCallback closeCallback;
  43. void updateSlots();
  44. std::optional<std::tuple<const CGHeroInstance*, const CArtifactInstance*>> getState();
  45. std::optional<CArtifactsOfHeroPtr> findAOHbyRef(CArtifactsOfHeroBase & artsInst);
  46. void markPossibleSlots();
  47. bool checkSpecialArts(const CArtifactInstance & artInst, const CGHeroInstance * hero, bool isTrade);
  48. };