diff options
Diffstat (limited to 'src/main/kotlin/moe/nea/firmament/gui/config/AllConfigsGui.kt')
-rw-r--r-- | src/main/kotlin/moe/nea/firmament/gui/config/AllConfigsGui.kt | 42 |
1 files changed, 42 insertions, 0 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 new file mode 100644 index 0000000..687959d --- /dev/null +++ b/src/main/kotlin/moe/nea/firmament/gui/config/AllConfigsGui.kt @@ -0,0 +1,42 @@ +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.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.data.Insets +import net.minecraft.text.Text +import moe.nea.firmament.features.FeatureManager +import moe.nea.firmament.repo.RepoManager +import moe.nea.firmament.util.ScreenUtil.setScreenLater + +object AllConfigsGui { + + fun showAllGuis() { + val lwgd = LightweightGuiDescription() + var screen: CottonClientScreen? = null + lwgd.setRootPanel(WListPanel( + listOf( + RepoManager.Config + ) + FeatureManager.allFeatures.mapNotNull { it.config }, ::WGridPanel + ) { config, panel -> + panel.insets = Insets.ROOT_PANEL + panel.backgroundPainter = BackgroundPainter.VANILLA + panel.add(WLabel(Text.translatable("firmament.config.${config.name}")), 0, 0, 10, 1) + panel.add(WButton(Text.translatable("firmanent.config.edit")).also { + it.setOnClick { + config.showConfigEditor(screen) + } + }, 0, 1, 10, 1) + println("Panel size: ${panel.width} ${panel.height}") + }.also { + it.setListItemHeight(52) + it.setSize(10 * 18 + 14 + 16, 300) + }) + screen = CottonClientScreen(lwgd) + setScreenLater(screen) + } +} |