Add a CommandBarBlacklist trait to blacklist Stop and Waypoint Mode
This commit is contained in:
@@ -291,6 +291,7 @@
|
||||
<Compile Include="Traits\Buildings\Reservable.cs" />
|
||||
<Compile Include="Traits\Burns.cs" />
|
||||
<Compile Include="Traits\ChangesTerrain.cs" />
|
||||
<Compile Include="Traits\CommandBarBlacklist.cs" />
|
||||
<Compile Include="Traits\Health.cs" />
|
||||
<Compile Include="Traits\HitShape.cs" />
|
||||
<Compile Include="Traits\PowerTooltip.cs" />
|
||||
|
||||
27
OpenRA.Mods.Common/Traits/CommandBarBlacklist.cs
Normal file
27
OpenRA.Mods.Common/Traits/CommandBarBlacklist.cs
Normal file
@@ -0,0 +1,27 @@
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright 2007-2017 The OpenRA Developers (see AUTHORS)
|
||||
* This file is part of OpenRA, which is free software. It is made
|
||||
* available to you under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation, either version 3 of
|
||||
* the License, or (at your option) any later version. For more
|
||||
* information, see COPYING.
|
||||
*/
|
||||
#endregion
|
||||
|
||||
using OpenRA.Traits;
|
||||
|
||||
namespace OpenRA.Mods.Common.Traits
|
||||
{
|
||||
[Desc("Blacklist certain order types to disable on the command bar when this unit is selected.")]
|
||||
public class CommandBarBlacklistInfo : TraitInfo<CommandBarBlacklist>
|
||||
{
|
||||
[Desc("Disable the 'Stop' button for this actor.")]
|
||||
public readonly bool DisableStop = true;
|
||||
|
||||
[Desc("Disable the 'Waypoint Mode' button for this actor.")]
|
||||
public readonly bool DisableWaypointMode = true;
|
||||
}
|
||||
|
||||
public class CommandBarBlacklist { }
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -669,6 +669,7 @@
|
||||
Demolishable:
|
||||
EditorTilesetFilter:
|
||||
Categories: Building
|
||||
CommandBarBlacklist:
|
||||
|
||||
^BaseBuilding:
|
||||
Inherits: ^Building
|
||||
@@ -1000,6 +1001,7 @@
|
||||
TargetTypes: Ground, C4, Structure, Defense
|
||||
EditorTilesetFilter:
|
||||
Categories: Defense
|
||||
-CommandBarBlacklist:
|
||||
|
||||
^DisabledOverlay:
|
||||
WithColoredOverlay@IDISABLE:
|
||||
|
||||
@@ -424,6 +424,7 @@
|
||||
Radius: 4c768
|
||||
EditorTilesetFilter:
|
||||
Categories: Building
|
||||
CommandBarBlacklist:
|
||||
|
||||
^Defense:
|
||||
Inherits: ^Building
|
||||
@@ -450,6 +451,7 @@
|
||||
TargetTypes: Ground, C4, Structure, Defense
|
||||
EditorTilesetFilter:
|
||||
Categories: Defense
|
||||
-CommandBarBlacklist:
|
||||
|
||||
^DisabledOverlay:
|
||||
WithColoredOverlay@IDISABLE:
|
||||
|
||||
@@ -592,6 +592,7 @@
|
||||
Demolishable:
|
||||
EditorTilesetFilter:
|
||||
Categories: Building
|
||||
CommandBarBlacklist:
|
||||
|
||||
^Building:
|
||||
Inherits: ^BasicBuilding
|
||||
@@ -634,6 +635,7 @@
|
||||
EmptyWeapon: SmallBuildingExplode
|
||||
EditorTilesetFilter:
|
||||
Categories: Defense
|
||||
-CommandBarBlacklist:
|
||||
|
||||
^Wall:
|
||||
Inherits@1: ^ExistsInWorld
|
||||
|
||||
Reference in New Issue
Block a user