just fetch the font once in ChatDisplayWidget

This commit is contained in:
Chris Forbes
2011-09-24 21:51:18 +12:00
parent 9fcddc0df2
commit 1c2f857222

View File

@@ -33,6 +33,7 @@ namespace OpenRA.Widgets
: base(widget) { }
public override Rectangle EventBounds { get { return Rectangle.Empty; } }
public override void Draw()
{
var pos = RenderOrigin;
@@ -42,7 +43,10 @@ namespace OpenRA.Widgets
if (DrawBackground)
WidgetUtils.DrawPanel("dialog3", chatLogArea);
var font = Game.Renderer.Fonts["Regular"];
Game.Renderer.EnableScissor(chatLogArea.Left, chatLogArea.Top, chatLogArea.Width, chatLogArea.Height);
foreach (var line in recentLines.AsEnumerable().Reverse())
{
chatpos.Y -= 20;
@@ -51,13 +55,13 @@ namespace OpenRA.Widgets
if (!string.IsNullOrEmpty(line.Owner))
{
var owner = line.Owner + ":";
inset = Game.Renderer.Fonts["Regular"].Measure(owner).X + 10;
inset = font.Measure(owner).X + 10;
Game.Renderer.Fonts["Regular"].DrawTextWithContrast(owner, chatpos,
font.DrawTextWithContrast(owner, chatpos,
line.Color, Color.Black, UseContrast ? 1 : 0);
}
Game.Renderer.Fonts["Regular"].DrawTextWithContrast(line.Text, chatpos + new int2(inset, 0),
font.DrawTextWithContrast(line.Text, chatpos + new int2(inset, 0),
Color.White, Color.Black, UseContrast ? 1 : 0);
}