Input Roll - simpler and more efficient code, with a decent speedup

This commit is contained in:
adelikat 2014-08-10 21:35:17 +00:00
parent 1de36a0e2f
commit 7f053fc007
2 changed files with 10 additions and 12 deletions

View File

@ -121,12 +121,12 @@ namespace BizHawk.Client.EmuHawk.CustomControls
/// <param name="font">the font to use to draw the string</param> /// <param name="font">the font to use to draw the string</param>
/// <param name="color">the text color to set</param> /// <param name="color">the text color to set</param>
/// <param name="point">the location to start string draw (top-left)</param> /// <param name="point">the location to start string draw (top-left)</param>
public void DrawString(String str, Font font, Point point) public void DrawString(String str, Point point)
{ {
TextOut(_hdc, point.X, point.Y, str, str.Length); TextOut(_hdc, point.X, point.Y, str, str.Length);
} }
public void PrepDrawString(String str, Font font, Color color, Point point) public void PrepDrawString(Font font, Color color)
{ {
SetFont(font); SetFont(font);
SetTextColor(color); SetTextColor(color);

View File

@ -166,7 +166,6 @@ namespace BizHawk.Client.EmuHawk
{ {
var colWidth = _horizontalOrientedColumnWidth; var colWidth = _horizontalOrientedColumnWidth;
gdi.DrawRectangle(0, 0, colWidth, Height); gdi.DrawRectangle(0, 0, colWidth, Height);
gdi.FillRectangle(1, 1, colWidth - 3, Height - 3);
int start = 0; int start = 0;
foreach (var column in Columns) foreach (var column in Columns)
@ -243,22 +242,22 @@ namespace BizHawk.Client.EmuHawk
if (HorizontalOrientation) if (HorizontalOrientation)
{ {
int start = 0; int start = 0;
gdi.PrepDrawString(this.Font, this.ForeColor);
foreach (var column in Columns) foreach (var column in Columns)
{ {
var point = new Point(CellPadding, start + CellPadding); var point = new Point(CellPadding, start + CellPadding);
gdi.PrepDrawString(column.Text, this.Font, this.ForeColor, point); gdi.DrawString(column.Text, point);
gdi.DrawString(column.Text, this.Font, point);
start += CellHeight; start += CellHeight;
} }
} }
else else
{ {
int start = CellPadding; int start = CellPadding;
gdi.PrepDrawString(this.Font, this.ForeColor);
foreach(var column in Columns) foreach(var column in Columns)
{ {
var point = new Point(start + CellPadding, CellPadding); var point = new Point(start + CellPadding, CellPadding);
gdi.PrepDrawString(column.Text, this.Font, this.ForeColor, point); gdi.DrawString(column.Text, point);
gdi.DrawString(column.Text, this.Font, point);
start += CalcWidth(column); start += CalcWidth(column);
} }
} }
@ -271,6 +270,7 @@ namespace BizHawk.Client.EmuHawk
if (HorizontalOrientation) if (HorizontalOrientation)
{ {
var visibleRows = (Width - _horizontalOrientedColumnWidth) / CellWidth; var visibleRows = (Width - _horizontalOrientedColumnWidth) / CellWidth;
gdi.PrepDrawString(this.Font, this.ForeColor);
for (int i = 0; i < visibleRows; i++) for (int i = 0; i < visibleRows; i++)
{ {
for (int j = 0; j < Columns.Count; j++) for (int j = 0; j < Columns.Count; j++)
@ -280,14 +280,14 @@ namespace BizHawk.Client.EmuHawk
int y = j * CellHeight; int y = j * CellHeight;
var point = new Point(x, y); var point = new Point(x, y);
QueryItemText(i, j, out text); QueryItemText(i, j, out text);
gdi.PrepDrawString(text, this.Font, this.ForeColor, point); gdi.DrawString(text, point);
gdi.DrawString(text, this.Font, point);
} }
} }
} }
else else
{ {
var visibleRows = (Height / CellHeight) - 1; var visibleRows = (Height / CellHeight) - 1;
gdi.PrepDrawString(this.Font, this.ForeColor);
for (int i = 1; i < visibleRows; i++) for (int i = 1; i < visibleRows; i++)
{ {
int x = 1; int x = 1;
@ -296,9 +296,7 @@ namespace BizHawk.Client.EmuHawk
string text; string text;
var point = new Point(x + CellPadding, i * CellHeight); var point = new Point(x + CellPadding, i * CellHeight);
QueryItemText(i, j, out text); QueryItemText(i, j, out text);
gdi.DrawString(text, point);
gdi.PrepDrawString(text, this.Font, this.ForeColor, point);
gdi.DrawString(text, this.Font, point);
x += CalcWidth(Columns[j]); x += CalcWidth(Columns[j]);
} }
} }