diff options
author | Linnea Gräf <nea@nea.moe> | 2024-10-13 19:53:10 +0200 |
---|---|---|
committer | Linnea Gräf <nea@nea.moe> | 2024-10-13 19:53:10 +0200 |
commit | 87b851373071490bb371ba1160f85f0341579cb2 (patch) | |
tree | 45d267d83baad2e3cb6caad6127f6a4d40e7fcbf /src/main/kotlin/gui/config/AllConfigsGui.kt | |
parent | e6142bb93619dee768fc18b87ffdd28558d4bcab (diff) | |
download | Firmament-87b851373071490bb371ba1160f85f0341579cb2.tar.gz Firmament-87b851373071490bb371ba1160f85f0341579cb2.tar.bz2 Firmament-87b851373071490bb371ba1160f85f0341579cb2.zip |
Add YACL config menu
Diffstat (limited to 'src/main/kotlin/gui/config/AllConfigsGui.kt')
-rw-r--r-- | src/main/kotlin/gui/config/AllConfigsGui.kt | 71 |
1 files changed, 36 insertions, 35 deletions
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 <T> List<T>.toObservableList(): ObservableList<T> = ObservableList(this) - - class MainMapping(val allConfigs: List<ManagedConfig>) { - @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 <T> List<T>.toObservableList(): ObservableList<T> = ObservableList(this) + + class MainMapping(val allConfigs: List<ManagedConfig>) { + @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()) + } } |