[WIP] Remove LibGUI

This commit is contained in:
Linnea Gräf
2024-07-01 03:42:51 +02:00
parent dff1f9c0e2
commit 5ee4b8d925
44 changed files with 439 additions and 1141 deletions

View File

@@ -6,7 +6,9 @@
package moe.nea.firmament.gui.config
import io.github.cottonmc.cotton.gui.widget.WToggleButton
import io.github.notenoughupdates.moulconfig.gui.component.CenterComponent
import io.github.notenoughupdates.moulconfig.gui.component.SwitchComponent
import io.github.notenoughupdates.moulconfig.observer.GetSetter
import kotlinx.serialization.json.JsonElement
import kotlinx.serialization.json.JsonPrimitive
import kotlinx.serialization.json.boolean
@@ -24,13 +26,16 @@ class BooleanHandler(val config: ManagedConfig) : ManagedConfig.OptionHandler<Bo
override fun emitGuiElements(opt: ManagedOption<Boolean>, guiAppender: GuiAppender) {
guiAppender.appendLabeledRow(
opt.labelText,
WToggleButton(opt.labelText).apply {
guiAppender.onReload { toggle = opt.value }
setOnToggle {
opt.value = it
CenterComponent(SwitchComponent(object : GetSetter<Boolean> {
override fun get(): Boolean {
return opt.get()
}
override fun set(newValue: Boolean) {
opt.set(newValue)
config.save()
}
}
)
}, 200)
))
}
}