aboutsummaryrefslogtreecommitdiff
path: root/src/main/kotlin/moe/nea
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/kotlin/moe/nea')
-rw-r--r--src/main/kotlin/moe/nea/firmament/gui/WFixedPanel.kt25
-rw-r--r--src/main/kotlin/moe/nea/firmament/gui/config/AllConfigsGui.kt10
2 files changed, 31 insertions, 4 deletions
diff --git a/src/main/kotlin/moe/nea/firmament/gui/WFixedPanel.kt b/src/main/kotlin/moe/nea/firmament/gui/WFixedPanel.kt
new file mode 100644
index 0000000..4ada681
--- /dev/null
+++ b/src/main/kotlin/moe/nea/firmament/gui/WFixedPanel.kt
@@ -0,0 +1,25 @@
+package moe.nea.firmament.gui
+
+import io.github.cottonmc.cotton.gui.widget.WPanel
+import io.github.cottonmc.cotton.gui.widget.WWidget
+
+class WFixedPanel() : WPanel() {
+ var child: WWidget
+ set(value) {
+ children.clear()
+ setSize(0, 0)
+ children.add(value)
+ }
+ get() = children.single()
+
+ constructor(child: WWidget) : this() {
+ this.child = child
+ }
+
+ override fun layout() {
+ setSize(0, 0)
+ super.layout()
+ }
+
+ override fun canResize(): Boolean = false
+}
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 6740471..411d7bd 100644
--- a/src/main/kotlin/moe/nea/firmament/gui/config/AllConfigsGui.kt
+++ b/src/main/kotlin/moe/nea/firmament/gui/config/AllConfigsGui.kt
@@ -26,8 +26,10 @@ 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.data.Insets
+import io.ktor.http.*
import net.minecraft.text.Text
import moe.nea.firmament.features.FeatureManager
+import moe.nea.firmament.gui.WFixedPanel
import moe.nea.firmament.repo.RepoManager
import moe.nea.firmament.util.ScreenUtil.setScreenLater
@@ -39,8 +41,9 @@ object AllConfigsGui {
lwgd.setRootPanel(WListPanel(
listOf(
RepoManager.Config
- ) + FeatureManager.allFeatures.mapNotNull { it.config }, ::WGridPanel
- ) { config, panel ->
+ ) + FeatureManager.allFeatures.mapNotNull { it.config }, ::WFixedPanel
+ ) { config, fixedPanel ->
+ val panel = WGridPanel()
panel.insets = Insets.ROOT_PANEL
panel.backgroundPainter = BackgroundPainter.VANILLA
panel.add(WLabel(Text.translatable("firmament.config.${config.name}")), 0, 0, 10, 1)
@@ -49,9 +52,8 @@ object AllConfigsGui {
config.showConfigEditor(screen)
}
}, 0, 1, 10, 1)
- println("Panel size: ${panel.width} ${panel.height}")
+ fixedPanel.child = panel
}.also {
- it.setListItemHeight(52)
it.setSize(10 * 18 + 14 + 16, 300)
})
screen = CottonClientScreen(lwgd)