Fix incorrect assumptions in getPersistedOrDefault() in orx-gui
This commit is contained in:
@@ -32,7 +32,8 @@ private fun <T : Any> getPersistedOrDefault(compartmentLabel: String, property:
|
|||||||
if (state == null) {
|
if (state == null) {
|
||||||
return property.get(obj)
|
return property.get(obj)
|
||||||
} else {
|
} else {
|
||||||
return state.parameterValues[property.name] as? T?
|
@Suppress("UNCHECKED_CAST")
|
||||||
|
return (state.parameterValues[property.name] as? T?) ?: return property.get(obj)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -71,7 +72,7 @@ class GUI : Extension {
|
|||||||
}
|
}
|
||||||
|
|
||||||
styleSheet(has class_ "toolbar") {
|
styleSheet(has class_ "toolbar") {
|
||||||
this.height = 30.px
|
this.height = 50.px
|
||||||
this.width = 100.percent
|
this.width = 100.percent
|
||||||
this.display = Display.FLEX
|
this.display = Display.FLEX
|
||||||
this.flexDirection = FlexDirection.Row
|
this.flexDirection = FlexDirection.Row
|
||||||
@@ -150,7 +151,7 @@ class GUI : Extension {
|
|||||||
div("sidebar") {
|
div("sidebar") {
|
||||||
id = "sidebar"
|
id = "sidebar"
|
||||||
for ((labeledObject, binding) in trackedObjects) {
|
for ((labeledObject, binding) in trackedObjects) {
|
||||||
val (label, obj) = labeledObject
|
val (label, _) = labeledObject
|
||||||
|
|
||||||
val header = h3 { label }
|
val header = h3 { label }
|
||||||
val collapsible = div("compartment") {
|
val collapsible = div("compartment") {
|
||||||
@@ -325,11 +326,12 @@ class GUI : Extension {
|
|||||||
fun <T> KMutableProperty1<out Any, Any?>?.qset(obj: Any, value: T) {
|
fun <T> KMutableProperty1<out Any, Any?>?.qset(obj: Any, value: T) {
|
||||||
return (this as KMutableProperty1<Any, T>).set(obj, value)
|
return (this as KMutableProperty1<Any, T>).set(obj, value)
|
||||||
}
|
}
|
||||||
|
|
||||||
val json = file.readText()
|
val json = file.readText()
|
||||||
val tt = object : TypeToken<Map<String, Map<String, ParameterValue>>>() {}
|
val tt = object : TypeToken<Map<String, Map<String, ParameterValue>>>() {}
|
||||||
val labeledValues: Map<String, Map<String, ParameterValue>> = Gson().fromJson(json, tt.type)
|
val labeledValues: Map<String, Map<String, ParameterValue>> = Gson().fromJson(json, tt.type)
|
||||||
|
|
||||||
labeledValues.forEach { label, ps ->
|
labeledValues.forEach { (label, ps) ->
|
||||||
trackedObjects.keys.find { it.label == label }?.let { lo ->
|
trackedObjects.keys.find { it.label == label }?.let { lo ->
|
||||||
val binding = trackedObjects[lo]!!
|
val binding = trackedObjects[lo]!!
|
||||||
ps.forEach { (parameterName, parameterValue) ->
|
ps.forEach { (parameterName, parameterValue) ->
|
||||||
@@ -407,7 +409,7 @@ class GUI : Extension {
|
|||||||
(parameter.property as KMutableProperty1<Any, ColorRGBa>).set(labeledObject.obj, c)
|
(parameter.property as KMutableProperty1<Any, ColorRGBa>).set(labeledObject.obj, c)
|
||||||
}
|
}
|
||||||
else -> {
|
else -> {
|
||||||
// do nothing
|
// intentionally do nothing
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user