Skip to content

Commit 73e4668

Browse files
committed
Refactor keybind settings
1 parent 2683f92 commit 73e4668

File tree

5 files changed

+26
-27
lines changed

5 files changed

+26
-27
lines changed

Common/src/main/java/gay/object/hexdebug/mixin/interop/emi/MixinEmiScreenManager.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ public abstract class MixinEmiScreenManager {
1818
@ModifyExpressionValue(method = "keyPressed", at = @At(value = "MIXINEXTRAS:EXPRESSION"), require = 0)
1919
private static boolean hexdebug$cancelHardcodedKeybindInSplicingTable(boolean original) {
2020
if (
21-
HexDebugClientConfig.getConfig().getEnableSplicingTableKeybinds()
21+
HexDebugClientConfig.getConfig().getSplicingTableKeybinds().getEnabled()
2222
&& Minecraft.getInstance().screen instanceof SplicingTableScreen
2323
) {
2424
return false;

Common/src/main/kotlin/gay/object/hexdebug/config/HexDebugClientConfig.kt

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ object HexDebugClientConfig {
3838
entryBuilder.startModifierKeyCodeField(
3939
when (config) {
4040
is ClientConfig.SplicingTableKeybinds,
41-
is ClientConfig.EnlightenedSplicingTableKeybinds -> {
41+
is ClientConfig.SplicingTableKeybinds.Enlightened -> {
4242
SplicingTableScreen.buttonText(field.name.camelToSnakeCase())
4343
}
4444
else -> i18n.asTranslatedComponent
@@ -96,19 +96,15 @@ object HexDebugClientConfig {
9696
@Tooltip
9797
val invertSplicingTableScrollDirection: Boolean = false
9898

99-
@Tooltip
100-
val enableSplicingTableKeybinds: Boolean = true
101-
10299
@Tooltip
103100
@CollapsibleObject
104101
val splicingTableKeybinds = SplicingTableKeybinds()
105102

106-
@Tooltip
107-
@CollapsibleObject
108-
val enlightenedSplicingTableKeybinds = EnlightenedSplicingTableKeybinds()
109-
110103
@Suppress("MemberVisibilityCanBePrivate")
111104
class SplicingTableKeybinds {
105+
@Tooltip
106+
val enabled: Boolean = true
107+
112108
@Tooltip
113109
val overrideVanillaArrowKeys = true
114110

@@ -145,6 +141,10 @@ object HexDebugClientConfig {
145141
val pasteSplat = ConfigModifierKey(InputConstants.KEY_V, ctrl = true)
146142
val pasteVerbatim = ConfigModifierKey(InputConstants.KEY_V, ctrl = true, shift = true)
147143

144+
@Tooltip
145+
@CollapsibleObject
146+
val enlightened = Enlightened()
147+
148148
fun getActionForKey(keyCode: Int, scanCode: Int): SplicingTableAction? {
149149
for ((key, action) in arrayOf(
150150
viewLeft to SplicingTableAction.VIEW_LEFT,
@@ -179,10 +179,10 @@ object HexDebugClientConfig {
179179
}
180180
return null
181181
}
182-
}
183182

184-
class EnlightenedSplicingTableKeybinds {
185-
val cast = ConfigModifierKey(InputConstants.KEY_RETURN, ctrl = true)
183+
class Enlightened {
184+
val cast = ConfigModifierKey(InputConstants.KEY_RETURN, ctrl = true)
185+
}
186186
}
187187
}
188188
}

Common/src/main/kotlin/gay/object/hexdebug/gui/splicing/SplicingTableScreen.kt

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -538,7 +538,7 @@ class SplicingTableScreen(
538538
}
539539

540540
override fun keyPressed(keyCode: Int, scanCode: Int, modifiers: Int): Boolean {
541-
if (HexDebugClientConfig.config.enableSplicingTableKeybinds) {
541+
if (HexDebugClientConfig.config.splicingTableKeybinds.enabled) {
542542
// AbstractContainerScreen.keyPressed always returns true, so check our keys first
543543
if (keyPressedInner(keyCode, scanCode)) return true
544544

@@ -556,8 +556,10 @@ class SplicingTableScreen(
556556
}
557557

558558
private fun keyPressedInner(keyCode: Int, scanCode: Int): Boolean {
559+
val keybinds = HexDebugClientConfig.config.splicingTableKeybinds
560+
559561
if (
560-
HexDebugClientConfig.config.enlightenedSplicingTableKeybinds.cast.matchesKey(keyCode, scanCode)
562+
keybinds.enlightened.cast.matchesKey(keyCode, scanCode)
561563
&& canCastIgnoringCooldown
562564
&& castingCooldown <= 0
563565
) {
@@ -567,7 +569,7 @@ class SplicingTableScreen(
567569
return true
568570
}
569571

570-
val action = HexDebugClientConfig.config.splicingTableKeybinds.getActionForKey(keyCode, scanCode)
572+
val action = keybinds.getActionForKey(keyCode, scanCode)
571573
?: return false
572574

573575
if (data.isListReadable && action.test()) {

Common/src/main/kotlin/gay/object/hexdebug/gui/splicing/widgets/SplicingTableButton.kt

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,10 +66,7 @@ abstract class SplicingTableButton(
6666
open fun reload() {}
6767

6868
override fun updateTooltip() {
69-
if (
70-
HexDebugClientConfig.config.enableSplicingTableKeybinds
71-
&& HexDebugClientConfig.config.splicingTableKeybinds.overrideVanillaArrowKeys
72-
) {
69+
if (HexDebugClientConfig.config.splicingTableKeybinds.let { it.enabled && it.overrideVanillaArrowKeys }) {
7370
updateFocus()
7471
}
7572
super.updateTooltip()

Common/src/main/resources/assets/hexdebug/lang/en_us.flatten.json5

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -95,21 +95,21 @@
9595
"": "Invert Splicing Table Scroll Direction",
9696
"@Tooltip": "Whether scrolling up (as opposed to down) will increase the view index of the splicing table, and vice versa.",
9797
},
98-
enableSplicingTableKeybinds: {
99-
"": "Enable Splicing/Mindsplice Table Keybinds",
100-
"@Tooltip": "Enable custom keybinds in the Splicing Table and Mindsplice Table GUIs. If disabled, all settings in the next two categories are ignored.",
101-
},
10298
splicingTableKeybinds: {
10399
"": "Splicing Table Keybinds",
104100
"@Tooltip": "Keybinds for actions in the Splicing Table GUI.",
101+
enabled: {
102+
"": "Enable Keybinds",
103+
"@Tooltip": "Enable custom keybinds in the Splicing Table and Mindsplice Table GUIs. If disabled, all other settings in this category are ignored.",
104+
},
105105
overrideVanillaArrowKeys: {
106106
"": "Override Vanilla Arrow Key Navigation",
107107
"@Tooltip": "In the Splicing Table GUI, override the vanilla feature that allows the arrow keys to be used to focus on UI elements. This setting improves usability with the default keybinds, but you may want to disable it if you rely on this feature for accessibility purposes.",
108108
},
109-
},
110-
enlightenedSplicingTableKeybinds: {
111-
"": "Mindsplice Table Keybinds",
112-
"@Tooltip": "Keybinds for actions in the Mindsplice Table GUI.",
109+
enlightened: {
110+
"": "Mindsplice Table",
111+
"@Tooltip": "Keybinds for actions in the Mindsplice Table GUI.",
112+
},
113113
},
114114
},
115115
server: {

0 commit comments

Comments
 (0)