1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-01-26 03:52:01 +02:00

Add quick swapping artifacts between heroes via CTRL+click

This commit is contained in:
M 2024-04-20 20:25:45 +02:00
parent bfda73f69f
commit 9e6f558631

View File

@ -148,7 +148,34 @@ void CWindowWithArtifacts::clickPressedArtPlaceHero(CArtifactsOfHeroBase & artsI
{
assert(artSetPtr->getHero()->getSlotByInstance(art) != ArtifactPosition::PRE_FIRST);
if(GH.isKeyboardAltDown())
if(GH.isKeyboardCtrlDown())
{
std::shared_ptr<CArtifactsOfHeroMain> anotherHeroEquipmentPointer = nullptr;
for(auto set : artSets)
{
if(std::holds_alternative<std::weak_ptr<CArtifactsOfHeroMain>>(set))
{
std::shared_ptr<CArtifactsOfHeroMain> heroEquipmentPointer = std::get<std::weak_ptr<CArtifactsOfHeroMain>>(set).lock();
if(heroEquipmentPointer->getHero()->id != artSetPtr->getHero()->id)
{
anotherHeroEquipmentPointer = heroEquipmentPointer;
break;
}
}
}
if(anotherHeroEquipmentPointer != nullptr)
{
ArtifactPosition availablePosition = ArtifactUtils::getArtAnyPosition(anotherHeroEquipmentPointer->getHero(), art->getTypeId());
if(availablePosition != ArtifactPosition::PRE_FIRST)
{
LOCPLINT->cb->swapArtifacts(ArtifactLocation(artSetPtr->getHero()->id, artSetPtr->getHero()->getSlotByInstance(art)),
ArtifactLocation(anotherHeroEquipmentPointer->getHero()->id, availablePosition));
}
}
}
else if(GH.isKeyboardAltDown())
{
ArtifactPosition destinationPosition = ArtifactPosition::PRE_FIRST;