Change loadParameters, saveParameters to be public, add label to addTo

This commit is contained in:
Edwin Jakobs
2020-02-16 23:08:18 +01:00
parent 4dd7075aa9
commit 81ce0ad9b2

View File

@@ -399,7 +399,7 @@ class GUI : Extension {
var textValue: String? = null) var textValue: String? = null)
private fun saveParameters(file: File) { fun saveParameters(file: File) {
fun <T> KMutableProperty1<out Any, Any?>?.qget(obj: Any): T { fun <T> KMutableProperty1<out Any, Any?>?.qget(obj: Any): T {
return (this as KMutableProperty1<Any, T>).get(obj) return (this as KMutableProperty1<Any, T>).get(obj)
} }
@@ -421,7 +421,7 @@ class GUI : Extension {
file.writeText(Gson().toJson(toSave)) file.writeText(Gson().toJson(toSave))
} }
private fun loadParameters(file: File) { fun loadParameters(file: File) {
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)
} }
@@ -584,7 +584,7 @@ class GUI : Extension {
} }
@JvmName("addToGui") @JvmName("addToGui")
fun <T : Any> T.addTo(gui: GUI): T { fun <T : Any> T.addTo(gui: GUI, label:String? = this.title()): T {
gui.add(this) gui.add(this, label)
return this return this
} }