Makes ButtonWidget and Widgets based on it more customizable, sets defaults in metrics.yaml.

This commit is contained in:
reaperrr
2013-11-19 01:39:57 +01:00
parent 915bf2cff0
commit 394a2b5166
7 changed files with 58 additions and 7 deletions

View File

@@ -43,6 +43,9 @@ namespace OpenRA.Widgets
{
var disabled = IsDisabled();
var font = Game.Renderer.Fonts[Font];
var color = GetColor();
var colordisabled = GetColorDisabled();
var contrast = GetContrastColor();
var rect = RenderBounds;
var check = new Rectangle(rect.Location, new Size(Bounds.Height, Bounds.Height));
var state = disabled ? "checkbox-disabled" :
@@ -53,9 +56,15 @@ namespace OpenRA.Widgets
WidgetUtils.DrawPanel(state, check);
var textSize = font.Measure(Text);
font.DrawText(Text,
new float2(rect.Left + rect.Height * 1.5f, RenderOrigin.Y - BaseLine + (Bounds.Height - textSize.Y)/2),
disabled ? Color.Gray : Color.White);
if (Contrast)
font.DrawTextWithContrast(Text,
new float2(rect.Left + rect.Height * 1.5f, RenderOrigin.Y - BaseLine + (Bounds.Height - textSize.Y)/2),
disabled ? colordisabled : color, contrast, 2);
else
font.DrawText(Text,
new float2(rect.Left + rect.Height * 1.5f, RenderOrigin.Y - BaseLine + (Bounds.Height - textSize.Y)/2),
disabled ? colordisabled : color);
if (IsChecked() || (Depressed && HasPressedState && !disabled))
{