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

It is now possible to cancel attack-via-swiping by moving finger away

This commit is contained in:
Ivan Savenko 2023-06-05 15:09:10 +03:00
parent 6283329aeb
commit 238a02eb5e
3 changed files with 22 additions and 2 deletions

View File

@ -100,7 +100,13 @@ void BattleFieldController::panning(bool on, const Point & initialPosition, cons
void BattleFieldController::gesturePanning(const Point & initialPosition, const Point & currentPosition, const Point & lastUpdateDistance)
{
hoveredHex = getHexAtPosition(initialPosition);
Point distance = currentPosition - initialPosition;
if (distance.length() < settings["battle"]["swipeAttackDistance"].Float())
hoveredHex = getHexAtPosition(initialPosition);
else
hoveredHex = BattleHex::INVALID;
currentAttackOriginPoint = currentPosition;
if (pos.isInside(initialPosition))

View File

@ -286,7 +286,7 @@
"type" : "object",
"additionalProperties" : false,
"default" : {},
"required" : [ "speedFactor", "mouseShadow", "cellBorders", "stackRange", "movementHighlightOnHover", "showQueue", "queueSize" ],
"required" : [ "speedFactor", "mouseShadow", "cellBorders", "stackRange", "movementHighlightOnHover", "showQueue", "swipeAttackDistance", "queueSize" ],
"properties" : {
"speedFactor" : {
"type" : "number",
@ -312,6 +312,10 @@
"type" : "boolean",
"default" : true
},
"swipeAttackDistance" : {
"type" : "number",
"default" : 250
},
"queueSize" : {
"type" : "string",
"default" : "auto",

View File

@ -101,6 +101,16 @@ public:
return x > std::numeric_limits<int>::min() && y > std::numeric_limits<int>::min();
}
constexpr int lengthSquared() const
{
return x * x + y * y;
}
int length() const
{
return std::sqrt(lengthSquared());
}
template <typename Handler>
void serialize(Handler &h, const int version)
{