1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-11-25 22:42:04 +02:00

preparation

This commit is contained in:
Michael
2023-08-26 19:53:36 +02:00
committed by GitHub
parent 3b06abd0d7
commit bd0f9bb280
6 changed files with 36 additions and 4 deletions

View File

@@ -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);

View File

@@ -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);

View File

@@ -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;
};