mirror of
https://github.com/vcmi/vcmi.git
synced 2025-04-13 11:40:38 +02:00
Add ctrl+click and shift+click behavior for creatures "arrows" - hero exchange
This commit is contained in:
parent
3f390c4aac
commit
a6ab76d3ec
@ -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)
|
void CExchangeController::swapArtifacts(bool equipped, bool baclpack)
|
||||||
{
|
{
|
||||||
LOCPLINT->cb->bulkMoveArtifacts(left->id, right->id, true, equipped, baclpack);
|
LOCPLINT->cb->bulkMoveArtifacts(left->id, right->id, true, equipped, baclpack);
|
||||||
|
@ -20,6 +20,7 @@ public:
|
|||||||
void swapArmy();
|
void swapArmy();
|
||||||
void moveArmy(bool leftToRight, std::optional<SlotID> heldSlot);
|
void moveArmy(bool leftToRight, std::optional<SlotID> heldSlot);
|
||||||
void moveStack(bool leftToRight, SlotID sourceSlot);
|
void moveStack(bool leftToRight, SlotID sourceSlot);
|
||||||
|
void moveSingleStackCreature(bool leftToRight, SlotID sourceSlot, bool forceEmptySlotTarget);
|
||||||
void swapArtifacts(bool equipped, bool baclpack);
|
void swapArtifacts(bool equipped, bool baclpack);
|
||||||
void moveArtifacts(bool leftToRight, bool equipped, bool baclpack);
|
void moveArtifacts(bool leftToRight, bool equipped, bool baclpack);
|
||||||
|
|
||||||
|
@ -268,6 +268,10 @@ void CExchangeWindow::creatureArrowButtonCallback(bool leftToRight, SlotID slotI
|
|||||||
{
|
{
|
||||||
if (GH.isKeyboardAltDown())
|
if (GH.isKeyboardAltDown())
|
||||||
controller.moveArmy(leftToRight, slotId);
|
controller.moveArmy(leftToRight, slotId);
|
||||||
|
else if (GH.isKeyboardCtrlDown())
|
||||||
|
controller.moveSingleStackCreature(leftToRight, slotId, true);
|
||||||
|
else if (GH.isKeyboardShiftDown())
|
||||||
|
controller.moveSingleStackCreature(leftToRight, slotId, false);
|
||||||
else
|
else
|
||||||
controller.moveStack(leftToRight, slotId);
|
controller.moveStack(leftToRight, slotId);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user