@@ -30,11 +30,14 @@ private void DrawColorTablePairSelector(ColorTable table, bool disabled)
30
30
var buttonWidth = ( ImGui . GetContentRegionAvail ( ) . X - itemSpacing * 7.0f ) * 0.125f ;
31
31
var frameHeight = ImGui . GetFrameHeight ( ) ;
32
32
var highlighterSize = ImUtf8 . CalcIconSize ( FontAwesomeIcon . Crosshairs ) + framePadding * 2.0f ;
33
- var spaceWidth = ImUtf8 . CalcTextSize ( " "u8 ) . X ;
34
- var spacePadding = ( int ) MathF . Ceiling ( ( highlighterSize . X + framePadding . X + itemInnerSpacing ) / spaceWidth ) ;
35
33
36
34
using var font = ImRaii . PushFont ( UiBuilder . MonoFont ) ;
37
35
using var alignment = ImRaii . PushStyle ( ImGuiStyleVar . ButtonTextAlign , new Vector2 ( 0 , 0.5f ) ) ;
36
+
37
+ // This depends on the font being pushed for "proper" alignment of the pair indices in the buttons.
38
+ var spaceWidth = ImUtf8 . CalcTextSize ( " "u8 ) . X ;
39
+ var spacePadding = ( int ) MathF . Ceiling ( ( highlighterSize . X + framePadding . X + itemInnerSpacing ) / spaceWidth ) ;
40
+
38
41
for ( var i = 0 ; i < ColorTable . NumRows > > 1 ; i += 8 )
39
42
{
40
43
for ( var j = 0 ; j < 8 ; ++ j )
@@ -72,7 +75,7 @@ private void DrawColorTablePairSelector(ColorTable table, bool disabled)
72
75
var cursor = ImGui . GetCursorScreenPos ( ) ;
73
76
ImGui . SetCursorScreenPos ( rcMin with { Y = float . Lerp ( rcMin . Y , rcMax . Y , 0.5f ) - highlighterSize . Y * 0.5f } ) ;
74
77
font . Pop ( ) ;
75
- ColorTableHighlightButton ( pairIndex , disabled ) ;
78
+ ColorTablePairHighlightButton ( pairIndex , disabled ) ;
76
79
font . Push ( UiBuilder . MonoFont ) ;
77
80
ImGui . SetCursorScreenPos ( cursor ) ;
78
81
}
@@ -83,6 +86,8 @@ private bool DrawColorTablePairEditor(ColorTable table, ColorDyeTable? dyeTable,
83
86
{
84
87
var retA = false ;
85
88
var retB = false ;
89
+ var rowAIdx = _colorTableSelectedPair << 1 ;
90
+ var rowBIdx = rowAIdx | 1 ;
86
91
var dyeA = dyeTable ? [ _colorTableSelectedPair << 1 ] ?? default ;
87
92
var dyeB = dyeTable ? [ ( _colorTableSelectedPair << 1 ) | 1 ] ?? default ;
88
93
var previewDyeA = _stainService . GetStainCombo ( dyeA . Channel ) . CurrentSelection . Key ;
@@ -91,17 +96,15 @@ private bool DrawColorTablePairEditor(ColorTable table, ColorDyeTable? dyeTable,
91
96
var dyePackB = _stainService . GudStmFile . GetValueOrNull ( dyeB . Template , previewDyeB ) ;
92
97
using ( var columns = ImUtf8 . Columns ( 2 , "ColorTable"u8 ) )
93
98
{
94
- ColorTableCopyClipboardButton ( _colorTableSelectedPair << 1 ) ;
95
- ImUtf8 . SameLineInner ( ) ;
96
- retA |= ColorTablePasteFromClipboardButton ( _colorTableSelectedPair << 1 , disabled ) ;
97
- ImGui . SameLine ( ) ;
98
- CenteredTextInRest ( $ "Row { _colorTableSelectedPair + 1 } A") ;
99
+ using ( ImUtf8 . PushId ( "RowHeaderA"u8 ) )
100
+ {
101
+ retA |= DrawRowHeader ( rowAIdx , disabled ) ;
102
+ }
99
103
columns . Next ( ) ;
100
- ColorTableCopyClipboardButton ( ( _colorTableSelectedPair << 1 ) | 1 ) ;
101
- ImUtf8 . SameLineInner ( ) ;
102
- retB |= ColorTablePasteFromClipboardButton ( ( _colorTableSelectedPair << 1 ) | 1 , disabled ) ;
103
- ImGui . SameLine ( ) ;
104
- CenteredTextInRest ( $ "Row { _colorTableSelectedPair + 1 } B") ;
104
+ using ( ImUtf8 . PushId ( "RowHeaderB"u8 ) )
105
+ {
106
+ retB |= DrawRowHeader ( rowBIdx , disabled ) ;
107
+ }
105
108
}
106
109
107
110
DrawHeader ( " Colors"u8 ) ;
@@ -110,13 +113,13 @@ private bool DrawColorTablePairEditor(ColorTable table, ColorDyeTable? dyeTable,
110
113
using var dis = ImRaii . Disabled ( disabled ) ;
111
114
using ( ImUtf8 . PushId ( "ColorsA"u8 ) )
112
115
{
113
- retA |= DrawColors ( table , dyeTable , dyePackA , _colorTableSelectedPair << 1 ) ;
116
+ retA |= DrawColors ( table , dyeTable , dyePackA , rowAIdx ) ;
114
117
}
115
118
116
119
columns . Next ( ) ;
117
120
using ( ImUtf8 . PushId ( "ColorsB"u8 ) )
118
121
{
119
- retB |= DrawColors ( table , dyeTable , dyePackB , ( _colorTableSelectedPair << 1 ) | 1 ) ;
122
+ retB |= DrawColors ( table , dyeTable , dyePackB , rowBIdx ) ;
120
123
}
121
124
}
122
125
@@ -126,13 +129,13 @@ private bool DrawColorTablePairEditor(ColorTable table, ColorDyeTable? dyeTable,
126
129
using var dis = ImRaii . Disabled ( disabled ) ;
127
130
using ( ImUtf8 . PushId ( "PbrA"u8 ) )
128
131
{
129
- retA |= DrawPbr ( table , dyeTable , dyePackA , _colorTableSelectedPair << 1 ) ;
132
+ retA |= DrawPbr ( table , dyeTable , dyePackA , rowAIdx ) ;
130
133
}
131
134
132
135
columns . Next ( ) ;
133
136
using ( ImUtf8 . PushId ( "PbrB"u8 ) )
134
137
{
135
- retB |= DrawPbr ( table , dyeTable , dyePackB , ( _colorTableSelectedPair << 1 ) | 1 ) ;
138
+ retB |= DrawPbr ( table , dyeTable , dyePackB , rowBIdx ) ;
136
139
}
137
140
}
138
141
@@ -142,13 +145,13 @@ private bool DrawColorTablePairEditor(ColorTable table, ColorDyeTable? dyeTable,
142
145
using var dis = ImRaii . Disabled ( disabled ) ;
143
146
using ( ImUtf8 . PushId ( "SheenA"u8 ) )
144
147
{
145
- retA |= DrawSheen ( table , dyeTable , dyePackA , _colorTableSelectedPair << 1 ) ;
148
+ retA |= DrawSheen ( table , dyeTable , dyePackA , rowAIdx ) ;
146
149
}
147
150
148
151
columns . Next ( ) ;
149
152
using ( ImUtf8 . PushId ( "SheenB"u8 ) )
150
153
{
151
- retB |= DrawSheen ( table , dyeTable , dyePackB , ( _colorTableSelectedPair << 1 ) | 1 ) ;
154
+ retB |= DrawSheen ( table , dyeTable , dyePackB , rowBIdx ) ;
152
155
}
153
156
}
154
157
@@ -158,13 +161,13 @@ private bool DrawColorTablePairEditor(ColorTable table, ColorDyeTable? dyeTable,
158
161
using var dis = ImRaii . Disabled ( disabled ) ;
159
162
using ( ImUtf8 . PushId ( "BlendingA"u8 ) )
160
163
{
161
- retA |= DrawBlending ( table , dyeTable , dyePackA , _colorTableSelectedPair << 1 ) ;
164
+ retA |= DrawBlending ( table , dyeTable , dyePackA , rowAIdx ) ;
162
165
}
163
166
164
167
columns . Next ( ) ;
165
168
using ( ImUtf8 . PushId ( "BlendingB"u8 ) )
166
169
{
167
- retB |= DrawBlending ( table , dyeTable , dyePackB , ( _colorTableSelectedPair << 1 ) | 1 ) ;
170
+ retB |= DrawBlending ( table , dyeTable , dyePackB , rowBIdx ) ;
168
171
}
169
172
}
170
173
@@ -174,13 +177,13 @@ private bool DrawColorTablePairEditor(ColorTable table, ColorDyeTable? dyeTable,
174
177
using var dis = ImRaii . Disabled ( disabled ) ;
175
178
using ( ImUtf8 . PushId ( "TemplateA"u8 ) )
176
179
{
177
- retA |= DrawTemplate ( table , dyeTable , dyePackA , _colorTableSelectedPair << 1 ) ;
180
+ retA |= DrawTemplate ( table , dyeTable , dyePackA , rowAIdx ) ;
178
181
}
179
182
180
183
columns . Next ( ) ;
181
184
using ( ImUtf8 . PushId ( "TemplateB"u8 ) )
182
185
{
183
- retB |= DrawTemplate ( table , dyeTable , dyePackB , ( _colorTableSelectedPair << 1 ) | 1 ) ;
186
+ retB |= DrawTemplate ( table , dyeTable , dyePackB , rowBIdx ) ;
184
187
}
185
188
}
186
189
@@ -191,13 +194,13 @@ private bool DrawColorTablePairEditor(ColorTable table, ColorDyeTable? dyeTable,
191
194
using var dis = ImRaii . Disabled ( disabled ) ;
192
195
using ( ImUtf8 . PushId ( "DyeA"u8 ) )
193
196
{
194
- retA |= DrawDye ( dyeTable , dyePackA , _colorTableSelectedPair << 1 ) ;
197
+ retA |= DrawDye ( dyeTable , dyePackA , rowAIdx ) ;
195
198
}
196
199
197
200
columns . Next ( ) ;
198
201
using ( ImUtf8 . PushId ( "DyeB"u8 ) )
199
202
{
200
- retB |= DrawDye ( dyeTable , dyePackB , ( _colorTableSelectedPair << 1 ) | 1 ) ;
203
+ retB |= DrawDye ( dyeTable , dyePackB , rowBIdx ) ;
201
204
}
202
205
}
203
206
@@ -207,20 +210,20 @@ private bool DrawColorTablePairEditor(ColorTable table, ColorDyeTable? dyeTable,
207
210
using var dis = ImRaii . Disabled ( disabled ) ;
208
211
using ( ImUtf8 . PushId ( "FurtherA"u8 ) )
209
212
{
210
- retA |= DrawFurther ( table , dyeTable , dyePackA , _colorTableSelectedPair << 1 ) ;
213
+ retA |= DrawFurther ( table , dyeTable , dyePackA , rowAIdx ) ;
211
214
}
212
215
213
216
columns . Next ( ) ;
214
217
using ( ImUtf8 . PushId ( "FurtherB"u8 ) )
215
218
{
216
- retB |= DrawFurther ( table , dyeTable , dyePackB , ( _colorTableSelectedPair << 1 ) | 1 ) ;
219
+ retB |= DrawFurther ( table , dyeTable , dyePackB , rowBIdx ) ;
217
220
}
218
221
}
219
222
220
223
if ( retA )
221
- UpdateColorTableRowPreview ( _colorTableSelectedPair << 1 ) ;
224
+ UpdateColorTableRowPreview ( rowAIdx ) ;
222
225
if ( retB )
223
- UpdateColorTableRowPreview ( ( _colorTableSelectedPair << 1 ) | 1 ) ;
226
+ UpdateColorTableRowPreview ( rowBIdx ) ;
224
227
225
228
return retA | retB ;
226
229
}
@@ -233,6 +236,20 @@ private static void DrawHeader(ReadOnlySpan<byte> label)
233
236
ImUtf8 . CollapsingHeader ( label , ImGuiTreeNodeFlags . Leaf ) ;
234
237
}
235
238
239
+ private bool DrawRowHeader ( int rowIdx , bool disabled )
240
+ {
241
+ ColorTableCopyClipboardButton ( rowIdx ) ;
242
+ ImUtf8 . SameLineInner ( ) ;
243
+ var ret = ColorTablePasteFromClipboardButton ( rowIdx , disabled ) ;
244
+ ImUtf8 . SameLineInner ( ) ;
245
+ ColorTableRowHighlightButton ( rowIdx , disabled ) ;
246
+
247
+ ImGui . SameLine ( ) ;
248
+ CenteredTextInRest ( $ "Row { ( rowIdx >> 1 ) + 1 } { "AB" [ rowIdx & 1 ] } ") ;
249
+
250
+ return ret ;
251
+ }
252
+
236
253
private static bool DrawColors ( ColorTable table , ColorDyeTable ? dyeTable , DyePack ? dyePack , int rowIdx )
237
254
{
238
255
var dyeOffset = ImGui . GetContentRegionAvail ( ) . X
@@ -589,7 +606,7 @@ private bool DrawDye(ColorDyeTable dyeTable, DyePack? dyePack, int rowIdx)
589
606
if ( _stainService . GudTemplateCombo . Draw ( "##dyeTemplate" , dye . Template . ToString ( ) , string . Empty ,
590
607
scalarSize + ImGui . GetStyle ( ) . ScrollbarSize / 2 , ImGui . GetTextLineHeightWithSpacing ( ) , ImGuiComboFlags . NoArrowButton ) )
591
608
{
592
- dye . Template = _stainService . LegacyTemplateCombo . CurrentSelection ;
609
+ dye . Template = _stainService . GudTemplateCombo . CurrentSelection ;
593
610
ret = true ;
594
611
}
595
612
0 commit comments