aboutsummaryrefslogtreecommitdiff
path: root/src/main/kotlin/moe/nea/firmament/gui/config/ClickHandler.kt
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/kotlin/moe/nea/firmament/gui/config/ClickHandler.kt')
-rw-r--r--src/main/kotlin/moe/nea/firmament/gui/config/ClickHandler.kt25
1 files changed, 25 insertions, 0 deletions
diff --git a/src/main/kotlin/moe/nea/firmament/gui/config/ClickHandler.kt b/src/main/kotlin/moe/nea/firmament/gui/config/ClickHandler.kt
new file mode 100644
index 0000000..4948ade
--- /dev/null
+++ b/src/main/kotlin/moe/nea/firmament/gui/config/ClickHandler.kt
@@ -0,0 +1,25 @@
+package moe.nea.firmament.gui.config
+
+import io.github.cottonmc.cotton.gui.widget.WButton
+import io.github.cottonmc.cotton.gui.widget.WLabel
+import kotlinx.serialization.json.JsonElement
+import net.minecraft.text.Text
+
+class ClickHandler(val config: ManagedConfig, val runnable: () -> Unit) : ManagedConfig.OptionHandler<Unit> {
+ override fun toJson(element: Unit): JsonElement? {
+ return null
+ }
+
+ override fun fromJson(element: JsonElement) {}
+
+ override fun emitGuiElements(opt: ManagedConfig.Option<Unit>, guiAppender: GuiAppender) {
+ guiAppender.appendLabeledRow(
+ Text.translatable("firmament.config.${config.name}.${opt.propertyName}"),
+ WButton(Text.translatable("firmament.config.${config.name}.${opt.propertyName}")).apply {
+ setOnClick {
+ runnable()
+ }
+ },
+ )
+ }
+}