Skip to content

Commit ea46308

Browse files
committed
create the reset button with the custom id
1 parent c67e3a9 commit ea46308

File tree

2 files changed

+10
-8
lines changed

2 files changed

+10
-8
lines changed

src/main/kotlin/com/lambda/config/Configurable.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ import com.lambda.config.settings.complex.Bind
3636
import com.lambda.config.settings.complex.BlockPosSetting
3737
import com.lambda.config.settings.complex.BlockSetting
3838
import com.lambda.config.settings.complex.ColorSetting
39-
import com.lambda.config.settings.complex.KeybindSettingCore
39+
import com.lambda.config.settings.complex.KeybindSetting
4040
import com.lambda.config.settings.complex.Vec3dSetting
4141
import com.lambda.config.settings.numeric.DoubleSetting
4242
import com.lambda.config.settings.numeric.FloatSetting
@@ -229,14 +229,14 @@ abstract class Configurable(
229229
defaultValue: Bind,
230230
description: String = "",
231231
visibility: () -> Boolean = { true },
232-
) = Setting(name, description, KeybindSettingCore(defaultValue), this, visibility).register()
232+
) = Setting(name, description, KeybindSetting(defaultValue), this, visibility).register()
233233

234234
fun setting(
235235
name: String,
236236
defaultValue: KeyCode,
237237
description: String = "",
238238
visibility: () -> Boolean = { true },
239-
) = Setting(name, description, KeybindSettingCore(defaultValue), this, visibility).register()
239+
) = Setting(name, description, KeybindSetting(defaultValue), this, visibility).register()
240240

241241
fun setting(
242242
name: String,

src/main/kotlin/com/lambda/config/settings/complex/KeybindSetting.kt

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ import org.lwjgl.glfw.GLFW.GLFW_MOD_NUM_LOCK
4848
import org.lwjgl.glfw.GLFW.GLFW_MOD_SHIFT
4949
import org.lwjgl.glfw.GLFW.GLFW_MOD_SUPER
5050

51-
class KeybindSettingCore(defaultValue: Bind) : SettingCore<Bind>(
51+
class KeybindSetting(defaultValue: Bind) : SettingCore<Bind>(
5252
defaultValue,
5353
TypeToken.get(Bind::class.java).type
5454
) {
@@ -66,7 +66,7 @@ class KeybindSettingCore(defaultValue: Bind) : SettingCore<Bind>(
6666
if (listening) "Press any key…"
6767
else bind.name
6868

69-
withId("##Bind-${this@KeybindSettingCore.hashCode()}") {
69+
withId("##Bind-${this@KeybindSetting.hashCode()}") {
7070
if (listening) {
7171
withStyleColor(ImGuiCol.Button, 0.20f, 0.50f, 1.00f, 1.00f) {
7272
withStyleColor(ImGuiCol.ButtonHovered, 0.25f, 0.60f, 1.00f, 1.00f) {
@@ -90,9 +90,11 @@ class KeybindSettingCore(defaultValue: Bind) : SettingCore<Bind>(
9090
}
9191

9292
sameLine()
93-
withId("##Unbind-${this@KeybindSettingCore.hashCode()}") {
94-
value = Bind.EMPTY
95-
listening = false
93+
withId("##Unbind-${this@KeybindSetting.hashCode()}") {
94+
smallButton("Unbind") {
95+
value = Bind.EMPTY
96+
listening = false
97+
}
9698
}
9799
onItemHover(ImGuiHoveredFlags.Stationary) {
98100
lambdaTooltip("Clear binding")

0 commit comments

Comments
 (0)