1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-07-05 00:49:09 +02:00

Add ctrl+click and shift+click behavior for creatures "arrows" - hero exchange

This commit is contained in:
Dydzio
2025-02-15 18:49:12 +01:00
parent 3f390c4aac
commit a6ab76d3ec
3 changed files with 21 additions and 0 deletions

View File

@ -110,6 +110,22 @@ void CExchangeController::moveStack(bool leftToRight, SlotID sourceSlot)
}
}
void CExchangeController::moveSingleStackCreature(bool leftToRight, SlotID sourceSlot, bool forceEmptySlotTarget)
{
const auto source = leftToRight ? left : right;
const auto target = leftToRight ? right : left;
auto creature = source->getCreature(sourceSlot);
if(creature == nullptr || source->stacksCount() == 1)
return;
SlotID targetSlot = forceEmptySlotTarget ? target->getFreeSlot() : target->getSlotFor(creature);
if(targetSlot.validSlot())
{
LOCPLINT->cb->splitStack(source, target, sourceSlot, targetSlot, target->getStackCount(targetSlot) + 1);
}
}
void CExchangeController::swapArtifacts(bool equipped, bool baclpack)
{
LOCPLINT->cb->bulkMoveArtifacts(left->id, right->id, true, equipped, baclpack);