1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-11-24 08:32:34 +02:00

CArtifactsOfHeroBase refactoring

This commit is contained in:
SoundSSGood 2024-05-20 15:31:07 +03:00
parent 03aaf849f0
commit 3692ca25ed
15 changed files with 76 additions and 136 deletions

View File

@ -1780,7 +1780,10 @@ void CPlayerInterface::artifactMoved(const ArtifactLocation &src, const Artifact
{
artWin->artifactMoved(src, dst);
if(numOfMovedArts == 0)
{
artWin->update();
artWin->redraw();
}
}
waitWhileDialog();
}

View File

@ -21,12 +21,8 @@
CArtifactsOfHeroAltar::CArtifactsOfHeroAltar(const Point & position)
{
init(
std::bind(&CArtifactsOfHeroBase::clickPrassedArtPlace, this, _1, _2),
std::bind(&CArtifactsOfHeroBase::showPopupArtPlace, this, _1, _2),
position,
std::bind(&CArtifactsOfHeroBase::scrollBackpack, this, _1));
init(position, std::bind(&CArtifactsOfHeroBase::scrollBackpack, this, _1));
enableGesture();
// The backpack is in the altar window above and to the right
for(auto & slot : backpack)
slot->moveBy(Point(2, -1));

View File

@ -47,8 +47,6 @@ void CArtifactsOfHeroBase::putBackPickedArtifact()
}
void CArtifactsOfHeroBase::init(
const CArtPlace::ClickFunctor & onClickPressedCallback,
const CArtPlace::ClickFunctor & onShowPopupCallback,
const Point & position,
const BpackScrollFunctor & scrollCallback)
{
@ -69,14 +67,14 @@ void CArtifactsOfHeroBase::init(
{
artPlace.second->slot = artPlace.first;
artPlace.second->setArtifact(nullptr);
artPlace.second->setClickPressedCallback(onClickPressedCallback);
artPlace.second->setShowPopupCallback(onShowPopupCallback);
artPlace.second->setClickPressedCallback(std::bind(&CArtifactsOfHeroBase::clickPrassedArtPlace, this, _1, _2));
artPlace.second->setShowPopupCallback(std::bind(&CArtifactsOfHeroBase::showPopupArtPlace, this, _1, _2));
}
for(auto artPlace : backpack)
{
artPlace->setArtifact(nullptr);
artPlace->setClickPressedCallback(onClickPressedCallback);
artPlace->setShowPopupCallback(onShowPopupCallback);
artPlace->setClickPressedCallback(std::bind(&CArtifactsOfHeroBase::clickPrassedArtPlace, this, _1, _2));
artPlace->setShowPopupCallback(std::bind(&CArtifactsOfHeroBase::showPopupArtPlace, this, _1, _2));
}
leftBackpackRoll = std::make_shared<CButton>(Point(379, 364), AnimationPath::builtin("hsbtns3.def"), CButton::tooltip(),
[scrollCallback](){scrollCallback(true);}, EShortcut::MOVE_LEFT);
@ -226,11 +224,11 @@ const CArtifactInstance * CArtifactsOfHeroBase::getPickedArtifact()
return nullptr;
}
void CArtifactsOfHeroBase::addGestureCallback(CArtPlace::ClickFunctor callback)
void CArtifactsOfHeroBase::enableGesture()
{
for(auto & artPlace : artWorn)
{
artPlace.second->setGestureCallback(callback);
artPlace.second->setGestureCallback(std::bind(&CArtifactsOfHeroBase::gestureArtPlace, this, _1, _2));
artPlace.second->addUsedEvents(GESTURE);
}
}

View File

@ -45,11 +45,10 @@ public:
virtual void updateBackpackSlots();
virtual void updateSlot(const ArtifactPosition & slot);
virtual const CArtifactInstance * getPickedArtifact();
void addGestureCallback(CArtPlace::ClickFunctor callback);
void enableGesture();
const CArtifactInstance * getArt(const ArtifactPosition & slot) const;
void enableKeyboardShortcuts();
protected:
const CGHeroInstance * curHero;
ArtPlaceMap artWorn;
std::vector<ArtPlacePtr> backpack;
@ -67,8 +66,8 @@ protected:
Point(381,295) //18
};
virtual void init(const CHeroArtPlace::ClickFunctor & lClickCallback, const CHeroArtPlace::ClickFunctor & showPopupCallback,
const Point & position, const BpackScrollFunctor & scrollCallback);
protected:
virtual void init(const Point & position, const BpackScrollFunctor & scrollCallback);
// Assigns an artifacts to an artifact place depending on it's new slot ID
virtual void setSlotData(ArtPlacePtr artPlace, const ArtifactPosition & slot);
};

View File

@ -33,7 +33,7 @@ CArtifactsOfHeroKingdom::CArtifactsOfHeroKingdom(ArtPlaceMap ArtWorn, std::vecto
artPlace.second->setClickPressedCallback(std::bind(&CArtifactsOfHeroBase::clickPrassedArtPlace, this, _1, _2));
artPlace.second->setShowPopupCallback(std::bind(&CArtifactsOfHeroBase::showPopupArtPlace, this, _1, _2));
}
addGestureCallback(std::bind(&CArtifactsOfHeroBase::gestureArtPlace, this, _1, _2));
enableGesture();
for(auto artPlace : backpack)
{
artPlace->setArtifact(nullptr);

View File

@ -20,12 +20,8 @@
CArtifactsOfHeroMain::CArtifactsOfHeroMain(const Point & position)
{
init(
std::bind(&CArtifactsOfHeroBase::clickPrassedArtPlace, this, _1, _2),
std::bind(&CArtifactsOfHeroBase::showPopupArtPlace, this, _1, _2),
position,
std::bind(&CArtifactsOfHeroBase::scrollBackpack, this, _1));
addGestureCallback(std::bind(&CArtifactsOfHeroBase::gestureArtPlace, this, _1, _2));
init(position, std::bind(&CArtifactsOfHeroBase::scrollBackpack, this, _1));
enableGesture();
}
CArtifactsOfHeroMain::~CArtifactsOfHeroMain()

View File

@ -14,11 +14,7 @@
CArtifactsOfHeroMarket::CArtifactsOfHeroMarket(const Point & position, const int selectionWidth)
{
init(
std::bind(&CArtifactsOfHeroBase::clickPrassedArtPlace, this, _1, _2),
std::bind(&CArtifactsOfHeroBase::showPopupArtPlace, this, _1, _2),
position,
std::bind(&CArtifactsOfHeroBase::scrollBackpack, this, _1));
init(position, std::bind(&CArtifactsOfHeroBase::scrollBackpack, this, _1));
for(const auto & [slot, artPlace] : artWorn)
artPlace->setSelectionWidth(selectionWidth);
@ -26,8 +22,11 @@ CArtifactsOfHeroMarket::CArtifactsOfHeroMarket(const Point & position, const int
artPlace->setSelectionWidth(selectionWidth);
};
void CArtifactsOfHeroMarket::onClickPressedArtPlace(CArtPlace & artPlace)
void CArtifactsOfHeroMarket::clickPrassedArtPlace(CArtPlace & artPlace, const Point & cursorPosition)
{
if(artPlace.isLocked())
return;
if(const auto art = getArt(artPlace.slot))
{
if(onSelectArtCallback && art->artType->isTradable())

View File

@ -18,5 +18,5 @@ public:
std::function<void()> onClickNotTradableCallback;
CArtifactsOfHeroMarket(const Point & position, const int selectionWidth);
void onClickPressedArtPlace(CArtPlace & artPlace);
void clickPrassedArtPlace(CArtPlace & artPlace, const Point & cursorPosition) override;
};

View File

@ -31,7 +31,7 @@ CHeroBackpackWindow::CHeroBackpackWindow(const CGHeroInstance * hero, const std:
stretchedBackground = std::make_shared<CFilledTexture>(ImagePath::builtin("DIBOXBCK"), Rect(0, 0, 0, 0));
arts = std::make_shared<CArtifactsOfHeroBackpack>();
arts->moveBy(Point(windowMargin, windowMargin));
arts->clickPressedCallback = [this](CArtPlace & artPlace, const Point & cursorPosition)
arts->clickPressedCallback = [this](const CArtPlace & artPlace, const Point & cursorPosition)
{
clickPressedOnArtPlace(arts->getHero(), artPlace.slot, true, false, true);
};
@ -41,7 +41,6 @@ CHeroBackpackWindow::CHeroBackpackWindow(const CGHeroInstance * hero, const std:
};
addSet(arts);
arts->setHero(hero);
addCloseCallback(std::bind(&CHeroBackpackWindow::close, this));
quitButton = std::make_shared<CButton>(Point(), AnimationPath::builtin("IOKAY32.def"), CButton::tooltip(""),
[this]() { WindowBase::close(); }, EShortcut::GLOBAL_RETURN);
pos.w = stretchedBackground->pos.w = arts->pos.w + 2 * windowMargin;
@ -66,18 +65,17 @@ CHeroQuickBackpackWindow::CHeroQuickBackpackWindow(const CGHeroInstance * hero,
stretchedBackground = std::make_shared<CFilledTexture>(ImagePath::builtin("DIBOXBCK"), Rect(0, 0, 0, 0));
arts = std::make_shared<CArtifactsOfHeroQuickBackpack>(targetSlot);
arts->moveBy(Point(windowMargin, windowMargin));
arts->clickPressedCallback = [this](CArtPlace & artPlace, const Point & cursorPosition)
arts->clickPressedCallback = [this](const CArtPlace & artPlace, const Point & cursorPosition)
{
if(const auto curHero = arts->getHero())
swapArtifactAndClose(*arts, artPlace.slot, ArtifactLocation(curHero->id, arts->getFilterSlot()));
};
arts->showPopupCallback = [this](CArtPlace & artPlace, const Point & cursorPosition)
{
showArifactInfo(artPlace, cursorPosition);
showArifactInfo(*arts, artPlace, cursorPosition);
};
addSet(arts);
arts->setHero(hero);
addCloseCallback(std::bind(&CHeroQuickBackpackWindow::close, this));
addUsedEvents(GESTURE);
pos.w = stretchedBackground->pos.w = arts->pos.w + 2 * windowMargin;
pos.h = stretchedBackground->pos.h = arts->pos.h + windowMargin;

View File

@ -213,19 +213,10 @@ void CHeroWindow::update()
if(!arts)
{
arts = std::make_shared<CArtifactsOfHeroMain>(Point(-65, -8));
arts->clickPressedCallback = [this](const CArtPlace & artPlace, const Point & cursorPosition){clickPressedOnArtPlace(curHero, artPlace.slot, true, false, false);};
arts->showPopupCallback = [this](CArtPlace & artPlace, const Point & cursorPosition){showArtifactAssembling(*arts, artPlace, cursorPosition);};
arts->gestureCallback = [this](const CArtPlace & artPlace, const Point & cursorPosition){showQuickBackpackWindow(curHero, artPlace.slot, cursorPosition);};
arts->setHero(curHero);
arts->clickPressedCallback = [this](CArtPlace & artPlace, const Point & cursorPosition)
{
clickPressedOnArtPlace(arts->getHero(), artPlace.slot, true, false, false);
};
arts->showPopupCallback = [this](CArtPlace & artPlace, const Point & cursorPosition)
{
showArtifactAssembling(*arts, artPlace, cursorPosition);
};
arts->gestureCallback = [this](CArtPlace & artPlace, const Point & cursorPosition)
{
showQuickBackpackWindow(arts->getHero(), artPlace.slot, cursorPosition);
};
addSet(arts);
enableKeyboardShortcuts();
}

View File

@ -550,7 +550,7 @@ std::shared_ptr<CIntObject> CKingdomInterface::createMainTab(size_t index)
case 0:
return std::make_shared<CKingdHeroList>(size, [this](const CWindowWithArtifacts::CArtifactsOfHeroPtr & newHeroSet)
{
newHeroSet->clickPressedCallback = [this, newHeroSet](CArtPlace & artPlace, const Point & cursorPosition)
newHeroSet->clickPressedCallback = [this, newHeroSet](const CArtPlace & artPlace, const Point & cursorPosition)
{
clickPressedOnArtPlace(newHeroSet->getHero(), artPlace.slot, false, false, false);
};
@ -558,7 +558,7 @@ std::shared_ptr<CIntObject> CKingdomInterface::createMainTab(size_t index)
{
showArtifactAssembling(*newHeroSet, artPlace, cursorPosition);
};
newHeroSet->gestureCallback = [this, newHeroSet](CArtPlace & artPlace, const Point & cursorPosition)
newHeroSet->gestureCallback = [this, newHeroSet](const CArtPlace & artPlace, const Point & cursorPosition)
{
showQuickBackpackWindow(newHeroSet->getHero(), artPlace.slot, cursorPosition);
};

View File

@ -195,14 +195,7 @@ void CMarketWindow::createArtifactsSelling(const IMarket * market, const CGHeroI
auto artsSellingMarket = std::make_shared<CArtifactsSelling>(market, hero);
artSets.clear();
const auto heroArts = artsSellingMarket->getAOHset();
heroArts->clickPressedCallback = [heroArts](CArtPlace & artPlace, const Point & cursorPosition)
{
heroArts->onClickPressedArtPlace(artPlace);
};
heroArts->showPopupCallback = [this](CArtPlace & artPlace, const Point & cursorPosition)
{
showArifactInfo(artPlace, cursorPosition);
};
heroArts->showPopupCallback = [this, heroArts](CArtPlace & artPlace, const Point & cursorPosition){showArifactInfo(*heroArts, artPlace, cursorPosition);};
addSet(heroArts);
marketWidget = artsSellingMarket;
initWidgetInternals(EMarketMode::ARTIFACT_RESOURCE, CGI->generaltexth->zelp[600]);
@ -244,7 +237,7 @@ void CMarketWindow::createAltarArtifacts(const IMarket * market, const CGHeroIns
marketWidget = altarArtifacts;
artSets.clear();
const auto heroArts = altarArtifacts->getAOHset();
heroArts->clickPressedCallback = [this, heroArts](CArtPlace & artPlace, const Point & cursorPosition)
heroArts->clickPressedCallback = [this, heroArts](const CArtPlace & artPlace, const Point & cursorPosition)
{
clickPressedOnArtPlace(heroArts->getHero(), artPlace.slot, true, true, false);
};
@ -252,7 +245,7 @@ void CMarketWindow::createAltarArtifacts(const IMarket * market, const CGHeroIns
{
showArtifactAssembling(*heroArts, artPlace, cursorPosition);
};
heroArts->gestureCallback = [this, heroArts](CArtPlace & artPlace, const Point & cursorPosition)
heroArts->gestureCallback = [this, heroArts](const CArtPlace & artPlace, const Point & cursorPosition)
{
showQuickBackpackWindow(heroArts->getHero(), artPlace.slot, cursorPosition);
};

View File

@ -44,16 +44,11 @@ void CWindowWithArtifacts::addSet(const std::shared_ptr<CArtifactsOfHeroBase> &
artSets.emplace_back(newArtSet);
}
void CWindowWithArtifacts::addCloseCallback(const CloseCallback & callback)
{
closeCallback = callback;
}
const CGHeroInstance * CWindowWithArtifacts::getHeroPickedArtifact()
const CGHeroInstance * CWindowWithArtifacts::getHeroPickedArtifact() const
{
const CGHeroInstance * hero = nullptr;
for(auto & artSet : artSets)
for(const auto & artSet : artSets)
if(const auto pickedArt = artSet->getHero()->getArt(ArtifactPosition::TRANSITION_POS))
{
hero = artSet->getHero();
@ -62,11 +57,11 @@ const CGHeroInstance * CWindowWithArtifacts::getHeroPickedArtifact()
return hero;
}
const CArtifactInstance * CWindowWithArtifacts::getPickedArtifact()
const CArtifactInstance * CWindowWithArtifacts::getPickedArtifact() const
{
const CArtifactInstance * art = nullptr;
for(auto & artSet : artSets)
for(const auto & artSet : artSets)
if(const auto pickedArt = artSet->getHero()->getArt(ArtifactPosition::TRANSITION_POS))
{
art = pickedArt;
@ -108,11 +103,10 @@ void CWindowWithArtifacts::clickPressedOnArtPlace(const CGHeroInstance * hero, c
}
void CWindowWithArtifacts::swapArtifactAndClose(const CArtifactsOfHeroBase & artsInst, const ArtifactPosition & slot,
const ArtifactLocation & dstLoc) const
const ArtifactLocation & dstLoc)
{
LOCPLINT->cb->swapArtifacts(ArtifactLocation(artsInst.getHero()->id, slot), dstLoc);
if(closeCallback)
closeCallback();
close();
}
void CWindowWithArtifacts::showArtifactAssembling(const CArtifactsOfHeroBase & artsInst, CArtPlace & artPlace,
@ -129,9 +123,9 @@ void CWindowWithArtifacts::showArtifactAssembling(const CArtifactsOfHeroBase & a
}
}
void CWindowWithArtifacts::showArifactInfo(CArtPlace & artPlace, const Point & cursorPosition) const
void CWindowWithArtifacts::showArifactInfo(const CArtifactsOfHeroBase & artsInst, CArtPlace & artPlace, const Point & cursorPosition) const
{
if(artPlace.getArt() && artPlace.text.size())
if(artsInst.getArt(artPlace.slot) && artPlace.text.size())
artPlace.LRClickableAreaWTextComp::showPopupWindow(cursorPosition);
}
@ -176,7 +170,7 @@ void CWindowWithArtifacts::artifactRemoved(const ArtifactLocation & artLoc)
void CWindowWithArtifacts::artifactMoved(const ArtifactLocation & srcLoc, const ArtifactLocation & destLoc)
{
for(auto & artSet : artSets)
for(const auto & artSet : artSets)
if(const auto pickedArtInst = getPickedArtifact())
{
markPossibleSlots();
@ -202,7 +196,7 @@ void CWindowWithArtifacts::artifactAssembled(const ArtifactLocation & artLoc)
void CWindowWithArtifacts::update()
{
for(auto & artSet : artSets)
for(const auto & artSet : artSets)
{
artSet->updateWornSlots();
artSet->updateBackpackSlots();
@ -213,20 +207,19 @@ void CWindowWithArtifacts::update()
}
}
void CWindowWithArtifacts::markPossibleSlots()
void CWindowWithArtifacts::markPossibleSlots() const
{
if(const auto pickedArtInst = getPickedArtifact())
{
const auto heroArtOwner = getHeroPickedArtifact();
for(auto & artSet : artSets)
for(const auto & artSet : artSets)
{
if(artSet->isActive())
{
const auto hero = artSet->getHero();
if(heroArtOwner == hero || !std::dynamic_pointer_cast<CArtifactsOfHeroKingdom>(artSet))
artSet->markPossibleSlots(pickedArtInst, hero->tempOwner == LOCPLINT->playerID);
}
};
const auto hero = artSet->getHero();
if(hero == nullptr || !artSet->isActive())
continue;
if(getHeroPickedArtifact() == hero || !std::dynamic_pointer_cast<CArtifactsOfHeroKingdom>(artSet))
artSet->markPossibleSlots(pickedArtInst, hero->tempOwner == LOCPLINT->playerID);
}
}
}
@ -255,7 +248,7 @@ bool CWindowWithArtifacts::checkSpecialArts(const CArtifactInstance & artInst, c
return true;
}
void CWindowWithArtifacts::setCursorAnimation(const CArtifactInstance & artInst)
void CWindowWithArtifacts::setCursorAnimation(const CArtifactInstance & artInst) const
{
if(artInst.isScroll() && settings["general"]["enableUiEnhancements"].Bool())
{
@ -270,7 +263,7 @@ void CWindowWithArtifacts::setCursorAnimation(const CArtifactInstance & artInst)
}
}
void CWindowWithArtifacts::putPickedArtifact(const CGHeroInstance & curHero, const ArtifactPosition & targetSlot)
void CWindowWithArtifacts::putPickedArtifact(const CGHeroInstance & curHero, const ArtifactPosition & targetSlot) const
{
const auto heroArtOwner = getHeroPickedArtifact();
const auto pickedArt = getPickedArtifact();
@ -307,16 +300,13 @@ void CWindowWithArtifacts::onClickPressedCommonArtifact(const CGHeroInstance & c
if(GH.isKeyboardCmdDown())
{
for(auto & anotherSet : artSets)
for(const auto & anotherSet : artSets)
{
if(std::dynamic_pointer_cast<CArtifactsOfHeroMain>(anotherSet))
if(std::dynamic_pointer_cast<CArtifactsOfHeroMain>(anotherSet) && curHero.id != anotherSet->getHero()->id)
{
if(curHero.id != anotherSet->getHero()->id)
{
dstLoc.slot = ArtifactPosition::FIRST_AVAILABLE;
dstLoc.artHolder = anotherSet->getHero()->id;
break;
}
dstLoc.slot = ArtifactPosition::FIRST_AVAILABLE;
dstLoc.artHolder = anotherSet->getHero()->id;
break;
}
if(const auto heroSetAltar = std::dynamic_pointer_cast<CArtifactsOfHeroAltar>(anotherSet))
{
@ -334,11 +324,10 @@ void CWindowWithArtifacts::onClickPressedCommonArtifact(const CGHeroInstance & c
else if(ArtifactUtils::isSlotBackpack(slot))
dstLoc.slot = ArtifactUtils::getArtEquippedPosition(&curHero, artId);
}
else if(closeWindow && closeCallback)
else if(closeWindow)
{
closeCallback();
close();
}
if(dstLoc.slot != ArtifactPosition::PRE_FIRST)
LOCPLINT->cb->swapArtifacts(srcLoc, dstLoc);
}

View File

@ -20,21 +20,18 @@ class CWindowWithArtifacts : virtual public CWindowObject
{
public:
using CArtifactsOfHeroPtr = std::shared_ptr<CArtifactsOfHeroBase>;
using CloseCallback = std::function<void()>;
std::vector<CArtifactsOfHeroPtr> artSets;
CloseCallback closeCallback;
explicit CWindowWithArtifacts(const std::vector<CArtifactsOfHeroPtr> * artSets = nullptr);
void addSet(const std::shared_ptr<CArtifactsOfHeroBase> & newArtSet);
void addCloseCallback(const CloseCallback & callback);
const CGHeroInstance * getHeroPickedArtifact();
const CArtifactInstance * getPickedArtifact();
const CGHeroInstance * getHeroPickedArtifact() const;
const CArtifactInstance * getPickedArtifact() const;
void clickPressedOnArtPlace(const CGHeroInstance * hero, const ArtifactPosition & slot,
bool allowExchange, bool altarTrading, bool closeWindow);
void swapArtifactAndClose(const CArtifactsOfHeroBase & artsInst, const ArtifactPosition & slot, const ArtifactLocation & dstLoc) const;
void swapArtifactAndClose(const CArtifactsOfHeroBase & artsInst, const ArtifactPosition & slot, const ArtifactLocation & dstLoc);
void showArtifactAssembling(const CArtifactsOfHeroBase & artsInst, CArtPlace & artPlace, const Point & cursorPosition) const;
void showArifactInfo(CArtPlace & artPlace, const Point & cursorPosition) const;
void showArifactInfo(const CArtifactsOfHeroBase & artsInst, CArtPlace & artPlace, const Point & cursorPosition) const;
void showQuickBackpackWindow(const CGHeroInstance * hero, const ArtifactPosition & slot, const Point & cursorPosition) const;
void activate() override;
void deactivate() override;
@ -47,9 +44,9 @@ public:
virtual void update();
protected:
void markPossibleSlots();
void markPossibleSlots() const;
bool checkSpecialArts(const CArtifactInstance & artInst, const CGHeroInstance & hero, bool isTrade) const;
void setCursorAnimation(const CArtifactInstance & artInst);
void putPickedArtifact(const CGHeroInstance & curHero, const ArtifactPosition & targetSlot);
void setCursorAnimation(const CArtifactInstance & artInst) const;
void putPickedArtifact(const CGHeroInstance & curHero, const ArtifactPosition & targetSlot) const;
void onClickPressedCommonArtifact(const CGHeroInstance & curHero, const ArtifactPosition & slot, bool closeWindow);
};

View File

@ -759,35 +759,16 @@ CExchangeWindow::CExchangeWindow(ObjectInstanceID hero1, ObjectInstanceID hero2,
}
artifs[0] = std::make_shared<CArtifactsOfHeroMain>(Point(-334, 151));
artifs[0]->clickPressedCallback = [this, hero = heroInst[0]](const CArtPlace & artPlace, const Point & cursorPosition){clickPressedOnArtPlace(hero, artPlace.slot, true, false, false);};
artifs[0]->showPopupCallback = [this, heroArts = artifs[0]](CArtPlace & artPlace, const Point & cursorPosition){showArtifactAssembling(*heroArts, artPlace, cursorPosition);};
artifs[0]->gestureCallback = [this, hero = heroInst[0]](const CArtPlace & artPlace, const Point & cursorPosition){showQuickBackpackWindow(hero, artPlace.slot, cursorPosition);};
artifs[0]->setHero(heroInst[0]);
artifs[1] = std::make_shared<CArtifactsOfHeroMain>(Point(98, 151));
artifs[1]->clickPressedCallback = [this, hero = heroInst[1]](const CArtPlace & artPlace, const Point & cursorPosition){clickPressedOnArtPlace(hero, artPlace.slot, true, false, false);};
artifs[1]->showPopupCallback = [this, heroArts = artifs[1]](CArtPlace & artPlace, const Point & cursorPosition){showArtifactAssembling(*heroArts, artPlace, cursorPosition);};
artifs[1]->gestureCallback = [this, hero = heroInst[1]](const CArtPlace & artPlace, const Point & cursorPosition){showQuickBackpackWindow(hero, artPlace.slot, cursorPosition);};
artifs[1]->setHero(heroInst[1]);
artifs[0]->clickPressedCallback = [this, heroArts = artifs[0]](CArtPlace & artPlace, const Point & cursorPosition)
{
clickPressedOnArtPlace(heroArts->getHero(), artPlace.slot, true, false, false);
};
artifs[0]->showPopupCallback = [this, heroArts = artifs[0]](CArtPlace & artPlace, const Point & cursorPosition)
{
showArtifactAssembling(*heroArts, artPlace, cursorPosition);
};
artifs[0]->gestureCallback = [this, heroArts = artifs[0]](CArtPlace & artPlace, const Point & cursorPosition)
{
showQuickBackpackWindow(heroArts->getHero(), artPlace.slot, cursorPosition);
};
artifs[1]->clickPressedCallback = [this, heroArts = artifs[1]](CArtPlace & artPlace, const Point & cursorPosition)
{
clickPressedOnArtPlace(heroArts->getHero(), artPlace.slot, true, false, false);
};
artifs[1]->showPopupCallback = [this, heroArts = artifs[1]](CArtPlace & artPlace, const Point & cursorPosition)
{
showArtifactAssembling(*heroArts, artPlace, cursorPosition);
};
artifs[1]->gestureCallback = [this, heroArts = artifs[1]](CArtPlace & artPlace, const Point & cursorPosition)
{
showQuickBackpackWindow(heroArts->getHero(), artPlace.slot, cursorPosition);
};
addSet(artifs[0]);
addSet(artifs[1]);
@ -950,7 +931,7 @@ CExchangeWindow::CExchangeWindow(ObjectInstanceID hero1, ObjectInstanceID hero2,
}
}
update();
CWindowWithArtifacts::update();
}
const CGarrisonSlot * CExchangeWindow::getSelectedSlotID() const