Show FPS counter on F2

This commit is contained in:
LeshaInc 2020-06-28 18:38:43 +03:00
parent 0dcb183812
commit 337446fba7
No known key found for this signature in database
GPG Key ID: B4855290FC36DE72
2 changed files with 12 additions and 2 deletions

View File

@ -177,7 +177,6 @@ object UiHandler extends Logging {
Display.update()
fpsCalculator.tick()
windowTitle = s"Ocelot Desktop [FPS: ${fpsCalculator.fps}]"
}
}

View File

@ -30,12 +30,14 @@ class RootWidget extends Widget {
children :+= statusBar
private var isDebugViewVisible = false
private var isFPSVisible = false
eventHandlers += {
case KeyEvent(KeyEvent.State.Release, Keyboard.KEY_F1, _) =>
isDebugViewVisible = !isDebugViewVisible
case KeyEvent(KeyEvent.State.Release, Keyboard.KEY_F2, _) =>
isFPSVisible = !isFPSVisible
}
override def draw(g: Graphics): Unit = {
@ -54,4 +56,13 @@ class RootWidget extends Widget {
}
}
}
override def update(): Unit = {
super.update()
if (isFPSVisible)
UiHandler.windowTitle = s"Ocelot Desktop [FPS: ${UiHandler.fps}]"
else
UiHandler.windowTitle = "Ocelot Desktop"
}
}