Skip to content

Commit 6b012ef

Browse files
committed
differentiate between RollColumn vertical width and horizontal height
don't really like this code too much, but it works. And the RollColumn has no idea what orientation it has, so it can't do the logic itself. see #3708
1 parent 1e39743 commit 6b012ef

File tree

4 files changed

+34
-19
lines changed

4 files changed

+34
-19
lines changed

src/BizHawk.Client.EmuHawk/CustomControls/InputRoll/InputRoll.Drawing.cs

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -142,33 +142,31 @@ private void DrawColumnText(List<RollColumn> visibleColumns)
142142
{
143143
_renderer.PrepDrawString(Font, _foreColor);
144144

145-
int h = ColumnHeight;
146-
int yOffset = HorizontalOrientation ? -_vBar.Value : 0;
147-
148145
for (int j = 0; j < visibleColumns.Count; j++)
149146
{
150147
var column = visibleColumns[j];
151-
var w = column.Width;
152-
int x, y;
148+
int x, y, w, h;
153149

154150
if (HorizontalOrientation)
155151
{
156-
var columnHeight = column.Width;
157152
var textSize = _renderer.MeasureString(column.Text, Font);
158153
x = MaxColumnWidth - CellWidthPadding - (int)textSize.Width;
159-
y = yOffset + ((columnHeight - (int)textSize.Height) / 2);
160-
yOffset += columnHeight;
154+
y = column.Left + ((column.Width - (int)textSize.Height) / 2) - _vBar.Value;
155+
w = MaxColumnWidth;
156+
h = column.Width;
161157
}
162158
else
163159
{
164160
x = 1 + column.Left + CellWidthPadding - _hBar.Value;
165161
y = CellHeightPadding;
162+
w = column.Width;
163+
h = ColumnHeight;
166164
}
167165

168166
if (IsHoveringOnColumnCell && column == CurrentCell.Column)
169167
{
170168
_renderer.PrepDrawString(Font, SystemColors.HighlightText);
171-
DrawString(column.Text, new Rectangle(x, y, column.Width, h));
169+
DrawString(column.Text, new Rectangle(x, y, w, h));
172170
_renderer.PrepDrawString(Font, _foreColor);
173171
}
174172
else
@@ -301,20 +299,19 @@ private void DrawColumnBg(List<RollColumn> visibleColumns, Rectangle rect)
301299
{
302300
_renderer.FillRectangle(new Rectangle(0, 0, MaxColumnWidth + 1, rect.Height));
303301

304-
int y = -_vBar.Value;
305302
for (int j = 0; j < visibleColumns.Count; j++)
306303
{
304+
int y = visibleColumns[j].Left - _vBar.Value;
307305
_renderer.Line(1, y, MaxColumnWidth, y);
308-
y += visibleColumns[j].Width;
309306
}
310307

311308
if (visibleColumns.Count is not 0)
312309
{
313-
_renderer.Line(1, y, MaxColumnWidth, y);
310+
_renderer.Line(1, TotalColWidth, MaxColumnWidth, TotalColWidth);
314311
}
315312

316-
_renderer.Line(0, 0, 0, y);
317-
_renderer.Line(MaxColumnWidth, 0, MaxColumnWidth, y);
313+
_renderer.Line(0, 0, 0, rect.Height);
314+
_renderer.Line(MaxColumnWidth, 0, MaxColumnWidth, rect.Height);
318315
}
319316
else
320317
{

src/BizHawk.Client.EmuHawk/CustomControls/InputRoll/InputRoll.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1645,7 +1645,7 @@ private void ColumnChangedCallback()
16451645
RecalculateScrollBars();
16461646
if (_columns.VisibleColumns.Any())
16471647
{
1648-
MaxColumnWidth = _columns.VisibleColumns.Max(c => c.Width);
1648+
MaxColumnWidth = _columns.VisibleColumns.Max(c => c.VerticalWidth);
16491649
}
16501650
}
16511651

@@ -1966,7 +1966,7 @@ private void UpdateCellSize()
19661966

19671967
if (_columns.VisibleColumns.Any())
19681968
{
1969-
MaxColumnWidth = _columns.VisibleColumns.Max(c => c.Width);
1969+
MaxColumnWidth = _columns.VisibleColumns.Max(c => c.VerticalWidth);
19701970
}
19711971
}
19721972

src/BizHawk.Client.EmuHawk/CustomControls/InputRoll/RollColumn.cs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ namespace BizHawk.Client.EmuHawk
44
{
55
public class RollColumn
66
{
7+
public int VerticalWidth { get; }
8+
public int HorizontalHeight { get; }
79
public int Width { get; set; }
810
public int Left { get; set; }
911
public int Right { get; set; }
@@ -36,11 +38,16 @@ private RollColumn()
3638
}
3739

3840
public RollColumn(string name, int widthUnscaled, ColumnType type, string text)
41+
: this(name, widthUnscaled, widthUnscaled, type, text) { }
42+
43+
public RollColumn(string name, int verticalWidth, int horizontalHeight, ColumnType type, string text)
3944
{
4045
Name = name;
4146
Text = text;
4247
Type = type;
43-
Width = UIHelper.ScaleX(widthUnscaled);
48+
VerticalWidth = UIHelper.ScaleX(verticalWidth);
49+
HorizontalHeight = UIHelper.ScaleX(horizontalHeight);
50+
Width = VerticalWidth;
4451
}
4552

4653
public RollColumn(string name, int widthUnscaled, string text)

src/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.cs

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -347,7 +347,8 @@ private void SetUpColumns()
347347

348348
TasView.AllColumns.Add(new(
349349
name: name,
350-
widthUnscaled: (maxLength * 6) + 14, // magic numbers reused in EditBranchTextPopUp() --feos // not since eb63fa5a9 (before 2.3.3) --yoshi
350+
verticalWidth: (Math.Max(maxLength, mnemonic.Length) * 6) + 14,
351+
horizontalHeight: (maxLength * 6) + 14,
351352
type: type,
352353
text: mnemonic)
353354
{
@@ -1233,7 +1234,7 @@ private IMovieController ControllerFromMnemonicStr(string inputLogEntry)
12331234
if (axisSpec.HasValue)
12341235
{
12351236
string mnemonic = Bk2MnemonicLookup.LookupAxis(name, MovieSession.Movie.SystemID);
1236-
yield return (name, mnemonic, Math.Max(mnemonic.Length, axisSpec.Value.MaxDigits));
1237+
yield return (name, mnemonic, axisSpec.Value.MaxDigits);
12371238
}
12381239
else
12391240
{
@@ -1250,12 +1251,22 @@ private void HandleRotationChanged(object sender, EventArgs e)
12501251
{
12511252
BranchesMarkersSplit.Orientation = Orientation.Vertical;
12521253
BranchesMarkersSplit.SplitterDistance = 200;
1254+
foreach (var rollColumn in TasView.AllColumns)
1255+
{
1256+
rollColumn.Width = rollColumn.HorizontalHeight;
1257+
}
12531258
}
12541259
else
12551260
{
12561261
BranchesMarkersSplit.Orientation = Orientation.Horizontal;
12571262
BranchesMarkersSplit.SplitterDistance = _defaultBranchMarkerSplitDistance;
1263+
foreach (var rollColumn in TasView.AllColumns)
1264+
{
1265+
rollColumn.Width = rollColumn.VerticalWidth;
1266+
}
12581267
}
1268+
1269+
TasView.AllColumns.ColumnsChanged();
12591270
}
12601271
}
12611272
}

0 commit comments

Comments
 (0)