Skip to content

Commit 5cb30ab

Browse files
committed
Refactor client config and add option for disabling nested pattern name rendering
1 parent 2fd29aa commit 5cb30ab

File tree

7 files changed

+60
-35
lines changed

7 files changed

+60
-35
lines changed

Common/src/main/java/gay/object/hexdebug/api/client/splicing/SplicingTableIotaRenderer.java

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import at.petrak.hexcasting.api.casting.iota.IotaType;
44
import at.petrak.hexcasting.common.lib.hex.HexIotaTypes;
55
import gay.object.hexdebug.api.splicing.SplicingTableIotaClientView;
6+
import gay.object.hexdebug.config.HexDebugClientConfig;
67
import gay.object.hexdebug.gui.splicing.SplicingTableScreen;
78
import net.minecraft.client.gui.GuiGraphics;
89
import net.minecraft.client.gui.components.Tooltip;
@@ -75,7 +76,17 @@ public Tooltip createTooltip() {
7576
*/
7677
@NotNull
7778
protected SplicingTableIotaTooltipBuilder buildTooltip() {
78-
var builder = new SplicingTableIotaTooltipBuilder(iota.name())
79+
Component name;
80+
if (
81+
type == HexIotaTypes.PATTERN
82+
|| HexDebugClientConfig.getConfig().getSplicingTable().getShowNestedPatternNames()
83+
) {
84+
name = iota.display();
85+
} else {
86+
name = type.display(iota.getData());
87+
}
88+
89+
var builder = new SplicingTableIotaTooltipBuilder(name)
7990
.addDetailsLine(SplicingTableScreen.tooltipText("index", iota.index()));
8091

8192
var typeKey = HexIotaTypes.REGISTRY.getKey(type);

Common/src/main/java/gay/object/hexdebug/api/splicing/SplicingTableIotaClientView.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,17 @@
1818
* NOTE: Consumers should not construct this class themselves, as its fields may change at any time.
1919
* All constructors are annotated with {@link ApiStatus.Internal} to indicate this.
2020
* @param tag The raw iota NBT.
21-
* @param name The formatted name of the iota for use in tooltips.
21+
* @param display The formatted iota for use in tooltips. For patterns (including those nested in
22+
* lists), this is the pattern's name as calculated on the server, so that per-world
23+
* patterns and special handlers can be displayed with their actual names instead of
24+
* just the raw angle signature.
2225
* @param hexpatternSource The iota converted to a plain string in {@code .hexpattern} format.
2326
* @param index The index of this iota in the list.
2427
* @param depth The number of unclosed Introspection patterns preceding this iota.
2528
*/
2629
public record SplicingTableIotaClientView(
2730
@NotNull CompoundTag tag,
28-
@NotNull Component name,
31+
@NotNull Component display,
2932
@NotNull String hexpatternSource,
3033
int index,
3134
int depth

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

Lines changed: 24 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -115,28 +115,35 @@ object HexDebugClientConfig {
115115
@Tooltip
116116
val showDebugClientLineNumber: Boolean = false
117117

118-
@Tooltip
119-
val invertSplicingTableScrollDirection: Boolean = false
120-
121-
@Tooltip
122-
val enableSplicingTableRainbowBrackets: Boolean = true
123-
124-
// split Turbo into 8 samples, took the middle 6
125-
@Tooltip
126-
@ColorPicker
127-
val rainbowBracketColors: List<Int> = listOf(
128-
0xda3907,
129-
0xfe9b2d,
130-
0xd1e934,
131-
0x62fc6b,
132-
0x1bcfd5,
133-
0x4676ee,
134-
)
118+
@CollapsibleObject(startExpanded = true)
119+
val splicingTable = SplicingTable()
135120

136121
@Tooltip
137122
@CollapsibleObject
138123
val splicingTableKeybinds = SplicingTableKeybinds()
139124

125+
class SplicingTable {
126+
@Tooltip
127+
val invertScrollDirection: Boolean = false
128+
129+
@Tooltip
130+
val enableRainbowBrackets: Boolean = true
131+
132+
// split Turbo into 8 samples, took the middle 6
133+
@ColorPicker
134+
val rainbowBracketColors: List<Int> = listOf(
135+
0xda3907,
136+
0xfe9b2d,
137+
0xd1e934,
138+
0x62fc6b,
139+
0x1bcfd5,
140+
0x4676ee,
141+
)
142+
143+
@Tooltip
144+
val showNestedPatternNames: Boolean = true
145+
}
146+
140147
@Suppress("MemberVisibilityCanBePrivate")
141148
class SplicingTableKeybinds {
142149
@Tooltip

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -607,7 +607,7 @@ class SplicingTableScreen(
607607
override fun mouseScrolled(mouseX: Double, mouseY: Double, delta: Double): Boolean {
608608
if (super.mouseScrolled(mouseX, mouseY, delta)) return true
609609

610-
val adjustedDelta = if (HexDebugClientConfig.config.invertSplicingTableScrollDirection) {
610+
val adjustedDelta = if (HexDebugClientConfig.config.splicingTable.invertScrollDirection) {
611611
delta * -1
612612
} else {
613613
delta

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,10 @@ class PatternRenderer(
5353
)
5454

5555
private val outer = if (
56-
HexDebugClientConfig.config.enableSplicingTableRainbowBrackets
56+
HexDebugClientConfig.config.splicingTable.enableRainbowBrackets
5757
&& (pattern.sigsEqual(SpecialPatterns.INTROSPECTION) || pattern.sigsEqual(SpecialPatterns.RETROSPECTION))
5858
) {
59-
HexDebugClientConfig.config.rainbowBracketColors.getWrapping(iota.depth)
59+
HexDebugClientConfig.config.splicingTable.rainbowBracketColors.getWrapping(iota.depth)
6060
} else {
6161
0xd2c8c8
6262
} or 0xff_000000.toInt()

Common/src/main/kotlin/gay/object/hexdebug/networking/msg/MsgSplicingTableNewDataS2C.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ data class MsgSplicingTableNewDataS2C(
4848
buf.writeNullable(list) { _, list ->
4949
buf.writeCollection(list) { _, it ->
5050
buf.writeNbt(it.tag)
51-
buf.writeComponent(it.name)
51+
buf.writeComponent(it.display)
5252
buf.writeUtf(it.hexpatternSource)
5353
buf.writeInt(it.index)
5454
buf.writeInt(it.depth)

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

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -95,17 +95,21 @@
9595
"": "Show Debug Client Line Number",
9696
"@Tooltip": "If true, show the line number (usually 1-indexed) from the debug client (eg. VSCode) in Debugger status messages; otherwise, show the list index (0-indexed)."
9797
},
98-
invertSplicingTableScrollDirection: {
99-
"": "Invert Splicing Table Scroll Direction",
100-
"@Tooltip": "Whether scrolling up (as opposed to down) will increase the view index of the splicing table, and vice versa.",
101-
},
102-
enableSplicingTableRainbowBrackets: {
103-
"": "Enable Splicing Table Rainbow Brackets",
104-
"@Tooltip": "If true, tint the outline of Introspection and Retrospection with rainbow colors to help identify matching brackets.",
105-
},
106-
rainbowBracketColors: {
107-
"": "Rainbow Bracket Colors",
108-
"@Tooltip": "Colors for rainbow brackets in the Splicing Table GUI.",
98+
splicingTable: {
99+
"": "General Splicing Table Options",
100+
invertScrollDirection: {
101+
"": "Invert Scroll Direction",
102+
"@Tooltip": "Whether scrolling up (as opposed to down) will increase the view index of the Splicing Table, and vice versa.",
103+
},
104+
enableRainbowBrackets: {
105+
"": "Enable Rainbow Brackets",
106+
"@Tooltip": "If true, tint the outline of Introspection and Retrospection with rainbow colors to help identify matching brackets.",
107+
},
108+
rainbowBracketColors: "Rainbow Bracket Colors",
109+
showNestedPatternNames: {
110+
"": "Show Nested Pattern Names",
111+
"@Tooltip": "If true, for patterns inside of embedded lists, show pattern names in the tooltip instead of the built-in inline pattern display.",
112+
},
109113
},
110114
splicingTableKeybinds: {
111115
"": "Splicing Table Keybinds",

0 commit comments

Comments
 (0)