Add a CommandBarBlacklist trait to blacklist Stop and Waypoint Mode

This commit is contained in:
abcdefg30
2017-07-05 14:10:09 +02:00
committed by Paul Chote
parent f921a45747
commit 0b6b997e81
6 changed files with 42 additions and 2 deletions

View File

@@ -33,6 +33,8 @@ namespace OpenRA.Mods.Common.Widgets
bool forceAttackDisabled = true;
bool guardDisabled = true;
bool scatterDisabled = true;
bool stopDisabled = true;
bool waypointModeDisabled = true;
int deployHighlighted;
int scatterHighlighted;
@@ -148,7 +150,7 @@ namespace OpenRA.Mods.Common.Widgets
BindButtonIcon(stopButton);
stopButton.GetKey = _ => ks.StopKey;
stopButton.IsDisabled = () => { UpdateStateIfNecessary(); return !selectedActors.Any(); };
stopButton.IsDisabled = () => { UpdateStateIfNecessary(); return stopDisabled; };
stopButton.IsHighlighted = () => stopHighlighted > 0;
stopButton.OnClick = () => PerformKeyboardOrderOnSelection(a => new Order("Stop", a, false));
stopButton.OnKeyPress = ki => { stopHighlighted = 2; stopButton.OnClick(); };
@@ -159,7 +161,7 @@ namespace OpenRA.Mods.Common.Widgets
{
BindButtonIcon(queueOrdersButton);
queueOrdersButton.IsDisabled = () => { UpdateStateIfNecessary(); return !selectedActors.Any(); };
queueOrdersButton.IsDisabled = () => { UpdateStateIfNecessary(); return waypointModeDisabled; };
queueOrdersButton.IsHighlighted = () => !queueOrdersButton.IsDisabled() && IsForceModifiersActive(Modifiers.Shift);
queueOrdersButton.OnClick = () =>
{
@@ -224,6 +226,10 @@ namespace OpenRA.Mods.Common.Widgets
.Select(d => new TraitPair<IIssueDeployOrder>(a, d)))
.ToArray();
var cbbInfos = selectedActors.Select(a => a.Info.TraitInfoOrDefault<CommandBarBlacklistInfo>()).ToArray();
stopDisabled = !cbbInfos.Any(i => i == null || !i.DisableStop);
waypointModeDisabled = !cbbInfos.Any(i => i == null || !i.DisableWaypointMode);
selectionHash = world.Selection.Hash;
}