Add color support to LabelWidget

This commit is contained in:
Paul Chote
2011-05-07 13:04:48 +12:00
parent 24712825eb
commit f3a54a802a

View File

@@ -20,14 +20,15 @@ namespace OpenRA.Widgets
public enum TextAlign { Left, Center, Right } public enum TextAlign { Left, Center, Right }
public enum TextVAlign { Top, Middle, Bottom } public enum TextVAlign { Top, Middle, Bottom }
public enum LabelFont { Regular, Bold, Title, Tiny, TinyBold, BigBold } public enum LabelFont { Regular, Bold, Title, Tiny, TinyBold, BigBold }
public string Text = null; public string Text = null;
public string Background = null; public string Background = null;
public TextAlign Align = TextAlign.Left; public TextAlign Align = TextAlign.Left;
public TextVAlign VAlign = TextVAlign.Middle; public TextVAlign VAlign = TextVAlign.Middle;
public LabelFont Font = LabelFont.Regular; public LabelFont Font = LabelFont.Regular;
public bool Bold = false; public Color Color = Color.White;
public bool Bold = false; // Legacy flag. TODO: Remove
public bool Contrast = false; public bool Contrast = false;
public Color ContrastColor = Color.Black;
public bool WordWrap = false; public bool WordWrap = false;
public Func<string> GetText; public Func<string> GetText;
public Func<string> GetBackground; public Func<string> GetBackground;
@@ -45,7 +46,10 @@ namespace OpenRA.Widgets
Text = other.Text; Text = other.Text;
Align = other.Align; Align = other.Align;
Bold = other.Bold; Bold = other.Bold;
Font = other.Font;
Color = other.Color;
Contrast = other.Contrast; Contrast = other.Contrast;
ContrastColor = other.ContrastColor;
GetText = other.GetText; GetText = other.GetText;
GetBackground = other.GetBackground; GetBackground = other.GetBackground;
} }
@@ -151,9 +155,9 @@ namespace OpenRA.Widgets
} }
if (Contrast) if (Contrast)
font.DrawTextWithContrast(text, position, Color.White, Color.Black, 2); font.DrawTextWithContrast(text, position, Color, ContrastColor, 2);
else else
font.DrawText(text, position, Color.White); font.DrawText(text, position, Color);
} }
public override Widget Clone() { return new LabelWidget(this); } public override Widget Clone() { return new LabelWidget(this); }