Skip to content

Commit 75b734e

Browse files
committed
allow InputRoll users to specify forecolor of individual cells; make marker state "x" indicator red
1 parent 11aeaf2 commit 75b734e

3 files changed

Lines changed: 32 additions & 30 deletions

File tree

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

Lines changed: 6 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,6 @@ private void DrawData(List<RollColumn> visibleColumns, int firstVisibleRow, int
186186

187187
int startRow = firstVisibleRow;
188188
int range = Math.Min(lastVisibleRow, RowCount - 1) - startRow + 1;
189-
_renderer.PrepDrawString(Font, _foreColor);
190189

191190
Cell currentCell = new();
192191
Cell mouseCell = null;
@@ -226,28 +225,21 @@ private void DrawData(List<RollColumn> visibleColumns, int firstVisibleRow, int
226225
int strOffsetY = 0;
227226
QueryItemText(this, f + startRow, col, out var text, ref strOffsetX, ref strOffsetY);
228227

229-
bool rePrep = false;
230-
Color foreColor = _foreColor;
228+
Color? foreColor = QueryItemForeColor?.Invoke(this, f + startRow, col);
231229
Font font = Font;
232230
currentCell.Column = col;
233231
currentCell.RowIndex = f + startRow;
234-
if (_selectedItems.Contains(currentCell))
232+
if (foreColor == null && _selectedItems.Contains(currentCell))
235233
{
236234
foreColor = SystemColors.HighlightText;
237-
rePrep = true;
238235
}
239236
if (string.IsNullOrEmpty(text) && mouseCell == currentCell)
240237
{
241238
font = new Font(Font, FontStyle.Regular);
242239
foreColor = SystemColors.GrayText;
243240
text = col.Text;
244-
rePrep = true;
245-
}
246-
if (col.Rotatable || rePrep)
247-
{
248-
_renderer.PrepDrawString(font, foreColor, rotate: col.Rotatable);
249-
rePrep = true;
250241
}
242+
_renderer.PrepDrawString(font, foreColor ?? _foreColor, rotate: col.Rotatable);
251243

252244
int textWidth = (int)_renderer.MeasureString(text, font).Width;
253245
if (col.Rotatable)
@@ -266,11 +258,6 @@ private void DrawData(List<RollColumn> visibleColumns, int firstVisibleRow, int
266258

267259
DrawString(text, new Rectangle(baseX + textX, baseY + textY, MaxColumnWidth, CellHeight));
268260
}
269-
270-
if (rePrep)
271-
{
272-
_renderer.PrepDrawString(Font, _foreColor);
273-
}
274261
}
275262
}
276263
}
@@ -299,34 +286,23 @@ private void DrawData(List<RollColumn> visibleColumns, int firstVisibleRow, int
299286

300287
QueryItemText(this, f + startRow, column, out var text, ref strOffsetX, ref strOffsetY);
301288

302-
bool rePrep = false;
303-
Color foreColor = _foreColor;
289+
Color? foreColor = QueryItemForeColor?.Invoke(this, f + startRow, column);
304290
Font font = Font;
305291
currentCell.Column = column;
306292
currentCell.RowIndex = f + startRow;
307-
if (_selectedItems.Contains(currentCell))
293+
if (foreColor == null && _selectedItems.Contains(currentCell))
308294
{
309295
foreColor = SystemColors.HighlightText;
310-
rePrep = true;
311296
}
312297
if (string.IsNullOrEmpty(text) && mouseCell == currentCell)
313298
{
314299
font = new Font(Font, FontStyle.Regular);
315300
foreColor = SystemColors.GrayText;
316301
text = column.Text;
317-
rePrep = true;
318-
}
319-
if (rePrep)
320-
{
321-
_renderer.PrepDrawString(font, foreColor);
322302
}
323303

304+
_renderer.PrepDrawString(font, foreColor ?? _foreColor);
324305
DrawString(text, new Rectangle(point.X + strOffsetX, point.Y + strOffsetY, column.Width, ColumnHeight));
325-
326-
if (rePrep)
327-
{
328-
_renderer.PrepDrawString(Font, _foreColor);
329-
}
330306
}
331307
}
332308
}

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

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -449,6 +449,12 @@ public int HoverInterval
449449
[Category("Virtual")]
450450
public event QueryItemBkColorHandler QueryItemBkColor;
451451

452+
/// <summary>
453+
/// Fire the <see cref="QueryItemForeColor"/> event which requests the color of text for the passed cell
454+
/// </summary>
455+
[Category("Virtual")]
456+
public event QueryItemForeColorHandler QueryItemForeColor;
457+
452458
[Category("Virtual")]
453459
public event QueryRowBkColorHandler QueryRowBkColor;
454460

@@ -531,6 +537,11 @@ public int HoverInterval
531537
/// </summary>
532538
public delegate void QueryItemTextHandler(InputRoll sender, int index, RollColumn column, out string text, ref int offsetX, ref int offsetY);
533539

540+
/// <summary>
541+
/// Retrieve the foreground color for a cell. Return null to use the default.
542+
/// </summary>
543+
public delegate Color? QueryItemForeColorHandler(InputRoll sender, int index, RollColumn column);
544+
534545
/// <summary>
535546
/// Retrieve the background color for a cell
536547
/// </summary>

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

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ public MarkerControl()
4040
SetupColumns();
4141
MarkerView.QueryItemBkColor += MarkerView_QueryItemBkColor;
4242
MarkerView.QueryItemText += MarkerView_QueryItemText;
43+
MarkerView.QueryItemForeColor += MarkerView_QueryItemForeColor;
4344
}
4445

4546
public void UpdateHotkeyTooltips(Config config)
@@ -124,6 +125,20 @@ private void MarkerView_QueryItemText(InputRoll sender, int index, RollColumn co
124125
}
125126
}
126127

128+
private Color? MarkerView_QueryItemForeColor(InputRoll sender, int index, RollColumn column)
129+
{
130+
if (column.Name == SAVESTATE_COL_NAME)
131+
{
132+
TasMovieMarker marker = Markers[index];
133+
if (!marker.WantsState)
134+
{
135+
return Color.OrangeRed;
136+
}
137+
}
138+
139+
return null;
140+
}
141+
127142
private void MarkerContextMenu_Opening(object sender, CancelEventArgs e)
128143
{
129144
EditMarkerToolStripMenuItem.Enabled =

0 commit comments

Comments
 (0)