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

Test version of swipe gesture for in-combat attacks

This commit is contained in:
Ivan Savenko
2023-05-31 00:33:10 +03:00
parent 70155b48e1
commit b20109c830
20 changed files with 79 additions and 104 deletions

View File

@ -117,7 +117,6 @@ BattleActionsController::BattleActionsController(BattleInterface & owner):
selectedStack(nullptr),
heroSpellToCast(nullptr)
{
touchscreenMode = settings["battle"]["touchscreenMode"].Bool();
}
void BattleActionsController::endCastingSpell()
@ -826,10 +825,6 @@ void BattleActionsController::onHoverEnded()
void BattleActionsController::onHexLeftClicked(BattleHex clickedHex)
{
static BattleHex lastSelectedHex;
static BattleHex lastDirectionalHex;
static PossiblePlayerBattleAction::Actions lastSelectedAction;
if (owner.stacksController->getActiveStack() == nullptr)
return;
@ -840,24 +835,8 @@ void BattleActionsController::onHexLeftClicked(BattleHex clickedHex)
if (!actionIsLegal(action, clickedHex))
return;
auto directionalHex = lastDirectionalHex;
if(action.get() == PossiblePlayerBattleAction::ATTACK
|| action.get() == PossiblePlayerBattleAction::WALK_AND_ATTACK
|| action.get() == PossiblePlayerBattleAction::ATTACK_AND_RETURN)
directionalHex = owner.fieldController->fromWhichHexAttack(clickedHex);
if(!touchscreenMode || (lastSelectedAction == action.get() && lastSelectedHex == clickedHex && lastDirectionalHex == directionalHex))
{
actionRealize(action, clickedHex);
GH.statusbar()->clear();
}
else
{
lastSelectedAction = action.get();
lastSelectedHex = clickedHex;
lastDirectionalHex = directionalHex;
}
actionRealize(action, clickedHex);
GH.statusbar()->clear();
}
void BattleActionsController::tryActivateStackSpellcasting(const CStack *casterStack)
@ -1018,8 +997,3 @@ void BattleActionsController::pushFrontPossibleAction(PossiblePlayerBattleAction
{
possibleActions.insert(possibleActions.begin(), action);
}
void BattleActionsController::setTouchScreenMode(bool enabled)
{
touchscreenMode = enabled;
}