From ead6762eb1c005914b05f9d3c29f334989c67513 Mon Sep 17 00:00:00 2001 From: nea Date: Tue, 16 May 2023 01:23:43 +0200 Subject: Replace references to NEU with Firmament --- .../moe/nea/notenoughupdates/gui/ConfigGui.kt | 94 ---------------------- .../notenoughupdates/gui/WGridPanelWithPadding.kt | 33 -------- .../kotlin/moe/nea/notenoughupdates/gui/repogui.kt | 36 --------- 3 files changed, 163 deletions(-) delete mode 100644 src/main/kotlin/moe/nea/notenoughupdates/gui/ConfigGui.kt delete mode 100644 src/main/kotlin/moe/nea/notenoughupdates/gui/WGridPanelWithPadding.kt delete mode 100644 src/main/kotlin/moe/nea/notenoughupdates/gui/repogui.kt (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 deleted file mode 100644 index 06d0ad0..0000000 --- a/src/main/kotlin/moe/nea/notenoughupdates/gui/ConfigGui.kt +++ /dev/null @@ -1,94 +0,0 @@ -package moe.nea.notenoughupdates.gui - -import io.github.cottonmc.cotton.gui.client.LightweightGuiDescription -import io.github.cottonmc.cotton.gui.widget.WButton -import io.github.cottonmc.cotton.gui.widget.WLabel -import io.github.cottonmc.cotton.gui.widget.WTextField -import io.github.cottonmc.cotton.gui.widget.WToggleButton -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.data.DataHolder -import net.minecraft.text.Text -import kotlin.reflect.KMutableProperty1 - -class ConfigGui(val holder: DataHolder, val build: ConfigGui.() -> Unit) : LightweightGuiDescription() { - private val root = WGridPanelWithPadding(verticalPadding = 4) - private val reloadables = mutableListOf<(() -> Unit)>() - - init { - setRootPanel(root) - root.insets = Insets.ROOT_PANEL - build() - reload() - } - - fun title(text: Text) { - if (col != 0) { - NotEnoughUpdates.logger.warn("Set title not at the top of the ConfigGui") - } - val label = WLabel(text) - label.verticalAlignment = VerticalAlignment.TOP - label.horizontalAlignment = HorizontalAlignment.CENTER - root.add(label, 0, col, 11, 1) - col++ - } - - private fun label(text: Text) { - val label = WLabel(text) - label.verticalAlignment = VerticalAlignment.CENTER - root.add(label, 0, col, 5, 1) - } - - fun toggle(text: Text, prop: KMutableProperty1) { - val toggle = WToggleButton(text) - reloadables.add { toggle.toggle = prop.get(holder.data) } - toggle.setOnToggle { - prop.set(holder.data, true) - holder.markDirty() - } - root.add(toggle, 5, col, 6, 1) - label(text) - col++ - } - - fun button(text: Text, buttonText: Text, runnable: () -> Unit) { - val button = WButton(buttonText) - button.setOnClick { - runnable.invoke() - } - root.add(button, 5, col, 6, 1) - label(text) - col++ - } - - fun textfield( - text: Text, - background: Text, - prop: KMutableProperty1, - maxLength: Int = 255 - ) { - val textfield = WTextField(background) - textfield.isEditable = true - reloadables.add { - textfield.text = prop.get(holder.data) - } - textfield.maxLength = maxLength - textfield.setChangedListener { - prop.set(holder.data, it) - holder.markDirty() - } - root.add(textfield, 5, col, 6, 11) - label(text) - col++ - } - - fun reload() { - reloadables.forEach { it.invoke() } - } - - private var col = 0 - - -} diff --git a/src/main/kotlin/moe/nea/notenoughupdates/gui/WGridPanelWithPadding.kt b/src/main/kotlin/moe/nea/notenoughupdates/gui/WGridPanelWithPadding.kt deleted file mode 100644 index 287483e..0000000 --- a/src/main/kotlin/moe/nea/notenoughupdates/gui/WGridPanelWithPadding.kt +++ /dev/null @@ -1,33 +0,0 @@ -package moe.nea.notenoughupdates.gui - -import io.github.cottonmc.cotton.gui.widget.WPanelWithInsets -import io.github.cottonmc.cotton.gui.widget.WWidget -import io.github.cottonmc.cotton.gui.widget.data.Insets - -class WGridPanelWithPadding( - val grid: Int = 18, - val verticalPadding: Int = 0, - val horizontalPadding: Int = 0, -) : WPanelWithInsets() { - - private inline val vertOffset get() = grid + verticalPadding - private inline val horiOffset get() = grid + horizontalPadding - - fun add(w: WWidget, x: Int, y: Int, width: Int = 1, height: Int = 1) { - children.add(w) - w.parent = this - w.setLocation(x * horiOffset + insets.left, y * vertOffset + insets.top) - if (w.canResize()) - w.setSize( - grid + (horiOffset * (width - 1)), - grid + (vertOffset * (height - 1)), - ) - expandToFit(w, insets) - } - - override fun setInsets(insets: Insets): WGridPanelWithPadding { - super.setInsets(insets) - return this - } - -} \ No newline at end of file diff --git a/src/main/kotlin/moe/nea/notenoughupdates/gui/repogui.kt b/src/main/kotlin/moe/nea/notenoughupdates/gui/repogui.kt deleted file mode 100644 index b2fba91..0000000 --- a/src/main/kotlin/moe/nea/notenoughupdates/gui/repogui.kt +++ /dev/null @@ -1,36 +0,0 @@ -package moe.nea.notenoughupdates.gui - -import net.minecraft.text.Text -import moe.nea.notenoughupdates.repo.RepoManager - -fun repoGui(): ConfigGui { - return ConfigGui(RepoManager) { - title(Text.translatable("notenoughupdates.gui.repo.title")) - toggle(Text.translatable("notenoughupdates.gui.repo.autoupdate"), RepoManager.Config::autoUpdate) - textfield( - Text.translatable("notenoughupdates.gui.repo.username"), - Text.translatable("notenoughupdates.gui.repo.hint.username"), - RepoManager.Config::user, - maxLength = 255 - ) - textfield( - Text.translatable("notenoughupdates.gui.repo.reponame"), - Text.translatable("notenoughupdates.gui.repo.hint.reponame"), - RepoManager.Config::repo - ) - textfield( - Text.translatable("notenoughupdates.gui.repo.branch"), - Text.translatable("notenoughupdates.gui.repo.hint.branch"), - RepoManager.Config::branch - ) - button( - Text.translatable("notenoughupdates.gui.repo.reset.label"), - Text.translatable("notenoughupdates.gui.repo.reset"), - ) { - RepoManager.data.user = "NotEnoughUpdates" - RepoManager.data.repo = "NotEnoughUpdates-REPO" - RepoManager.data.branch = "dangerous" - reload() - } - } -} -- cgit