From a6f06a5dfd1193740c971c150c9418cbabe31e3c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20Mail=C3=A4nder?= Date: Sat, 9 Nov 2013 11:32:21 +0100 Subject: [PATCH] fixed broken build palette hotkeys support modifiers for build palette hotkeys --- CHANGELOG | 1 + OpenRA.FileFormats/Hotkey.cs | 4 ++++ OpenRA.Mods.RA/Buildable.cs | 2 +- OpenRA.Mods.RA/Widgets/BuildPaletteWidget.cs | 4 ++-- OpenRA.Mods.RA/Widgets/OrderButtonWidget.cs | 2 +- 5 files changed, 9 insertions(+), 4 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index d2b496a4ea..020c5ad84b 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -98,6 +98,7 @@ NEW: Added new traits to world: ScreenMap, ActorMap. Removed traits from World: SpatialBins. Added InvalidTargets property to weapons. + Added modifier support for build palette hotkeys. 20130915: All mods: diff --git a/OpenRA.FileFormats/Hotkey.cs b/OpenRA.FileFormats/Hotkey.cs index da14dab10f..d185032baf 100755 --- a/OpenRA.FileFormats/Hotkey.cs +++ b/OpenRA.FileFormats/Hotkey.cs @@ -18,6 +18,10 @@ namespace OpenRA public struct Hotkey { public static Hotkey Invalid = new Hotkey(Keycode.UNKNOWN, Modifiers.None); + public bool IsValid() + { + return Key != Keycode.UNKNOWN; + } public readonly Keycode Key; public readonly Modifiers Modifiers; diff --git a/OpenRA.Mods.RA/Buildable.cs b/OpenRA.Mods.RA/Buildable.cs index ff3e2a5a74..f02476f896 100755 --- a/OpenRA.Mods.RA/Buildable.cs +++ b/OpenRA.Mods.RA/Buildable.cs @@ -23,7 +23,7 @@ namespace OpenRA.Mods.RA // TODO: UI fluff; doesn't belong here public readonly int BuildPaletteOrder = 9999; - public readonly string Hotkey = null; + public readonly Hotkey Hotkey = Hotkey.Invalid; } public class Buildable { } diff --git a/OpenRA.Mods.RA/Widgets/BuildPaletteWidget.cs b/OpenRA.Mods.RA/Widgets/BuildPaletteWidget.cs index 2f658a89b0..1d9b018707 100755 --- a/OpenRA.Mods.RA/Widgets/BuildPaletteWidget.cs +++ b/OpenRA.Mods.RA/Widgets/BuildPaletteWidget.cs @@ -461,7 +461,7 @@ namespace OpenRA.Mods.RA.Widgets WidgetUtils.DrawPanel("dialog4", new Rectangle(Game.Renderer.Resolution.Width - 300, pos.Y, 300, longDescSize + 65)); Game.Renderer.Fonts["Bold"].DrawText( - tooltip.Name + ((buildable.Hotkey != null) ? " ({0})".F(buildable.Hotkey.ToUpper()) : ""), + tooltip.Name + (buildable.Hotkey.IsValid() ? " ({0})".F(buildable.Hotkey.DisplayString()) : ""), p.ToInt2() + new int2(5, 5), Color.White); var resources = pl.PlayerActor.Trait(); @@ -502,7 +502,7 @@ namespace OpenRA.Mods.RA.Widgets if (!paletteOpen) return false; if (CurrentQueue == null) return false; - var toBuild = CurrentQueue.BuildableItems().FirstOrDefault(b => b.Traits.Get().Hotkey == KeycodeExts.DisplayString(e.Key)); + var toBuild = CurrentQueue.BuildableItems().FirstOrDefault(b => b.Traits.Get().Hotkey == Hotkey.FromKeyInput(e)); if (toBuild != null) { diff --git a/OpenRA.Mods.RA/Widgets/OrderButtonWidget.cs b/OpenRA.Mods.RA/Widgets/OrderButtonWidget.cs index 386681042d..5d6f7d0cd5 100755 --- a/OpenRA.Mods.RA/Widgets/OrderButtonWidget.cs +++ b/OpenRA.Mods.RA/Widgets/OrderButtonWidget.cs @@ -27,7 +27,7 @@ namespace OpenRA.Mods.RA.Widgets public OrderButtonWidget() { GetImage = () => Enabled() ? Pressed() ? "pressed" : "normal" : "disabled"; - GetDescription = () => Key != Hotkey.Invalid ? "{0} ({1})".F(Description, Key.DisplayString()) : Description; + GetDescription = () => Key.IsValid() ? "{0} ({1})".F(Description, Key.DisplayString()) : Description; GetLongDesc = () => LongDesc; }