diff --git a/client/adventureMap/CMinimap.cpp b/client/adventureMap/CMinimap.cpp index a2e86a542..b0b79a8f5 100644 --- a/client/adventureMap/CMinimap.cpp +++ b/client/adventureMap/CMinimap.cpp @@ -88,7 +88,7 @@ void CMinimapInstance::showAll(Canvas & to) } CMinimap::CMinimap(const Rect & position) - : CIntObject(LCLICK | RCLICK | HOVER | MOVE, position.topLeft()), + : CIntObject(LCLICK | RCLICK | HOVER | MOVE | GESTURE_PANNING, position.topLeft()), level(0) { OBJECT_CONSTRUCTION_CAPTURING(255-DISPOSE); @@ -126,9 +126,9 @@ Point CMinimap::tileToPixels(const int3 &tile) const return Point(x,y); } -void CMinimap::moveAdvMapSelection() +void CMinimap::moveAdvMapSelection(const Point & positionGlobal) { - int3 newLocation = pixelToTile(GH.getCursorPosition() - pos.topLeft()); + int3 newLocation = pixelToTile(positionGlobal - pos.topLeft()); adventureInt->centerOnTile(newLocation); if (!(adventureInt->isActive())) @@ -137,10 +137,15 @@ void CMinimap::moveAdvMapSelection() redraw();//redraw only this } +void CMinimap::gesturePanning(const Point & initialPosition, const Point & currentPosition, const Point & lastUpdateDistance) +{ + moveAdvMapSelection(currentPosition); +} + void CMinimap::clickLeft(tribool down, bool previousState) { if(down) - moveAdvMapSelection(); + moveAdvMapSelection(GH.getCursorPosition()); } void CMinimap::clickRight(tribool down, bool previousState) @@ -160,7 +165,7 @@ void CMinimap::hover(bool on) void CMinimap::mouseMoved(const Point & cursorPosition) { if(isMouseButtonPressed(MouseButton::LEFT)) - moveAdvMapSelection(); + moveAdvMapSelection(cursorPosition); } void CMinimap::showAll(Canvas & to) diff --git a/client/adventureMap/CMinimap.h b/client/adventureMap/CMinimap.h index 2e7a27f54..7fe4b02a9 100644 --- a/client/adventureMap/CMinimap.h +++ b/client/adventureMap/CMinimap.h @@ -43,13 +43,14 @@ class CMinimap : public CIntObject Rect screenArea; int level; + void gesturePanning(const Point & initialPosition, const Point & currentPosition, const Point & lastUpdateDistance) override; void clickLeft(tribool down, bool previousState) override; void clickRight(tribool down, bool previousState) override; void hover (bool on) override; void mouseMoved (const Point & cursorPosition) override; /// relocates center of adventure map screen to currently hovered tile - void moveAdvMapSelection(); + void moveAdvMapSelection(const Point & positionGlobal); protected: /// computes coordinates of tile below cursor pos diff --git a/client/eventsSDL/InputHandler.cpp b/client/eventsSDL/InputHandler.cpp index b1135e593..cb272dbd6 100644 --- a/client/eventsSDL/InputHandler.cpp +++ b/client/eventsSDL/InputHandler.cpp @@ -29,7 +29,6 @@ #include "../../lib/CConfigHandler.h" #include -#include InputHandler::InputHandler() : mouseHandler(std::make_unique())