diff --git a/client/widgets/CArtifactsOfHeroBase.cpp b/client/widgets/CArtifactsOfHeroBase.cpp index b287a9449..eedb5d4e8 100644 --- a/client/widgets/CArtifactsOfHeroBase.cpp +++ b/client/widgets/CArtifactsOfHeroBase.cpp @@ -240,6 +240,11 @@ const CArtifactInstance * CArtifactsOfHeroBase::getArt(const ArtifactPosition & return curHero ? curHero->getArt(slot) : nullptr; } +void CArtifactsOfHeroBase::enableKeyboardShortcuts() +{ + addUsedEvents(AEventsReceiver::KEYBOARD); +} + void CArtifactsOfHeroBase::setSlotData(ArtPlacePtr artPlace, const ArtifactPosition & slot) { // Spurious call from artifactMoved in attempt to update hidden backpack slot diff --git a/client/widgets/CArtifactsOfHeroBase.h b/client/widgets/CArtifactsOfHeroBase.h index 7b067d3ab..fbbb8bb0f 100644 --- a/client/widgets/CArtifactsOfHeroBase.h +++ b/client/widgets/CArtifactsOfHeroBase.h @@ -11,9 +11,11 @@ #include "CArtPlace.h" +#include "../gui/Shortcut.h" + class CButton; -class CArtifactsOfHeroBase : virtual public CIntObject +class CArtifactsOfHeroBase : virtual public CIntObject, public CKeyShortcut { protected: using ArtPlacePtr = std::shared_ptr; @@ -45,6 +47,7 @@ public: virtual const CArtifactInstance * getPickedArtifact(); void addGestureCallback(CArtPlace::ClickFunctor callback); const CArtifactInstance * getArt(const ArtifactPosition & slot) const; + void enableKeyboardShortcuts(); protected: const CGHeroInstance * curHero; diff --git a/client/widgets/CArtifactsOfHeroMain.cpp b/client/widgets/CArtifactsOfHeroMain.cpp index e6953cb07..808cb0cd2 100644 --- a/client/widgets/CArtifactsOfHeroMain.cpp +++ b/client/widgets/CArtifactsOfHeroMain.cpp @@ -33,11 +33,6 @@ CArtifactsOfHeroMain::~CArtifactsOfHeroMain() CArtifactsOfHeroBase::putBackPickedArtifact(); } -void CArtifactsOfHeroMain::enableArtifactsCostumeSwitcher() -{ - addUsedEvents(AEventsReceiver::KEYBOARD); -} - void CArtifactsOfHeroMain::keyPressed(EShortcut key) { if(!shortcutPressed) diff --git a/client/widgets/CArtifactsOfHeroMain.h b/client/widgets/CArtifactsOfHeroMain.h index c3aa837e9..620ef967a 100644 --- a/client/widgets/CArtifactsOfHeroMain.h +++ b/client/widgets/CArtifactsOfHeroMain.h @@ -11,14 +11,11 @@ #include "CArtifactsOfHeroBase.h" -#include "../gui/Shortcut.h" - -class CArtifactsOfHeroMain : public CArtifactsOfHeroBase, public CKeyShortcut +class CArtifactsOfHeroMain : public CArtifactsOfHeroBase { public: CArtifactsOfHeroMain(const Point & position); ~CArtifactsOfHeroMain() override; - void enableArtifactsCostumeSwitcher(); void keyPressed(EShortcut key) override; void keyReleased(EShortcut key) override; diff --git a/client/windows/CHeroBackpackWindow.cpp b/client/windows/CHeroBackpackWindow.cpp index 328a2bdb8..e63dc991e 100644 --- a/client/windows/CHeroBackpackWindow.cpp +++ b/client/windows/CHeroBackpackWindow.cpp @@ -20,7 +20,10 @@ #include "render/Canvas.h" #include "CPlayerInterface.h" -CHeroBackpackWindow::CHeroBackpackWindow(const CGHeroInstance * hero, const std::vector & artsSets) +#include "../../lib/mapObjects/CGHeroInstance.h" +#include "../../lib/networkPacks/ArtifactLocation.h" + +CHeroBackpackWindow::CHeroBackpackWindow(const CGHeroInstance * hero, const std::vector & artsSets) : CWindowWithArtifacts(&artsSets) { OBJECT_CONSTRUCTION_CAPTURING(255 - DISPOSE); @@ -28,7 +31,15 @@ CHeroBackpackWindow::CHeroBackpackWindow(const CGHeroInstance * hero, const std: stretchedBackground = std::make_shared(ImagePath::builtin("DIBOXBCK"), Rect(0, 0, 0, 0)); arts = std::make_shared(); arts->moveBy(Point(windowMargin, windowMargin)); - addSetAndCallbacks(arts); + arts->clickPressedCallback = [this](CArtPlace & artPlace, const Point & cursorPosition) + { + clickPressedOnArtPlace(arts->getHero(), artPlace.slot, true, false, true); + }; + arts->showPopupCallback = [this](CArtPlace & artPlace, const Point & cursorPosition) + { + showArtifactAssembling(*arts, artPlace, cursorPosition); + }; + addSet(arts); arts->setHero(hero); addCloseCallback(std::bind(&CHeroBackpackWindow::close, this)); quitButton = std::make_shared(Point(), AnimationPath::builtin("IOKAY32.def"), CButton::tooltip(""), @@ -55,7 +66,16 @@ CHeroQuickBackpackWindow::CHeroQuickBackpackWindow(const CGHeroInstance * hero, stretchedBackground = std::make_shared(ImagePath::builtin("DIBOXBCK"), Rect(0, 0, 0, 0)); arts = std::make_shared(targetSlot); arts->moveBy(Point(windowMargin, windowMargin)); - addSetAndCallbacks(static_cast>(arts)); + arts->clickPressedCallback = [this](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); + }; + addSet(arts); arts->setHero(hero); addCloseCallback(std::bind(&CHeroQuickBackpackWindow::close, this)); addUsedEvents(GESTURE); diff --git a/client/windows/CHeroBackpackWindow.h b/client/windows/CHeroBackpackWindow.h index 4541cc467..aff8cbca9 100644 --- a/client/windows/CHeroBackpackWindow.h +++ b/client/windows/CHeroBackpackWindow.h @@ -16,7 +16,7 @@ class CFilledTexture; class CHeroBackpackWindow : public CStatusbarWindow, public CWindowWithArtifacts { public: - CHeroBackpackWindow(const CGHeroInstance * hero, const std::vector & artsSets); + CHeroBackpackWindow(const CGHeroInstance * hero, const std::vector & artsSets); protected: std::shared_ptr arts; diff --git a/client/windows/CHeroWindow.cpp b/client/windows/CHeroWindow.cpp index 7d4bfccfd..2399701e1 100644 --- a/client/windows/CHeroWindow.cpp +++ b/client/windows/CHeroWindow.cpp @@ -214,8 +214,20 @@ void CHeroWindow::update() { arts = std::make_shared(Point(-65, -8)); arts->setHero(curHero); - addSetAndCallbacks(arts); - enableArtifactsCostumeSwitcher(); + 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(); } int serial = LOCPLINT->cb->getHeroSerial(curHero, false); diff --git a/client/windows/CKingdomInterface.cpp b/client/windows/CKingdomInterface.cpp index 191b6cf56..5170fe595 100644 --- a/client/windows/CKingdomInterface.cpp +++ b/client/windows/CKingdomInterface.cpp @@ -548,9 +548,21 @@ std::shared_ptr CKingdomInterface::createMainTab(size_t index) switch(index) { case 0: - return std::make_shared(size, [this](const CWindowWithArtifacts::ArtifactsOfHeroVar & newHeroSet) + return std::make_shared(size, [this](const CWindowWithArtifacts::CArtifactsOfHeroPtr & newHeroSet) { - addSetAndCallbacks(newHeroSet); + newHeroSet->clickPressedCallback = [this, newHeroSet](CArtPlace & artPlace, const Point & cursorPosition) + { + clickPressedOnArtPlace(newHeroSet->getHero(), artPlace.slot, false, false, false); + }; + newHeroSet->showPopupCallback = [this, newHeroSet](CArtPlace & artPlace, const Point & cursorPosition) + { + showArtifactAssembling(*newHeroSet, artPlace, cursorPosition); + }; + newHeroSet->gestureCallback = [this, newHeroSet](CArtPlace & artPlace, const Point & cursorPosition) + { + showQuickBackpackWindow(newHeroSet->getHero(), artPlace.slot, cursorPosition); + }; + addSet(newHeroSet); }); case 1: return std::make_shared(size); diff --git a/client/windows/CKingdomInterface.h b/client/windows/CKingdomInterface.h index ff947a05a..50fbd1038 100644 --- a/client/windows/CKingdomInterface.h +++ b/client/windows/CKingdomInterface.h @@ -334,7 +334,7 @@ private: std::shared_ptr skillsLabel; public: - using CreateHeroItemFunctor = std::function; + using CreateHeroItemFunctor = std::function; CKingdHeroList(size_t maxSize, const CreateHeroItemFunctor & onCreateHeroItemCallback); void updateGarrisons() override; diff --git a/client/windows/CMarketWindow.cpp b/client/windows/CMarketWindow.cpp index 6d78dc528..366520e0d 100644 --- a/client/windows/CMarketWindow.cpp +++ b/client/windows/CMarketWindow.cpp @@ -194,7 +194,16 @@ void CMarketWindow::createArtifactsSelling(const IMarket * market, const CGHeroI artSlotBack->moveTo(pos.topLeft() + Point(18, 339)); auto artsSellingMarket = std::make_shared(market, hero); artSets.clear(); - addSetAndCallbacks(artsSellingMarket->getAOHset()); + 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); + }; + addSet(heroArts); marketWidget = artsSellingMarket; initWidgetInternals(EMarketMode::ARTIFACT_RESOURCE, CGI->generaltexth->zelp[600]); } @@ -234,7 +243,20 @@ void CMarketWindow::createAltarArtifacts(const IMarket * market, const CGHeroIns auto altarArtifacts = std::make_shared(market, hero); marketWidget = altarArtifacts; artSets.clear(); - addSetAndCallbacks(altarArtifacts->getAOHset()); + const auto heroArts = altarArtifacts->getAOHset(); + heroArts->clickPressedCallback = [this, heroArts](CArtPlace & artPlace, const Point & cursorPosition) + { + clickPressedOnArtPlace(heroArts->getHero(), artPlace.slot, true, true, false); + }; + heroArts->showPopupCallback = [this, heroArts](CArtPlace & artPlace, const Point & cursorPosition) + { + showArtifactAssembling(*heroArts, artPlace, cursorPosition); + }; + heroArts->gestureCallback = [this, heroArts](CArtPlace & artPlace, const Point & cursorPosition) + { + showQuickBackpackWindow(heroArts->getHero(), artPlace.slot, cursorPosition); + }; + addSet(heroArts); initWidgetInternals(EMarketMode::ARTIFACT_EXP, CGI->generaltexth->zelp[568]); updateHero(); quitButton->addCallback([altarArtifacts](){altarArtifacts->putBackArtifacts();}); diff --git a/client/windows/CWindowWithArtifacts.cpp b/client/windows/CWindowWithArtifacts.cpp index f9e9b3e09..1c9ab0802 100644 --- a/client/windows/CWindowWithArtifacts.cpp +++ b/client/windows/CWindowWithArtifacts.cpp @@ -33,85 +33,17 @@ #include "../../CCallback.h" -CWindowWithArtifacts::CWindowWithArtifacts(const std::vector * artSets) +CWindowWithArtifacts::CWindowWithArtifacts(const std::vector * artSets) { if(artSets) this->artSets.insert(this->artSets.end(), artSets->begin(), artSets->end()); } -void CWindowWithArtifacts::addSet(ArtifactsOfHeroVar newArtSet) +void CWindowWithArtifacts::addSet(const std::shared_ptr & newArtSet) { artSets.emplace_back(newArtSet); } -void CWindowWithArtifacts::addSetAndCallbacks(ArtifactsOfHeroVar newArtSet) -{ - addSet(newArtSet); - std::visit([this](auto artSet) - { - if constexpr(std::is_same_v>) - { - artSet->clickPressedCallback = [artSet](CArtPlace & artPlace, const Point & cursorPosition) - { - artSet->onClickPressedArtPlace(artPlace); - }; - } - if constexpr(std::is_same_v>) - { - artSet->clickPressedCallback = [this, artSet](CArtPlace & artPlace, const Point & cursorPosition) - { - if(const auto curHero = artSet->getHero()) - swapArtifactAndClose(*artSet, artPlace.slot, ArtifactLocation(curHero->id, artSet->getFilterSlot())); - }; - } - if constexpr( - std::is_same_v> || - std::is_same_v> || - std::is_same_v> || - std::is_same_v>) - { - artSet->clickPressedCallback = [this, artSet](CArtPlace & artPlace, const Point & cursorPosition) - { - if(const auto curHero = artSet->getHero()) - clickPressedOnArtPlace(*curHero, artPlace.slot, - !std::is_same_v>, - std::is_same_v>, - std::is_same_v>); - }; - } - if constexpr( - std::is_same_v> || - std::is_same_v>) - { - artSet->showPopupCallback = [this](CArtPlace & artPlace, const Point & cursorPosition) - { - showArifactInfo(artPlace, cursorPosition); - }; - } - if constexpr( - std::is_same_v> || - std::is_same_v> || - std::is_same_v> || - std::is_same_v>) - { - artSet->showPopupCallback = [this, artSet](CArtPlace & artPlace, const Point & cursorPosition) - { - showArtifactAssembling(*artSet, artPlace, cursorPosition); - }; - } - if constexpr( - std::is_same_v> || - std::is_same_v>) - { - artSet->gestureCallback = [this, artSet](CArtPlace & artPlace, const Point & cursorPosition) - { - if(const auto curHero = artSet->getHero()) - showQuickBackpackWindow(*curHero, artPlace.slot, cursorPosition); - }; - } - }, newArtSet); -} - void CWindowWithArtifacts::addCloseCallback(const CloseCallback & callback) { closeCallback = callback; @@ -122,14 +54,11 @@ const CGHeroInstance * CWindowWithArtifacts::getHeroPickedArtifact() const CGHeroInstance * hero = nullptr; for(auto & artSet : artSets) - std::visit([&hero](auto artSetPtr) - { - if(const auto pickedArt = artSetPtr->getHero()->getArt(ArtifactPosition::TRANSITION_POS)) - { - hero = artSetPtr->getHero(); - return; - } - }, artSet); + if(const auto pickedArt = artSet->getHero()->getArt(ArtifactPosition::TRANSITION_POS)) + { + hero = artSet->getHero(); + break; + } return hero; } @@ -138,34 +67,33 @@ const CArtifactInstance * CWindowWithArtifacts::getPickedArtifact() const CArtifactInstance * art = nullptr; for(auto & artSet : artSets) - std::visit([&art](auto artSetPtr) - { - if(const auto pickedArt = artSetPtr->getHero()->getArt(ArtifactPosition::TRANSITION_POS)) - { - art = pickedArt; - return; - } - }, artSet); + if(const auto pickedArt = artSet->getHero()->getArt(ArtifactPosition::TRANSITION_POS)) + { + art = pickedArt; + break; + } return art; } -void CWindowWithArtifacts::clickPressedOnArtPlace(const CGHeroInstance & hero, const ArtifactPosition & slot, +void CWindowWithArtifacts::clickPressedOnArtPlace(const CGHeroInstance * hero, const ArtifactPosition & slot, bool allowExchange, bool altarTrading, bool closeWindow) { if(!LOCPLINT->makingTurn) return; + if(hero == nullptr) + return; if(const auto heroArtOwner = getHeroPickedArtifact()) { - if(allowExchange || hero.id == heroArtOwner->id) - putPickedArtifact(hero, slot); + if(allowExchange || hero->id == heroArtOwner->id) + putPickedArtifact(*hero, slot); } - else if(auto art = hero.getArt(slot)) + else if(auto art = hero->getArt(slot)) { - if(hero.getOwner() == LOCPLINT->playerID) + if(hero->getOwner() == LOCPLINT->playerID) { - if(checkSpecialArts(*art, hero, altarTrading)) - onClickPressedCommonArtifact(hero, slot, closeWindow); + if(checkSpecialArts(*art, *hero, altarTrading)) + onClickPressedCommonArtifact(*hero, slot, closeWindow); } else { @@ -207,13 +135,13 @@ void CWindowWithArtifacts::showArifactInfo(CArtPlace & artPlace, const Point & c artPlace.LRClickableAreaWTextComp::showPopupWindow(cursorPosition); } -void CWindowWithArtifacts::showQuickBackpackWindow(const CGHeroInstance & hero, const ArtifactPosition & slot, +void CWindowWithArtifacts::showQuickBackpackWindow(const CGHeroInstance * hero, const ArtifactPosition & slot, const Point & cursorPosition) const { if(!settings["general"]["enableUiEnhancements"].Bool()) return; - GH.windows().createAndPushWindow(&hero, slot); + GH.windows().createAndPushWindow(hero, slot); auto backpackWindow = GH.windows().topWindow(); backpackWindow->moveTo(cursorPosition - Point(1, 1)); backpackWindow->fitToScreen(15); @@ -235,15 +163,10 @@ void CWindowWithArtifacts::deactivate() CWindowObject::deactivate(); } -void CWindowWithArtifacts::enableArtifactsCostumeSwitcher() const +void CWindowWithArtifacts::enableKeyboardShortcuts() const { for(auto & artSet : artSets) - std::visit( - [](auto artSetPtr) - { - if constexpr(std::is_same_v>) - artSetPtr->enableArtifactsCostumeSwitcher(); - }, artSet); + artSet->enableKeyboardShortcuts(); } void CWindowWithArtifacts::artifactRemoved(const ArtifactLocation & artLoc) @@ -254,19 +177,16 @@ void CWindowWithArtifacts::artifactRemoved(const ArtifactLocation & artLoc) void CWindowWithArtifacts::artifactMoved(const ArtifactLocation & srcLoc, const ArtifactLocation & destLoc) { for(auto & artSet : artSets) - std::visit([this](auto artSetPtr) - { - if(const auto pickedArtInst = getPickedArtifact()) - { - markPossibleSlots(); - setCursorAnimation(*pickedArtInst); - } - else - { - artSetPtr->unmarkSlots(); - CCS->curh->dragAndDropCursor(nullptr); - } - }, artSet); + if(const auto pickedArtInst = getPickedArtifact()) + { + markPossibleSlots(); + setCursorAnimation(*pickedArtInst); + } + else + { + artSet->unmarkSlots(); + CCS->curh->dragAndDropCursor(nullptr); + } } void CWindowWithArtifacts::artifactDisassembled(const ArtifactLocation & artLoc) @@ -283,15 +203,14 @@ void CWindowWithArtifacts::artifactAssembled(const ArtifactLocation & artLoc) void CWindowWithArtifacts::update() { for(auto & artSet : artSets) - std::visit([](auto artSetPtr) - { - artSetPtr->updateWornSlots(); - artSetPtr->updateBackpackSlots(); + { + artSet->updateWornSlots(); + artSet->updateBackpackSlots(); - // Make sure the status bar is updated so it does not display old text - if(auto artPlace = artSetPtr->getArtPlace(GH.getCursorPosition())) - artPlace->hover(true); - }, artSet); + // Make sure the status bar is updated so it does not display old text + if(auto artPlace = artSet->getArtPlace(GH.getCursorPosition())) + artPlace->hover(true); + } } void CWindowWithArtifacts::markPossibleSlots() @@ -299,18 +218,15 @@ void CWindowWithArtifacts::markPossibleSlots() if(const auto pickedArtInst = getPickedArtifact()) { const auto heroArtOwner = getHeroPickedArtifact(); - auto artifactAssembledBody = [&pickedArtInst, &heroArtOwner](auto artSetPtr) + for(auto & artSet : artSets) { - if(artSetPtr->isActive()) + if(artSet->isActive()) { - const auto hero = artSetPtr->getHero(); - if(heroArtOwner == hero || !std::is_same_v>) - artSetPtr->markPossibleSlots(pickedArtInst, hero->tempOwner == LOCPLINT->playerID); + const auto hero = artSet->getHero(); + if(heroArtOwner == hero || !std::dynamic_pointer_cast(artSet)) + artSet->markPossibleSlots(pickedArtInst, hero->tempOwner == LOCPLINT->playerID); } }; - - for(auto & artSet : artSets) - std::visit(artifactAssembledBody, artSet); } } @@ -393,21 +309,19 @@ void CWindowWithArtifacts::onClickPressedCommonArtifact(const CGHeroInstance & c { for(auto & anotherSet : artSets) { - if(std::holds_alternative>(anotherSet)) + if(std::dynamic_pointer_cast(anotherSet)) { - const auto anotherHeroEquipment = std::get>(anotherSet); - if(curHero.id != anotherHeroEquipment->getHero()->id) + if(curHero.id != anotherSet->getHero()->id) { dstLoc.slot = ArtifactPosition::FIRST_AVAILABLE; - dstLoc.artHolder = anotherHeroEquipment->getHero()->id; + dstLoc.artHolder = anotherSet->getHero()->id; break; } } - if(std::holds_alternative>(anotherSet)) + if(const auto heroSetAltar = std::dynamic_pointer_cast(anotherSet)) { - const auto heroEquipment = std::get>(anotherSet); dstLoc.slot = ArtifactPosition::FIRST_AVAILABLE; - dstLoc.artHolder = heroEquipment->altarId; + dstLoc.artHolder = heroSetAltar->altarId; break; } } diff --git a/client/windows/CWindowWithArtifacts.h b/client/windows/CWindowWithArtifacts.h index 3c495d49f..e874d867f 100644 --- a/client/windows/CWindowWithArtifacts.h +++ b/client/windows/CWindowWithArtifacts.h @@ -19,33 +19,26 @@ class CWindowWithArtifacts : virtual public CWindowObject { public: - using ArtifactsOfHeroVar = std::variant< - std::shared_ptr, - std::shared_ptr, - std::shared_ptr, - std::shared_ptr, - std::shared_ptr, - std::shared_ptr>; + using CArtifactsOfHeroPtr = std::shared_ptr; using CloseCallback = std::function; - std::vector artSets; + std::vector artSets; CloseCallback closeCallback; - explicit CWindowWithArtifacts(const std::vector * artSets = nullptr); - void addSet(ArtifactsOfHeroVar newArtSet); - void addSetAndCallbacks(ArtifactsOfHeroVar newArtSet); + explicit CWindowWithArtifacts(const std::vector * artSets = nullptr); + void addSet(const std::shared_ptr & newArtSet); void addCloseCallback(const CloseCallback & callback); const CGHeroInstance * getHeroPickedArtifact(); const CArtifactInstance * getPickedArtifact(); - void clickPressedOnArtPlace(const CGHeroInstance & hero, const ArtifactPosition & slot, + 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 showArtifactAssembling(const CArtifactsOfHeroBase & artsInst, CArtPlace & artPlace, const Point & cursorPosition) const; void showArifactInfo(CArtPlace & artPlace, const Point & cursorPosition) const; - void showQuickBackpackWindow(const CGHeroInstance & hero, const ArtifactPosition & slot, const Point & cursorPosition) const; + void showQuickBackpackWindow(const CGHeroInstance * hero, const ArtifactPosition & slot, const Point & cursorPosition) const; void activate() override; void deactivate() override; - void enableArtifactsCostumeSwitcher() const; + void enableKeyboardShortcuts() const; virtual void artifactRemoved(const ArtifactLocation & artLoc); virtual void artifactMoved(const ArtifactLocation & srcLoc, const ArtifactLocation & destLoc); diff --git a/client/windows/GUIClasses.cpp b/client/windows/GUIClasses.cpp index 7fb7f55a0..af3ca89f9 100644 --- a/client/windows/GUIClasses.cpp +++ b/client/windows/GUIClasses.cpp @@ -763,8 +763,33 @@ CExchangeWindow::CExchangeWindow(ObjectInstanceID hero1, ObjectInstanceID hero2, artifs[1] = std::make_shared(Point(98, 151)); artifs[1]->setHero(heroInst[1]); - addSetAndCallbacks(artifs[0]); - addSetAndCallbacks(artifs[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]); for(int g=0; g<4; ++g) {