diff --git a/client/CPlayerInterface.cpp b/client/CPlayerInterface.cpp index 858024fd7..37d32d2dc 100644 --- a/client/CPlayerInterface.cpp +++ b/client/CPlayerInterface.cpp @@ -1772,18 +1772,16 @@ void CPlayerInterface::artifactMoved(const ArtifactLocation &src, const Artifact EVENT_HANDLER_CALLED_BY_CLIENT; adventureInt->onHeroChanged(cb->getHero(dst.artHolder)); - bool redraw = true; // If a bulk transfer has arrived, then redrawing only the last art movement. if(numOfMovedArts != 0) - { numOfMovedArts--; - if(numOfMovedArts != 0) - redraw = false; - } for(auto artWin : GH.windows().findWindows()) - artWin->artifactMoved(src, dst, redraw); - + { + artWin->artifactMoved(src, dst); + if(numOfMovedArts == 0) + artWin->update(); + } waitWhileDialog(); } diff --git a/client/widgets/CArtifactsOfHeroAltar.h b/client/widgets/CArtifactsOfHeroAltar.h index ad291dbc2..a7d82894a 100644 --- a/client/widgets/CArtifactsOfHeroAltar.h +++ b/client/widgets/CArtifactsOfHeroAltar.h @@ -16,6 +16,8 @@ class CArtifactsOfHeroAltar : public CArtifactsOfHeroBase { public: + ObjectInstanceID altarId; + CArtifactsOfHeroAltar(const Point & position); void deactivate() override; }; diff --git a/client/widgets/CArtifactsOfHeroBase.cpp b/client/widgets/CArtifactsOfHeroBase.cpp index b8ed82455..b287a9449 100644 --- a/client/widgets/CArtifactsOfHeroBase.cpp +++ b/client/widgets/CArtifactsOfHeroBase.cpp @@ -235,7 +235,7 @@ void CArtifactsOfHeroBase::addGestureCallback(CArtPlace::ClickFunctor callback) } } -const CArtifactInstance * CArtifactsOfHeroBase::getArt(const ArtifactPosition & slot) +const CArtifactInstance * CArtifactsOfHeroBase::getArt(const ArtifactPosition & slot) const { return curHero ? curHero->getArt(slot) : nullptr; } diff --git a/client/widgets/CArtifactsOfHeroBase.h b/client/widgets/CArtifactsOfHeroBase.h index 1d40ff0fa..7b067d3ab 100644 --- a/client/widgets/CArtifactsOfHeroBase.h +++ b/client/widgets/CArtifactsOfHeroBase.h @@ -44,7 +44,7 @@ public: virtual void updateSlot(const ArtifactPosition & slot); virtual const CArtifactInstance * getPickedArtifact(); void addGestureCallback(CArtPlace::ClickFunctor callback); - const CArtifactInstance * getArt(const ArtifactPosition & slot); + const CArtifactInstance * getArt(const ArtifactPosition & slot) const; protected: const CGHeroInstance * curHero; diff --git a/client/widgets/CArtifactsOfHeroMarket.cpp b/client/widgets/CArtifactsOfHeroMarket.cpp index e9e915bba..4df55cdaa 100644 --- a/client/widgets/CArtifactsOfHeroMarket.cpp +++ b/client/widgets/CArtifactsOfHeroMarket.cpp @@ -26,7 +26,7 @@ CArtifactsOfHeroMarket::CArtifactsOfHeroMarket(const Point & position, const int artPlace->setSelectionWidth(selectionWidth); }; -void CArtifactsOfHeroMarket::onClickPrassedArtPlace(CArtPlace & artPlace) +void CArtifactsOfHeroMarket::onClickPressedArtPlace(CArtPlace & artPlace) { if(const auto art = getArt(artPlace.slot)) { diff --git a/client/widgets/CArtifactsOfHeroMarket.h b/client/widgets/CArtifactsOfHeroMarket.h index 9c7541a49..9dba21202 100644 --- a/client/widgets/CArtifactsOfHeroMarket.h +++ b/client/widgets/CArtifactsOfHeroMarket.h @@ -18,5 +18,5 @@ public: std::function onClickNotTradableCallback; CArtifactsOfHeroMarket(const Point & position, const int selectionWidth); - void onClickPrassedArtPlace(CArtPlace & artPlace); + void onClickPressedArtPlace(CArtPlace & artPlace); }; diff --git a/client/widgets/markets/CAltarArtifacts.cpp b/client/widgets/markets/CAltarArtifacts.cpp index cf614e7e8..04e90fa0d 100644 --- a/client/widgets/markets/CAltarArtifacts.cpp +++ b/client/widgets/markets/CAltarArtifacts.cpp @@ -32,7 +32,6 @@ CAltarArtifacts::CAltarArtifacts(const IMarket * market, const CGHeroInstance * assert(dynamic_cast(market)); auto altarObj = dynamic_cast(market); - altarId = altarObj->id; altarArtifacts = altarObj; deal = std::make_shared(Point(269, 520), AnimationPath::builtin("ALTSACR.DEF"), @@ -51,6 +50,7 @@ CAltarArtifacts::CAltarArtifacts(const IMarket * market, const CGHeroInstance * // Hero's artifacts heroArts = std::make_shared(Point(-365, -11)); heroArts->setHero(hero); + heroArts->altarId = altarObj->id; // Altar offerTradePanel = std::make_shared([this](const std::shared_ptr & altarSlot) @@ -109,12 +109,12 @@ void CAltarArtifacts::makeDeal() void CAltarArtifacts::sacrificeAll() { - LOCPLINT->cb->bulkMoveArtifacts(heroArts->getHero()->id, altarId, false, true, true); + LOCPLINT->cb->bulkMoveArtifacts(heroArts->getHero()->id, heroArts->altarId, false, true, true); } void CAltarArtifacts::sacrificeBackpack() { - LOCPLINT->cb->bulkMoveArtifacts(heroArts->getHero()->id, altarId, false, false, true); + LOCPLINT->cb->bulkMoveArtifacts(heroArts->getHero()->id, heroArts->altarId, false, false, true); } std::shared_ptr CAltarArtifacts::getAOHset() const @@ -179,7 +179,7 @@ void CAltarArtifacts::putBackArtifacts() // TODO: If the backpack capacity limit is enabled, artifacts may remain on the altar. // Perhaps should be erased in CGameHandler::objectVisitEnded if id of visited object will be available if(!altarArtifacts->artifactsInBackpack.empty()) - LOCPLINT->cb->bulkMoveArtifacts(altarId, heroArts->getHero()->id, false, true, true); + LOCPLINT->cb->bulkMoveArtifacts(heroArts->altarId, heroArts->getHero()->id, false, true, true); } CMarketBase::MarketShowcasesParams CAltarArtifacts::getShowcasesParams() const @@ -208,7 +208,7 @@ void CAltarArtifacts::onSlotClickPressed(const std::shared_ptr & deal->block(!LOCPLINT->makingTurn); LOCPLINT->cb->swapArtifacts(ArtifactLocation(heroArts->getHero()->id, ArtifactPosition::TRANSITION_POS), - ArtifactLocation(altarId, ArtifactPosition::ALTAR)); + ArtifactLocation(heroArts->altarId, ArtifactPosition::ALTAR)); } else { @@ -222,7 +222,7 @@ void CAltarArtifacts::onSlotClickPressed(const std::shared_ptr & assert(tradeSlotsMap.at(altarSlot)); const auto slot = altarArtifacts->getSlotByInstance(tradeSlotsMap.at(altarSlot)); assert(slot != ArtifactPosition::PRE_FIRST); - LOCPLINT->cb->swapArtifacts(ArtifactLocation(altarId, slot), + LOCPLINT->cb->swapArtifacts(ArtifactLocation(heroArts->altarId, slot), ArtifactLocation(hero->id, GH.isKeyboardCtrlDown() ? ArtifactPosition::FIRST_AVAILABLE : ArtifactPosition::TRANSITION_POS)); tradeSlotsMap.erase(altarSlot); } diff --git a/client/widgets/markets/CAltarArtifacts.h b/client/widgets/markets/CAltarArtifacts.h index 9c3ea8ed8..6f714f70d 100644 --- a/client/widgets/markets/CAltarArtifacts.h +++ b/client/widgets/markets/CAltarArtifacts.h @@ -26,7 +26,6 @@ public: void putBackArtifacts(); private: - ObjectInstanceID altarId; const CArtifactSet * altarArtifacts; std::shared_ptr sacrificeBackpackButton; std::shared_ptr heroArts; diff --git a/client/windows/CHeroWindow.cpp b/client/windows/CHeroWindow.cpp index 1f194bcf4..7d4bfccfd 100644 --- a/client/windows/CHeroWindow.cpp +++ b/client/windows/CHeroWindow.cpp @@ -46,7 +46,7 @@ void CHeroSwitcher::clickPressed(const Point & cursorPosition) //TODO: do not recreate window if (false) { - owner->update(hero, true); + owner->update(); } else { @@ -175,20 +175,14 @@ CHeroWindow::CHeroWindow(const CGHeroInstance * hero) labels.push_back(std::make_shared(69, 232, FONT_SMALL, ETextAlignment::TOPLEFT, Colors::YELLOW, CGI->generaltexth->jktexts[6])); labels.push_back(std::make_shared(213, 232, FONT_SMALL, ETextAlignment::TOPLEFT, Colors::YELLOW, CGI->generaltexth->jktexts[7])); - update(hero); + CHeroWindow::update(); } -void CHeroWindow::update(const CGHeroInstance * hero, bool redrawNeeded) +void CHeroWindow::update() { + CWindowWithArtifacts::update(); auto & heroscrn = CGI->generaltexth->heroscrn; - - if(!hero) //something strange... no hero? it shouldn't happen - { - logGlobal->error("Set nullptr hero? no way..."); - return; - } - - assert(hero == curHero); + assert(curHero); name->setText(curHero->getNameTranslated()); title->setText((boost::format(CGI->generaltexth->allTexts[342]) % curHero->level % curHero->getClassNameTranslated()).str()); @@ -313,8 +307,7 @@ void CHeroWindow::update(const CGHeroInstance * hero, bool redrawNeeded) morale->set(curHero); luck->set(curHero); - if(redrawNeeded) - redraw(); + redraw(); } void CHeroWindow::dismissCurrent() diff --git a/client/windows/CHeroWindow.h b/client/windows/CHeroWindow.h index dfebf45d2..4de73bce7 100644 --- a/client/windows/CHeroWindow.h +++ b/client/windows/CHeroWindow.h @@ -100,7 +100,7 @@ public: CHeroWindow(const CGHeroInstance * hero); - void update(const CGHeroInstance * hero, bool redrawNeeded = false); //sets main displayed hero + void update() override; void dismissCurrent(); //dissmissed currently displayed hero (curHero) void commanderWindow(); diff --git a/client/windows/CMarketWindow.cpp b/client/windows/CMarketWindow.cpp index 8d598c158..6d78dc528 100644 --- a/client/windows/CMarketWindow.cpp +++ b/client/windows/CMarketWindow.cpp @@ -62,24 +62,27 @@ CMarketWindow::CMarketWindow(const IMarket * market, const CGHeroInstance * hero void CMarketWindow::updateArtifacts() { - assert(marketWidget); - marketWidget->update(); + update(); } void CMarketWindow::updateGarrisons() { - assert(marketWidget); - marketWidget->update(); + update(); } void CMarketWindow::updateResource() { - assert(marketWidget); - marketWidget->update(); + update(); } void CMarketWindow::updateHero() { + update(); +} + +void CMarketWindow::update() +{ + CWindowWithArtifacts::update(); assert(marketWidget); marketWidget->update(); } @@ -98,19 +101,6 @@ bool CMarketWindow::holdsGarrison(const CArmedInstance * army) return marketWidget->hero == army; } -void CMarketWindow::artifactRemoved(const ArtifactLocation & artLoc) -{ - marketWidget->update(); - CWindowWithArtifacts::artifactRemoved(artLoc); -} - -void CMarketWindow::artifactMoved(const ArtifactLocation & srcLoc, const ArtifactLocation & destLoc, bool withRedraw) -{ - CWindowWithArtifacts::artifactMoved(srcLoc, destLoc, withRedraw); - assert(marketWidget); - marketWidget->update(); -} - void CMarketWindow::createChangeModeButtons(EMarketMode currentMode, const IMarket * market, const CGHeroInstance * hero) { auto isButtonVisible = [currentMode, market, hero](EMarketMode modeButton) -> bool diff --git a/client/windows/CMarketWindow.h b/client/windows/CMarketWindow.h index e6b57f2a7..59403b84d 100644 --- a/client/windows/CMarketWindow.h +++ b/client/windows/CMarketWindow.h @@ -20,10 +20,9 @@ public: void updateArtifacts(); void updateGarrisons() override; void updateHero(); + void update() override; void close() override; bool holdsGarrison(const CArmedInstance * army) override; - void artifactRemoved(const ArtifactLocation & artLoc) override; - void artifactMoved(const ArtifactLocation & srcLoc, const ArtifactLocation & destLoc, bool withRedraw) override; private: void createChangeModeButtons(EMarketMode currentMode, const IMarket * market, const CGHeroInstance * hero); diff --git a/client/windows/CWindowWithArtifacts.cpp b/client/windows/CWindowWithArtifacts.cpp index cb79c69c1..f9e9b3e09 100644 --- a/client/windows/CWindowWithArtifacts.cpp +++ b/client/windows/CWindowWithArtifacts.cpp @@ -20,15 +20,14 @@ #include "../widgets/CComponent.h" -#include "../windows/CHeroWindow.h" #include "../windows/CSpellWindow.h" -#include "../windows/GUIClasses.h" #include "../windows/CHeroBackpackWindow.h" #include "../CPlayerInterface.h" #include "../CGameInfo.h" #include "../../lib/ArtifactUtils.h" #include "../../lib/CGeneralTextHandler.h" +#include "../../lib/mapObjects/CGHeroInstance.h" #include "../../lib/networkPacks/ArtifactLocation.h" #include "../../lib/CConfigHandler.h" @@ -54,7 +53,7 @@ void CWindowWithArtifacts::addSetAndCallbacks(ArtifactsOfHeroVar newArtSet) { artSet->clickPressedCallback = [artSet](CArtPlace & artPlace, const Point & cursorPosition) { - artSet->onClickPrassedArtPlace(artPlace); + artSet->onClickPressedArtPlace(artPlace); }; } if constexpr(std::is_same_v>) @@ -62,7 +61,7 @@ void CWindowWithArtifacts::addSetAndCallbacks(ArtifactsOfHeroVar newArtSet) artSet->clickPressedCallback = [this, artSet](CArtPlace & artPlace, const Point & cursorPosition) { if(const auto curHero = artSet->getHero()) - swapArtifactAndClose(*artSet, artPlace, ArtifactLocation(curHero->id, artSet->getFilterSlot())); + swapArtifactAndClose(*artSet, artPlace.slot, ArtifactLocation(curHero->id, artSet->getFilterSlot())); }; } if constexpr( @@ -106,7 +105,8 @@ void CWindowWithArtifacts::addSetAndCallbacks(ArtifactsOfHeroVar newArtSet) { artSet->gestureCallback = [this, artSet](CArtPlace & artPlace, const Point & cursorPosition) { - showQuickBackpackWindow(*artSet, artPlace, cursorPosition); + if(const auto curHero = artSet->getHero()) + showQuickBackpackWindow(*curHero, artPlace.slot, cursorPosition); }; } }, newArtSet); @@ -165,40 +165,7 @@ void CWindowWithArtifacts::clickPressedOnArtPlace(const CGHeroInstance & hero, c if(hero.getOwner() == LOCPLINT->playerID) { if(checkSpecialArts(*art, hero, altarTrading)) - { - assert(hero.getArt(slot)); - auto srcLoc = ArtifactLocation(hero.id, slot); - auto dstLoc = ArtifactLocation(hero.id, ArtifactPosition::TRANSITION_POS); - - if(GH.isKeyboardCtrlDown()) - { - for(auto & anotherSet : artSets) - if(std::holds_alternative>(anotherSet)) - { - const auto anotherHeroEquipment = std::get>(anotherSet); - if(hero.id != anotherHeroEquipment->getHero()->id) - { - dstLoc.slot = ArtifactPosition::FIRST_AVAILABLE; - dstLoc.artHolder = anotherHeroEquipment->getHero()->id; - break; - } - } - } - else if(GH.isKeyboardAltDown()) - { - const auto artId = hero.getArt(slot)->getTypeId(); - if(ArtifactUtils::isSlotEquipment(slot)) - dstLoc.slot = ArtifactUtils::getArtBackpackPosition(&hero, artId); - else if(ArtifactUtils::isSlotBackpack(slot)) - dstLoc.slot = ArtifactUtils::getArtEquippedPosition(&hero, artId); - } - else if(closeWindow && closeCallback) - { - closeCallback(); - } - if(dstLoc.slot != ArtifactPosition::PRE_FIRST) - LOCPLINT->cb->swapArtifacts(srcLoc, dstLoc); - } + onClickPressedCommonArtifact(hero, slot, closeWindow); } else { @@ -212,16 +179,18 @@ void CWindowWithArtifacts::clickPressedOnArtPlace(const CGHeroInstance & hero, c } } -void CWindowWithArtifacts::swapArtifactAndClose(const CArtifactsOfHeroBase & artsInst, CArtPlace & artPlace, const ArtifactLocation & dstLoc) +void CWindowWithArtifacts::swapArtifactAndClose(const CArtifactsOfHeroBase & artsInst, const ArtifactPosition & slot, + const ArtifactLocation & dstLoc) const { - LOCPLINT->cb->swapArtifacts(ArtifactLocation(artsInst.getHero()->id, artPlace.slot), dstLoc); + LOCPLINT->cb->swapArtifacts(ArtifactLocation(artsInst.getHero()->id, slot), dstLoc); if(closeCallback) closeCallback(); } -void CWindowWithArtifacts::showArtifactAssembling(const CArtifactsOfHeroBase & artsInst, CArtPlace & artPlace, const Point & cursorPosition) +void CWindowWithArtifacts::showArtifactAssembling(const CArtifactsOfHeroBase & artsInst, CArtPlace & artPlace, + const Point & cursorPosition) const { - if(artPlace.getArt()) + if(artsInst.getArt(artPlace.slot)) { if(ArtifactUtilsClient::askToDisassemble(artsInst.getHero(), artPlace.slot)) return; @@ -232,18 +201,19 @@ void CWindowWithArtifacts::showArtifactAssembling(const CArtifactsOfHeroBase & a } } -void CWindowWithArtifacts::showArifactInfo(CArtPlace & artPlace, const Point & cursorPosition) +void CWindowWithArtifacts::showArifactInfo(CArtPlace & artPlace, const Point & cursorPosition) const { if(artPlace.getArt() && artPlace.text.size()) artPlace.LRClickableAreaWTextComp::showPopupWindow(cursorPosition); } -void CWindowWithArtifacts::showQuickBackpackWindow(const CArtifactsOfHeroBase & artsInst, CArtPlace & artPlace, const Point & cursorPosition) +void CWindowWithArtifacts::showQuickBackpackWindow(const CGHeroInstance & hero, const ArtifactPosition & slot, + const Point & cursorPosition) const { if(!settings["general"]["enableUiEnhancements"].Bool()) return; - GH.windows().createAndPushWindow(artsInst.getHero(), artPlace.slot); + GH.windows().createAndPushWindow(&hero, slot); auto backpackWindow = GH.windows().topWindow(); backpackWindow->moveTo(cursorPosition - Point(1, 1)); backpackWindow->fitToScreen(15); @@ -252,7 +222,10 @@ void CWindowWithArtifacts::showQuickBackpackWindow(const CArtifactsOfHeroBase & void CWindowWithArtifacts::activate() { if(const auto art = getPickedArtifact()) + { + markPossibleSlots(); setCursorAnimation(*art); + } CWindowObject::activate(); } @@ -278,26 +251,22 @@ void CWindowWithArtifacts::artifactRemoved(const ArtifactLocation & artLoc) update(); } -void CWindowWithArtifacts::artifactMoved(const ArtifactLocation & srcLoc, const ArtifactLocation & destLoc, bool withRedraw) +void CWindowWithArtifacts::artifactMoved(const ArtifactLocation & srcLoc, const ArtifactLocation & destLoc) { - auto artifactMovedBody = [this](auto artSetPtr) - { - if(const auto pickedArtInst = getPickedArtifact()) - { - setCursorAnimation(*pickedArtInst); - } - else - { - artSetPtr->unmarkSlots(); - CCS->curh->dragAndDropCursor(nullptr); - } - }; - for(auto & artSet : artSets) - std::visit(artifactMovedBody, artSet); - - if(withRedraw) - update(); + std::visit([this](auto artSetPtr) + { + if(const auto pickedArtInst = getPickedArtifact()) + { + markPossibleSlots(); + setCursorAnimation(*pickedArtInst); + } + else + { + artSetPtr->unmarkSlots(); + CCS->curh->dragAndDropCursor(nullptr); + } + }, artSet); } void CWindowWithArtifacts::artifactDisassembled(const ArtifactLocation & artLoc) @@ -314,27 +283,14 @@ void CWindowWithArtifacts::artifactAssembled(const ArtifactLocation & artLoc) void CWindowWithArtifacts::update() { for(auto & artSet : artSets) - std::visit([this](auto artSetPtr) + std::visit([](auto artSetPtr) { artSetPtr->updateWornSlots(); artSetPtr->updateBackpackSlots(); - // Update arts bonuses on window. - // TODO rework this part when CHeroWindow and CExchangeWindow are reworked - if(auto * chw = dynamic_cast(this)) - { - chw->update(artSetPtr->getHero(), true); - } - else if(auto * cew = dynamic_cast(this)) - { - cew->updateWidgets(); - } - // Make sure the status bar is updated so it does not display old text if(auto artPlace = artSetPtr->getArtPlace(GH.getCursorPosition())) artPlace->hover(true); - - artSetPtr->redraw(); }, artSet); } @@ -385,7 +341,6 @@ bool CWindowWithArtifacts::checkSpecialArts(const CArtifactInstance & artInst, c void CWindowWithArtifacts::setCursorAnimation(const CArtifactInstance & artInst) { - markPossibleSlots(); if(artInst.isScroll() && settings["general"]["enableUiEnhancements"].Bool()) { assert(artInst.getScrollSpellID().num >= 0); @@ -427,3 +382,49 @@ void CWindowWithArtifacts::putPickedArtifact(const CGHeroInstance & curHero, con LOCPLINT->cb->swapArtifacts(srcLoc, dstLoc); } } + +void CWindowWithArtifacts::onClickPressedCommonArtifact(const CGHeroInstance & curHero, const ArtifactPosition & slot, bool closeWindow) +{ + assert(curHero.getArt(slot)); + auto srcLoc = ArtifactLocation(curHero.id, slot); + auto dstLoc = ArtifactLocation(curHero.id, ArtifactPosition::TRANSITION_POS); + + if(GH.isKeyboardCmdDown()) + { + for(auto & anotherSet : artSets) + { + if(std::holds_alternative>(anotherSet)) + { + const auto anotherHeroEquipment = std::get>(anotherSet); + if(curHero.id != anotherHeroEquipment->getHero()->id) + { + dstLoc.slot = ArtifactPosition::FIRST_AVAILABLE; + dstLoc.artHolder = anotherHeroEquipment->getHero()->id; + break; + } + } + if(std::holds_alternative>(anotherSet)) + { + const auto heroEquipment = std::get>(anotherSet); + dstLoc.slot = ArtifactPosition::FIRST_AVAILABLE; + dstLoc.artHolder = heroEquipment->altarId; + break; + } + } + } + else if(GH.isKeyboardAltDown()) + { + const auto artId = curHero.getArt(slot)->getTypeId(); + if(ArtifactUtils::isSlotEquipment(slot)) + dstLoc.slot = ArtifactUtils::getArtBackpackPosition(&curHero, artId); + else if(ArtifactUtils::isSlotBackpack(slot)) + dstLoc.slot = ArtifactUtils::getArtEquippedPosition(&curHero, artId); + } + else if(closeWindow && closeCallback) + { + closeCallback(); + } + if(dstLoc.slot != ArtifactPosition::PRE_FIRST) + LOCPLINT->cb->swapArtifacts(srcLoc, dstLoc); + +} diff --git a/client/windows/CWindowWithArtifacts.h b/client/windows/CWindowWithArtifacts.h index 9ab26a713..3c495d49f 100644 --- a/client/windows/CWindowWithArtifacts.h +++ b/client/windows/CWindowWithArtifacts.h @@ -39,23 +39,24 @@ public: const CArtifactInstance * getPickedArtifact(); void clickPressedOnArtPlace(const CGHeroInstance & hero, const ArtifactPosition & slot, bool allowExchange, bool altarTrading, bool closeWindow); - void swapArtifactAndClose(const CArtifactsOfHeroBase & artsInst, CArtPlace & artPlace, const ArtifactLocation & dstLoc); - void showArtifactAssembling(const CArtifactsOfHeroBase & artsInst, CArtPlace & artPlace, const Point & cursorPosition); - void showArifactInfo(CArtPlace & artPlace, const Point & cursorPosition); - void showQuickBackpackWindow(const CArtifactsOfHeroBase & artsInst, CArtPlace & artPlace, const Point & cursorPosition); + 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 activate() override; void deactivate() override; void enableArtifactsCostumeSwitcher() const; virtual void artifactRemoved(const ArtifactLocation & artLoc); - virtual void artifactMoved(const ArtifactLocation & srcLoc, const ArtifactLocation & destLoc, bool withRedraw); + virtual void artifactMoved(const ArtifactLocation & srcLoc, const ArtifactLocation & destLoc); virtual void artifactDisassembled(const ArtifactLocation & artLoc); virtual void artifactAssembled(const ArtifactLocation & artLoc); + virtual void update(); protected: - void update(); void markPossibleSlots(); 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 onClickPressedCommonArtifact(const CGHeroInstance & curHero, const ArtifactPosition & slot, bool closeWindow); }; diff --git a/client/windows/GUIClasses.cpp b/client/windows/GUIClasses.cpp index 38d6677b9..7fb7f55a0 100644 --- a/client/windows/GUIClasses.cpp +++ b/client/windows/GUIClasses.cpp @@ -925,7 +925,7 @@ CExchangeWindow::CExchangeWindow(ObjectInstanceID hero1, ObjectInstanceID hero2, } } - updateWidgets(); + update(); } const CGarrisonSlot * CExchangeWindow::getSelectedSlotID() const @@ -937,7 +937,7 @@ void CExchangeWindow::updateGarrisons() { garr->recreateSlots(); - updateWidgets(); + update(); } bool CExchangeWindow::holdsGarrison(const CArmedInstance * army) @@ -951,8 +951,9 @@ void CExchangeWindow::questlog(int whichHero) LOCPLINT->showQuestLog(); } -void CExchangeWindow::updateWidgets() +void CExchangeWindow::update() { + CWindowWithArtifacts::update(); for(size_t leftRight : {0, 1}) { const CGHeroInstance * hero = heroInst.at(leftRight); diff --git a/client/windows/GUIClasses.h b/client/windows/GUIClasses.h index 6cce1a0ea..5edd609a2 100644 --- a/client/windows/GUIClasses.h +++ b/client/windows/GUIClasses.h @@ -328,7 +328,7 @@ public: void questlog(int whichHero); //questlog button callback; whichHero: 0 - left, 1 - right - void updateWidgets(); + void update() override; const CGarrisonSlot * getSelectedSlotID() const;