aboutsummaryrefslogtreecommitdiff
path: root/src/main/kotlin/moe/nea/firmament/features/debug
diff options
context:
space:
mode:
authornea <nea@nea.moe>2023-07-30 20:00:38 +0200
committernea <nea@nea.moe>2023-07-30 20:00:38 +0200
commitdbc56fb352134839800fad2a9d71dce6ab67349a (patch)
tree7e10d144bfbe1a064045d9b27b9f92746c1a3297 /src/main/kotlin/moe/nea/firmament/features/debug
parentb9a22305dce467764b55b81cd0ae4e8fa6f6990d (diff)
downloadfirmament-dbc56fb352134839800fad2a9d71dce6ab67349a.tar.gz
firmament-dbc56fb352134839800fad2a9d71dce6ab67349a.tar.bz2
firmament-dbc56fb352134839800fad2a9d71dce6ab67349a.zip
Add more fishing debug stats. (waiting on admins lol)
Diffstat (limited to 'src/main/kotlin/moe/nea/firmament/features/debug')
-rw-r--r--src/main/kotlin/moe/nea/firmament/features/debug/DebugView.kt28
1 files changed, 21 insertions, 7 deletions
diff --git a/src/main/kotlin/moe/nea/firmament/features/debug/DebugView.kt b/src/main/kotlin/moe/nea/firmament/features/debug/DebugView.kt
index e8c85d8..96ea7aa 100644
--- a/src/main/kotlin/moe/nea/firmament/features/debug/DebugView.kt
+++ b/src/main/kotlin/moe/nea/firmament/features/debug/DebugView.kt
@@ -2,8 +2,11 @@ package moe.nea.firmament.features.debug
import io.github.cottonmc.cotton.gui.client.CottonHud
import io.github.cottonmc.cotton.gui.widget.WBox
+import io.github.cottonmc.cotton.gui.widget.WDynamicLabel
+import io.github.cottonmc.cotton.gui.widget.WLabel
import io.github.cottonmc.cotton.gui.widget.data.Axis
import java.util.Optional
+import java.util.stream.Collectors
import kotlin.time.Duration.Companion.seconds
import net.minecraft.scoreboard.Scoreboard
import net.minecraft.scoreboard.Team
@@ -23,7 +26,7 @@ object DebugView : FirmamentFeature {
val timer: TimeMark,
)
- private val storedVariables: MutableMap<String, StoredVariable<*>> = mutableMapOf()
+ private val storedVariables: MutableMap<String, StoredVariable<*>> = sortedMapOf()
override val identifier: String
get() = "debug-view"
override val defaultEnabled: Boolean
@@ -35,18 +38,29 @@ object DebugView : FirmamentFeature {
}
}
+ fun recalculateDebugWidget() {
+ storedVariables.entries.removeIf { it.value.timer.passedTime() > 1.seconds }
+ debugWidget.streamChildren().collect(Collectors.toList()).forEach {
+ debugWidget.remove(it)
+ }
+ storedVariables.entries.forEach {
+ debugWidget.add(WDynamicLabel({ "${it.key}: ${it.value.obj}" }))
+ }
+ debugWidget.layout()
+ if (storedVariables.isNotEmpty()) {
+ CottonHud.add(debugWidget, 20, 20)
+ } else {
+ CottonHud.remove(debugWidget)
+ }
+ }
+
val debugWidget = WBox(Axis.VERTICAL)
override fun onLoad() {
TickEvent.subscribe {
synchronized(this) {
- storedVariables.entries.removeIf { it.value.timer.passedTime() > 1.seconds }
- if (storedVariables.isEmpty()) {
- CottonHud.add(debugWidget, 20, 20)
- } else {
- CottonHud.remove(debugWidget)
- }
+ recalculateDebugWidget()
}
}
}