mirror of
https://github.com/vcmi/vcmi.git
synced 2024-12-24 22:14:36 +02:00
preparation
This commit is contained in:
parent
3b06abd0d7
commit
bd0f9bb280
@ -14,12 +14,13 @@
|
||||
#include "CMusicHandler.h"
|
||||
#include "CGameInfo.h"
|
||||
#include "renderSDL/SDLRWwrapper.h"
|
||||
#include "eventsSDL/InputHandler.h"
|
||||
#include "gui/CGuiHandler.h"
|
||||
|
||||
#include "../lib/JsonNode.h"
|
||||
#include "../lib/GameConstants.h"
|
||||
#include "../lib/filesystem/Filesystem.h"
|
||||
#include "../lib/constants/StringConstants.h"
|
||||
#include "../lib/StringConstants.h"
|
||||
#include "../lib/CRandomGenerator.h"
|
||||
#include "../lib/VCMIDirs.h"
|
||||
#include "../lib/TerrainHandler.h"
|
||||
@ -629,7 +630,8 @@ bool MusicEntry::play()
|
||||
}
|
||||
}
|
||||
|
||||
startTime = SDL_GetTicks();
|
||||
startTime = GH.input().getTicks();
|
||||
|
||||
playing = true;
|
||||
return true;
|
||||
}
|
||||
@ -640,7 +642,7 @@ bool MusicEntry::stop(int fade_ms)
|
||||
{
|
||||
playing = false;
|
||||
loop = 0;
|
||||
uint32_t endTime = SDL_GetTicks();
|
||||
uint32_t endTime = GH.input().getTicks();
|
||||
assert(startTime != uint32_t(-1));
|
||||
float playDuration = (endTime - startTime + startPosition) / 1000.f;
|
||||
owner->trackPositions[currentName] = playDuration;
|
||||
|
@ -28,6 +28,7 @@
|
||||
#include "../../lib/CConfigHandler.h"
|
||||
|
||||
#include <SDL_events.h>
|
||||
#include <SDL_timer.h>
|
||||
|
||||
InputHandler::InputHandler()
|
||||
: mouseHandler(std::make_unique<InputSourceMouse>())
|
||||
@ -253,6 +254,11 @@ void InputHandler::hapticFeedback()
|
||||
fingerHandler->hapticFeedback();
|
||||
}
|
||||
|
||||
uint64_t InputHandler::getTicks()
|
||||
{
|
||||
return SDL_GetTicks64();
|
||||
}
|
||||
|
||||
bool InputHandler::hasTouchInputDevice() const
|
||||
{
|
||||
return fingerHandler->hasTouchInputDevice();
|
||||
|
@ -68,6 +68,9 @@ public:
|
||||
/// do a haptic feedback
|
||||
void hapticFeedback();
|
||||
|
||||
/// Get the number of milliseconds since SDL library initialization
|
||||
uint64_t getTicks();
|
||||
|
||||
/// returns true if system has active touchscreen
|
||||
bool hasTouchInputDevice() const;
|
||||
|
||||
|
@ -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;
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user