aboutsummaryrefslogtreecommitdiff
path: root/src/main/kotlin/moe/nea/firmament/features/debug/ObjectRenderer.kt
diff options
context:
space:
mode:
authorLinnea Gräf <nea@nea.moe>2024-07-01 03:42:51 +0200
committerLinnea Gräf <nea@nea.moe>2024-07-03 21:05:51 +0200
commit5ee4b8d925eb12e068038a1fd2e1f35cdd8ef87e (patch)
treea5b0a6fbc8878ae62bb2c3a01dbb255388353fda /src/main/kotlin/moe/nea/firmament/features/debug/ObjectRenderer.kt
parentdff1f9c0e2b728dba902d72816104abccc61f511 (diff)
downloadFirmament-5ee4b8d925eb12e068038a1fd2e1f35cdd8ef87e.tar.gz
Firmament-5ee4b8d925eb12e068038a1fd2e1f35cdd8ef87e.tar.bz2
Firmament-5ee4b8d925eb12e068038a1fd2e1f35cdd8ef87e.zip
[WIP] Remove LibGUI
Diffstat (limited to 'src/main/kotlin/moe/nea/firmament/features/debug/ObjectRenderer.kt')
-rw-r--r--src/main/kotlin/moe/nea/firmament/features/debug/ObjectRenderer.kt58
1 files changed, 0 insertions, 58 deletions
diff --git a/src/main/kotlin/moe/nea/firmament/features/debug/ObjectRenderer.kt b/src/main/kotlin/moe/nea/firmament/features/debug/ObjectRenderer.kt
deleted file mode 100644
index 18f502c..0000000
--- a/src/main/kotlin/moe/nea/firmament/features/debug/ObjectRenderer.kt
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * SPDX-FileCopyrightText: 2023 Linnea Gräf <nea@nea.moe>
- *
- * SPDX-License-Identifier: GPL-3.0-or-later
- */
-
-package moe.nea.firmament.features.debug
-
-import io.github.cottonmc.cotton.gui.widget.WBox
-import io.github.cottonmc.cotton.gui.widget.WLabel
-import io.github.cottonmc.cotton.gui.widget.WWidget
-import io.github.cottonmc.cotton.gui.widget.data.Axis
-import kotlinx.serialization.encodeToString
-import kotlinx.serialization.json.Json
-import kotlin.reflect.KProperty1
-import net.minecraft.text.Text
-import moe.nea.firmament.gui.WSpacer
-
-class ObjectRenderer(val box: WBox) {
- var indent = 0
-
- fun beginObject() {
- indent++
- }
-
- fun endObject() {
- indent--
- }
-
- fun emit(label: String, widget: WWidget) {
- WSpacer(WBox(Axis.VERTICAL).also {
- it.add(WWidget())
- it.add(widget)
- }, indent * 18)
- }
-
- fun <T : Any?> getDebuggingView(label: String, obj: T) {
- if (obj == null) {
- emit(label, WLabel(Text.literal("§cnull")))
- return
- }
- if (obj is String) {
- emit(label, WLabel(Text.literal(Json.encodeToString(obj))))
- }
- getObject(label, obj)
- }
-
- fun <T : Any> getObject(label: String, obj: T) {
- emit(label, WLabel(Text.literal(obj::class.simpleName ?: "<unknown>")))
- beginObject()
- for (prop in obj::class.members.filterIsInstance<KProperty1<T, *>>()) {
- val child = prop.get(obj)
- getDebuggingView(prop.name, child)
- }
- endObject()
- }
-
-}