mirror of
https://github.com/vcmi/vcmi.git
synced 2025-01-12 02:28:11 +02:00
Artifacts altar ctrl+click
This commit is contained in:
parent
09bb9895ce
commit
0501073d4c
@ -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<CWindowWithArtifacts>())
|
||||
artWin->artifactMoved(src, dst, redraw);
|
||||
|
||||
{
|
||||
artWin->artifactMoved(src, dst);
|
||||
if(numOfMovedArts == 0)
|
||||
artWin->update();
|
||||
}
|
||||
waitWhileDialog();
|
||||
}
|
||||
|
||||
|
@ -16,6 +16,8 @@
|
||||
class CArtifactsOfHeroAltar : public CArtifactsOfHeroBase
|
||||
{
|
||||
public:
|
||||
ObjectInstanceID altarId;
|
||||
|
||||
CArtifactsOfHeroAltar(const Point & position);
|
||||
void deactivate() override;
|
||||
};
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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;
|
||||
|
@ -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))
|
||||
{
|
||||
|
@ -18,5 +18,5 @@ public:
|
||||
std::function<void()> onClickNotTradableCallback;
|
||||
|
||||
CArtifactsOfHeroMarket(const Point & position, const int selectionWidth);
|
||||
void onClickPrassedArtPlace(CArtPlace & artPlace);
|
||||
void onClickPressedArtPlace(CArtPlace & artPlace);
|
||||
};
|
||||
|
@ -32,7 +32,6 @@ CAltarArtifacts::CAltarArtifacts(const IMarket * market, const CGHeroInstance *
|
||||
|
||||
assert(dynamic_cast<const CGArtifactsAltar*>(market));
|
||||
auto altarObj = dynamic_cast<const CGArtifactsAltar*>(market);
|
||||
altarId = altarObj->id;
|
||||
altarArtifacts = altarObj;
|
||||
|
||||
deal = std::make_shared<CButton>(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<CArtifactsOfHeroAltar>(Point(-365, -11));
|
||||
heroArts->setHero(hero);
|
||||
heroArts->altarId = altarObj->id;
|
||||
|
||||
// Altar
|
||||
offerTradePanel = std::make_shared<ArtifactsAltarPanel>([this](const std::shared_ptr<CTradeableItem> & 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<CArtifactsOfHeroAltar> 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<CTradeableItem> &
|
||||
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<CTradeableItem> &
|
||||
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);
|
||||
}
|
||||
|
@ -26,7 +26,6 @@ public:
|
||||
void putBackArtifacts();
|
||||
|
||||
private:
|
||||
ObjectInstanceID altarId;
|
||||
const CArtifactSet * altarArtifacts;
|
||||
std::shared_ptr<CButton> sacrificeBackpackButton;
|
||||
std::shared_ptr<CArtifactsOfHeroAltar> heroArts;
|
||||
|
@ -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<CLabel>(69, 232, FONT_SMALL, ETextAlignment::TOPLEFT, Colors::YELLOW, CGI->generaltexth->jktexts[6]));
|
||||
labels.push_back(std::make_shared<CLabel>(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()
|
||||
|
@ -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();
|
||||
|
@ -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
|
||||
|
@ -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);
|
||||
|
@ -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<decltype(artSet), std::shared_ptr<CArtifactsOfHeroQuickBackpack>>)
|
||||
@ -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<std::shared_ptr<CArtifactsOfHeroMain>>(anotherSet))
|
||||
{
|
||||
const auto anotherHeroEquipment = std::get<std::shared_ptr<CArtifactsOfHeroMain>>(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<CHeroQuickBackpackWindow>(artsInst.getHero(), artPlace.slot);
|
||||
GH.windows().createAndPushWindow<CHeroQuickBackpackWindow>(&hero, slot);
|
||||
auto backpackWindow = GH.windows().topWindow<CHeroQuickBackpackWindow>();
|
||||
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<CHeroWindow*>(this))
|
||||
{
|
||||
chw->update(artSetPtr->getHero(), true);
|
||||
}
|
||||
else if(auto * cew = dynamic_cast<CExchangeWindow*>(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<std::shared_ptr<CArtifactsOfHeroMain>>(anotherSet))
|
||||
{
|
||||
const auto anotherHeroEquipment = std::get<std::shared_ptr<CArtifactsOfHeroMain>>(anotherSet);
|
||||
if(curHero.id != anotherHeroEquipment->getHero()->id)
|
||||
{
|
||||
dstLoc.slot = ArtifactPosition::FIRST_AVAILABLE;
|
||||
dstLoc.artHolder = anotherHeroEquipment->getHero()->id;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(std::holds_alternative<std::shared_ptr<CArtifactsOfHeroAltar>>(anotherSet))
|
||||
{
|
||||
const auto heroEquipment = std::get<std::shared_ptr<CArtifactsOfHeroAltar>>(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);
|
||||
|
||||
}
|
||||
|
@ -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);
|
||||
};
|
||||
|
@ -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);
|
||||
|
@ -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;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user