mirror of
https://github.com/vcmi/vcmi.git
synced 2025-11-25 22:42:04 +02:00
preparation
This commit is contained in:
@@ -25,6 +25,7 @@
|
||||
#include "../render/Canvas.h"
|
||||
#include "../render/IImage.h"
|
||||
#include "../renderSDL/SDL_Extensions.h"
|
||||
#include "../eventsSDL/InputHandler.h"
|
||||
|
||||
#include "../../CCallback.h"
|
||||
|
||||
@@ -82,6 +83,13 @@ void BasicMapView::showAll(Canvas & to)
|
||||
render(to, true);
|
||||
}
|
||||
|
||||
void MapView::tick(uint32_t msPassed)
|
||||
{
|
||||
postSwipe(msPassed);
|
||||
|
||||
controller->tick(msPassed);
|
||||
}
|
||||
|
||||
void MapView::show(Canvas & to)
|
||||
{
|
||||
actions->setContext(controller->getContext());
|
||||
@@ -115,9 +123,16 @@ void MapView::onMapScrolled(const Point & distance)
|
||||
|
||||
void MapView::onMapSwiped(const Point & viewPosition)
|
||||
{
|
||||
swipeHistory[GH.input().getTicks()] = viewPosition;
|
||||
|
||||
controller->setViewCenter(model->getMapViewCenter() + viewPosition, model->getLevel());
|
||||
}
|
||||
|
||||
void MapView::postSwipe(uint32_t msPassed) {
|
||||
if(!actions->dragActive)
|
||||
swipeHistory.clear();
|
||||
}
|
||||
|
||||
void MapView::onCenteredTile(const int3 & tile)
|
||||
{
|
||||
controller->setViewCenter(tile);
|
||||
|
||||
@@ -49,7 +49,12 @@ class MapView : public BasicMapView
|
||||
{
|
||||
std::shared_ptr<MapViewActions> actions;
|
||||
|
||||
std::map<uint64_t, Point> swipeHistory;
|
||||
|
||||
void postSwipe(uint32_t msPassed);
|
||||
|
||||
public:
|
||||
void tick(uint32_t msPassed) override;
|
||||
void show(Canvas & to) override;
|
||||
|
||||
MapView(const Point & offset, const Point & dimensions);
|
||||
|
||||
@@ -24,7 +24,6 @@ class MapViewActions : public CIntObject
|
||||
|
||||
Point dragDistance;
|
||||
double pinchZoomFactor;
|
||||
bool dragActive;
|
||||
|
||||
void handleHover(const Point & cursorPosition);
|
||||
|
||||
@@ -44,4 +43,6 @@ public:
|
||||
void mouseMoved(const Point & cursorPosition, const Point & lastUpdateDistance) override;
|
||||
void mouseDragged(const Point & cursorPosition, const Point & lastUpdateDistance) override;
|
||||
void wheelScrolled(int distance) override;
|
||||
|
||||
bool dragActive;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user