Skip to content

Commit af16dfd

Browse files
committed
allow InputRoll users to specify forecolor of individual cells; make marker state "x" indicator red
1 parent 8077e1c commit af16dfd

3 files changed

Lines changed: 45 additions & 29 deletions

File tree

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

Lines changed: 18 additions & 29 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
if (HorizontalOrientation)
@@ -221,20 +220,17 @@ private void DrawData(List<RollColumn> visibleColumns, int firstVisibleRow, int
221220
int strOffsetY = 0;
222221
QueryItemText(this, f + startRow, col, out var text, ref strOffsetX, ref strOffsetY);
223222

224-
bool rePrep = false;
225-
Color foreColor = _foreColor;
226-
currentCell.Column = col;
227-
currentCell.RowIndex = f + startRow;
228-
if (_selectedItems.Contains(currentCell))
229-
{
230-
foreColor = SystemColors.HighlightText;
231-
rePrep = true;
232-
}
233-
if (col.Rotatable || rePrep)
223+
Color? foreColor = QueryItemForeColor?.Invoke(this, f + startRow, col);
224+
if (foreColor == null)
234225
{
235-
_renderer.PrepDrawString(Font, foreColor, rotate: col.Rotatable);
236-
rePrep = true;
226+
currentCell.Column = col;
227+
currentCell.RowIndex = f + startRow;
228+
if (_selectedItems.Contains(currentCell))
229+
{
230+
foreColor = SystemColors.HighlightText;
231+
}
237232
}
233+
_renderer.PrepDrawString(Font, foreColor ?? _foreColor, rotate: col.Rotatable);
238234

239235
int textWidth = (int)_renderer.MeasureString(text, Font).Width;
240236
if (col.Rotatable)
@@ -253,11 +249,6 @@ private void DrawData(List<RollColumn> visibleColumns, int firstVisibleRow, int
253249

254250
DrawString(text, new Rectangle(baseX + textX, baseY + textY, MaxColumnWidth, CellHeight));
255251
}
256-
257-
if (rePrep)
258-
{
259-
_renderer.PrepDrawString(Font, _foreColor);
260-
}
261252
}
262253
}
263254
}
@@ -285,22 +276,20 @@ private void DrawData(List<RollColumn> visibleColumns, int firstVisibleRow, int
285276
}
286277

287278
QueryItemText(this, f + startRow, column, out var text, ref strOffsetX, ref strOffsetY);
279+
Color? foreColor = QueryItemForeColor?.Invoke(this, f + startRow, column);
288280

289-
bool rePrep = false;
290-
currentCell.Column = column;
291-
currentCell.RowIndex = f + startRow;
292-
if (_selectedItems.Contains(currentCell))
281+
if (foreColor == null)
293282
{
294-
_renderer.PrepDrawString(Font, SystemColors.HighlightText);
295-
rePrep = true;
283+
currentCell.Column = column;
284+
currentCell.RowIndex = f + startRow;
285+
if (_selectedItems.Contains(currentCell))
286+
{
287+
foreColor = SystemColors.HighlightText;
288+
}
296289
}
297290

291+
_renderer.PrepDrawString(Font, foreColor ?? _foreColor);
298292
DrawString(text, new Rectangle(point.X + strOffsetX, point.Y + strOffsetY, column.Width, ColumnHeight));
299-
300-
if (rePrep)
301-
{
302-
_renderer.PrepDrawString(Font, _foreColor);
303-
}
304293
}
305294
}
306295
}

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

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -438,6 +438,12 @@ public int HoverInterval
438438
[Category("Virtual")]
439439
public event QueryItemBkColorHandler QueryItemBkColor;
440440

441+
/// <summary>
442+
/// Fire the <see cref="QueryItemForeColor"/> event which requests the color of text for the passed cell
443+
/// </summary>
444+
[Category("Virtual")]
445+
public event QueryItemForeColorHandler QueryItemForeColor;
446+
441447
[Category("Virtual")]
442448
public event QueryRowBkColorHandler QueryRowBkColor;
443449

@@ -520,10 +526,16 @@ public int HoverInterval
520526
/// </summary>
521527
public delegate void QueryItemTextHandler(InputRoll sender, int index, RollColumn column, out string text, ref int offsetX, ref int offsetY);
522528

529+
/// <summary>
530+
/// Retrieve the foreground color for a cell. Return null to use the default.
531+
/// </summary>
532+
public delegate Color? QueryItemForeColorHandler(InputRoll sender, int index, RollColumn column);
533+
523534
/// <summary>
524535
/// Retrieve the background color for a cell
525536
/// </summary>
526537
public delegate void QueryItemBkColorHandler(InputRoll sender, int index, RollColumn column, ref Color color);
538+
527539
public delegate void QueryRowBkColorHandler(InputRoll sender, int index, ref Color color);
528540

529541
/// <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)