fixes #2866: added ButtonWidget.GetKey as delegate

This commit is contained in:
Sascha Biedermann
2013-03-28 10:03:41 +01:00
parent 37e0a189fb
commit 467002a88b
2 changed files with 10 additions and 4 deletions

View File

@@ -17,7 +17,13 @@ namespace OpenRA.Widgets
{ {
public class ButtonWidget : Widget 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 string Text = "";
public bool Depressed = false; public bool Depressed = false;
public int VisualHeight = ChromeMetrics.Get<int>("ButtonDepth"); 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"); var moneybin = gameRoot.Get("INGAME_MONEY_BIN");
moneybin.Get<OrderButtonWidget>("SELL").Key = Game.Settings.Keys.SellKey; moneybin.Get<OrderButtonWidget>("SELL").GetKey = _ => Game.Settings.Keys.SellKey;
moneybin.Get<OrderButtonWidget>("POWER_DOWN").Key = Game.Settings.Keys.PowerDownKey; moneybin.Get<OrderButtonWidget>("POWER_DOWN").GetKey = _ => Game.Settings.Keys.PowerDownKey;
moneybin.Get<OrderButtonWidget>("REPAIR").Key = Game.Settings.Keys.RepairKey; moneybin.Get<OrderButtonWidget>("REPAIR").GetKey = _ => Game.Settings.Keys.RepairKey;
optionsBG.Get<ButtonWidget>("DISCONNECT").OnClick = () => LeaveGame(optionsBG, world); optionsBG.Get<ButtonWidget>("DISCONNECT").OnClick = () => LeaveGame(optionsBG, world);