diff options
author | Linnea Gräf <nea@nea.moe> | 2024-10-13 21:46:46 +0200 |
---|---|---|
committer | Linnea Gräf <nea@nea.moe> | 2024-10-13 21:46:46 +0200 |
commit | 4e9b0ded27df8b6ce7f5b2fa1b4b1ddbc1cbd452 (patch) | |
tree | a489fdd97e6c4dde1bd77bf216ed9c2ec2657db3 /src/main/kotlin/gui/config/AllConfigsGui.kt | |
parent | 0cc77949c907d38497f8cdf6fd8198fe5f0a9440 (diff) | |
download | Firmament-4e9b0ded27df8b6ce7f5b2fa1b4b1ddbc1cbd452.tar.gz Firmament-4e9b0ded27df8b6ce7f5b2fa1b4b1ddbc1cbd452.tar.bz2 Firmament-4e9b0ded27df8b6ce7f5b2fa1b4b1ddbc1cbd452.zip |
Add config categories
Diffstat (limited to 'src/main/kotlin/gui/config/AllConfigsGui.kt')
-rw-r--r-- | src/main/kotlin/gui/config/AllConfigsGui.kt | 46 |
1 files changed, 37 insertions, 9 deletions
diff --git a/src/main/kotlin/gui/config/AllConfigsGui.kt b/src/main/kotlin/gui/config/AllConfigsGui.kt index c72b8b0..0e68bc8 100644 --- a/src/main/kotlin/gui/config/AllConfigsGui.kt +++ b/src/main/kotlin/gui/config/AllConfigsGui.kt @@ -4,24 +4,35 @@ import io.github.notenoughupdates.moulconfig.observer.ObservableList import io.github.notenoughupdates.moulconfig.xml.Bind import net.minecraft.client.gui.screen.Screen import net.minecraft.text.Text -import moe.nea.firmament.features.FeatureManager import moe.nea.firmament.repo.RepoManager import moe.nea.firmament.util.MC import moe.nea.firmament.util.MoulConfigUtils import moe.nea.firmament.util.ScreenUtil.setScreenLater object AllConfigsGui { +// +// val allConfigs +// get() = listOf( +// RepoManager.Config +// ) + FeatureManager.allFeatures.mapNotNull { it.config } - val allConfigs - get() = listOf( - RepoManager.Config - ) + FeatureManager.allFeatures.mapNotNull { it.config } + object ConfigConfig : ManagedConfig("configconfig", Category.META) { + val enableYacl by toggle("enable-yacl") { false } + } fun <T> List<T>.toObservableList(): ObservableList<T> = ObservableList(this) - class MainMapping(val allConfigs: List<ManagedConfig>) { + class CategoryMapping(val category: ManagedConfig.Category) { @get:Bind("configs") - val configs = allConfigs.map { EntryMapping(it) }.toObservableList() + val configs = category.configs.map { EntryMapping(it) }.toObservableList() + + @Bind + fun name() = category.labelText.string + + @Bind + fun close() { + MC.screen?.close() + } class EntryMapping(val config: ManagedConfig) { @Bind @@ -34,12 +45,29 @@ object AllConfigsGui { } } + class CategoryView { + @get:Bind("categories") + val categories = ManagedConfig.Category.entries + .map { CategoryEntry(it) } + .toObservableList() + + class CategoryEntry(val category: ManagedConfig.Category) { + @Bind + fun name() = category.labelText.string + + @Bind + fun open() { + MC.screen = MoulConfigUtils.loadScreen("config/category", CategoryMapping(category), MC.screen) + } + } + } + fun makeBuiltInScreen(parent: Screen? = null): Screen { - return MoulConfigUtils.loadScreen("config/main", MainMapping(allConfigs), parent) + return MoulConfigUtils.loadScreen("config/main", CategoryView(), parent) } fun makeScreen(parent: Screen? = null): Screen { - val wantedKey = if (RepoManager.Config.enableYacl) "yacl" else "builtin" + val wantedKey = if (ConfigConfig.enableYacl) "yacl" else "builtin" val provider = FirmamentConfigScreenProvider.providers.find { it.key == wantedKey } ?: FirmamentConfigScreenProvider.providers.first() return provider.open(parent) |