Skip to content

Commit 6332bdf

Browse files
committed
fix duplicate, move, & transform sounds playing when nothing is selected
1 parent 27b1067 commit 6332bdf

File tree

1 file changed

+21
-8
lines changed

1 file changed

+21
-8
lines changed

src/gd_hooks.cpp

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -62,13 +62,16 @@ class $modify(SFXEditorUI, EditorUI) {
6262

6363
$override
6464
void keyDown(enumKeyCodes key) {
65-
bool playDeselectSound = m_selectedObjects->count() > 0 || m_selectedObject;
65+
bool playSound = m_selectedObjects->count() > 0 || m_selectedObject;
6666

6767
EditorUI::keyDown(key);
6868

6969
// windows 2.2074 inlines EditorUI::onDeselectAll in EditorUI::keyDown
70-
if (key == enumKeyCodes::KEY_D && CCKeyboardDispatcher::get()->getAltKeyPressed()
71-
&& playDeselectSound) {
70+
if (
71+
key == enumKeyCodes::KEY_D &&
72+
CCKeyboardDispatcher::get()->getAltKeyPressed() &&
73+
playSound
74+
) {
7275
sfx::queue(EditorSFX::Deselect);
7376
}
7477
}
@@ -91,10 +94,10 @@ class $modify(SFXEditorUI, EditorUI) {
9194

9295
$override
9396
void onDeselectAll(CCObject* sender) {
94-
bool playDeselectSound = m_selectedObjects->count() > 0 || m_selectedObject;
97+
bool playSound = m_selectedObjects->count() > 0 || m_selectedObject;
9598
EditorUI::onDeselectAll(sender);
9699

97-
if (playDeselectSound) {
100+
if (playSound) {
98101
sfx::queue(EditorSFX::Deselect);
99102
}
100103
}
@@ -137,8 +140,10 @@ class $modify(SFXEditorUI, EditorUI) {
137140

138141
$override
139142
void onDuplicate(CCObject* sender) {
143+
bool playSound = m_selectedObjects->count() > 0 || m_selectedObject;
144+
140145
EditorUI::onDuplicate(sender);
141-
if (isEditorButtonDisabled(sender)) return;
146+
if (!playSound || isEditorButtonDisabled(sender)) return;
142147

143148
sfx::queue(EditorSFX::Duplicate);
144149
}
@@ -233,14 +238,22 @@ class $modify(SFXEditorUI, EditorUI) {
233238

234239
$override
235240
void moveObjectCall(EditCommand p0) {
241+
bool playSound = m_selectedObjects->count() > 0 || m_selectedObject;
236242
EditorUI::moveObjectCall(p0);
237-
sfx::queue(EditorSFX::Move);
243+
244+
if (playSound) {
245+
sfx::queue(EditorSFX::Move);
246+
}
238247
}
239248

240249
$override
241250
void transformObjectCall(EditCommand command) {
251+
bool playSound = m_selectedObjects->count() > 0 || m_selectedObject;
242252
EditorUI::transformObjectCall(command);
243-
sfx::queue(EditorSFX::Transform);
253+
254+
if (playSound) {
255+
sfx::queue(EditorSFX::Transform);
256+
}
244257
}
245258

246259
$override

0 commit comments

Comments
 (0)