fix: boolean & cycle values not saved properly

This commit is contained in:
xtex 2023-07-29 20:03:55 +08:00
parent 2f7c9a883a
commit d5c9eb6b41
Signed by: xtex
GPG Key ID: B918086ED8045B91

View File

@ -109,17 +109,25 @@ class ProjectionEffectShell(val effect: ProjectionEffect) {
fun intCycle(key: String, property: KMutableProperty0<Int>, range: IntProgression) = fun intCycle(key: String, property: KMutableProperty0<Int>, range: IntProgression) =
row(key) { row(key) {
CycleButton.builder<Int> { Component.literal(it.toString()) } CycleButton.builder<Int> {
property.set(it)
Component.literal(it.toString())
}
.displayOnlyValue() .displayOnlyValue()
.withValues(range.toList()) .withValues(range.toList())
.withInitialValue(property.get())
.create(0, 0, width, height, Component.translatable(key)) .create(0, 0, width, height, Component.translatable(key))
} }
fun boolean(key: String, property: KMutableProperty0<Boolean>) = fun boolean(key: String, property: KMutableProperty0<Boolean>) =
row(key) { row(key) {
CycleButton.builder<Boolean> { Component.translatable("$key.$it") } CycleButton.builder<Boolean> {
property.set(it)
Component.translatable("$key.$it")
}
.displayOnlyValue() .displayOnlyValue()
.withValues(listOf(true, false)) .withValues(listOf(true, false))
.withInitialValue(property.get())
.create(0, 0, width, height, Component.translatable(key)) .create(0, 0, width, height, Component.translatable(key))
} }