mirror of
https://github.com/vcmi/vcmi.git
synced 2024-12-24 22:14:36 +02:00
Add quick artifact equip-unequip via holding alt button while clicking
This commit is contained in:
parent
6fed084055
commit
bfda73f69f
@ -147,8 +147,39 @@ void CWindowWithArtifacts::clickPressedArtPlaceHero(CArtifactsOfHeroBase & artsI
|
||||
if(checkSpecialArts(*art, hero, std::is_same_v<decltype(artSetWeak), std::weak_ptr<CArtifactsOfHeroAltar>> ? true : false))
|
||||
{
|
||||
assert(artSetPtr->getHero()->getSlotByInstance(art) != ArtifactPosition::PRE_FIRST);
|
||||
LOCPLINT->cb->swapArtifacts(ArtifactLocation(artSetPtr->getHero()->id, artSetPtr->getHero()->getSlotByInstance(art)),
|
||||
ArtifactLocation(artSetPtr->getHero()->id, ArtifactPosition::TRANSITION_POS));
|
||||
|
||||
if(GH.isKeyboardAltDown())
|
||||
{
|
||||
ArtifactPosition destinationPosition = ArtifactPosition::PRE_FIRST;
|
||||
|
||||
if(ArtifactUtils::isSlotEquipment(artSetPtr->getHero()->getSlotByInstance(art)))
|
||||
{
|
||||
ArtifactPosition availablePosition = ArtifactUtils::getArtBackpackPosition(artSetPtr->getHero(), art->getTypeId());
|
||||
if(availablePosition != ArtifactPosition::PRE_FIRST)
|
||||
{
|
||||
destinationPosition = availablePosition;
|
||||
}
|
||||
}
|
||||
else if(ArtifactUtils::isSlotBackpack(artSetPtr->getHero()->getSlotByInstance(art)))
|
||||
{
|
||||
ArtifactPosition availablePosition = ArtifactUtils::getArtAnyPosition(artSetPtr->getHero(), art->getTypeId());
|
||||
if(availablePosition != ArtifactPosition::PRE_FIRST && availablePosition != ArtifactPosition::BACKPACK_START)
|
||||
{
|
||||
destinationPosition = availablePosition;
|
||||
}
|
||||
}
|
||||
|
||||
if(destinationPosition != ArtifactPosition::PRE_FIRST)
|
||||
{
|
||||
LOCPLINT->cb->swapArtifacts(ArtifactLocation(artSetPtr->getHero()->id, artSetPtr->getHero()->getSlotByInstance(art)),
|
||||
ArtifactLocation(artSetPtr->getHero()->id, destinationPosition));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
LOCPLINT->cb->swapArtifacts(ArtifactLocation(artSetPtr->getHero()->id, artSetPtr->getHero()->getSlotByInstance(art)),
|
||||
ArtifactLocation(artSetPtr->getHero()->id, ArtifactPosition::TRANSITION_POS));
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
|
Loading…
Reference in New Issue
Block a user