Skip to content

Commit ed8641d

Browse files
committed
add sounds for F1-F6 and CTRL/ALT 0-9 keybinds
1 parent 177db8c commit ed8641d

File tree

1 file changed

+44
-6
lines changed

1 file changed

+44
-6
lines changed

src/gd_hooks.cpp

Lines changed: 44 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -72,17 +72,55 @@ class $modify(SFXEditorUI, EditorUI) {
7272

7373
$override
7474
void keyDown(enumKeyCodes key) {
75-
bool playSound = m_selectedObjects->count() > 0 || m_selectedObject;
75+
bool hasObjectsSelected = m_selectedObjects->count() > 0 || m_selectedObject;
7676

7777
EditorUI::keyDown(key);
7878

79+
bool ctrl = CCKeyboardDispatcher::get()->getControlKeyPressed();
80+
bool cmd = CCKeyboardDispatcher::get()->getCommandKeyPressed();
81+
bool alt = CCKeyboardDispatcher::get()->getAltKeyPressed();
82+
bool shift = CCKeyboardDispatcher::get()->getShiftKeyPressed();
83+
7984
// windows 2.2074 inlines EditorUI::onDeselectAll in EditorUI::keyDown
80-
if (
81-
key == enumKeyCodes::KEY_D &&
82-
CCKeyboardDispatcher::get()->getAltKeyPressed() &&
83-
playSound
84-
) {
85+
86+
if (key == KEY_D && !ctrl && !cmd && alt && !shift && hasObjectsSelected) {
8587
sfx::queue(EditorSFX::Deselect);
88+
return;
89+
}
90+
91+
if (key >= KEY_Zero && key <= KEY_Nine) {
92+
if ((ctrl || cmd) && !alt && !shift) {
93+
sfx::queue(EditorSFX::Copy);
94+
} else if (alt && !cmd && !ctrl && !shift) {
95+
sfx::queue(EditorSFX::Paste);
96+
}
97+
98+
return;
99+
}
100+
101+
if (ctrl || cmd || alt || shift) return;
102+
103+
switch (key) {
104+
case KEY_F1: // lock preview
105+
sfx::queue(EditorSFX::Lock);
106+
break;
107+
case KEY_F2: // unlock preview
108+
sfx::queue(EditorSFX::Unlock);
109+
break;
110+
case KEY_F3: // toggle preview mode
111+
sfx::queue(EditorSFX::ToggleButton);
112+
break;
113+
case KEY_F4: // toggle particle icons
114+
sfx::queue(EditorSFX::ToggleButton);
115+
break;
116+
case KEY_F5: // toggle show hitboxes
117+
sfx::queue(EditorSFX::ToggleButton);
118+
break;
119+
case KEY_F6: // toggle hide invisible
120+
sfx::queue(EditorSFX::ToggleButton);
121+
break;
122+
default: // don't yell at me compiler ty
123+
break;
86124
}
87125
}
88126

0 commit comments

Comments
 (0)