Skip to content

Commit f3757f6

Browse files
committed
Global toggle sounds
1 parent 3500a1b commit f3757f6

File tree

2 files changed

+14
-8
lines changed

2 files changed

+14
-8
lines changed

common/src/main/kotlin/com/lambda/gui/impl/clickgui/buttons/ModuleButton.kt

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -174,12 +174,11 @@ class ModuleButton(
174174
}
175175

176176
override fun performClickAction(e: GuiEvent.MouseClick) {
177-
val sound = when (e.button) {
177+
when (e.button) {
178178
Mouse.Button.Left -> {
179179
module.toggle()
180-
if (module.isEnabled) LambdaSound.MODULE_ON else LambdaSound.MODULE_OFF
181-
}
182180

181+
}
183182
Mouse.Button.Right -> {
184183
// Don't let user spam
185184
val targetHeight = if (isOpen) settingsHeight else 0.0
@@ -189,13 +188,10 @@ class ModuleButton(
189188
if (isOpen) settingsLayer.onEvent(GuiEvent.Show())
190189
updateHeight()
191190

192-
if (isOpen) LambdaSound.SETTINGS_OPEN else LambdaSound.SETTINGS_CLOSE
191+
val sound = if (isOpen) LambdaSound.SETTINGS_OPEN else LambdaSound.SETTINGS_CLOSE
192+
playSoundRandomly(sound.event)
193193
}
194-
195-
else -> return
196194
}
197-
198-
playSoundRandomly(sound.event)
199195
}
200196

201197
override fun equals(other: Any?) =

common/src/main/kotlin/com/lambda/module/Module.kt

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ import com.lambda.gui.impl.clickgui.LambdaClickGui
1818
import com.lambda.gui.impl.clickgui.buttons.ModuleButton
1919
import com.lambda.module.modules.client.ClickGui
2020
import com.lambda.module.tag.ModuleTag
21+
import com.lambda.sound.LambdaSound
22+
import com.lambda.sound.SoundManager.playSoundRandomly
2123
import com.lambda.util.KeyCode
2224
import com.lambda.util.Nameable
2325

@@ -119,6 +121,14 @@ abstract class Module(
119121
|| screen is LambdaClickGui)
120122
) toggle()
121123
}
124+
125+
onEnable {
126+
playSoundRandomly(LambdaSound.MODULE_ON.event)
127+
}
128+
129+
onDisable {
130+
playSoundRandomly(LambdaSound.MODULE_OFF.event)
131+
}
122132
}
123133

124134
fun enable() {

0 commit comments

Comments
 (0)