diff --git a/CHANGELOG b/CHANGELOG index 6edcfcdd2f..341c716717 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -78,6 +78,7 @@ NEW: Added language translation support. Added game ID and version information to exception and sync reports. Map folders are now explicitly specified in mod.yaml. + Most UI widgets are now customizable in terms of font type, color, contrast and had their global defaults moved from code to metrics.yaml. Replaced the OS X binary launcher with a script to use a new SDL2 renderer. Improved cash tick sound playback. Added modifier support to hotkeys. @@ -94,6 +95,7 @@ NEW: Linux packages now install to /usr/lib/openra for consistency with other Mono applications. Mod / Custom map compatibility: Mods can now include traits from TD and D2K in RA. + Mods can now customize UI text settings like font type/color/contrast for most widgets and set global defaults in metrics.yaml. New sections MapFolders and Translations added to mod.yaml. Renamed CarpetBomb trait to AttackBomber, and additional functionality added. An Armament trait is now required to specify the weapons. Renamed Capture trait to ExternalCapture. diff --git a/OpenRA.Game/Widgets/ButtonWidget.cs b/OpenRA.Game/Widgets/ButtonWidget.cs index 4b3b6c7389..9b3016be55 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,20 @@ 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); + var position = new int2(rb.X + (UsableWidth - s.X) / 2, rb.Y + (Bounds.Height - s.Y) / 2); 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, position + stateOffset, + disabled ? colordisabled : color, contrast, 2); + else + font.DrawText(text, position + 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..a8c1fd41e5 100644 --- a/OpenRA.Game/Widgets/CheckboxWidget.cs +++ b/OpenRA.Game/Widgets/CheckboxWidget.cs @@ -43,7 +43,11 @@ 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 textSize = font.Measure(Text); var check = new Rectangle(rect.Location, new Size(Bounds.Height, Bounds.Height)); var state = disabled ? "checkbox-disabled" : Depressed && HasPressedState ? "checkbox-pressed" : @@ -51,11 +55,14 @@ namespace OpenRA.Widgets "checkbox"; WidgetUtils.DrawPanel(state, check); + var position = new float2(rect.Left + rect.Height * 1.5f, RenderOrigin.Y - BaseLine + (Bounds.Height - textSize.Y)/2); - 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, position, + disabled ? colordisabled : color, contrast, 2); + else + font.DrawText(Text, position, + 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/OpenRA.Game/Widgets/HotkeyEntryWidget.cs b/OpenRA.Game/Widgets/HotkeyEntryWidget.cs index 93ba40f735..5b3941a580 100644 --- a/OpenRA.Game/Widgets/HotkeyEntryWidget.cs +++ b/OpenRA.Game/Widgets/HotkeyEntryWidget.cs @@ -25,9 +25,9 @@ namespace OpenRA.Widgets public Action OnLoseFocus = () => { }; public Func IsDisabled = () => false; - public Color TextColor = Color.White; - public Color DisabledColor = Color.Gray; - public string Font = "Regular"; + public string Font = ChromeMetrics.Get("HotkeyFont"); + public Color TextColor = ChromeMetrics.Get("HotkeyColor"); + public Color TextColorDisabled = ChromeMetrics.Get("HotkeyColorDisabled"); public HotkeyEntryWidget() {} protected HotkeyEntryWidget(HotkeyEntryWidget widget) @@ -35,7 +35,7 @@ namespace OpenRA.Widgets { Font = widget.Font; TextColor = widget.TextColor; - DisabledColor = widget.DisabledColor; + TextColorDisabled = widget.TextColorDisabled; VisualHeight = widget.VisualHeight; } @@ -126,7 +126,7 @@ namespace OpenRA.Widgets Bounds.Width - LeftMargin - RightMargin, Bounds.Bottom)); } - var color = disabled ? DisabledColor : TextColor; + var color = disabled ? TextColorDisabled : TextColor; font.DrawText(apparentText, textPos, color); if (textSize.X > Bounds.Width - LeftMargin - RightMargin) diff --git a/OpenRA.Game/Widgets/LabelWidget.cs b/OpenRA.Game/Widgets/LabelWidget.cs index d4546a9890..5f454f14fe 100644 --- a/OpenRA.Game/Widgets/LabelWidget.cs +++ b/OpenRA.Game/Widgets/LabelWidget.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, @@ -23,10 +23,10 @@ namespace OpenRA.Widgets [Translate] public string Text = null; public TextAlign Align = TextAlign.Left; public TextVAlign VAlign = TextVAlign.Middle; - public string Font = "Regular"; - public Color Color = Color.White; - public bool Contrast = false; - public Color ContrastColor = Color.Black; + public string Font = ChromeMetrics.Get("TextFont"); + public Color TextColor = ChromeMetrics.Get("TextColor"); + public bool Contrast = ChromeMetrics.Get("TextContrast"); + public Color ContrastColor = ChromeMetrics.Get("TextContrastColor"); public bool WordWrap = false; public Func GetText; public Func GetColor; @@ -35,7 +35,7 @@ namespace OpenRA.Widgets public LabelWidget() { GetText = () => Text; - GetColor = () => Color; + GetColor = () => TextColor; GetContrastColor = () => ContrastColor; } @@ -45,7 +45,7 @@ namespace OpenRA.Widgets Text = other.Text; Align = other.Align; Font = other.Font; - Color = other.Color; + TextColor = other.TextColor; Contrast = other.Contrast; ContrastColor = other.ContrastColor; WordWrap = other.WordWrap; diff --git a/OpenRA.Game/Widgets/TextFieldWidget.cs b/OpenRA.Game/Widgets/TextFieldWidget.cs index de1125b588..bf9a3c50d5 100644 --- a/OpenRA.Game/Widgets/TextFieldWidget.cs +++ b/OpenRA.Game/Widgets/TextFieldWidget.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, @@ -34,9 +34,9 @@ namespace OpenRA.Widgets public int CursorPosition { get; set; } public Func IsDisabled = () => false; - public Color TextColor = Color.White; - public Color DisabledColor = Color.Gray; - public string Font = "Regular"; + public string Font = ChromeMetrics.Get("TextfieldFont"); + public Color TextColor = ChromeMetrics.Get("TextfieldColor"); + public Color TextColorDisabled = ChromeMetrics.Get("TextfieldColorDisabled"); public TextFieldWidget() {} protected TextFieldWidget(TextFieldWidget widget) @@ -46,7 +46,7 @@ namespace OpenRA.Widgets MaxLength = widget.MaxLength; Font = widget.Font; TextColor = widget.TextColor; - DisabledColor = widget.DisabledColor; + TextColorDisabled = widget.TextColorDisabled; VisualHeight = widget.VisualHeight; } @@ -215,11 +215,11 @@ namespace OpenRA.Widgets Bounds.Width - LeftMargin - RightMargin, Bounds.Bottom)); } - var color = disabled ? DisabledColor : TextColor; + var color = disabled ? TextColorDisabled : TextColor; font.DrawText(apparentText, textPos, color); if (showCursor && HasKeyboardFocus) - font.DrawText("|", new float2(textPos.X + cursorPosition.X - 2, textPos.Y), Color.White); + font.DrawText("|", new float2(textPos.X + cursorPosition.X - 2, textPos.Y), TextColor); if (textSize.X > Bounds.Width - LeftMargin - RightMargin) Game.Renderer.DisableScissor(); diff --git a/OpenRA.Game/Widgets/TimerWidget.cs b/OpenRA.Game/Widgets/TimerWidget.cs index e66bbc2611..9a63adf860 100644 --- a/OpenRA.Game/Widgets/TimerWidget.cs +++ b/OpenRA.Game/Widgets/TimerWidget.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, @@ -8,20 +8,28 @@ */ #endregion +using System; using System.Drawing; +using OpenRA.FileFormats; +using OpenRA.Graphics; namespace OpenRA.Widgets { - public class TimerWidget : Widget + public class TimerWidget : LabelWidget { public override void Draw() { - var font = Game.Renderer.Fonts["Title"]; + var font = Game.Renderer.Fonts[Font]; var rb = RenderBounds; + var color = GetColor(); + var contrast = GetContrastColor(); var s = WidgetUtils.FormatTime(Game.LocalTick) + (Game.orderManager.world.Paused?" (paused)":""); var pos = new float2(rb.Left - font.Measure(s).X / 2, rb.Top); - font.DrawTextWithContrast(s, pos, Color.White, Color.Black, 1); + if (Contrast) + font.DrawTextWithContrast(s, pos, color, contrast, 1); + else + font.DrawText(s, pos, color); } } } diff --git a/mods/cnc/chrome/ingame.yaml b/mods/cnc/chrome/ingame.yaml index 3533a7f621..fa94cd273f 100644 --- a/mods/cnc/chrome/ingame.yaml +++ b/mods/cnc/chrome/ingame.yaml @@ -4,6 +4,8 @@ Container@INGAME_ROOT: Timer@GAME_TIMER: X: WINDOW_RIGHT/2 Y: 0 + Font: Title + Contrast: true StrategicProgress@STRATEGIC_PROGRESS: X: WINDOW_RIGHT/2 Y: 40 diff --git a/mods/cnc/metrics.yaml b/mods/cnc/metrics.yaml index 80121ae959..dcbaf3bfa1 100644 --- a/mods/cnc/metrics.yaml +++ b/mods/cnc/metrics.yaml @@ -3,5 +3,19 @@ Metrics: ButtonDepth: 0 ButtonFont: Bold + ButtonTextColor: 255,255,255 + ButtonTextColorDisabled: 128,128,128 + ButtonTextContrast: false + ButtonTextContrastColor: 0,0,0 CheckboxPressedState: true + HotkeyFont: Regular + HotkeyColor: 255,255,255 + HotkeyColorDisabled: 128,128,128 + TextfieldFont: Regular + TextfieldColor: 255,255,255 + TextfieldColorDisabled: 128,128,128 + TextFont: Regular + TextColor: 255,255,255 + TextContrast: false + TextContrastColor: 0,0,0 ColorPickerRemapIndices: 176, 178, 180, 182, 184, 186, 189, 191, 177, 179, 181, 183, 185, 187, 188, 190 \ No newline at end of file diff --git a/mods/d2k/chrome/ingame.yaml b/mods/d2k/chrome/ingame.yaml index 3d1dd5e046..92876a52a9 100644 --- a/mods/d2k/chrome/ingame.yaml +++ b/mods/d2k/chrome/ingame.yaml @@ -20,6 +20,8 @@ Container@INGAME_ROOT: Timer@GAME_TIMER: X: WINDOW_RIGHT/2 Y: 0 + Font: Title + Contrast: true StrategicProgress@STRATEGIC_PROGRESS: X: WINDOW_RIGHT/2 Y: 40 diff --git a/mods/d2k/metrics.yaml b/mods/d2k/metrics.yaml index c88a8055d8..1f3a480376 100644 --- a/mods/d2k/metrics.yaml +++ b/mods/d2k/metrics.yaml @@ -3,5 +3,19 @@ Metrics: ButtonDepth: 1 ButtonFont: Regular + ButtonTextColor: 255,255,255 + ButtonTextColorDisabled: 128,128,128 + ButtonTextContrast: false + ButtonTextContrastColor: 0,0,0 CheckboxPressedState: false + HotkeyFont: Regular + HotkeyColor: 255,255,255 + HotkeyColorDisabled: 128,128,128 + TextfieldFont: Regular + TextfieldColor: 255,255,255 + TextfieldColorDisabled: 128,128,128 + TextFont: Regular + TextColor: 255,255,255 + TextContrast: false + TextContrastColor: 0,0,0 ColorPickerRemapIndices: 255, 254, 253, 252, 251, 250, 249, 248, 247, 246, 245, 244, 243, 242, 241, 240 diff --git a/mods/ra/chrome/ingame.yaml b/mods/ra/chrome/ingame.yaml index 21280cc850..233cb833ea 100644 --- a/mods/ra/chrome/ingame.yaml +++ b/mods/ra/chrome/ingame.yaml @@ -20,6 +20,8 @@ Container@INGAME_ROOT: Timer@GAME_TIMER: X: WINDOW_RIGHT/2 Y: 0-10 + Font: Title + Contrast: true StrategicProgress@STRATEGIC_PROGRESS: X: WINDOW_RIGHT/2 Y: 40 diff --git a/mods/ra/metrics.yaml b/mods/ra/metrics.yaml index e5ae5dd388..8917a2d756 100644 --- a/mods/ra/metrics.yaml +++ b/mods/ra/metrics.yaml @@ -3,5 +3,19 @@ Metrics: ButtonDepth: 1 ButtonFont: Regular + ButtonTextColor: 255,255,255 + ButtonTextColorDisabled: 128,128,128 + ButtonTextContrast: false + ButtonTextContrastColor: 0,0,0 CheckboxPressedState: false + HotkeyFont: Regular + HotkeyColor: 255,255,255 + HotkeyColorDisabled: 128,128,128 + TextfieldFont: Regular + TextfieldColor: 255,255,255 + TextfieldColorDisabled: 128,128,128 + TextFont: Regular + TextColor: 255,255,255 + TextContrast: false + TextContrastColor: 0,0,0 ColorPickerRemapIndices: 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95 diff --git a/mods/ts/metrics.yaml b/mods/ts/metrics.yaml index c9c34371f2..f0e66e52a0 100644 --- a/mods/ts/metrics.yaml +++ b/mods/ts/metrics.yaml @@ -3,5 +3,19 @@ Metrics: ButtonDepth: 1 ButtonFont: Regular + ButtonTextColor: 255,255,255 + ButtonTextColorDisabled: 128,128,128 + ButtonTextContrast: false + ButtonTextContrastColor: 0,0,0 CheckboxPressedState: false + HotkeyFont: Regular + HotkeyColor: 255,255,255 + HotkeyColorDisabled: 128,128,128 + TextfieldFont: Regular + TextfieldColor: 255,255,255 + TextfieldColorDisabled: 128,128,128 + TextFont: Regular + TextColor: 255,255,255 + TextContrast: false + TextContrastColor: 0,0,0 ColorPickerRemapIndices: 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31