@@ -108,6 +108,16 @@ struct $modify(UILayer) {
108
108
return playLayer != nullptr && playLayer == PlayLayer::get () && getChildOfType<UILayer>(playLayer, 0 ) == this ;
109
109
}
110
110
111
+ void pressKeyFallthrough (enumKeyCodes key, bool down) {
112
+ allowKeyDownThrough = true ;
113
+ if (down) {
114
+ this ->keyDown (key);
115
+ } else {
116
+ this ->keyUp (key);
117
+ }
118
+ allowKeyDownThrough = false ;
119
+ }
120
+
111
121
bool init (GJBaseGameLayer* layer) {
112
122
if (!UILayer::init (layer))
113
123
return false ;
@@ -118,25 +128,16 @@ struct $modify(UILayer) {
118
128
if (!PlayLayer::get ()) return ;
119
129
120
130
this ->defineKeybind (" robtop.geometry-dash/jump-p1" , [=](bool down) {
121
- // todo: event priority
122
- if (this ->isCurrentPlayLayer () && !this ->isPaused ()) {
123
- PlayLayer::get ()->queueButton (platformButton (), down, false );
124
- }
131
+ this ->pressKeyFallthrough (KEY_Space, down);
125
132
});
126
133
this ->defineKeybind (" robtop.geometry-dash/jump-p2" , [=](bool down) {
127
- if (this ->isCurrentPlayLayer () && !this ->isPaused ()) {
128
- PlayLayer::get ()->queueButton (platformButton (), down, true );
129
- }
134
+ this ->pressKeyFallthrough (KEY_Up, down);
130
135
});
131
136
this ->defineKeybind (" robtop.geometry-dash/place-checkpoint" , [=](bool down) {
132
- if (down && this ->isCurrentPlayLayer () && PlayLayer::get ()->m_isPracticeMode ) {
133
- this ->onCheck (nullptr );
134
- }
137
+ this ->pressKeyFallthrough (KEY_Z, down);
135
138
});
136
139
this ->defineKeybind (" robtop.geometry-dash/delete-checkpoint" , [=](bool down) {
137
- if (down && this ->isCurrentPlayLayer () && PlayLayer::get ()->m_isPracticeMode ) {
138
- this ->onDeleteCheck (nullptr );
139
- }
140
+ this ->pressKeyFallthrough (KEY_X, down);
140
141
});
141
142
this ->defineKeybind (" robtop.geometry-dash/pause-level" , [=](bool down) {
142
143
if (down && this ->isCurrentPlayLayer () && !this ->isPaused ()) {
@@ -154,31 +155,21 @@ struct $modify(UILayer) {
154
155
}
155
156
});
156
157
this ->defineKeybind (" robtop.geometry-dash/move-left-p1" , [=](bool down) {
157
- if (this ->isCurrentPlayLayer () && !this ->isPaused ()) {
158
- PlayLayer::get ()->queueButton (static_cast <int >(PlayerButton::Left), down, false );
159
- }
158
+ this ->pressKeyFallthrough (KEY_A, down);
160
159
});
161
160
this ->defineKeybind (" robtop.geometry-dash/move-right-p1" , [=](bool down) {
162
- if (this ->isCurrentPlayLayer () && !this ->isPaused ()) {
163
- PlayLayer::get ()->queueButton (static_cast <int >(PlayerButton::Right), down, false );
164
- }
161
+ this ->pressKeyFallthrough (KEY_D, down);
165
162
});
166
163
this ->defineKeybind (" robtop.geometry-dash/move-left-p2" , [=](bool down) {
167
- if (this ->isCurrentPlayLayer () && !this ->isPaused ()) {
168
- PlayLayer::get ()->queueButton (static_cast <int >(PlayerButton::Left), down, true );
169
- }
164
+ this ->pressKeyFallthrough (KEY_Left, down);
170
165
});
171
166
this ->defineKeybind (" robtop.geometry-dash/move-right-p2" , [=](bool down) {
172
- if (this ->isCurrentPlayLayer () && !this ->isPaused ()) {
173
- PlayLayer::get ()->queueButton (static_cast <int >(PlayerButton::Right), down, true );
174
- }
167
+ this ->pressKeyFallthrough (KEY_Right, down);
175
168
});
176
169
this ->defineKeybind (" robtop.geometry-dash/toggle-hitboxes" , [=](bool down) {
177
170
if (down && this ->isCurrentPlayLayer () && !this ->isPaused ()) {
178
- // TODO actually reverse PlayLayer::toggleDebugDraw (its inlined and needs 2 members, a bool and a CCDrawNode*)
179
- allowKeyDownThrough = true ;
180
- this ->keyDown (enumKeyCodes::KEY_P);
181
- allowKeyDownThrough = false ;
171
+ // This assumes you have quick keys on
172
+ this ->pressKeyFallthrough (KEY_P, down);
182
173
}
183
174
});
184
175
// display practice mode button keybinds
@@ -211,12 +202,18 @@ struct $modify(UILayer) {
211
202
212
203
// silly hack for hitboxes..
213
204
static inline bool allowKeyDownThrough = false ;
214
- void keyDown (enumKeyCodes key) {
205
+ void keyDown (enumKeyCodes key) override {
215
206
if (key == enumKeyCodes::KEY_Escape || allowKeyDownThrough) {
216
207
UILayer::keyDown (key);
208
+ allowKeyDownThrough = false ;
209
+ }
210
+ }
211
+ void keyUp (enumKeyCodes key) override {
212
+ if (allowKeyDownThrough) {
213
+ UILayer::keyUp (key);
214
+ allowKeyDownThrough = false ;
217
215
}
218
216
}
219
- void keyUp (enumKeyCodes) {}
220
217
};
221
218
222
219
$execute {
0 commit comments