Skip to content

Commit 9a9bdfb

Browse files
committed
disable on release setting in all modules
1 parent 8cc0dab commit 9a9bdfb

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

src/main/kotlin/com/lambda/gui/components/SettingsWidget.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ object SettingsWidget {
3232
group {
3333
if (config is Module) {
3434
with(config.keybindSetting) { buildLayout() }
35+
with(config.disableOnReleaseSetting) { buildLayout() }
3536
}
3637
sameLine()
3738
smallButton("Reset") {
@@ -40,7 +41,7 @@ object SettingsWidget {
4041
lambdaTooltip("Resets all settings for this module to their default values")
4142
}
4243
separator()
43-
val toIgnoreSettings = if (config is Module) setOf(config.keybindSetting) else emptySet()
44+
val toIgnoreSettings = if (config is Module) setOf(config.keybindSetting, config.disableOnReleaseSetting) else emptySet()
4445
val visibleSettings = config.settings.filter { it.visibility() } - toIgnoreSettings
4546
val (grouped, ungrouped) = visibleSettings.partition { it.groups.isNotEmpty() }
4647
ungrouped.forEach { with(it) { buildLayout() } }

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

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717

1818
package com.lambda.module
1919

20+
import com.lambda.Lambda
2021
import com.lambda.command.LambdaCommand
2122
import com.lambda.config.AbstractSetting
2223
import com.lambda.config.Configurable
@@ -116,26 +117,28 @@ abstract class Module(
116117
) : Nameable, Muteable, Configurable(ModuleConfig) {
117118
private val isEnabledSetting = setting("Enabled", enabledByDefault) { false }
118119
val keybindSetting = setting("Keybind", defaultKeybind) { false }
120+
val disableOnReleaseSetting = setting("Disable On Release", false) { false }
119121

120122
open val isVisible: Boolean = true
121123

122124
var isEnabled by isEnabledSetting
123125
val isDisabled get() = !isEnabled
124126

125127
val keybind by keybindSetting
128+
val disableOnRelease by disableOnReleaseSetting
126129

127130
override val isMuted: Boolean
128131
get() = !isEnabled && !alwaysListening
129132

130133
init {
131134
listen<KeyboardEvent.Press>(alwaysListen = true) { event ->
132-
if (mc.options.commandKey.isPressed) return@listen
133-
if (!event.isPressed) return@listen
135+
if (Lambda.mc.options.commandKey.isPressed) return@listen
134136
if (keybind == KeyCode.UNBOUND) return@listen
135137
if (event.translated != keybind) return@listen
136-
if (mc.currentScreen != null) return@listen
138+
if (Lambda.mc.currentScreen != null) return@listen
137139

138-
toggle()
140+
if (event.isPressed) toggle()
141+
else if (event.isReleased && disableOnRelease) disable()
139142
}
140143

141144
onEnable { LambdaSound.MODULE_ON.play() }

0 commit comments

Comments
 (0)