aboutsummaryrefslogtreecommitdiff
path: root/src/main/kotlin/moe/nea/firmament/gui/config
diff options
context:
space:
mode:
authornea <nea@nea.moe>2023-05-26 23:23:03 +0200
committernea <nea@nea.moe>2023-05-26 23:23:03 +0200
commit59ea00dabceeddf01fec7bf87ec548d7beedd7cc (patch)
tree9711c61022f2bac793c423de97901d2370b7c316 /src/main/kotlin/moe/nea/firmament/gui/config
parent484a4b1a61493eb1401ac9c8ac063db3f847cf98 (diff)
downloadfirmament-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/config')
-rw-r--r--src/main/kotlin/moe/nea/firmament/gui/config/AllConfigsGui.kt23
1 files changed, 14 insertions, 9 deletions
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() {