diff --git a/orx-gui/src/main/kotlin/Gui.kt b/orx-gui/src/main/kotlin/Gui.kt index 97a0e701..24144957 100644 --- a/orx-gui/src/main/kotlin/Gui.kt +++ b/orx-gui/src/main/kotlin/Gui.kt @@ -48,7 +48,6 @@ private fun sidebarState(): SidebarState = persistentSidebarStates.getOrPut(Driv SidebarState() } - private fun getPersistedOrDefault(compartmentLabel: String, property: KMutableProperty1, obj: Any): T? { val state = persistentCompartmentStates[Driver.instance.contextID]!![compartmentLabel] if (state == null) { @@ -278,6 +277,7 @@ class GUI : Extension { } getPersistedOrDefault(compartment.label, parameter.property as KMutableProperty1, obj)?.let { value = it.toDouble() + setAndPersist(compartment.label, parameter.property as KMutableProperty1, obj, it) } } } @@ -292,6 +292,9 @@ class GUI : Extension { } getPersistedOrDefault(compartment.label, parameter.property as KMutableProperty1, obj)?.let { value = it + /* this is generally not needed, but when the persisted value is equal to the slider default + it will not emit the newly set value */ + setAndPersist(compartment.label, parameter.property as KMutableProperty1, obj, it) } } } @@ -399,8 +402,8 @@ class GUI : Extension { } val json = file.readText() - val tt = object : TypeToken>>() {} - val labeledValues: Map> = Gson().fromJson(json, tt.type) + val typeToken = object : TypeToken>>() {} + val labeledValues: Map> = Gson().fromJson(json, typeToken.type) labeledValues.forEach { (label, ps) -> trackedObjects.keys.find { it.label == label }?.let { lo ->