diff options
author | nea <nea@nea.moe> | 2023-05-26 23:23:03 +0200 |
---|---|---|
committer | nea <nea@nea.moe> | 2023-05-26 23:23:03 +0200 |
commit | 59ea00dabceeddf01fec7bf87ec548d7beedd7cc (patch) | |
tree | 9711c61022f2bac793c423de97901d2370b7c316 /src/main/kotlin/moe/nea/firmament/gui | |
parent | 484a4b1a61493eb1401ac9c8ac063db3f847cf98 (diff) | |
download | Firmament-59ea00dabceeddf01fec7bf87ec548d7beedd7cc.tar.gz Firmament-59ea00dabceeddf01fec7bf87ec548d7beedd7cc.tar.bz2 Firmament-59ea00dabceeddf01fec7bf87ec548d7beedd7cc.zip |
Fix bug in WFixedPanel and use WScrollPanel + WBox for config
Diffstat (limited to 'src/main/kotlin/moe/nea/firmament/gui')
-rw-r--r-- | src/main/kotlin/moe/nea/firmament/gui/WFixedPanel.kt | 1 | ||||
-rw-r--r-- | src/main/kotlin/moe/nea/firmament/gui/config/AllConfigsGui.kt | 23 |
2 files changed, 15 insertions, 9 deletions
diff --git a/src/main/kotlin/moe/nea/firmament/gui/WFixedPanel.kt b/src/main/kotlin/moe/nea/firmament/gui/WFixedPanel.kt index 4ada681..0c5eb05 100644 --- a/src/main/kotlin/moe/nea/firmament/gui/WFixedPanel.kt +++ b/src/main/kotlin/moe/nea/firmament/gui/WFixedPanel.kt @@ -8,6 +8,7 @@ class WFixedPanel() : WPanel() { set(value) { children.clear() setSize(0, 0) + value.parent = this children.add(value) } get() = children.single() diff --git a/src/main/kotlin/moe/nea/firmament/gui/config/AllConfigsGui.kt b/src/main/kotlin/moe/nea/firmament/gui/config/AllConfigsGui.kt index dd8108f..e547e3b 100644 --- a/src/main/kotlin/moe/nea/firmament/gui/config/AllConfigsGui.kt +++ b/src/main/kotlin/moe/nea/firmament/gui/config/AllConfigsGui.kt @@ -21,10 +21,12 @@ package moe.nea.firmament.gui.config import io.github.cottonmc.cotton.gui.client.BackgroundPainter import io.github.cottonmc.cotton.gui.client.CottonClientScreen import io.github.cottonmc.cotton.gui.client.LightweightGuiDescription +import io.github.cottonmc.cotton.gui.widget.WBox import io.github.cottonmc.cotton.gui.widget.WButton import io.github.cottonmc.cotton.gui.widget.WGridPanel import io.github.cottonmc.cotton.gui.widget.WLabel -import io.github.cottonmc.cotton.gui.widget.WListPanel +import io.github.cottonmc.cotton.gui.widget.WScrollPanel +import io.github.cottonmc.cotton.gui.widget.data.Axis import io.github.cottonmc.cotton.gui.widget.data.Insets import io.ktor.http.* import net.minecraft.client.gui.screen.Screen @@ -40,11 +42,11 @@ object AllConfigsGui { fun makeScreen(parent: Screen? = null): CottonClientScreen { val lwgd = LightweightGuiDescription() var screen: CottonClientScreen? = null - lwgd.setRootPanel(WListPanel( - listOf( - RepoManager.Config - ) + FeatureManager.allFeatures.mapNotNull { it.config }, ::WFixedPanel - ) { config, fixedPanel -> + val configs = listOf( + RepoManager.Config + ) + FeatureManager.allFeatures.mapNotNull { it.config } + val box = WBox(Axis.VERTICAL) + configs.forEach { config -> val panel = WGridPanel() panel.insets = Insets.ROOT_PANEL panel.backgroundPainter = BackgroundPainter.VANILLA @@ -54,9 +56,12 @@ object AllConfigsGui { config.showConfigEditor(screen) } }, 0, 1, 10, 1) - fixedPanel.child = panel - }.also { - it.setSize(10 * 18 + 14 + 16, 300) + box.add(WFixedPanel(panel)) + } + box.insets = Insets.ROOT_PANEL + lwgd.setRootPanel(WScrollPanel((box)).also { + box.layout() + it.setSize(box.width + 8, MC.window.scaledHeight / 2) }) screen = object : CottonClientScreen(lwgd) { override fun close() { |