Unify all mods on the C&C order button logic.

This commit is contained in:
Paul Chote
2014-03-21 19:10:46 +13:00
parent 255bfc70d1
commit 0bc3a68e9f
15 changed files with 148 additions and 217 deletions

View File

@@ -24,17 +24,6 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic
Widget ingameRoot;
World world;
static void BindOrderButton<T>(World world, Widget parent, string button, string icon)
where T : IOrderGenerator, new()
{
var w = parent.Get<ButtonWidget>(button);
w.OnClick = () => world.ToggleInputMode<T>();
w.IsHighlighted = () => world.OrderGenerator is T;
w.Get<ImageWidget>("ICON").GetImageName =
() => world.OrderGenerator is T ? icon + "-active" : icon;
}
[ObjectCreator.UseCtor]
public CncIngameChromeLogic(Widget widget, World world)
{
@@ -87,13 +76,6 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic
playerWidgets.IsVisible = () => true;
var sidebarRoot = playerWidgets.Get("SIDEBAR_BACKGROUND");
BindOrderButton<SellOrderGenerator>(world, sidebarRoot, "SELL_BUTTON", "sell");
BindOrderButton<RepairOrderGenerator>(world, sidebarRoot, "REPAIR_BUTTON", "repair");
sidebarRoot.Get<ButtonWidget>("SELL_BUTTON").Key = Game.Settings.Keys.SellKey;
sidebarRoot.Get<ButtonWidget>("REPAIR_BUTTON").Key = Game.Settings.Keys.RepairKey;
var powerManager = world.LocalPlayer.PlayerActor.Trait<PowerManager>();
var playerResources = world.LocalPlayer.PlayerActor.Trait<PlayerResources>();
sidebarRoot.Get<LabelWidget>("CASH").GetText = () =>