From e92205128252a1a21cdc55a092f0a23251a22569 Mon Sep 17 00:00:00 2001 From: Chris Forbes Date: Tue, 16 Aug 2011 19:46:02 +1200 Subject: [PATCH] factor formatting code out of CashTick ctor --- OpenRA.Mods.RA/Effects/CashTick.cs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/OpenRA.Mods.RA/Effects/CashTick.cs b/OpenRA.Mods.RA/Effects/CashTick.cs index 57947dbc4a..efecf73311 100644 --- a/OpenRA.Mods.RA/Effects/CashTick.cs +++ b/OpenRA.Mods.RA/Effects/CashTick.cs @@ -22,13 +22,18 @@ namespace OpenRA.Mods.RA.Effects int velocity; float2 pos, offset; Color color; - + + static string FormatCashAmount(int x) { return "{0}${1}".F(x < 0 ? "-" : "+", x); } + public CashTick(int value, int lifetime, int velocity, float2 pos, Color color) + : this( FormatCashAmount(value), lifetime, velocity, pos, color ) { } + + public CashTick(string value, int lifetime, int velocity, float2 pos, Color color) { this.color = color; this.velocity = velocity; - s = "{0}${1}".F(value < 0 ? "-" : "+", value); this.pos = pos; + s = value; offset = 0.5f*Game.Renderer.Fonts["TinyBold"].Measure(s).ToFloat2(); remaining = lifetime; }