fixed broken build palette hotkeys

support modifiers for build palette hotkeys
This commit is contained in:
Matthias Mailänder
2013-11-09 11:32:21 +01:00
parent 6c11ae36c7
commit a6f06a5dfd
5 changed files with 9 additions and 4 deletions

View File

@@ -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:

View File

@@ -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;

View File

@@ -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 { }

View File

@@ -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<PlayerResources>();
@@ -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<BuildableInfo>().Hotkey == KeycodeExts.DisplayString(e.Key));
var toBuild = CurrentQueue.BuildableItems().FirstOrDefault(b => b.Traits.Get<BuildableInfo>().Hotkey == Hotkey.FromKeyInput(e));
if (toBuild != null)
{

View File

@@ -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;
}