@@ -52,35 +52,43 @@ open class KtConfig(id: String, title: String, category: Category, icon: String?
5252 * create a new delegate for the given property.
5353 */
5454 @JvmSynthetic
55- protected inline fun <reified T > property (def : T ? = null, name : String? = null, description : String? = null, visualizer : Class <out Visualizer >) = Provider (def, name, description, T ::class .java, visualizer)
55+ protected inline fun <reified T > property (def : T ? = null, name : String? = null, description : String? = null, category : String? = null, subcategory : String? = null, visualizer : Class <out Visualizer >) =
56+ Provider (def, name, description, category, subcategory, T ::class .java, visualizer)
5657
5758 @JvmSynthetic
58- protected fun switch (def : Boolean = false, name : String? = null, description : String? = null) = Provider (def, name, description, Boolean ::class .java, Visualizer .SwitchVisualizer ::class .java)
59+ protected fun switch (def : Boolean = false, name : String? = null, description : String? = null, category : String? = null, subcategory : String? = null) =
60+ Provider (def, name, description, category, subcategory, Boolean ::class .java, Visualizer .SwitchVisualizer ::class .java)
5961
6062 @JvmSynthetic
61- protected fun color (def : PolyColor = rgba(0, 0, 0, 1f), name : String? = null, description : String? = null) = Provider (def, name, description, PolyColor ::class .java, Visualizer .ColorVisualizer ::class .java)
63+ protected fun color (def : PolyColor = rgba(0, 0, 0, 1f), name : String? = null, description : String? = null, category : String? = null, subcategory : String? = null) =
64+ Provider (def, name, description, category, subcategory, PolyColor ::class .java, Visualizer .ColorVisualizer ::class .java)
6265
6366 @JvmSynthetic
64- protected fun slider (min : Float = 0f, max : Float = 0f, def : Float = 0f, name : String? = null, description : String? = null) = Provider (def, name, description, Float ::class .java, Visualizer .SliderVisualizer ::class .java) {
65- addMetadata(" min" , min)
66- addMetadata(" max" , max)
67- }
67+ protected fun slider (min : Float = 0f, max : Float = 0f, def : Float = 0f, name : String? = null, description : String? = null, category : String? = null, subcategory : String? = null) =
68+ Provider (def, name, description, category, subcategory, Float ::class .java, Visualizer .SliderVisualizer ::class .java) {
69+ addMetadata(" min" , min)
70+ addMetadata(" max" , max)
71+ }
6872
6973 @JvmSynthetic
70- protected fun text (def : String = "", name : String? = null, description : String? = null) = Provider (def, name, description, String ::class .java, Visualizer .TextVisualizer ::class .java)
74+ protected fun text (def : String = "", name : String? = null, description : String? = null, category : String? = null, subcategory : String? = null) =
75+ Provider (def, name, description, category, subcategory, String ::class .java, Visualizer .TextVisualizer ::class .java)
7176
7277 @JvmSynthetic
73- protected fun keybind (def : KeyBinder .Bind ? = null, name : String? = null, description : String? = null) = Provider (def, name, description, KeyBinder .Bind ::class .java, Visualizer .KeybindVisualizer ::class .java)
78+ protected fun keybind (def : KeyBinder .Bind ? = null, name : String? = null, description : String? = null, category : String? = null, subcategory : String? = null) =
79+ Provider (def, name, description, category, subcategory, KeyBinder .Bind ::class .java, Visualizer .KeybindVisualizer ::class .java)
7480
7581 @JvmSynthetic
76- protected fun radiobutton (options : Array <String >, def : Int = 0, name : String? = null, description : String? = null) = Provider (def, name, description, Int ::class .java, Visualizer .RadioVisualizer ::class .java) {
77- addMetadata(" options" , options)
78- }
82+ protected fun radiobutton (options : Array <String >, def : Int = 0, name : String? = null, description : String? = null, category : String? = null, subcategory : String? = null) =
83+ Provider (def, name, description, category, subcategory, Int ::class .java, Visualizer .RadioVisualizer ::class .java) {
84+ addMetadata(" options" , options)
85+ }
7986
8087 @JvmSynthetic
81- protected fun dropdown (options : Array <String >, def : Int = 0, name : String? = null, description : String? = null) = Provider (def, name, description, Int ::class .java, Visualizer .DropdownVisualizer ::class .java) {
82- addMetadata(" options" , options)
83- }
88+ protected fun dropdown (options : Array <String >, def : Int = 0, name : String? = null, description : String? = null, category : String? = null, subcategory : String? = null) =
89+ Provider (def, name, description, category, subcategory, Int ::class .java, Visualizer .DropdownVisualizer ::class .java) {
90+ addMetadata(" options" , options)
91+ }
8492
8593
8694 /* *
@@ -90,14 +98,18 @@ open class KtConfig(id: String, title: String, category: Category, icon: String?
9098 private val def : T ? ,
9199 private val name : String? ,
92100 private val description : String? ,
101+ private val category : String? ,
102+ private val subcategory : String? ,
93103 private val type : Class <T >,
94104 private val visualizer : Class <out Visualizer >,
95105 private val extra : (Property <T >.() -> Unit )? = null
96- ) : PropertyDelegateProvider<KtConfig, ReadWriteProperty<KtConfig, T>> {
97- override operator fun provideDelegate (thisRef : KtConfig , property : KProperty <* >): ReadWriteProperty <KtConfig , T > {
106+ ) : PropertyDelegateProvider<KtConfig, ReadWriteProperty<KtConfig, T? >> {
107+ override operator fun provideDelegate (thisRef : KtConfig , property : KProperty <* >): ReadWriteProperty <KtConfig , T ? > {
98108 val p = Properties .simple(property.name, name ? : property.name, description, def, type)
99109 extra?.invoke(p)
100110 p.addMetadata(" visualizer" , visualizer)
111+ p.addMetadata(" category" , category)
112+ p.addMetadata(" subcategory" , subcategory)
101113 thisRef.tree.put(p)
102114 return PropertyDelegate (p)
103115 }
@@ -106,12 +118,10 @@ open class KtConfig(id: String, title: String, category: Category, icon: String?
106118 /* *
107119 * The actual delegate property. very simple.
108120 */
109- private class PropertyDelegate <T >(val property : Property <T >) : ReadWriteProperty<KtConfig, T> {
110- override operator fun getValue (thisRef : KtConfig , property : KProperty <* >): T {
111- return this .property.get()!!
112- }
121+ private class PropertyDelegate <T >(val property : Property <T >) : ReadWriteProperty<KtConfig, T?> {
122+ override operator fun getValue (thisRef : KtConfig , property : KProperty <* >): T ? = this .property.get()
113123
114- override operator fun setValue (thisRef : KtConfig , property : KProperty <* >, value : T ) {
124+ override operator fun setValue (thisRef : KtConfig , property : KProperty <* >, value : T ? ) {
115125 this .property.set(value)
116126 }
117127 }
0 commit comments