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\Buildings\Reservable.cs" />
|
||||||
<Compile Include="Traits\Burns.cs" />
|
<Compile Include="Traits\Burns.cs" />
|
||||||
<Compile Include="Traits\ChangesTerrain.cs" />
|
<Compile Include="Traits\ChangesTerrain.cs" />
|
||||||
|
<Compile Include="Traits\CommandBarBlacklist.cs" />
|
||||||
<Compile Include="Traits\Health.cs" />
|
<Compile Include="Traits\Health.cs" />
|
||||||
<Compile Include="Traits\HitShape.cs" />
|
<Compile Include="Traits\HitShape.cs" />
|
||||||
<Compile Include="Traits\PowerTooltip.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 forceAttackDisabled = true;
|
||||||
bool guardDisabled = true;
|
bool guardDisabled = true;
|
||||||
bool scatterDisabled = true;
|
bool scatterDisabled = true;
|
||||||
|
bool stopDisabled = true;
|
||||||
|
bool waypointModeDisabled = true;
|
||||||
|
|
||||||
int deployHighlighted;
|
int deployHighlighted;
|
||||||
int scatterHighlighted;
|
int scatterHighlighted;
|
||||||
@@ -148,7 +150,7 @@ namespace OpenRA.Mods.Common.Widgets
|
|||||||
BindButtonIcon(stopButton);
|
BindButtonIcon(stopButton);
|
||||||
|
|
||||||
stopButton.GetKey = _ => ks.StopKey;
|
stopButton.GetKey = _ => ks.StopKey;
|
||||||
stopButton.IsDisabled = () => { UpdateStateIfNecessary(); return !selectedActors.Any(); };
|
stopButton.IsDisabled = () => { UpdateStateIfNecessary(); return stopDisabled; };
|
||||||
stopButton.IsHighlighted = () => stopHighlighted > 0;
|
stopButton.IsHighlighted = () => stopHighlighted > 0;
|
||||||
stopButton.OnClick = () => PerformKeyboardOrderOnSelection(a => new Order("Stop", a, false));
|
stopButton.OnClick = () => PerformKeyboardOrderOnSelection(a => new Order("Stop", a, false));
|
||||||
stopButton.OnKeyPress = ki => { stopHighlighted = 2; stopButton.OnClick(); };
|
stopButton.OnKeyPress = ki => { stopHighlighted = 2; stopButton.OnClick(); };
|
||||||
@@ -159,7 +161,7 @@ namespace OpenRA.Mods.Common.Widgets
|
|||||||
{
|
{
|
||||||
BindButtonIcon(queueOrdersButton);
|
BindButtonIcon(queueOrdersButton);
|
||||||
|
|
||||||
queueOrdersButton.IsDisabled = () => { UpdateStateIfNecessary(); return !selectedActors.Any(); };
|
queueOrdersButton.IsDisabled = () => { UpdateStateIfNecessary(); return waypointModeDisabled; };
|
||||||
queueOrdersButton.IsHighlighted = () => !queueOrdersButton.IsDisabled() && IsForceModifiersActive(Modifiers.Shift);
|
queueOrdersButton.IsHighlighted = () => !queueOrdersButton.IsDisabled() && IsForceModifiersActive(Modifiers.Shift);
|
||||||
queueOrdersButton.OnClick = () =>
|
queueOrdersButton.OnClick = () =>
|
||||||
{
|
{
|
||||||
@@ -224,6 +226,10 @@ namespace OpenRA.Mods.Common.Widgets
|
|||||||
.Select(d => new TraitPair<IIssueDeployOrder>(a, d)))
|
.Select(d => new TraitPair<IIssueDeployOrder>(a, d)))
|
||||||
.ToArray();
|
.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;
|
selectionHash = world.Selection.Hash;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -669,6 +669,7 @@
|
|||||||
Demolishable:
|
Demolishable:
|
||||||
EditorTilesetFilter:
|
EditorTilesetFilter:
|
||||||
Categories: Building
|
Categories: Building
|
||||||
|
CommandBarBlacklist:
|
||||||
|
|
||||||
^BaseBuilding:
|
^BaseBuilding:
|
||||||
Inherits: ^Building
|
Inherits: ^Building
|
||||||
@@ -1000,6 +1001,7 @@
|
|||||||
TargetTypes: Ground, C4, Structure, Defense
|
TargetTypes: Ground, C4, Structure, Defense
|
||||||
EditorTilesetFilter:
|
EditorTilesetFilter:
|
||||||
Categories: Defense
|
Categories: Defense
|
||||||
|
-CommandBarBlacklist:
|
||||||
|
|
||||||
^DisabledOverlay:
|
^DisabledOverlay:
|
||||||
WithColoredOverlay@IDISABLE:
|
WithColoredOverlay@IDISABLE:
|
||||||
|
|||||||
@@ -424,6 +424,7 @@
|
|||||||
Radius: 4c768
|
Radius: 4c768
|
||||||
EditorTilesetFilter:
|
EditorTilesetFilter:
|
||||||
Categories: Building
|
Categories: Building
|
||||||
|
CommandBarBlacklist:
|
||||||
|
|
||||||
^Defense:
|
^Defense:
|
||||||
Inherits: ^Building
|
Inherits: ^Building
|
||||||
@@ -450,6 +451,7 @@
|
|||||||
TargetTypes: Ground, C4, Structure, Defense
|
TargetTypes: Ground, C4, Structure, Defense
|
||||||
EditorTilesetFilter:
|
EditorTilesetFilter:
|
||||||
Categories: Defense
|
Categories: Defense
|
||||||
|
-CommandBarBlacklist:
|
||||||
|
|
||||||
^DisabledOverlay:
|
^DisabledOverlay:
|
||||||
WithColoredOverlay@IDISABLE:
|
WithColoredOverlay@IDISABLE:
|
||||||
|
|||||||
@@ -592,6 +592,7 @@
|
|||||||
Demolishable:
|
Demolishable:
|
||||||
EditorTilesetFilter:
|
EditorTilesetFilter:
|
||||||
Categories: Building
|
Categories: Building
|
||||||
|
CommandBarBlacklist:
|
||||||
|
|
||||||
^Building:
|
^Building:
|
||||||
Inherits: ^BasicBuilding
|
Inherits: ^BasicBuilding
|
||||||
@@ -634,6 +635,7 @@
|
|||||||
EmptyWeapon: SmallBuildingExplode
|
EmptyWeapon: SmallBuildingExplode
|
||||||
EditorTilesetFilter:
|
EditorTilesetFilter:
|
||||||
Categories: Defense
|
Categories: Defense
|
||||||
|
-CommandBarBlacklist:
|
||||||
|
|
||||||
^Wall:
|
^Wall:
|
||||||
Inherits@1: ^ExistsInWorld
|
Inherits@1: ^ExistsInWorld
|
||||||
|
|||||||
Reference in New Issue
Block a user