[WIP] Remove LibGUI
This commit is contained in:
@@ -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)
|
||||
))
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user