diff --git a/OpenRA.Game/Widgets/ButtonWidget.cs b/OpenRA.Game/Widgets/ButtonWidget.cs index 4b3b6c7389..6f87839c2d 100644 --- a/OpenRA.Game/Widgets/ButtonWidget.cs +++ b/OpenRA.Game/Widgets/ButtonWidget.cs @@ -1,6 +1,6 @@ #region Copyright & License Information /* - * Copyright 2007-2011 The OpenRA Developers (see AUTHORS) + * Copyright 2007-2013 The OpenRA Developers (see AUTHORS) * This file is part of OpenRA, which is free software. It is made * available to you under the terms of the GNU General Public License * as published by the Free Software Foundation. For more information, @@ -27,9 +27,16 @@ namespace OpenRA.Widgets public bool Depressed = false; public int VisualHeight = ChromeMetrics.Get("ButtonDepth"); public string Font = ChromeMetrics.Get("ButtonFont"); + public Color TextColor = ChromeMetrics.Get("ButtonTextColor"); + public Color TextColorDisabled = ChromeMetrics.Get("ButtonTextColorDisabled"); + public bool Contrast = ChromeMetrics.Get("ButtonTextContrast"); + public Color ContrastColor = ChromeMetrics.Get("ButtonTextContrastColor"); public bool Disabled = false; public bool Highlighted = false; public Func GetText; + public Func GetColor; + public Func GetColorDisabled; + public Func GetContrastColor; public Func IsDisabled; public Func IsHighlighted; public Action OnMouseDown = _ => {}; @@ -48,6 +55,9 @@ namespace OpenRA.Widgets public ButtonWidget() { GetText = () => { return Text; }; + GetColor = () => TextColor; + GetColorDisabled = () => TextColorDisabled; + GetContrastColor = () => ContrastColor; OnMouseUp = _ => OnClick(); OnKeyPress = _ => OnClick(); IsDisabled = () => Disabled; @@ -61,9 +71,16 @@ namespace OpenRA.Widgets { Text = other.Text; Font = other.Font; + TextColor = other.TextColor; + TextColorDisabled = other.TextColorDisabled; + Contrast = other.Contrast; + ContrastColor = other.ContrastColor; Depressed = other.Depressed; VisualHeight = other.VisualHeight; GetText = other.GetText; + GetColor = other.GetColor; + GetColorDisabled = other.GetColorDisabled; + GetContrastColor = other.GetContrastColor; OnMouseDown = other.OnMouseDown; Disabled = other.Disabled; IsDisabled = other.IsDisabled; @@ -172,12 +189,19 @@ namespace OpenRA.Widgets var font = Game.Renderer.Fonts[Font]; var text = GetText(); + var color = GetColor(); + var colordisabled = GetColorDisabled(); + var contrast = GetContrastColor(); var s = font.Measure(text); var stateOffset = (Depressed) ? new int2(VisualHeight, VisualHeight) : new int2(0, 0); DrawBackground(rb, disabled, Depressed, Ui.MouseOverWidget == this, highlighted); - font.DrawText(text, new int2(rb.X + (UsableWidth - s.X)/ 2, rb.Y + (Bounds.Height - s.Y) / 2) + stateOffset, - disabled ? Color.Gray : Color.White); + if (Contrast) + font.DrawTextWithContrast(text, new int2(rb.X + (UsableWidth - s.X) / 2, rb.Y + (Bounds.Height - s.Y) / 2) + stateOffset, + disabled ? colordisabled : color, contrast, 2); + else + font.DrawText(text, new int2(rb.X + (UsableWidth - s.X)/ 2, rb.Y + (Bounds.Height - s.Y) / 2) + stateOffset, + disabled ? colordisabled : color); } public override Widget Clone() { return new ButtonWidget(this); } diff --git a/OpenRA.Game/Widgets/CheckboxWidget.cs b/OpenRA.Game/Widgets/CheckboxWidget.cs index f6bfd941b9..523dc05f97 100644 --- a/OpenRA.Game/Widgets/CheckboxWidget.cs +++ b/OpenRA.Game/Widgets/CheckboxWidget.cs @@ -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)) { diff --git a/OpenRA.Game/Widgets/DropDownButtonWidget.cs b/OpenRA.Game/Widgets/DropDownButtonWidget.cs index ca3ae8aba0..d3ccc37a6d 100644 --- a/OpenRA.Game/Widgets/DropDownButtonWidget.cs +++ b/OpenRA.Game/Widgets/DropDownButtonWidget.cs @@ -31,6 +31,8 @@ namespace OpenRA.Widgets var image = ChromeProvider.GetImage("scrollbar", IsDisabled() ? "down_pressed" : "down_arrow"); var rb = RenderBounds; + var color = GetColor(); + var colordisabled = GetColorDisabled(); WidgetUtils.DrawRGBA( image, stateOffset + new float2( rb.Right - rb.Height + 4, @@ -38,7 +40,7 @@ namespace OpenRA.Widgets WidgetUtils.FillRectWithColor(new Rectangle(stateOffset.X + rb.Right - rb.Height, stateOffset.Y + rb.Top + 3, 1, rb.Height - 6), - Color.White); + IsDisabled() ? colordisabled : color); } public override Widget Clone() { return new DropDownButtonWidget(this); } diff --git a/mods/cnc/metrics.yaml b/mods/cnc/metrics.yaml index 9cff61744d..2de15b4c20 100644 --- a/mods/cnc/metrics.yaml +++ b/mods/cnc/metrics.yaml @@ -3,6 +3,10 @@ Metrics: ButtonDepth: 0 ButtonFont: Bold + ButtonTextColor: 255,255,255 + ButtonTextColorDisabled: 128,128,128 + ButtonTextContrast: false + ButtonTextContrastColor: 0,0,0 CheckboxPressedState: true TextFont: Regular TextColor: 255,255,255 diff --git a/mods/d2k/metrics.yaml b/mods/d2k/metrics.yaml index 22430341c3..37a2ec020a 100644 --- a/mods/d2k/metrics.yaml +++ b/mods/d2k/metrics.yaml @@ -3,6 +3,10 @@ Metrics: ButtonDepth: 1 ButtonFont: Regular + ButtonTextColor: 255,255,255 + ButtonTextColorDisabled: 128,128,128 + ButtonTextContrast: false + ButtonTextContrastColor: 0,0,0 CheckboxPressedState: false TextFont: Regular TextColor: 255,255,255 diff --git a/mods/ra/metrics.yaml b/mods/ra/metrics.yaml index f9f698467d..b1318e9ccb 100644 --- a/mods/ra/metrics.yaml +++ b/mods/ra/metrics.yaml @@ -3,6 +3,10 @@ Metrics: ButtonDepth: 1 ButtonFont: Regular + ButtonTextColor: 255,255,255 + ButtonTextColorDisabled: 128,128,128 + ButtonTextContrast: true + ButtonTextContrastColor: 0,0,0 CheckboxPressedState: false TextFont: Regular TextColor: 255,255,255 diff --git a/mods/ts/metrics.yaml b/mods/ts/metrics.yaml index d016b5aab9..7de90760a5 100644 --- a/mods/ts/metrics.yaml +++ b/mods/ts/metrics.yaml @@ -3,6 +3,10 @@ Metrics: ButtonDepth: 1 ButtonFont: Regular + ButtonTextColor: 255,255,255 + ButtonTextColorDisabled: 128,128,128 + ButtonTextContrast: false + ButtonTextContrastColor: 0,0,0 CheckboxPressedState: false TextFont: Regular TextColor: 255,255,255