mirror of
https://github.com/vcmi/vcmi.git
synced 2025-08-13 19:54:17 +02:00
Minor improvements to swipe in battle
This commit is contained in:
@@ -96,31 +96,22 @@ void BattleFieldController::panning(bool on, const Point & initialPosition, cons
|
||||
|
||||
void BattleFieldController::gesturePanning(const Point & initialPosition, const Point & currentPosition, const Point & lastUpdateDistance)
|
||||
{
|
||||
if (pos.isInside(currentPosition))
|
||||
{
|
||||
hoveredHex = getHexAtPosition(initialPosition);
|
||||
currentAttackDirection = selectAttackDirection(getHoveredHex(), currentPosition);
|
||||
hoveredHex = getHexAtPosition(initialPosition);
|
||||
currentAttackOriginPoint = currentPosition;
|
||||
|
||||
if (pos.isInside(initialPosition))
|
||||
owner.actionsController->onHexHovered(getHoveredHex());
|
||||
}
|
||||
else
|
||||
{
|
||||
hoveredHex = BattleHex::INVALID;
|
||||
}
|
||||
}
|
||||
|
||||
void BattleFieldController::mouseMoved(const Point & cursorPosition)
|
||||
{
|
||||
hoveredHex = getHexAtPosition(cursorPosition);
|
||||
currentAttackDirection = selectAttackDirection(getHoveredHex(), cursorPosition);
|
||||
currentAttackOriginPoint = cursorPosition;
|
||||
|
||||
if (!pos.isInside(cursorPosition))
|
||||
{
|
||||
if (pos.isInside(cursorPosition))
|
||||
owner.actionsController->onHexHovered(getHoveredHex());
|
||||
else
|
||||
owner.actionsController->onHoverEnded();
|
||||
return;
|
||||
}
|
||||
|
||||
owner.actionsController->onHexHovered(getHoveredHex());
|
||||
}
|
||||
|
||||
void BattleFieldController::clickLeft(tribool down, bool previousState)
|
||||
@@ -161,7 +152,7 @@ void BattleFieldController::renderBattlefield(Canvas & canvas)
|
||||
|
||||
void BattleFieldController::showBackground(Canvas & canvas)
|
||||
{
|
||||
if (owner.stacksController->getActiveStack() != nullptr ) //&& creAnims[stacksController->getActiveStack()->unitId()]->isIdle() //show everything with range
|
||||
if (owner.stacksController->getActiveStack() != nullptr )
|
||||
showBackgroundImageWithHexes(canvas);
|
||||
else
|
||||
showBackgroundImage(canvas);
|
||||
@@ -193,7 +184,7 @@ void BattleFieldController::showBackgroundImage(Canvas & canvas)
|
||||
|
||||
void BattleFieldController::showBackgroundImageWithHexes(Canvas & canvas)
|
||||
{
|
||||
canvas.draw(*backgroundWithHexes.get(), Point(0, 0));
|
||||
canvas.draw(*backgroundWithHexes, Point(0, 0));
|
||||
}
|
||||
|
||||
void BattleFieldController::redrawBackgroundWithHexes()
|
||||
@@ -457,7 +448,7 @@ void BattleFieldController::setBattleCursor(BattleHex myNumber)
|
||||
Cursor::Combat::HIT_NORTH,
|
||||
};
|
||||
|
||||
auto direction = static_cast<size_t>(currentAttackDirection);
|
||||
auto direction = static_cast<size_t>(selectAttackDirection(getHoveredHex(), currentAttackOriginPoint));
|
||||
|
||||
assert(direction != -1);
|
||||
if (direction != -1)
|
||||
@@ -540,7 +531,7 @@ BattleHex::EDir BattleFieldController::selectAttackDirection(BattleHex myNumber,
|
||||
|
||||
BattleHex BattleFieldController::fromWhichHexAttack(BattleHex attackTarget)
|
||||
{
|
||||
BattleHex::EDir direction = currentAttackDirection;
|
||||
BattleHex::EDir direction = selectAttackDirection(getHoveredHex(), currentAttackOriginPoint);
|
||||
|
||||
const CStack * attacker = owner.stacksController->getActiveStack();
|
||||
|
||||
|
@@ -10,14 +10,12 @@
|
||||
#pragma once
|
||||
|
||||
#include "../../lib/battle/BattleHex.h"
|
||||
#include "../../lib/Point.h"
|
||||
#include "../gui/CIntObject.h"
|
||||
|
||||
VCMI_LIB_NAMESPACE_BEGIN
|
||||
|
||||
class CStack;
|
||||
class Rect;
|
||||
class Point;
|
||||
|
||||
VCMI_LIB_NAMESPACE_END
|
||||
|
||||
class BattleHero;
|
||||
@@ -40,7 +38,7 @@ class BattleFieldController : public CIntObject
|
||||
std::unique_ptr<Canvas> backgroundWithHexes;
|
||||
|
||||
/// direction which will be used to perform attack with current cursor position
|
||||
BattleHex::EDir currentAttackDirection;
|
||||
Point currentAttackOriginPoint;
|
||||
|
||||
/// hex currently under mouse hover
|
||||
BattleHex hoveredHex;
|
||||
|
@@ -24,10 +24,10 @@ void InputSourceMouse::handleEventMouseMotion(const SDL_MouseMotionEvent & motio
|
||||
Point newPosition(motion.x, motion.y);
|
||||
Point distance(-motion.xrel, -motion.yrel);
|
||||
|
||||
GH.input().setCursorPosition(newPosition);
|
||||
|
||||
if (mouseButtonsMask & SDL_BUTTON(SDL_BUTTON_MIDDLE))
|
||||
GH.events().dispatchGesturePanning(middleClickPosition, newPosition, distance);
|
||||
else
|
||||
GH.input().setCursorPosition(newPosition);
|
||||
|
||||
mouseButtonsMask = motion.state;
|
||||
}
|
||||
|
@@ -72,17 +72,15 @@ enum class TouchState
|
||||
|
||||
struct TouchInputParameters
|
||||
{
|
||||
/// Speed factor of mouse pointer when relative mode is used
|
||||
double relativeModeSpeedFactor = 1.0;
|
||||
|
||||
/// tap for period longer than specified here will be qualified as "long tap", triggering corresponding gesture
|
||||
uint32_t longPressTimeMilliseconds = 500;
|
||||
uint32_t longPressTimeMilliseconds = 750;
|
||||
|
||||
/// moving finger for distance larger than specified will be qualified as panning gesture instead of long press
|
||||
uint32_t panningSensitivityThreshold = 16;
|
||||
uint32_t panningSensitivityThreshold = 10;
|
||||
|
||||
bool useHoldGesture = true;
|
||||
bool usePanGesture = true;
|
||||
bool usePinchGesture = true;
|
||||
bool useRelativeMode = false;
|
||||
};
|
||||
|
||||
|
Reference in New Issue
Block a user