Skip to content

Commit 2d438a5

Browse files
committed
Change cursed capitalization
1 parent 1920a45 commit 2d438a5

File tree

3 files changed

+90
-90
lines changed

3 files changed

+90
-90
lines changed

src/main/kotlin/com/lambda/module/hud/Fps.kt renamed to src/main/kotlin/com/lambda/module/hud/FPS.kt

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -23,34 +23,34 @@ import com.lambda.gui.dsl.ImGuiBuilder
2323
import com.lambda.module.HudModule
2424
import com.lambda.module.tag.ModuleTag
2525

26-
object Fps : HudModule(
27-
name = "Fps",
28-
description = "Displays your games frames per second",
29-
tag = ModuleTag.HUD
26+
object FPS : HudModule(
27+
name = "FPS",
28+
description = "Displays your games frames per second",
29+
tag = ModuleTag.HUD
3030
) {
31-
val updateDelay by setting("Update Delay", 50, 0..1000, 1,"Time between updating the fps value")
32-
33-
var lastUpdated = System.currentTimeMillis()
34-
var lastFrameTime = System.nanoTime()
35-
var fps = 0
36-
37-
init {
38-
listen<RenderEvent.Render> {
39-
val currentTimeNano = System.nanoTime()
40-
41-
val currentTypeMilli = System.currentTimeMillis()
42-
if (currentTypeMilli - lastUpdated >= updateDelay) {
43-
lastUpdated = currentTypeMilli
44-
val elapsedNs = currentTimeNano - lastFrameTime
45-
fps = if (elapsedNs > 0) (1000000000 / elapsedNs).toInt()
46-
else 0
47-
}
48-
49-
lastFrameTime = currentTimeNano
50-
}
51-
}
52-
53-
override fun ImGuiBuilder.buildLayout() {
54-
text("FPS: $fps")
55-
}
31+
val updateDelay by setting("Update Delay", 50, 0..1000, 1, "Time between updating the fps value")
32+
33+
var lastUpdated = System.currentTimeMillis()
34+
var lastFrameTime = System.nanoTime()
35+
var fps = 0
36+
37+
init {
38+
listen<RenderEvent.Render> {
39+
val currentTimeNano = System.nanoTime()
40+
41+
val currentTypeMilli = System.currentTimeMillis()
42+
if (currentTypeMilli - lastUpdated >= updateDelay) {
43+
lastUpdated = currentTypeMilli
44+
val elapsedNs = currentTimeNano - lastFrameTime
45+
fps = if (elapsedNs > 0) (1000000000 / elapsedNs).toInt()
46+
else 0
47+
}
48+
49+
lastFrameTime = currentTimeNano
50+
}
51+
}
52+
53+
override fun ImGuiBuilder.buildLayout() {
54+
text("FPS: $fps")
55+
}
5656
}
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
/*
2+
* Copyright 2025 Lambda
3+
*
4+
* This program is free software: you can redistribute it and/or modify
5+
* it under the terms of the GNU General Public License as published by
6+
* the Free Software Foundation, either version 3 of the License, or
7+
* (at your option) any later version.
8+
*
9+
* This program is distributed in the hope that it will be useful,
10+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
* GNU General Public License for more details.
13+
*
14+
* You should have received a copy of the GNU General Public License
15+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
16+
*/
17+
18+
package com.lambda.module.hud
19+
20+
import com.lambda.gui.dsl.ImGuiBuilder
21+
import com.lambda.module.HudModule
22+
import com.lambda.module.tag.ModuleTag
23+
import com.lambda.util.Formatting.format
24+
import com.lambda.util.ServerTPS
25+
import com.lambda.util.ServerTPS.recentData
26+
import imgui.ImVec2
27+
28+
object TPS : HudModule(
29+
name = "TPS",
30+
description = "Display the server's tick rate",
31+
tag = ModuleTag.HUD,
32+
) {
33+
private val format by setting("Tick format", ServerTPS.TickFormat.Tps)
34+
private val showGraph by setting("Show TPS Graph", false)
35+
private val graphHeight by setting("Graph Height", 40f, 10f..200f, 1f)
36+
private val graphWidth by setting("Graph Width", 200f, 10f..500f, 1f)
37+
private val graphStride by setting("Graph Stride", 1, 1..20, 1)
38+
39+
override fun ImGuiBuilder.buildLayout() {
40+
val data = recentData(format)
41+
if (data.isEmpty()) {
42+
text("No ${format.displayName} data yet")
43+
return
44+
}
45+
val current = data.last()
46+
val avg = data.average().toFloat()
47+
if (!showGraph) {
48+
text("${format.displayName}: ${avg.format()}${format.unit}")
49+
return
50+
}
51+
val overlay = "cur ${current.format()}${format.unit} | avg ${avg.format()}${format.unit}"
52+
53+
plotLines(
54+
label = "##TPSPlot",
55+
values = data,
56+
overlayText = overlay,
57+
graphSize = ImVec2(graphWidth, graphHeight),
58+
stride = graphStride
59+
)
60+
}
61+
}

src/main/kotlin/com/lambda/module/hud/Tps.kt

Lines changed: 0 additions & 61 deletions
This file was deleted.

0 commit comments

Comments
 (0)