@@ -44,71 +44,69 @@ struct GameView: View {
44
44
var body : some View {
45
45
JoinServerAndThen ( serverDescriptor, with: account) { client in
46
46
WithRenderCoordinator ( for: client) { renderCoordinator in
47
- if let renderCoordinator = renderCoordinator {
48
- VStack {
49
- switch state {
50
- case . playing:
51
- ZStack {
52
- WithController ( controller, listening: $inputCaptured) {
53
- if controllerOnly {
47
+ VStack {
48
+ switch state {
49
+ case . playing:
50
+ ZStack {
51
+ WithController ( controller, listening: $inputCaptured) {
52
+ if controllerOnly {
53
+ gameView ( client: client, renderCoordinator: renderCoordinator)
54
+ } else {
55
+ InputView ( listening: $inputCaptured, cursorCaptured: !inGameMenuPresented && cursorCaptured) {
54
56
gameView ( client: client, renderCoordinator: renderCoordinator)
55
- } else {
56
- InputView ( listening: $inputCaptured, cursorCaptured: !inGameMenuPresented && cursorCaptured) {
57
- gameView ( client: client, renderCoordinator: renderCoordinator)
58
- }
59
- . onKeyPress { [ weak client] key, characters in
60
- client? . press ( key, characters)
61
- }
62
- . onKeyRelease { [ weak client] key in
63
- client? . release ( key)
64
- }
65
- . onMouseMove { [ weak client] deltaX, deltaY in
66
- // TODO: Formalise this adjustment factor somewhere
67
- let sensitivityAdjustmentFactor : Float = 0.004
68
- let sensitivity = sensitivityAdjustmentFactor * managedConfig. mouseSensitivity
69
- client? . moveMouse ( sensitivity * deltaX, sensitivity * deltaY)
70
- }
71
- . passthroughClicks ( !cursorCaptured)
72
57
}
73
- }
74
- . onButtonPress { [ weak client] button in
75
- guard let input = input ( for: button) else {
76
- return
58
+ . onKeyPress { [ weak client] key, characters in
59
+ client? . press ( key, characters)
77
60
}
78
- client? . press ( input)
79
- }
80
- . onButtonRelease { [ weak client] button in
81
- guard let input = input ( for: button) else {
82
- return
61
+ . onKeyRelease { [ weak client] key in
62
+ client? . release ( key)
83
63
}
84
- client? . release ( input)
85
- }
86
- . onThumbstickMove { [ weak client] thumbstick, x, y in
87
- switch thumbstick {
88
- case . left:
89
- client? . moveLeftThumbstick ( x, y)
90
- case . right:
91
- client? . moveRightThumbstick ( x, y)
64
+ . onMouseMove { [ weak client] deltaX, deltaY in
65
+ // TODO: Formalise this adjustment factor somewhere
66
+ let sensitivityAdjustmentFactor : Float = 0.004
67
+ let sensitivity = sensitivityAdjustmentFactor * managedConfig. mouseSensitivity
68
+ client? . moveMouse ( sensitivity * deltaX, sensitivity * deltaY)
92
69
}
70
+ . passthroughClicks ( !cursorCaptured)
71
+ }
72
+ }
73
+ . onButtonPress { [ weak client] button in
74
+ guard let input = input ( for: button) else {
75
+ return
93
76
}
77
+ client? . press ( input)
94
78
}
95
- case . gpuFrameCaptureComplete( let file) :
96
- frameCaptureResult ( file)
97
- . onAppear {
98
- cursorCaptured = false
99
- inputCaptured = false
79
+ . onButtonRelease { [ weak client] button in
80
+ guard let input = input ( for: button) else {
81
+ return
100
82
}
101
- }
83
+ client? . release ( input)
84
+ }
85
+ . onThumbstickMove { [ weak client] thumbstick, x, y in
86
+ switch thumbstick {
87
+ case . left:
88
+ client? . moveLeftThumbstick ( x, y)
89
+ case . right:
90
+ client? . moveRightThumbstick ( x, y)
91
+ }
92
+ }
93
+ }
94
+ case . gpuFrameCaptureComplete( let file) :
95
+ frameCaptureResult ( file)
96
+ . onAppear {
97
+ cursorCaptured = false
98
+ inputCaptured = false
99
+ }
102
100
}
103
- . onAppear {
104
- modal. onError { [ weak client] _ in
105
- client? . game. tickScheduler. cancel ( )
106
- cursorCaptured = false
107
- inputCaptured = false
108
- }
109
-
110
- registerEventHandler ( client, renderCoordinator)
101
+ }
102
+ . onAppear {
103
+ modal. onError { [ weak client] _ in
104
+ client? . game. tickScheduler. cancel ( )
105
+ cursorCaptured = false
106
+ inputCaptured = false
111
107
}
108
+
109
+ registerEventHandler ( client, renderCoordinator)
112
110
}
113
111
} cancellationHandler: {
114
112
appState. update ( to: . serverList)
0 commit comments