Add a Shadow option to LabelWidget and ButtonWidget
This commit is contained in:
@@ -27,17 +27,21 @@ namespace OpenRA.Mods.Common.Widgets
|
||||
public string Font = ChromeMetrics.Get<string>("TextFont");
|
||||
public Color TextColor = ChromeMetrics.Get<Color>("TextColor");
|
||||
public bool Contrast = ChromeMetrics.Get<bool>("TextContrast");
|
||||
public Color ContrastColor = ChromeMetrics.Get<Color>("TextContrastColorDark");
|
||||
public bool Shadow = ChromeMetrics.Get<bool>("TextShadow");
|
||||
public Color ContrastColorDark = ChromeMetrics.Get<Color>("TextContrastColorDark");
|
||||
public Color ContrastColorLight = ChromeMetrics.Get<Color>("TextContrastColorLight");
|
||||
public bool WordWrap = false;
|
||||
public Func<string> GetText;
|
||||
public Func<Color> GetColor;
|
||||
public Func<Color> GetContrastColor;
|
||||
public Func<Color> GetContrastColorDark;
|
||||
public Func<Color> GetContrastColorLight;
|
||||
|
||||
public LabelWidget()
|
||||
{
|
||||
GetText = () => Text;
|
||||
GetColor = () => TextColor;
|
||||
GetContrastColor = () => ContrastColor;
|
||||
GetContrastColorDark = () => ContrastColorDark;
|
||||
GetContrastColorLight = () => ContrastColorLight;
|
||||
}
|
||||
|
||||
protected LabelWidget(LabelWidget other)
|
||||
@@ -48,11 +52,14 @@ namespace OpenRA.Mods.Common.Widgets
|
||||
Font = other.Font;
|
||||
TextColor = other.TextColor;
|
||||
Contrast = other.Contrast;
|
||||
ContrastColor = other.ContrastColor;
|
||||
ContrastColorDark = other.ContrastColorDark;
|
||||
ContrastColorLight = other.ContrastColorLight;
|
||||
Shadow = other.Shadow;
|
||||
WordWrap = other.WordWrap;
|
||||
GetText = other.GetText;
|
||||
GetColor = other.GetColor;
|
||||
GetContrastColor = other.GetContrastColor;
|
||||
GetContrastColorDark = other.GetContrastColorDark;
|
||||
GetContrastColorLight = other.GetContrastColorLight;
|
||||
}
|
||||
|
||||
public override void Draw()
|
||||
@@ -84,9 +91,12 @@ namespace OpenRA.Mods.Common.Widgets
|
||||
text = WidgetUtils.WrapText(text, Bounds.Width, font);
|
||||
|
||||
var color = GetColor();
|
||||
var contrast = GetContrastColor();
|
||||
var bgDark = GetContrastColorDark();
|
||||
var bgLight = GetContrastColorLight();
|
||||
if (Contrast)
|
||||
font.DrawTextWithContrast(text, position, color, contrast, 2);
|
||||
font.DrawTextWithContrast(text, position, color, bgDark, bgLight, 2);
|
||||
else if (Shadow)
|
||||
font.DrawTextWithShadow(text, position, color, bgDark, bgLight, 1);
|
||||
else
|
||||
font.DrawText(text, position, color);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user