@@ -154,15 +154,21 @@ final class PadLayoutStore: @unchecked Sendable {
154154
155155 func setControlVisible( _ id: String , visible: Bool ) {
156156 if visible {
157- controlVisibility. removeValue ( forKey: id)
157+ let group = groupID ( for: id)
158+ if id == group {
159+ controlVisibility. removeValue ( forKey: id)
160+ } else if let groupVisible = controlVisibility [ group] , !groupVisible {
161+ controlVisibility [ id] = true
162+ } else {
163+ controlVisibility. removeValue ( forKey: id)
164+ }
158165 } else {
159166 controlVisibility [ id] = false
160167 }
161168 }
162169
163170 func resetControlVisibility( ) {
164171 controlVisibility. removeAll ( )
165- save ( )
166172 }
167173
168174 // MARK: - INI persistence
@@ -180,17 +186,25 @@ final class PadLayoutStore: @unchecked Sendable {
180186 ARMSX2Bridge . setINIFloat ( " ARMSX2iOS/PadLayout/Landscape " , key: " \( id) _scale " , value: Float ( pos. scale) )
181187 }
182188 }
183- // Per-button positions are only written if they have been moved by the user .
189+ // Per-button positions: write override if present, sentinel -1 otherwise .
184190 for id in Self . perButtonIDs {
185191 if let pos = perButtonPortrait [ id] {
186192 ARMSX2Bridge . setINIFloat ( " ARMSX2iOS/PadLayout/PerButtonPortrait " , key: " \( id) _x " , value: Float ( pos. x) )
187193 ARMSX2Bridge . setINIFloat ( " ARMSX2iOS/PadLayout/PerButtonPortrait " , key: " \( id) _y " , value: Float ( pos. y) )
188194 ARMSX2Bridge . setINIFloat ( " ARMSX2iOS/PadLayout/PerButtonPortrait " , key: " \( id) _scale " , value: Float ( pos. scale) )
195+ } else {
196+ ARMSX2Bridge . setINIFloat ( " ARMSX2iOS/PadLayout/PerButtonPortrait " , key: " \( id) _x " , value: - 1.0 )
197+ ARMSX2Bridge . setINIFloat ( " ARMSX2iOS/PadLayout/PerButtonPortrait " , key: " \( id) _y " , value: - 1.0 )
198+ ARMSX2Bridge . setINIFloat ( " ARMSX2iOS/PadLayout/PerButtonPortrait " , key: " \( id) _scale " , value: - 1.0 )
189199 }
190200 if let pos = perButtonLandscape [ id] {
191201 ARMSX2Bridge . setINIFloat ( " ARMSX2iOS/PadLayout/PerButtonLandscape " , key: " \( id) _x " , value: Float ( pos. x) )
192202 ARMSX2Bridge . setINIFloat ( " ARMSX2iOS/PadLayout/PerButtonLandscape " , key: " \( id) _y " , value: Float ( pos. y) )
193203 ARMSX2Bridge . setINIFloat ( " ARMSX2iOS/PadLayout/PerButtonLandscape " , key: " \( id) _scale " , value: Float ( pos. scale) )
204+ } else {
205+ ARMSX2Bridge . setINIFloat ( " ARMSX2iOS/PadLayout/PerButtonLandscape " , key: " \( id) _x " , value: - 1.0 )
206+ ARMSX2Bridge . setINIFloat ( " ARMSX2iOS/PadLayout/PerButtonLandscape " , key: " \( id) _y " , value: - 1.0 )
207+ ARMSX2Bridge . setINIFloat ( " ARMSX2iOS/PadLayout/PerButtonLandscape " , key: " \( id) _scale " , value: - 1.0 )
194208 }
195209 }
196210 // Visibility: `0` = hidden, `1` = visible. Absent means visible (default).
@@ -291,12 +305,10 @@ final class PadLayoutStore: @unchecked Sendable {
291305
292306 func resetPortrait( ) {
293307 portrait = Self . defaultPortrait
294- save ( )
295308 }
296309
297310 func resetLandscape( ) {
298311 landscape = Self . defaultLandscape
299- save ( )
300312 }
301313
302314 func reset( isLandscape: Bool ) {
@@ -307,38 +319,23 @@ final class PadLayoutStore: @unchecked Sendable {
307319 if isLandscape {
308320 for id in [ " triangle " , " circle " , " square " , " cross " ] {
309321 perButtonLandscape. removeValue ( forKey: id)
310- // Overwrite INI keys with sentinel so stale keys do not reload after restart.
311- ARMSX2Bridge . setINIFloat ( " ARMSX2iOS/PadLayout/PerButtonLandscape " , key: " \( id) _x " , value: - 1.0 )
312- ARMSX2Bridge . setINIFloat ( " ARMSX2iOS/PadLayout/PerButtonLandscape " , key: " \( id) _y " , value: - 1.0 )
313- ARMSX2Bridge . setINIFloat ( " ARMSX2iOS/PadLayout/PerButtonLandscape " , key: " \( id) _scale " , value: - 1.0 )
314322 }
315323 } else {
316324 for id in [ " triangle " , " circle " , " square " , " cross " ] {
317325 perButtonPortrait. removeValue ( forKey: id)
318- ARMSX2Bridge . setINIFloat ( " ARMSX2iOS/PadLayout/PerButtonPortrait " , key: " \( id) _x " , value: - 1.0 )
319- ARMSX2Bridge . setINIFloat ( " ARMSX2iOS/PadLayout/PerButtonPortrait " , key: " \( id) _y " , value: - 1.0 )
320- ARMSX2Bridge . setINIFloat ( " ARMSX2iOS/PadLayout/PerButtonPortrait " , key: " \( id) _scale " , value: - 1.0 )
321326 }
322327 }
323- save ( )
324328 }
325329
326330 func resetPerButtonDPad( isLandscape: Bool ) {
327331 if isLandscape {
328332 for id in [ " up " , " down " , " left " , " right " ] {
329333 perButtonLandscape. removeValue ( forKey: id)
330- ARMSX2Bridge . setINIFloat ( " ARMSX2iOS/PadLayout/PerButtonLandscape " , key: " \( id) _x " , value: - 1.0 )
331- ARMSX2Bridge . setINIFloat ( " ARMSX2iOS/PadLayout/PerButtonLandscape " , key: " \( id) _y " , value: - 1.0 )
332- ARMSX2Bridge . setINIFloat ( " ARMSX2iOS/PadLayout/PerButtonLandscape " , key: " \( id) _scale " , value: - 1.0 )
333334 }
334335 } else {
335336 for id in [ " up " , " down " , " left " , " right " ] {
336337 perButtonPortrait. removeValue ( forKey: id)
337- ARMSX2Bridge . setINIFloat ( " ARMSX2iOS/PadLayout/PerButtonPortrait " , key: " \( id) _x " , value: - 1.0 )
338- ARMSX2Bridge . setINIFloat ( " ARMSX2iOS/PadLayout/PerButtonPortrait " , key: " \( id) _y " , value: - 1.0 )
339- ARMSX2Bridge . setINIFloat ( " ARMSX2iOS/PadLayout/PerButtonPortrait " , key: " \( id) _scale " , value: - 1.0 )
340338 }
341339 }
342- save ( )
343340 }
344341}
0 commit comments