just fetch the font once in ChatDisplayWidget
This commit is contained in:
@@ -33,6 +33,7 @@ namespace OpenRA.Widgets
|
|||||||
: base(widget) { }
|
: base(widget) { }
|
||||||
|
|
||||||
public override Rectangle EventBounds { get { return Rectangle.Empty; } }
|
public override Rectangle EventBounds { get { return Rectangle.Empty; } }
|
||||||
|
|
||||||
public override void Draw()
|
public override void Draw()
|
||||||
{
|
{
|
||||||
var pos = RenderOrigin;
|
var pos = RenderOrigin;
|
||||||
@@ -42,7 +43,10 @@ namespace OpenRA.Widgets
|
|||||||
if (DrawBackground)
|
if (DrawBackground)
|
||||||
WidgetUtils.DrawPanel("dialog3", chatLogArea);
|
WidgetUtils.DrawPanel("dialog3", chatLogArea);
|
||||||
|
|
||||||
|
var font = Game.Renderer.Fonts["Regular"];
|
||||||
|
|
||||||
Game.Renderer.EnableScissor(chatLogArea.Left, chatLogArea.Top, chatLogArea.Width, chatLogArea.Height);
|
Game.Renderer.EnableScissor(chatLogArea.Left, chatLogArea.Top, chatLogArea.Width, chatLogArea.Height);
|
||||||
|
|
||||||
foreach (var line in recentLines.AsEnumerable().Reverse())
|
foreach (var line in recentLines.AsEnumerable().Reverse())
|
||||||
{
|
{
|
||||||
chatpos.Y -= 20;
|
chatpos.Y -= 20;
|
||||||
@@ -51,13 +55,13 @@ namespace OpenRA.Widgets
|
|||||||
if (!string.IsNullOrEmpty(line.Owner))
|
if (!string.IsNullOrEmpty(line.Owner))
|
||||||
{
|
{
|
||||||
var owner = 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);
|
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);
|
Color.White, Color.Black, UseContrast ? 1 : 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user