From f85c449ed586c7ced780423943e55bfa5abaeb0f Mon Sep 17 00:00:00 2001 From: nea Date: Sat, 22 Oct 2022 00:34:22 +0200 Subject: rudimentary config gui (again) --- src/main/kotlin/moe/nea/notenoughupdates/gui/ConfigGui.kt | 12 ++++++------ src/main/kotlin/moe/nea/notenoughupdates/gui/repogui.kt | 6 +++--- 2 files changed, 9 insertions(+), 9 deletions(-) (limited to 'src/main/kotlin/moe/nea/notenoughupdates/gui') diff --git a/src/main/kotlin/moe/nea/notenoughupdates/gui/ConfigGui.kt b/src/main/kotlin/moe/nea/notenoughupdates/gui/ConfigGui.kt index a5453a9..06d0ad0 100644 --- a/src/main/kotlin/moe/nea/notenoughupdates/gui/ConfigGui.kt +++ b/src/main/kotlin/moe/nea/notenoughupdates/gui/ConfigGui.kt @@ -9,11 +9,11 @@ import io.github.cottonmc.cotton.gui.widget.data.HorizontalAlignment import io.github.cottonmc.cotton.gui.widget.data.Insets import io.github.cottonmc.cotton.gui.widget.data.VerticalAlignment import moe.nea.notenoughupdates.NotEnoughUpdates -import moe.nea.notenoughupdates.util.config.ConfigHolder +import moe.nea.notenoughupdates.util.data.DataHolder import net.minecraft.text.Text import kotlin.reflect.KMutableProperty1 -class ConfigGui(val holder: ConfigHolder, val build: ConfigGui.() -> Unit) : LightweightGuiDescription() { +class ConfigGui(val holder: DataHolder, val build: ConfigGui.() -> Unit) : LightweightGuiDescription() { private val root = WGridPanelWithPadding(verticalPadding = 4) private val reloadables = mutableListOf<(() -> Unit)>() @@ -43,9 +43,9 @@ class ConfigGui(val holder: ConfigHolder, val build: ConfigGui.() -> Un fun toggle(text: Text, prop: KMutableProperty1) { val toggle = WToggleButton(text) - reloadables.add { toggle.toggle = prop.get(holder.config) } + reloadables.add { toggle.toggle = prop.get(holder.data) } toggle.setOnToggle { - prop.set(holder.config, true) + prop.set(holder.data, true) holder.markDirty() } root.add(toggle, 5, col, 6, 1) @@ -72,11 +72,11 @@ class ConfigGui(val holder: ConfigHolder, val build: ConfigGui.() -> Un val textfield = WTextField(background) textfield.isEditable = true reloadables.add { - textfield.text = prop.get(holder.config) + textfield.text = prop.get(holder.data) } textfield.maxLength = maxLength textfield.setChangedListener { - prop.set(holder.config, it) + prop.set(holder.data, it) holder.markDirty() } root.add(textfield, 5, col, 6, 11) diff --git a/src/main/kotlin/moe/nea/notenoughupdates/gui/repogui.kt b/src/main/kotlin/moe/nea/notenoughupdates/gui/repogui.kt index 23c8d18..b2fba91 100644 --- a/src/main/kotlin/moe/nea/notenoughupdates/gui/repogui.kt +++ b/src/main/kotlin/moe/nea/notenoughupdates/gui/repogui.kt @@ -27,9 +27,9 @@ fun repoGui(): ConfigGui { Text.translatable("notenoughupdates.gui.repo.reset.label"), Text.translatable("notenoughupdates.gui.repo.reset"), ) { - RepoManager.config.user = "NotEnoughUpdates" - RepoManager.config.repo = "NotEnoughUpdates-REPO" - RepoManager.config.branch = "dangerous" + RepoManager.data.user = "NotEnoughUpdates" + RepoManager.data.repo = "NotEnoughUpdates-REPO" + RepoManager.data.branch = "dangerous" reload() } } -- cgit