From a9d25b603c86a1b783977208ca1b5ab5332dfdd3 Mon Sep 17 00:00:00 2001 From: Chris Forbes Date: Tue, 16 Aug 2011 19:49:01 +1200 Subject: [PATCH] factor out duplicated hardcoded font in CashTick --- OpenRA.Mods.RA/Effects/CashTick.cs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/OpenRA.Mods.RA/Effects/CashTick.cs b/OpenRA.Mods.RA/Effects/CashTick.cs index efecf73311..b7033fca29 100644 --- a/OpenRA.Mods.RA/Effects/CashTick.cs +++ b/OpenRA.Mods.RA/Effects/CashTick.cs @@ -12,6 +12,7 @@ using System.Collections.Generic; using System.Drawing; using OpenRA.Effects; using OpenRA.Traits; +using OpenRA.Graphics; namespace OpenRA.Mods.RA.Effects { @@ -22,6 +23,7 @@ namespace OpenRA.Mods.RA.Effects int velocity; float2 pos, offset; Color color; + SpriteFont font; static string FormatCashAmount(int x) { return "{0}${1}".F(x < 0 ? "-" : "+", x); } @@ -34,7 +36,8 @@ namespace OpenRA.Mods.RA.Effects this.velocity = velocity; this.pos = pos; s = value; - offset = 0.5f*Game.Renderer.Fonts["TinyBold"].Measure(s).ToFloat2(); + font = Game.Renderer.Fonts["TinyBold"]; + offset = 0.5f*font.Measure(s).ToFloat2(); remaining = lifetime; } @@ -47,7 +50,7 @@ namespace OpenRA.Mods.RA.Effects public IEnumerable Render() { - Game.Renderer.Fonts["TinyBold"].DrawTextWithContrast(s, Game.viewport.Zoom*(pos - Game.viewport.Location) - offset, color, Color.Black,1); + font.DrawTextWithContrast(s, Game.viewport.Zoom*(pos - Game.viewport.Location) - offset, color, Color.Black,1); yield break; } }