@@ -102,18 +102,18 @@ open class AutomationConfig(
102102 }
103103
104104 @SettingEditorDsl
105- internal inline fun <T : Any > KProperty0<T>.edit (edits : FullEditBuilder <T >.(AbstractSetting <T >) -> Unit ) {
105+ internal inline fun <T : Any > KProperty0<T>.edit (edits : TypedEditBuilder <T >.(AbstractSetting <T >) -> Unit ) {
106106 val setting = delegate as ? AbstractSetting <T > ? : throw IllegalStateException (" Setting delegate did not match current value's type" )
107- FullEditBuilder ( setting, this @AutomationConfig).edits(setting)
107+ TypedEditBuilder ( listOf ( setting) , this @AutomationConfig).edits(setting)
108108 }
109109
110110 @SettingEditorDsl
111- internal inline fun <T : Any > KProperty0<T>.editWith (
112- other : KProperty0 <* >,
113- edits : FullEditBuilder <T >.(AbstractSetting <* >) -> Unit
111+ internal inline fun <T : Any , R : Any > KProperty0<T>.editWith (
112+ other : KProperty0 <R >,
113+ edits : TypedEditBuilder <T >.(AbstractSetting <R >) -> Unit
114114 ) {
115115 val setting = delegate as ? AbstractSetting <T > ? : throw IllegalStateException (" Setting delegate did not match current value's type" )
116- FullEditBuilder ( setting, this @AutomationConfig).edits(other.delegate as AbstractSetting <* >)
116+ TypedEditBuilder ( listOf ( setting) , this @AutomationConfig).edits(other.delegate as AbstractSetting <R >)
117117 }
118118
119119 @SettingEditorDsl
@@ -123,11 +123,11 @@ open class AutomationConfig(
123123 ) { BasicEditBuilder (this @AutomationConfig, settings.map { it.delegate } as List <AbstractSetting <* >>).apply (edits) }
124124
125125 @SettingEditorDsl
126- fun editWith (
126+ internal inline fun < T : Any > editWith (
127127 vararg settings : KProperty0 <* >,
128- other : KProperty0 <* >,
129- edits : BasicEditBuilder .(AbstractSetting <* >) -> Unit
130- ) { BasicEditBuilder (this @AutomationConfig, settings.map { it.delegate } as List <AbstractSetting <* >>).edits(other.delegate as AbstractSetting <* >) }
128+ other : KProperty0 <T >,
129+ edits : BasicEditBuilder .(AbstractSetting <T >) -> Unit
130+ ) { BasicEditBuilder (this @AutomationConfig, settings.map { it.delegate } as List <AbstractSetting <* >>).edits(other.delegate as AbstractSetting <T >) }
131131
132132 @SettingEditorDsl
133133 internal inline fun <T : Any > editTyped (
@@ -146,6 +146,21 @@ open class AutomationConfig(
146146 fun hide (vararg settings : KProperty0 <* >) =
147147 this @AutomationConfig.settings.removeAll(settings.map { it.delegate } as List <AbstractSetting <* >>)
148148
149+ @SettingEditorDsl
150+ fun hideAll (settingGroup : SettingGroup ) {
151+ settings.removeAll(settingGroup.settings)
152+ }
153+
154+ @SettingEditorDsl
155+ fun hideAll (vararg settingGroups : SettingGroup ) {
156+ settings.removeAll(settingGroups.flatMap { it.settings })
157+ }
158+
159+ @SettingEditorDsl
160+ fun hideAllExcept (settingGroup : SettingGroup , vararg settings : KProperty0 <* >) {
161+ this @AutomationConfig.settings.removeIf { it in settingGroup.settings && it !in (settings.toList() as List <AbstractSetting <* >>) }
162+ }
163+
149164 open class BasicEditBuilder (val c : Configurable , open val settings : Collection <AbstractSetting <* >>) {
150165 @SettingEditorDsl
151166 fun visibility (vis : () -> Boolean ) =
@@ -177,21 +192,6 @@ open class AutomationConfig(
177192 }
178193 }
179194
180- class FullEditBuilder <T : Any >(
181- private val setting : AbstractSetting <T >,
182- c : Configurable
183- ) : TypedEditBuilder<T>(setOf(setting), c) {
184- @SettingEditorDsl
185- fun name (name : String ) {
186- setting.name = name
187- }
188-
189- @SettingEditorDsl
190- fun description (description : String ) {
191- setting.description = description
192- }
193- }
194-
195195 enum class InsertMode {
196196 Above ,
197197 Below
0 commit comments