1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-06-27 00:41:08 +02:00

Removed getFrameDeltaMilliseconds from gui handler

This commit is contained in:
Ivan Savenko
2023-05-14 22:30:59 +03:00
parent 8a31aeb94b
commit f84c2c3bb5
4 changed files with 5 additions and 14 deletions

View File

@ -12,6 +12,7 @@
#include "CMT.h" #include "CMT.h"
#include "gui/CGuiHandler.h" #include "gui/CGuiHandler.h"
#include "gui/FramerateManager.h"
#include "renderSDL/SDL_Extensions.h" #include "renderSDL/SDL_Extensions.h"
#include "CPlayerInterface.h" #include "CPlayerInterface.h"
#include "../lib/filesystem/Filesystem.h" #include "../lib/filesystem/Filesystem.h"
@ -370,7 +371,7 @@ void CVideoPlayer::update( int x, int y, SDL_Surface *dst, bool forceRedraw, boo
auto packet_duration = frame->duration; auto packet_duration = frame->duration;
#endif #endif
double frameEndTime = (frame->pts + packet_duration) * av_q2d(format->streams[stream]->time_base); double frameEndTime = (frame->pts + packet_duration) * av_q2d(format->streams[stream]->time_base);
frameTime += GH.getFrameDeltaMilliseconds() / 1000.0; frameTime += GH.framerateManager().getElapsedMilliseconds() / 1000.0;
if (frameTime >= frameEndTime ) if (frameTime >= frameEndTime )
{ {

View File

@ -761,11 +761,6 @@ const Point & CGuiHandler::getCursorPosition() const
return cursorPosition; return cursorPosition;
} }
uint32_t CGuiHandler::getFrameDeltaMilliseconds() const
{
return framerateManagerInstance->getElapsedMilliseconds();
}
Point CGuiHandler::screenDimensions() const Point CGuiHandler::screenDimensions() const
{ {
return Point(screen->w, screen->h); return Point(screen->w, screen->h);

View File

@ -87,8 +87,6 @@ private:
void fakeMoveCursor(float dx, float dy); void fakeMoveCursor(float dx, float dy);
void fakeMouseButtonEventRelativeMode(bool down, bool right); void fakeMouseButtonEventRelativeMode(bool down, bool right);
FramerateManager & framerateManager();
public: public:
void handleElementActivate(CIntObject * elem, ui16 activityFlag); void handleElementActivate(CIntObject * elem, ui16 activityFlag);
void handleElementDeActivate(CIntObject * elem, ui16 activityFlag); void handleElementDeActivate(CIntObject * elem, ui16 activityFlag);
@ -100,11 +98,7 @@ public:
const Point & getCursorPosition() const; const Point & getCursorPosition() const;
ShortcutHandler & shortcutsHandler(); ShortcutHandler & shortcutsHandler();
FramerateManager & framerateManager();
/// returns duration of last frame in milliseconds
/// NOTE: avoid to use, preferred method is to overload CIntObject::tick(uint32_t)
uint32_t getFrameDeltaMilliseconds() const;
/// Returns current logical screen dimensions /// Returns current logical screen dimensions
/// May not match size of window if user has UI scaling different from 100% /// May not match size of window if user has UI scaling different from 100%

View File

@ -12,6 +12,7 @@
#include "CursorHandler.h" #include "CursorHandler.h"
#include "CGuiHandler.h" #include "CGuiHandler.h"
#include "FramerateManager.h"
#include "../renderSDL/CursorSoftware.h" #include "../renderSDL/CursorSoftware.h"
#include "../renderSDL/CursorHardware.h" #include "../renderSDL/CursorHardware.h"
#include "../render/CAnimation.h" #include "../render/CAnimation.h"
@ -250,7 +251,7 @@ void CursorHandler::updateSpellcastCursor()
{ {
static const float frameDisplayDuration = 0.1f; // H3 uses 100 ms per frame static const float frameDisplayDuration = 0.1f; // H3 uses 100 ms per frame
frameTime += GH.getFrameDeltaMilliseconds() / 1000.f; frameTime += GH.framerateManager().getElapsedMilliseconds() / 1000.f;
size_t newFrame = frame; size_t newFrame = frame;
while (frameTime >= frameDisplayDuration) while (frameTime >= frameDisplayDuration)