CArtifactsOfHeroMarket.cpp 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. /*
  2. * CArtifactsOfHeroMarket.cpp, 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. #include "StdInc.h"
  11. #include "CArtifactsOfHeroMarket.h"
  12. #include "../../lib/mapObjects/CGHeroInstance.h"
  13. CArtifactsOfHeroMarket::CArtifactsOfHeroMarket(const Point & position, const int selectionWidth)
  14. {
  15. init(position, std::bind(&CArtifactsOfHeroBase::scrollBackpack, this, _1));
  16. for(const auto & [slot, artPlace] : artWorn)
  17. artPlace->setSelectionWidth(selectionWidth);
  18. for(auto artPlace : backpack)
  19. artPlace->setSelectionWidth(selectionWidth);
  20. };
  21. void CArtifactsOfHeroMarket::clickPrassedArtPlace(CArtPlace & artPlace, const Point & cursorPosition)
  22. {
  23. if(artPlace.isLocked())
  24. return;
  25. if(const auto art = getArt(artPlace.slot))
  26. {
  27. if(onSelectArtCallback && art->artType->isTradable())
  28. {
  29. unmarkSlots();
  30. artPlace.selectSlot(true);
  31. onSelectArtCallback(&artPlace);
  32. }
  33. else
  34. {
  35. if(onClickNotTradableCallback)
  36. onClickNotTradableCallback();
  37. }
  38. }
  39. }