Merge pull request #2873 from bidifx/hotkeys

fixes #2866: allow Button.Key to be a delegate
This commit is contained in:
Chris Forbes
2013-03-28 02:17:45 -07:00
2 changed files with 10 additions and 4 deletions

View File

@@ -17,7 +17,13 @@ namespace OpenRA.Widgets
{
public class ButtonWidget : Widget
{
public string Key = null;
public Func<ButtonWidget, string> GetKey = _ => null;
public string Key
{
get { return GetKey(this); }
set { GetKey = _ => value; }
}
public string Text = "";
public bool Depressed = false;
public int VisualHeight = ChromeMetrics.Get<int>("ButtonDepth");

View File

@@ -54,9 +54,9 @@ namespace OpenRA.Mods.RA.Widgets.Logic
}
var moneybin = gameRoot.Get("INGAME_MONEY_BIN");
moneybin.Get<OrderButtonWidget>("SELL").Key = Game.Settings.Keys.SellKey;
moneybin.Get<OrderButtonWidget>("POWER_DOWN").Key = Game.Settings.Keys.PowerDownKey;
moneybin.Get<OrderButtonWidget>("REPAIR").Key = Game.Settings.Keys.RepairKey;
moneybin.Get<OrderButtonWidget>("SELL").GetKey = _ => Game.Settings.Keys.SellKey;
moneybin.Get<OrderButtonWidget>("POWER_DOWN").GetKey = _ => Game.Settings.Keys.PowerDownKey;
moneybin.Get<OrderButtonWidget>("REPAIR").GetKey = _ => Game.Settings.Keys.RepairKey;
optionsBG.Get<ButtonWidget>("DISCONNECT").OnClick = () => LeaveGame(optionsBG, world);