Cache font
This commit is contained in:
committed by
Matthias Mailänder
parent
2050d55b21
commit
2dbefaf375
@@ -11,6 +11,7 @@
|
|||||||
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using OpenRA.Graphics;
|
||||||
using OpenRA.Mods.Common.Traits;
|
using OpenRA.Mods.Common.Traits;
|
||||||
using OpenRA.Primitives;
|
using OpenRA.Primitives;
|
||||||
using OpenRA.Traits;
|
using OpenRA.Traits;
|
||||||
@@ -25,6 +26,7 @@ namespace OpenRA.Mods.Common.Widgets
|
|||||||
public readonly TextAlign Align = TextAlign.Left;
|
public readonly TextAlign Align = TextAlign.Left;
|
||||||
public readonly TimerOrder Order = TimerOrder.Descending;
|
public readonly TimerOrder Order = TimerOrder.Descending;
|
||||||
|
|
||||||
|
readonly SpriteFont font;
|
||||||
readonly IEnumerable<SupportPowerInstance> powers;
|
readonly IEnumerable<SupportPowerInstance> powers;
|
||||||
readonly Color bgDark, bgLight;
|
readonly Color bgDark, bgLight;
|
||||||
(string Text, Color Color)[] texts;
|
(string Text, Color Color)[] texts;
|
||||||
@@ -39,6 +41,7 @@ namespace OpenRA.Mods.Common.Widgets
|
|||||||
|
|
||||||
bgDark = ChromeMetrics.Get<Color>("TextContrastColorDark");
|
bgDark = ChromeMetrics.Get<Color>("TextContrastColorDark");
|
||||||
bgLight = ChromeMetrics.Get<Color>("TextContrastColorLight");
|
bgLight = ChromeMetrics.Get<Color>("TextContrastColorLight");
|
||||||
|
font = Game.Renderer.Fonts[Font];
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Tick()
|
public override void Tick()
|
||||||
@@ -74,7 +77,6 @@ namespace OpenRA.Mods.Common.Widgets
|
|||||||
var y = 0;
|
var y = 0;
|
||||||
foreach (var t in texts)
|
foreach (var t in texts)
|
||||||
{
|
{
|
||||||
var font = Game.Renderer.Fonts[Font];
|
|
||||||
var textSize = font.Measure(t.Text);
|
var textSize = font.Measure(t.Text);
|
||||||
var location = new float2(Bounds.Location) + new float2(0, y);
|
var location = new float2(Bounds.Location) + new float2(0, y);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user