Skip to content

Commit daebb8a

Browse files
committed
Align iOS landscape layout editor with gameplay
1 parent 803ff86 commit daebb8a

1 file changed

Lines changed: 39 additions & 35 deletions

File tree

app/src/main/swift/Views/Settings/PadLayoutEditView.swift

Lines changed: 39 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,10 @@ struct PadLayoutEditView: View {
5757
compactToolbar
5858
Spacer()
5959
}
60+
.padding(.top, 50)
6061
}
6162
}
63+
.ignoresSafeArea()
6264
.navigationBarHidden(true)
6365
.statusBarHidden()
6466
.persistentSystemOverlays(.hidden)
@@ -81,20 +83,6 @@ struct PadLayoutEditView: View {
8183
Color.clear
8284
.allowsHitTesting(false)
8385

84-
// Subtle safe zone guide
85-
let margin: CGFloat = 0.05
86-
let guideRect = CGRect(
87-
x: width * margin,
88-
y: height * margin,
89-
width: width * (1 - margin * 2),
90-
height: height * (1 - margin * 2)
91-
)
92-
Rectangle()
93-
.stroke(style: StrokeStyle(lineWidth: 1, dash: [6, 4]))
94-
.foregroundStyle(.yellow.opacity(0.3))
95-
.frame(width: guideRect.width, height: guideRect.height)
96-
.position(x: guideRect.midX, y: guideRect.midY)
97-
9886
customSkinPreview(isLandscape: true, width: width, height: height)
9987

10088
editorContent(areaW: width, areaH: height)
@@ -271,14 +259,15 @@ struct PadLayoutEditView: View {
271259

272260
@ViewBuilder
273261
private func editorContent(areaW: CGFloat, areaH: CGFloat) -> some View {
262+
let stickScale = min(max(CGFloat(settings.analogStickScale), 0.8), 1.6)
274263
ZStack {
275264
// Individual buttons for action and dpad
276265
ForEach(PadLayoutStore.perButtonIDs, id: \.self) { (id: String) in
277266
DraggableButton(id: id, areaW: areaW, areaH: areaH, isLandscape: editLandscape, onBeginEdit: pushSnapshot)
278267
}
279268
// Group widgets for other controls
280269
ForEach(PadLayoutStore.groupIDs.filter { $0 != "action" && $0 != "dpad" }, id: \.self) { (id: String) in
281-
DraggableGroup(id: id, areaW: areaW, areaH: areaH, isLandscape: editLandscape, onBeginEdit: pushSnapshot)
270+
DraggableGroup(id: id, areaW: areaW, areaH: areaH, isLandscape: editLandscape, analogStickScale: stickScale, onBeginEdit: pushSnapshot)
282271
}
283272
}
284273
.environment(\.padSkin, settings.virtualPadSkin)
@@ -288,14 +277,15 @@ struct PadLayoutEditView: View {
288277

289278
@ViewBuilder
290279
private func editorPortraitContent(areaW: CGFloat, areaH: CGFloat) -> some View {
280+
let stickScale = min(max(CGFloat(settings.analogStickScale), 0.8), 1.6)
291281
ZStack {
292282
// Individual buttons for action and dpad
293283
ForEach(PadLayoutStore.perButtonIDs, id: \.self) { (id: String) in
294284
DraggableButton(id: id, areaW: areaW, areaH: areaH, isLandscape: editLandscape, onBeginEdit: pushSnapshot)
295285
}
296286
// Group widgets for other controls
297287
ForEach(PadLayoutStore.groupIDs.filter { $0 != "action" && $0 != "dpad" }, id: \.self) { (id: String) in
298-
DraggableGroup(id: id, areaW: areaW, areaH: areaH, isLandscape: editLandscape, onBeginEdit: pushSnapshot)
288+
DraggableGroup(id: id, areaW: areaW, areaH: areaH, isLandscape: editLandscape, analogStickScale: stickScale, onBeginEdit: pushSnapshot)
299289
}
300290
}
301291
.environment(\.padSkin, settings.virtualPadSkin)
@@ -334,6 +324,7 @@ private struct DraggableGroup: View {
334324
let areaW: CGFloat
335325
let areaH: CGFloat
336326
let isLandscape: Bool
327+
let analogStickScale: CGFloat
337328
let onBeginEdit: () -> Void
338329

339330
@State private var layout = PadLayoutStore.shared
@@ -434,40 +425,53 @@ private struct DraggableGroup: View {
434425

435426
private var groupSize: CGSize {
436427
switch id {
437-
case "dpad": return CGSize(width: 120, height: 120)
438-
case "action": return CGSize(width: 120, height: 120)
439-
case "l1": return CGSize(width: 110, height: 36)
440-
case "l2": return CGSize(width: 120, height: 48)
441-
case "r1": return CGSize(width: 110, height: 36)
442-
case "r2": return CGSize(width: 120, height: 48)
443-
case "lstick", "rstick": return CGSize(width: 80, height: 90)
444-
case "select": return CGSize(width: 50, height: 28)
445-
case "start": return CGSize(width: 56, height: 28)
446-
default: return CGSize(width: 60, height: 40)
428+
case "dpad":
429+
let s = isLandscape ? VirtualPadButtonOffset.dpadLandscapeSize : VirtualPadButtonOffset.dpadPortraitSize
430+
return CGSize(width: s, height: s)
431+
case "action":
432+
let s = VirtualPadButtonOffset.actionButtonSize * 3.2
433+
return CGSize(width: s, height: s)
434+
case "l1":
435+
return CGSize(width: 120, height: 32)
436+
case "l2":
437+
return CGSize(width: 130, height: 44)
438+
case "r1":
439+
return CGSize(width: 120, height: 32)
440+
case "r2":
441+
return CGSize(width: 130, height: 44)
442+
case "lstick", "rstick":
443+
let s = 68 * min(max(analogStickScale, 0.8), 1.6)
444+
return CGSize(width: s, height: s)
445+
case "select":
446+
return CGSize(width: 40, height: 22)
447+
case "start":
448+
return CGSize(width: 48, height: 22)
449+
default:
450+
return CGSize(width: 60, height: 40)
447451
}
448452
}
449453

450454
@ViewBuilder
451455
private var groupContent: some View {
452456
switch id {
453457
case "dpad":
454-
DPadView(size: 100)
458+
DPadView(size: isLandscape ? VirtualPadButtonOffset.dpadLandscapeSize : VirtualPadButtonOffset.dpadPortraitSize)
455459
case "action":
456-
ActionButtonsView(size: 42)
460+
ActionButtonsView(size: VirtualPadButtonOffset.actionButtonSize)
457461
case "l1":
458-
PadBtn(label: "L1", w: 100, h: 30, btn: .L1)
462+
PadBtn(label: "L1", w: 120, h: 32, btn: .L1)
459463
case "l2":
460-
PadBtn(label: "L2", w: 110, h: 40, btn: .L2)
464+
PadBtn(label: "L2", w: 130, h: 44, btn: .L2)
461465
case "r1":
462-
PadBtn(label: "R1", w: 100, h: 30, btn: .R1)
466+
PadBtn(label: "R1", w: 120, h: 32, btn: .R1)
463467
case "r2":
464-
PadBtn(label: "R2", w: 110, h: 40, btn: .R2)
468+
PadBtn(label: "R2", w: 130, h: 44, btn: .R2)
465469
case "lstick":
466-
StickView(isLeft: true, sizeScale: 1.0)
470+
StickView(isLeft: true, sizeScale: analogStickScale)
467471
case "rstick":
468-
StickView(isLeft: false, sizeScale: 1.0)
472+
StickView(isLeft: false, sizeScale: analogStickScale)
469473
case "select":
470-
PadBtn(label: "SEL", w: 42, h: 22, btn: .select)
474+
PadBtn(label: "SEL", w: 40, h: 22, btn: .select)
471475
case "start":
472476
PadBtn(label: "START", w: 48, h: 22, btn: .start)
473477
default:

0 commit comments

Comments
 (0)