mirror of
https://github.com/The-Powder-Toy/The-Powder-Toy.git
synced 2025-08-30 03:09:53 +02:00
make fps update less often in hud
This commit is contained in:
@@ -286,7 +286,8 @@ std::map<ByteString, ByteString> readArguments(int argc, char * argv[])
|
|||||||
|
|
||||||
int elapsedTime = 0, currentTime = 0, lastTime = 0, currentFrame = 0;
|
int elapsedTime = 0, currentTime = 0, lastTime = 0, currentFrame = 0;
|
||||||
unsigned int lastTick = 0;
|
unsigned int lastTick = 0;
|
||||||
float fps = 0, delta = 1.0f;
|
unsigned int lastFpsUpdate = 0;
|
||||||
|
float fps = 0;
|
||||||
ui::Engine * engine = NULL;
|
ui::Engine * engine = NULL;
|
||||||
bool showDoubleScreenDialog = false;
|
bool showDoubleScreenDialog = false;
|
||||||
float currentWidth, currentHeight;
|
float currentWidth, currentHeight;
|
||||||
@@ -465,7 +466,11 @@ void EngineProcess()
|
|||||||
}
|
}
|
||||||
int correctedFrameTime = SDL_GetTicks() - frameStart;
|
int correctedFrameTime = SDL_GetTicks() - frameStart;
|
||||||
correctedFrameTimeAvg = correctedFrameTimeAvg * 0.95 + correctedFrameTime * 0.05;
|
correctedFrameTimeAvg = correctedFrameTimeAvg * 0.95 + correctedFrameTime * 0.05;
|
||||||
|
if (frameStart - lastFpsUpdate > 200)
|
||||||
|
{
|
||||||
engine->SetFps(1000.0 / correctedFrameTimeAvg);
|
engine->SetFps(1000.0 / correctedFrameTimeAvg);
|
||||||
|
lastFpsUpdate = frameStart;
|
||||||
|
}
|
||||||
if (frameStart - lastTick > 1000)
|
if (frameStart - lastTick > 1000)
|
||||||
{
|
{
|
||||||
//Run client tick every second
|
//Run client tick every second
|
||||||
|
@@ -2420,9 +2420,6 @@ void GameView::OnDraw()
|
|||||||
//FPS and some version info
|
//FPS and some version info
|
||||||
StringBuilder fpsInfo;
|
StringBuilder fpsInfo;
|
||||||
fpsInfo << Format::Precision(2) << "FPS: " << ui::Engine::Ref().GetFps();
|
fpsInfo << Format::Precision(2) << "FPS: " << ui::Engine::Ref().GetFps();
|
||||||
#ifdef DEBUG
|
|
||||||
fpsInfo << " Delta: " << ui::Engine::Ref().GetDelta();
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (showDebug)
|
if (showDebug)
|
||||||
{
|
{
|
||||||
|
@@ -60,7 +60,6 @@ namespace ui
|
|||||||
|
|
||||||
void SetFps(float fps);
|
void SetFps(float fps);
|
||||||
inline float GetFps() { return fps; }
|
inline float GetFps() { return fps; }
|
||||||
inline float GetDelta() { return dt; }
|
|
||||||
|
|
||||||
inline int GetMouseButton() { return mouseb_; }
|
inline int GetMouseButton() { return mouseb_; }
|
||||||
inline int GetMouseX() { return mousex_; }
|
inline int GetMouseX() { return mousex_; }
|
||||||
|
Reference in New Issue
Block a user