From 87b851373071490bb371ba1160f85f0341579cb2 Mon Sep 17 00:00:00 2001 From: Linnea Gräf Date: Sun, 13 Oct 2024 19:53:10 +0200 Subject: Add YACL config menu --- src/main/kotlin/gui/config/AllConfigsGui.kt | 71 +++++++++++++++-------------- 1 file changed, 36 insertions(+), 35 deletions(-) (limited to 'src/main/kotlin/gui/config/AllConfigsGui.kt') diff --git a/src/main/kotlin/gui/config/AllConfigsGui.kt b/src/main/kotlin/gui/config/AllConfigsGui.kt index 3091b2a..c72b8b0 100644 --- a/src/main/kotlin/gui/config/AllConfigsGui.kt +++ b/src/main/kotlin/gui/config/AllConfigsGui.kt @@ -12,39 +12,40 @@ import moe.nea.firmament.util.ScreenUtil.setScreenLater object AllConfigsGui { - val allConfigs - get() = listOf( - RepoManager.Config - ) + FeatureManager.allFeatures.mapNotNull { it.config } - - fun List.toObservableList(): ObservableList = ObservableList(this) - - class MainMapping(val allConfigs: List) { - @get:Bind("configs") - val configs = allConfigs.map { EntryMapping(it) }.toObservableList() - - class EntryMapping(val config: ManagedConfig) { - @Bind - fun name() = Text.translatable("firmament.config.${config.name}").string - - @Bind - fun openEditor() { - config.showConfigEditor(MC.screen) - } - } - } - - fun makeBuiltInScreen(parent: Screen? = null): Screen { - return MoulConfigUtils.loadScreen("config/main", MainMapping(allConfigs), parent) - } - - fun makeScreen(parent: Screen? = null): Screen { - val provider = FirmamentConfigScreenProvider.providers.find { it.key == "builtin" } - ?: FirmamentConfigScreenProvider.providers.first() - return provider.open(parent) - } - - fun showAllGuis() { - setScreenLater(makeScreen()) - } + val allConfigs + get() = listOf( + RepoManager.Config + ) + FeatureManager.allFeatures.mapNotNull { it.config } + + fun List.toObservableList(): ObservableList = ObservableList(this) + + class MainMapping(val allConfigs: List) { + @get:Bind("configs") + val configs = allConfigs.map { EntryMapping(it) }.toObservableList() + + class EntryMapping(val config: ManagedConfig) { + @Bind + fun name() = Text.translatable("firmament.config.${config.name}").string + + @Bind + fun openEditor() { + config.showConfigEditor(MC.screen) + } + } + } + + fun makeBuiltInScreen(parent: Screen? = null): Screen { + return MoulConfigUtils.loadScreen("config/main", MainMapping(allConfigs), parent) + } + + fun makeScreen(parent: Screen? = null): Screen { + val wantedKey = if (RepoManager.Config.enableYacl) "yacl" else "builtin" + val provider = FirmamentConfigScreenProvider.providers.find { it.key == wantedKey } + ?: FirmamentConfigScreenProvider.providers.first() + return provider.open(parent) + } + + fun showAllGuis() { + setScreenLater(makeScreen()) + } } -- cgit