mirror of
https://github.com/vcmi/vcmi.git
synced 2025-04-15 11:46:56 +02:00
code review
This commit is contained in:
parent
6b71820197
commit
4eecca2d9a
@ -87,7 +87,7 @@ void MapView::tick(uint32_t msPassed)
|
|||||||
{
|
{
|
||||||
postSwipe(msPassed);
|
postSwipe(msPassed);
|
||||||
|
|
||||||
controller->tick(msPassed);
|
BasicMapView::tick(msPassed);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MapView::show(Canvas & to)
|
void MapView::show(Canvas & to)
|
||||||
@ -123,7 +123,7 @@ void MapView::onMapScrolled(const Point & distance)
|
|||||||
|
|
||||||
void MapView::onMapSwiped(const Point & viewPosition)
|
void MapView::onMapSwiped(const Point & viewPosition)
|
||||||
{
|
{
|
||||||
swipeHistory[GH.input().getTicks()] = viewPosition;
|
swipeHistory.push_back(std::pair<uint32_t, Point>(GH.input().getTicks(), viewPosition));
|
||||||
|
|
||||||
controller->setViewCenter(model->getMapViewCenter() + viewPosition, model->getLevel());
|
controller->setViewCenter(model->getMapViewCenter() + viewPosition, model->getLevel());
|
||||||
}
|
}
|
||||||
@ -150,7 +150,8 @@ void MapView::postSwipe(uint32_t msPassed) {
|
|||||||
postSwipeSpeed = static_cast<double>(diff.length()) / static_cast<double>(timediff); // unit: pixel/millisecond
|
postSwipeSpeed = static_cast<double>(diff.length()) / static_cast<double>(timediff); // unit: pixel/millisecond
|
||||||
}
|
}
|
||||||
swipeHistory.clear();
|
swipeHistory.clear();
|
||||||
}
|
} else
|
||||||
|
postSwipeSpeed = 0.0;
|
||||||
if(postSwipeSpeed > 0.1) {
|
if(postSwipeSpeed > 0.1) {
|
||||||
double len = postSwipeSpeed * static_cast<double>(msPassed);
|
double len = postSwipeSpeed * static_cast<double>(msPassed);
|
||||||
Point delta = Point(len * cos(postSwipeAngle), len * sin(postSwipeAngle));
|
Point delta = Point(len * cos(postSwipeAngle), len * sin(postSwipeAngle));
|
||||||
|
@ -49,9 +49,9 @@ class MapView : public BasicMapView
|
|||||||
{
|
{
|
||||||
std::shared_ptr<MapViewActions> actions;
|
std::shared_ptr<MapViewActions> actions;
|
||||||
|
|
||||||
std::map<uint32_t, Point> swipeHistory;
|
std::vector<std::pair<uint32_t, Point>> swipeHistory;
|
||||||
double postSwipeAngle;
|
double postSwipeAngle = 0.0;
|
||||||
double postSwipeSpeed;
|
double postSwipeSpeed = 0.0;
|
||||||
|
|
||||||
void postSwipe(uint32_t msPassed);
|
void postSwipe(uint32_t msPassed);
|
||||||
|
|
||||||
|
@ -121,6 +121,8 @@ void MapViewActions::gesturePinch(const Point & centerPosition, double lastUpdat
|
|||||||
|
|
||||||
void MapViewActions::gesture(bool on, const Point & initialPosition, const Point & finalPosition)
|
void MapViewActions::gesture(bool on, const Point & initialPosition, const Point & finalPosition)
|
||||||
{
|
{
|
||||||
|
dragActive = on;
|
||||||
|
|
||||||
pinchZoomFactor = 1.0;
|
pinchZoomFactor = 1.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user