aboutsummaryrefslogtreecommitdiff
path: root/src/compat/configured/java
diff options
context:
space:
mode:
Diffstat (limited to 'src/compat/configured/java')
-rw-r--r--src/compat/configured/java/BaseConfigNode.kt40
-rw-r--r--src/compat/configured/java/ConfigCategory.kt48
-rw-r--r--src/compat/configured/java/ConfigNode.kt39
-rw-r--r--src/compat/configured/java/ConfigValue.kt72
-rw-r--r--src/compat/configured/java/ConfigValueNode.kt37
-rw-r--r--src/compat/configured/java/ConfiguredCompat.kt30
-rw-r--r--src/compat/configured/java/ConfiguredConfigScreenProvider.kt22
7 files changed, 0 insertions, 288 deletions
diff --git a/src/compat/configured/java/BaseConfigNode.kt b/src/compat/configured/java/BaseConfigNode.kt
deleted file mode 100644
index afe0375..0000000
--- a/src/compat/configured/java/BaseConfigNode.kt
+++ /dev/null
@@ -1,40 +0,0 @@
-package moe.nea.firmament.compat.configured
-
-import com.mrcrayfish.configured.api.IConfigEntry
-import com.mrcrayfish.configured.api.IConfigValue
-import net.minecraft.text.Text
-import moe.nea.firmament.gui.config.AllConfigsGui
-import moe.nea.firmament.gui.config.ManagedConfig
-
-object BaseConfigNode : IConfigEntry {
- override fun getChildren(): List<IConfigEntry> {
- return ManagedConfig.allManagedConfigs.getAll().map {
- ConfigNode(it) // TODO: fix add categories here
- }
- }
-
- override fun isRoot(): Boolean {
- return true
- }
-
- override fun isLeaf(): Boolean {
- return false
- }
-
- override fun getValue(): IConfigValue<*>? {
- return null
- }
-
- override fun getEntryName(): String {
- return "Firmament"
- }
-
- override fun getTooltip(): Text? {
- return null
- }
-
- override fun getTranslationKey(): String? {
- return null
- }
-
-}
diff --git a/src/compat/configured/java/ConfigCategory.kt b/src/compat/configured/java/ConfigCategory.kt
deleted file mode 100644
index 4e33b8b..0000000
--- a/src/compat/configured/java/ConfigCategory.kt
+++ /dev/null
@@ -1,48 +0,0 @@
-package moe.nea.firmament.compat.configured
-
-import com.mrcrayfish.configured.api.ConfigType
-import com.mrcrayfish.configured.api.IConfigEntry
-import com.mrcrayfish.configured.api.IModConfig
-import com.mrcrayfish.configured.util.ConfigHelper
-import java.nio.file.Path
-import java.util.function.Consumer
-import moe.nea.firmament.Firmament
-import moe.nea.firmament.gui.config.ManagedConfig
-
-class ConfigCategory(
- val category: ManagedConfig
-) : BaseConfig() {
-
- override fun getRoot(): IConfigEntry {
- return ConfigNode(category)
- }
-
- override fun getTranslationKey(): String? {
- return category.translationKey
- }
-}
-
-abstract class BaseConfig : IModConfig {
- override fun update(p0: IConfigEntry) {
- ConfigHelper.getChangedValues(p0).forEach {
- it as ConfigValue
- it.saveValue()
- }
- }
-
- override fun getType(): ConfigType {
- return ConfigType.CLIENT
- }
-
- override fun getFileName(): String {
- return ""
- }
-
- override fun getModId(): String {
- return Firmament.MOD_ID
- }
-
- override fun loadWorldConfig(p0: Path?, p1: Consumer<IModConfig>?) {
- }
-
-}
diff --git a/src/compat/configured/java/ConfigNode.kt b/src/compat/configured/java/ConfigNode.kt
deleted file mode 100644
index 16e54a6..0000000
--- a/src/compat/configured/java/ConfigNode.kt
+++ /dev/null
@@ -1,39 +0,0 @@
-package moe.nea.firmament.compat.configured
-
-import com.mrcrayfish.configured.api.IConfigEntry
-import com.mrcrayfish.configured.api.IConfigValue
-import net.minecraft.text.Text
-import moe.nea.firmament.gui.config.ManagedConfig
-
-class ConfigNode(val config: ManagedConfig) : IConfigEntry {
- override fun getChildren(): List<IConfigEntry> {
- return config.allOptions.map {
- ConfigValueNode(it.value)
- }
- }
-
- override fun isRoot(): Boolean {
- return false
- }
-
- override fun isLeaf(): Boolean {
- return false
- }
-
- override fun getValue(): IConfigValue<*>? {
- return null
- }
-
- override fun getEntryName(): String {
- return config.translationKey
- }
-
- override fun getTooltip(): Text? {
- return null
- }
-
- override fun getTranslationKey(): String {
- return config.translationKey
- }
-
-}
diff --git a/src/compat/configured/java/ConfigValue.kt b/src/compat/configured/java/ConfigValue.kt
deleted file mode 100644
index e16c51c..0000000
--- a/src/compat/configured/java/ConfigValue.kt
+++ /dev/null
@@ -1,72 +0,0 @@
-package moe.nea.firmament.compat.configured
-
-import com.mrcrayfish.configured.api.IConfigValue
-import net.minecraft.text.Text
-import moe.nea.firmament.gui.config.ManagedOption
-
-class ConfigValue<T: Any>(val option: ManagedOption<T>) : IConfigValue<T> {
- var value = option.get()
- var initialValue = option.get()
-
- override fun get(): T {
- return value
- }
-
- override fun set(p0: T) {
- this.value = p0
- }
-
- override fun getDefault(): T {
- return option.default()
- }
-
- override fun isDefault(): Boolean {
- // TODO: should this be an option in handlers?
- return option == option.default()
- }
-
- override fun isChanged(): Boolean {
- return value != initialValue
- }
-
- override fun restore() {
- this.value = option.default()
- }
-
- override fun getComment(): Text? {
- return null
- }
-
- override fun getTranslationKey(): String? {
- return option.rawLabelText
- }
-
- override fun getValidationHint(): Text? {
- return null
- }
-
- override fun getName(): String {
- return ""
- }
-
- override fun cleanCache() {
-
- }
-
- override fun requiresWorldRestart(): Boolean {
- return false
- }
-
- override fun requiresGameRestart(): Boolean {
- return false
- }
-
- override fun isValid(p0: T): Boolean {
- // TODO: should this be validated?
- return true
- }
-
- fun saveValue() {
- option.set(value)
- }
-}
diff --git a/src/compat/configured/java/ConfigValueNode.kt b/src/compat/configured/java/ConfigValueNode.kt
deleted file mode 100644
index df59739..0000000
--- a/src/compat/configured/java/ConfigValueNode.kt
+++ /dev/null
@@ -1,37 +0,0 @@
-package moe.nea.firmament.compat.configured
-
-import com.mrcrayfish.configured.api.IConfigEntry
-import com.mrcrayfish.configured.api.IConfigValue
-import net.minecraft.text.Text
-import moe.nea.firmament.gui.config.ManagedOption
-
-class ConfigValueNode(val option: ManagedOption<*>) : IConfigEntry {
- override fun getChildren(): List<IConfigEntry> {
- return listOf()
- }
-
- override fun isRoot(): Boolean {
- return false
- }
-
- override fun isLeaf(): Boolean {
- return true
- }
-
- val value = ConfigValue(option)
- override fun getValue(): IConfigValue<*>? {
- return value
- }
-
- override fun getEntryName(): String {
- return option.propertyName
- }
-
- override fun getTooltip(): Text? {
- return null
- }
-
- override fun getTranslationKey(): String? {
- return option.rawLabelText
- }
-}
diff --git a/src/compat/configured/java/ConfiguredCompat.kt b/src/compat/configured/java/ConfiguredCompat.kt
deleted file mode 100644
index 8e8b022..0000000
--- a/src/compat/configured/java/ConfiguredCompat.kt
+++ /dev/null
@@ -1,30 +0,0 @@
-package moe.nea.firmament.compat.configured
-
-import com.mrcrayfish.configured.api.IConfigEntry
-import com.mrcrayfish.configured.api.IModConfig
-import com.mrcrayfish.configured.api.IModConfigProvider
-import com.mrcrayfish.configured.api.ModContext
-import moe.nea.firmament.Firmament
-import moe.nea.firmament.gui.config.AllConfigsGui
-import moe.nea.firmament.gui.config.ManagedConfig
-
-/**
- * Registered in `fabric.mod.json` at `custom.configured.providers`
- */
-class ConfiguredCompat : IModConfigProvider {
- override fun getConfigurationsForMod(modContext: ModContext): Set<IModConfig> {
- if (modContext.modId != Firmament.MOD_ID) return emptySet()
- return buildSet {
- add(object : BaseConfig() {
- override fun getRoot(): IConfigEntry {
- return BaseConfigNode
- }
-
- override fun getTranslationKey(): String? {
- return "firmament.config.all-configs"
- }
- })
- ManagedConfig.allManagedConfigs.getAll().mapTo(this) { ConfigCategory(it) }
- }
- }
-}
diff --git a/src/compat/configured/java/ConfiguredConfigScreenProvider.kt b/src/compat/configured/java/ConfiguredConfigScreenProvider.kt
deleted file mode 100644
index c0095bf..0000000
--- a/src/compat/configured/java/ConfiguredConfigScreenProvider.kt
+++ /dev/null
@@ -1,22 +0,0 @@
-package moe.nea.firmament.compat.configured
-
-import com.google.auto.service.AutoService
-import com.mrcrayfish.configured.integration.CatalogueConfigFactory
-import net.fabricmc.loader.api.FabricLoader
-import net.minecraft.client.gui.screen.Screen
-import moe.nea.firmament.Firmament
-import moe.nea.firmament.gui.config.FirmamentConfigScreenProvider
-
-@AutoService(FirmamentConfigScreenProvider::class)
-class ConfiguredConfigScreenProvider : FirmamentConfigScreenProvider {
- override val key: String
- get() = "configured"
- override val isEnabled: Boolean
- get() = FabricLoader.getInstance().isModLoaded("configured")
-
- override fun open(parent: Screen?): Screen {
- return CatalogueConfigFactory.createConfigScreen(
- parent,
- FabricLoader.getInstance().getModContainer(Firmament.MOD_ID).get())
- }
-}