@@ -62,6 +62,8 @@ open class AutomationConfig(
6262 override val hotbarConfig = HotbarSettings (this , Group .Hotbar )
6363 override val eatConfig = EatSettings (this , Group .Eat )
6464
65+ val hiddenSettings = mutableSetOf<AbstractSetting <* >>()
66+
6567 companion object {
6668 context(module: Module )
6769 fun automationConfig (name : String = module.name, edits : (AutomationConfig .() -> Unit )? = null): AutomationConfig =
@@ -104,7 +106,7 @@ open class AutomationConfig(
104106 @SettingEditorDsl
105107 internal inline fun <T : Any > KProperty0<T>.edit (edits : TypedEditBuilder <T >.(AbstractSetting <T >) -> Unit ) {
106108 val setting = delegate as ? AbstractSetting <T > ? : throw IllegalStateException (" Setting delegate did not match current value's type" )
107- TypedEditBuilder (listOf (setting), this @AutomationConfig ).edits(setting)
109+ TypedEditBuilder (this @AutomationConfig, listOf (setting)).edits(setting)
108110 }
109111
110112 @SettingEditorDsl
@@ -113,7 +115,7 @@ open class AutomationConfig(
113115 edits : TypedEditBuilder <T >.(AbstractSetting <R >) -> Unit
114116 ) {
115117 val setting = delegate as ? AbstractSetting <T > ? : throw IllegalStateException (" Setting delegate did not match current value's type" )
116- TypedEditBuilder (listOf (setting), this @AutomationConfig ).edits(other.delegate as AbstractSetting <R >)
118+ TypedEditBuilder (this @AutomationConfig, listOf (setting)).edits(other.delegate as AbstractSetting <R >)
117119 }
118120
119121 @SettingEditorDsl
@@ -133,43 +135,57 @@ open class AutomationConfig(
133135 internal inline fun <T : Any > editTyped (
134136 vararg settings : KProperty0 <T >,
135137 edits : TypedEditBuilder <T >.() -> Unit
136- ) { TypedEditBuilder (settings.map { it.delegate } as List <AbstractSetting <T >>, this @AutomationConfig ).apply (edits) }
138+ ) { TypedEditBuilder (this @AutomationConfig, settings.map { it.delegate } as List <AbstractSetting <T >>).apply (edits) }
137139
138140 @SettingEditorDsl
139141 internal inline fun <T : Any , R : Any > editTypedWith (
140142 vararg settings : KProperty0 <T >,
141143 other : KProperty0 <R >,
142144 edits : TypedEditBuilder <T >.(AbstractSetting <R >) -> Unit
143- ) = TypedEditBuilder (settings.map { it.delegate } as List <AbstractSetting <T >>, this @AutomationConfig).edits(other.delegate as AbstractSetting <R >)
145+ ) = TypedEditBuilder (this @AutomationConfig, settings.map { it.delegate } as List <AbstractSetting <T >>).edits(other.delegate as AbstractSetting <R >)
146+
147+ @SettingEditorDsl
148+ fun hide (vararg settings : KProperty0 <* >) = {
149+ (settings.map { it.delegate } as List <AbstractSetting <* >>).let { removed ->
150+ this @AutomationConfig.settings.removeAll(removed)
151+ hiddenSettings.addAll(removed)
152+ }
153+ }
144154
145155 @SettingEditorDsl
146- fun hide (vararg settings : KProperty0 <* >) =
147- this @AutomationConfig.settings.removeAll(settings.map { it.delegate } as List <AbstractSetting <* >>)
156+ fun hideAll (settingGroup : SettingGroup ) = hideAll(settingGroup.settings)
148157
149158 @SettingEditorDsl
150- fun hideAll (settingGroup : SettingGroup ) {
151- settings.removeAll(settingGroup.settings)
159+ fun hideAll (settings : Collection <AbstractSetting <* >>) {
160+ this @AutomationConfig.settings.removeAll(settings)
161+ hiddenSettings.addAll(settings)
152162 }
153163
154164 @SettingEditorDsl
155165 fun hideAll (vararg settingGroups : SettingGroup ) {
156- settings.removeAll(settingGroups.flatMap { it.settings })
166+ settingGroups.flatMap { it.settings }.let { removed ->
167+ settings.removeAll(removed)
168+ hiddenSettings.addAll(removed)
169+ }
157170 }
158171
159172 @SettingEditorDsl
160173 fun hideAllExcept (settingGroup : SettingGroup , vararg settings : KProperty0 <* >) {
161- this @AutomationConfig.settings.removeIf { it in settingGroup.settings && it !in (settings.toList() as List <AbstractSetting <* >>) }
174+ this @AutomationConfig.settings.removeIf {
175+ return @removeIf if (it in settingGroup.settings && it !in (settings.toList() as List <AbstractSetting <* >>)) {
176+ hiddenSettings.add(it)
177+ true
178+ } else false
179+ }
162180 }
163181
164- open class BasicEditBuilder (val c : Configurable , open val settings : Collection <AbstractSetting <* >>) {
182+ open class BasicEditBuilder (val c : AutomationConfig , open val settings : Collection <AbstractSetting <* >>) {
165183 @SettingEditorDsl
166184 fun visibility (vis : () -> Boolean ) =
167185 settings.forEach { it.visibility = vis }
168186
169187 @SettingEditorDsl
170- fun hide () {
171- c.settings.removeAll(settings)
172- }
188+ fun hide () = c.hideAll(settings)
173189
174190 @SettingEditorDsl
175191 fun groups (vararg groups : NamedEnum ) =
@@ -181,8 +197,8 @@ open class AutomationConfig(
181197 }
182198
183199 open class TypedEditBuilder <T : Any >(
184- override val settings : Collection < AbstractSetting < T >> ,
185- c : Configurable
200+ c : AutomationConfig ,
201+ override val settings : Collection < AbstractSetting < T >>
186202 ) : BasicEditBuilder(c, settings) {
187203 @SettingEditorDsl
188204 fun defaultValue (value : T ) =
0 commit comments