From cb85f97064cc531dbd1d50e1f29bf63787d63ec5 Mon Sep 17 00:00:00 2001 From: cattyn Date: Mon, 15 Dec 2025 09:31:25 +0300 Subject: [PATCH 1/8] feat(ModuleList): add `Show Keybind` setting --- src/main/kotlin/com/lambda/module/hud/ModuleList.kt | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/main/kotlin/com/lambda/module/hud/ModuleList.kt b/src/main/kotlin/com/lambda/module/hud/ModuleList.kt index d0522dddb..540825b95 100644 --- a/src/main/kotlin/com/lambda/module/hud/ModuleList.kt +++ b/src/main/kotlin/com/lambda/module/hud/ModuleList.kt @@ -29,6 +29,8 @@ object ModuleList : HudModule( name = "ModuleList", tag = ModuleTag.HUD, ) { + val showKeybind by setting("Show Keybind", true, "Display keybind next to a module") + override val isVisible: Boolean get() = false @@ -41,7 +43,8 @@ object ModuleList : HudModule( text(it.name); sameLine() val color = if (it.keybind.key == 0 && it.keybind.mouse == -1) Color.RED else Color.GREEN - withStyleColor(ImGuiCol.Text, color) { text(" [${it.keybind.name}]") } + if (showKeybind) + withStyleColor(ImGuiCol.Text, color) { text(" [${it.keybind.name}]") } } } } From db59141002b62ea4c58acfacd4b596457a8b4eec Mon Sep 17 00:00:00 2001 From: cattyn Date: Mon, 15 Dec 2025 09:42:17 +0300 Subject: [PATCH 2/8] feat(FPS): add `Average` setting --- src/main/kotlin/com/lambda/module/hud/FPS.kt | 33 +++++++++++++------- 1 file changed, 22 insertions(+), 11 deletions(-) diff --git a/src/main/kotlin/com/lambda/module/hud/FPS.kt b/src/main/kotlin/com/lambda/module/hud/FPS.kt index 05d3185ec..dc4ee338d 100644 --- a/src/main/kotlin/com/lambda/module/hud/FPS.kt +++ b/src/main/kotlin/com/lambda/module/hud/FPS.kt @@ -22,31 +22,42 @@ import com.lambda.event.listener.SafeListener.Companion.listen import com.lambda.gui.dsl.ImGuiBuilder import com.lambda.module.HudModule import com.lambda.module.tag.ModuleTag +import kotlin.time.Duration.Companion.seconds object FPS : HudModule( name = "FPS", description = "Displays your games frames per second", tag = ModuleTag.HUD ) { - val updateDelay by setting("Update Delay", 50, 0..1000, 1, "Time between updating the fps value") + val average by setting("Average", false) + val updateDelay by setting("Update Delay", 50, 0..1000, 1, "Time between updating the fps value") { + !average + } + val frames = mutableListOf(); var lastUpdated = System.currentTimeMillis() var lastFrameTime = System.nanoTime() var fps = 0 init { listen { - val currentTimeNano = System.nanoTime() - - val currentTypeMilli = System.currentTimeMillis() - if (currentTypeMilli - lastUpdated >= updateDelay) { - lastUpdated = currentTypeMilli - val elapsedNs = currentTimeNano - lastFrameTime - fps = if (elapsedNs > 0) (1000000000 / elapsedNs).toInt() - else 0 - } + if (average) { + frames.add(System.nanoTime() + 1.seconds.inWholeNanoseconds) + frames.removeIf { System.nanoTime() > it } + fps = frames.size + } else { + val currentTimeNano = System.nanoTime() - lastFrameTime = currentTimeNano + val currentTypeMilli = System.currentTimeMillis() + if (currentTypeMilli - lastUpdated >= updateDelay) { + lastUpdated = currentTypeMilli + val elapsedNs = currentTimeNano - lastFrameTime + fps = if (elapsedNs > 0) (1000000000 / elapsedNs).toInt() + else 0 + } + + lastFrameTime = currentTimeNano + } } } From 15ae9313584f357ceecd0587c7c4ed692591c0ca Mon Sep 17 00:00:00 2001 From: cattyn Date: Mon, 15 Dec 2025 09:48:22 +0300 Subject: [PATCH 3/8] feat(FPS): make `Average` setting work with `Update Delay` --- src/main/kotlin/com/lambda/module/hud/FPS.kt | 24 +++++++++----------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/src/main/kotlin/com/lambda/module/hud/FPS.kt b/src/main/kotlin/com/lambda/module/hud/FPS.kt index dc4ee338d..d79b77dab 100644 --- a/src/main/kotlin/com/lambda/module/hud/FPS.kt +++ b/src/main/kotlin/com/lambda/module/hud/FPS.kt @@ -30,9 +30,7 @@ object FPS : HudModule( tag = ModuleTag.HUD ) { val average by setting("Average", false) - val updateDelay by setting("Update Delay", 50, 0..1000, 1, "Time between updating the fps value") { - !average - } + val updateDelay by setting("Update Delay", 50, 0..1000, 1, "Time between updating the fps value") val frames = mutableListOf(); var lastUpdated = System.currentTimeMillis() @@ -41,23 +39,23 @@ object FPS : HudModule( init { listen { + var currentFps = 0 if (average) { frames.add(System.nanoTime() + 1.seconds.inWholeNanoseconds) frames.removeIf { System.nanoTime() > it } - fps = frames.size + currentFps = frames.size } else { val currentTimeNano = System.nanoTime() - - val currentTypeMilli = System.currentTimeMillis() - if (currentTypeMilli - lastUpdated >= updateDelay) { - lastUpdated = currentTypeMilli - val elapsedNs = currentTimeNano - lastFrameTime - fps = if (elapsedNs > 0) (1000000000 / elapsedNs).toInt() - else 0 - } - + val elapsedNs = currentTimeNano - lastFrameTime + currentFps = if (elapsedNs > 0) (1000000000 / elapsedNs).toInt() else 0 lastFrameTime = currentTimeNano } + + val currentTypeMilli = System.currentTimeMillis() + if (currentTypeMilli - lastUpdated >= updateDelay) { + fps = currentFps + lastUpdated = currentTypeMilli + } } } From 28d6811aa049b53bffd6dd9533f64dc13a7847b2 Mon Sep 17 00:00:00 2001 From: cattyn Date: Mon, 15 Dec 2025 09:55:04 +0300 Subject: [PATCH 4/8] refactor(ModuleList): move color into if statement --- src/main/kotlin/com/lambda/module/hud/ModuleList.kt | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/main/kotlin/com/lambda/module/hud/ModuleList.kt b/src/main/kotlin/com/lambda/module/hud/ModuleList.kt index 540825b95..2145cdb8c 100644 --- a/src/main/kotlin/com/lambda/module/hud/ModuleList.kt +++ b/src/main/kotlin/com/lambda/module/hud/ModuleList.kt @@ -41,10 +41,11 @@ object ModuleList : HudModule( enabled.forEach { text(it.name); sameLine() - val color = if (it.keybind.key == 0 && it.keybind.mouse == -1) Color.RED else Color.GREEN - if (showKeybind) - withStyleColor(ImGuiCol.Text, color) { text(" [${it.keybind.name}]") } + if (showKeybind) { + val color = if (it.keybind.key == 0 && it.keybind.mouse == -1) Color.RED else Color.GREEN + withStyleColor(ImGuiCol.Text, color) { text(" [${it.keybind.name}]") } + } } } } From cdea7aff8de046191135742220b904c7aa5ff9a1 Mon Sep 17 00:00:00 2001 From: cattyn <60744119+cattyngmd@users.noreply.github.com> Date: Tue, 16 Dec 2025 01:13:24 +0300 Subject: [PATCH 5/8] fix(ModuleList): fix `sameLine` being invoked with `Show Keybin` off --- src/main/kotlin/com/lambda/module/hud/ModuleList.kt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/main/kotlin/com/lambda/module/hud/ModuleList.kt b/src/main/kotlin/com/lambda/module/hud/ModuleList.kt index 2145cdb8c..51d5214fe 100644 --- a/src/main/kotlin/com/lambda/module/hud/ModuleList.kt +++ b/src/main/kotlin/com/lambda/module/hud/ModuleList.kt @@ -40,10 +40,12 @@ object ModuleList : HudModule( .filter { it.isVisible } enabled.forEach { - text(it.name); sameLine() + text(it.name) if (showKeybind) { val color = if (it.keybind.key == 0 && it.keybind.mouse == -1) Color.RED else Color.GREEN + + sameLine() withStyleColor(ImGuiCol.Text, color) { text(" [${it.keybind.name}]") } } } From 14517c7991d9d9241fc6a446b525a046755df96a Mon Sep 17 00:00:00 2001 From: cattyn Date: Tue, 16 Dec 2025 01:21:51 +0300 Subject: [PATCH 6/8] refactor: remove extra tab --- src/main/kotlin/com/lambda/module/hud/ModuleList.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/kotlin/com/lambda/module/hud/ModuleList.kt b/src/main/kotlin/com/lambda/module/hud/ModuleList.kt index 51d5214fe..980a7345a 100644 --- a/src/main/kotlin/com/lambda/module/hud/ModuleList.kt +++ b/src/main/kotlin/com/lambda/module/hud/ModuleList.kt @@ -45,7 +45,7 @@ object ModuleList : HudModule( if (showKeybind) { val color = if (it.keybind.key == 0 && it.keybind.mouse == -1) Color.RED else Color.GREEN - sameLine() + sameLine() withStyleColor(ImGuiCol.Text, color) { text(" [${it.keybind.name}]") } } } From 0270a21c917b6eb8bbaea1f3919d6e5677f98390 Mon Sep 17 00:00:00 2001 From: cattyn Date: Tue, 16 Dec 2025 04:00:46 +0300 Subject: [PATCH 7/8] refactor: use `LimitedDecayQueue` instead of `ArrayList` --- src/main/kotlin/com/lambda/module/hud/FPS.kt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/kotlin/com/lambda/module/hud/FPS.kt b/src/main/kotlin/com/lambda/module/hud/FPS.kt index d79b77dab..abaf022d8 100644 --- a/src/main/kotlin/com/lambda/module/hud/FPS.kt +++ b/src/main/kotlin/com/lambda/module/hud/FPS.kt @@ -22,6 +22,7 @@ import com.lambda.event.listener.SafeListener.Companion.listen import com.lambda.gui.dsl.ImGuiBuilder import com.lambda.module.HudModule import com.lambda.module.tag.ModuleTag +import com.lambda.util.collections.LimitedDecayQueue import kotlin.time.Duration.Companion.seconds object FPS : HudModule( @@ -32,7 +33,7 @@ object FPS : HudModule( val average by setting("Average", false) val updateDelay by setting("Update Delay", 50, 0..1000, 1, "Time between updating the fps value") - val frames = mutableListOf(); + val frames = LimitedDecayQueue(Int.MAX_VALUE, 1.seconds.inWholeMilliseconds); var lastUpdated = System.currentTimeMillis() var lastFrameTime = System.nanoTime() var fps = 0 @@ -41,8 +42,7 @@ object FPS : HudModule( listen { var currentFps = 0 if (average) { - frames.add(System.nanoTime() + 1.seconds.inWholeNanoseconds) - frames.removeIf { System.nanoTime() > it } + frames.add(Unit) currentFps = frames.size } else { val currentTimeNano = System.nanoTime() From 47dcba202aef523148b401ed423b210c9b232eeb Mon Sep 17 00:00:00 2001 From: cattyn Date: Wed, 17 Dec 2025 00:08:24 +0300 Subject: [PATCH 8/8] refactor: remove semicolon and make `Average` enabled by default --- src/main/kotlin/com/lambda/module/hud/FPS.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/kotlin/com/lambda/module/hud/FPS.kt b/src/main/kotlin/com/lambda/module/hud/FPS.kt index abaf022d8..e2ec81ae1 100644 --- a/src/main/kotlin/com/lambda/module/hud/FPS.kt +++ b/src/main/kotlin/com/lambda/module/hud/FPS.kt @@ -30,10 +30,10 @@ object FPS : HudModule( description = "Displays your games frames per second", tag = ModuleTag.HUD ) { - val average by setting("Average", false) + val average by setting("Average", true) val updateDelay by setting("Update Delay", 50, 0..1000, 1, "Time between updating the fps value") - val frames = LimitedDecayQueue(Int.MAX_VALUE, 1.seconds.inWholeMilliseconds); + val frames = LimitedDecayQueue(Int.MAX_VALUE, 1.seconds.inWholeMilliseconds) var lastUpdated = System.currentTimeMillis() var lastFrameTime = System.nanoTime() var fps = 0