diff options
author | Linnea Gräf <nea@nea.moe> | 2024-12-22 15:32:18 +0100 |
---|---|---|
committer | Linnea Gräf <nea@nea.moe> | 2024-12-22 15:32:18 +0100 |
commit | a9a801048d694e5b250f3a23089075e9b7bd976c (patch) | |
tree | 9bd3eeb7cd3bfe650d4c098ee505df5116ac0799 /src/main/kotlin/gui | |
parent | ba79b46f64d541504b391dae17efb485a08e7745 (diff) | |
download | Firmament-a9a801048d694e5b250f3a23089075e9b7bd976c.tar.gz Firmament-a9a801048d694e5b250f3a23089075e9b7bd976c.tar.bz2 Firmament-a9a801048d694e5b250f3a23089075e9b7bd976c.zip |
feat: Option to not rendering slot binding lines
Diffstat (limited to 'src/main/kotlin/gui')
-rw-r--r-- | src/main/kotlin/gui/config/ManagedConfig.kt | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/src/main/kotlin/gui/config/ManagedConfig.kt b/src/main/kotlin/gui/config/ManagedConfig.kt index 47a9c92..ea55f67 100644 --- a/src/main/kotlin/gui/config/ManagedConfig.kt +++ b/src/main/kotlin/gui/config/ManagedConfig.kt @@ -15,6 +15,7 @@ import org.lwjgl.glfw.GLFW import kotlinx.serialization.encodeToString import kotlinx.serialization.json.JsonElement import kotlinx.serialization.json.JsonObject +import kotlin.enums.enumEntries import kotlin.io.path.createDirectories import kotlin.io.path.readText import kotlin.io.path.writeText @@ -123,6 +124,17 @@ abstract class ManagedConfig( return option(propertyName, default, ChoiceHandler(universe)) } + protected inline fun <reified E> choice( + propertyName: String, + noinline default: () -> E + ): ManagedOption<E> where E : Enum<E>, E : StringIdentifiable { + return choice(propertyName, enumEntries<E>(), default) + } + + private fun <E> createStringIdentifiable(x: () -> Array<out E>): Codec<E> where E : Enum<E>, E : StringIdentifiable { + return StringIdentifiable.createCodec { x() } + } + // TODO: wait on https://youtrack.jetbrains.com/issue/KT-73434 // protected inline fun <reified E> choice( // propertyName: String, |