Add a lint check for cursor definitions.

This commit is contained in:
Matthias Mailänder
2021-03-14 16:01:33 +01:00
committed by reaperrr
parent cefb2e7cc6
commit bbbed49f82
40 changed files with 211 additions and 28 deletions

View File

@@ -160,9 +160,11 @@ namespace OpenRA.Mods.Common.Traits
[Desc("Boolean expression defining the condition under which the regular (non-force) move cursor is disabled.")]
public readonly BooleanExpression RequireForceMoveCondition = null;
[CursorReference]
[Desc("Cursor to display when able to land at target building.")]
public readonly string EnterCursor = "enter";
[CursorReference]
[Desc("Cursor to display when unable to land at target building.")]
public readonly string EnterBlockedCursor = "enter-blocked";

View File

@@ -74,10 +74,12 @@ namespace OpenRA.Mods.Common.Traits
// TODO: instead of having multiple Armaments and unique AttackBase,
// an actor should be able to have multiple AttackBases with
// a single corresponding Armament each
[CursorReference]
[Desc("Cursor to display when hovering over a valid target.")]
public readonly string Cursor = "attack";
// TODO: same as above
[CursorReference]
[Desc("Cursor to display when hovering over a valid target that is outside of range.")]
public readonly string OutsideRangeCursor = "attackoutsiderange";

View File

@@ -27,9 +27,11 @@ namespace OpenRA.Mods.Common.Traits
[Desc("Armament names")]
public readonly string[] Armaments = { "primary", "secondary" };
[CursorReference]
[Desc("Cursor to display when hovering over a valid target.")]
public readonly string Cursor = null;
[CursorReference]
[Desc("Cursor to display when hovering over a valid target that is outside of range.")]
public readonly string OutsideRangeCursor = null;

View File

@@ -38,6 +38,18 @@ namespace OpenRA.Mods.Common.Traits
[Desc("Can the actor be ordered to move in to shroud?")]
public readonly bool MoveIntoShroud = true;
[CursorReference]
public readonly string AttackMoveCursor = "attackmove";
[CursorReference]
public readonly string AttackMoveBlockedCursor = "attackmove-blocked";
[CursorReference]
public readonly string AssaultMoveCursor = "assaultmove";
[CursorReference]
public readonly string AssaultMoveBlockedCursor = "assaultmove-blocked";
public override object Create(ActorInitializer init) { return new AttackMove(init.Self, this); }
}
@@ -137,16 +149,31 @@ namespace OpenRA.Mods.Common.Traits
public override string GetCursor(World world, CPos cell, int2 worldPixel, MouseInput mi)
{
var prefix = mi.Modifiers.HasModifier(Modifiers.Ctrl) ? "assaultmove" : "attackmove";
var isAssaultMove = mi.Modifiers.HasModifier(Modifiers.Ctrl);
if (world.Map.Contains(cell) && subjects.Any())
var subject = subjects.FirstOrDefault();
if (subject.Actor != null)
{
var explored = subjects.First().Actor.Owner.Shroud.IsExplored(cell);
var blocked = !explored && subjects.Any(a => !a.Trait.Info.MoveIntoShroud);
return blocked ? prefix + "-blocked" : prefix;
var info = subject.Trait.Info;
if (world.Map.Contains(cell))
{
var explored = subject.Actor.Owner.Shroud.IsExplored(cell);
var cannotMove = subjects.FirstOrDefault(a => !a.Trait.Info.MoveIntoShroud).Trait;
var blocked = !explored && cannotMove != null;
if (isAssaultMove)
return blocked ? cannotMove.Info.AssaultMoveBlockedCursor : info.AssaultMoveCursor;
return blocked ? cannotMove.Info.AttackMoveBlockedCursor : info.AttackMoveCursor;
}
if (isAssaultMove)
return info.AssaultMoveBlockedCursor;
else
return info.AttackMoveBlockedCursor;
}
return prefix + "-blocked";
return null;
}
public override bool InputOverridesSelection(World world, int2 xy, MouseInput mi)

View File

@@ -40,7 +40,11 @@ namespace OpenRA.Mods.Common.Traits
"If empty, the list given in the `Produces` property of the `Production` trait will be used.")]
public readonly string[] ProductionQueues = { };
public override object Create(ActorInitializer init) { return new PrimaryBuilding(init.Self, this); }
[CursorReference]
[Desc("Cursor to display when setting the primary building.")]
public readonly string Cursor = "deploy";
public override object Create(ActorInitializer init) { return new PrimaryBuilding(this); }
}
public class PrimaryBuilding : ConditionalTrait<PrimaryBuildingInfo>, IIssueOrder, IResolveOrder
@@ -51,7 +55,7 @@ namespace OpenRA.Mods.Common.Traits
public bool IsPrimary { get; private set; }
public PrimaryBuilding(Actor self, PrimaryBuildingInfo info)
public PrimaryBuilding(PrimaryBuildingInfo info)
: base(info) { }
IEnumerable<IOrderTargeter> IIssueOrder.Orders
@@ -61,7 +65,7 @@ namespace OpenRA.Mods.Common.Traits
if (IsTraitDisabled)
yield break;
yield return new DeployOrderTargeter(OrderID, 1);
yield return new DeployOrderTargeter(OrderID, 1, () => Info.Cursor);
}
}

View File

@@ -30,6 +30,7 @@ namespace OpenRA.Mods.Common.Traits
[SequenceReference(nameof(Image), allowNullImage: true)]
public readonly string CirclesSequence = "circles";
[CursorReference]
[Desc("Cursor to display when rally point can be set.")]
public readonly string Cursor = "ability";

View File

@@ -34,9 +34,11 @@ namespace OpenRA.Mods.Common.Traits
[Desc("Require the force-move modifier to display the move cursor.")]
public readonly bool RequiresForceMove = false;
[CursorReference]
[Desc("Cursor to display when able to land at target building.")]
public readonly string EnterCursor = "enter";
[CursorReference]
[Desc("Cursor to display when unable to land at target building.")]
public readonly string EnterBlockedCursor = "enter-blocked";

View File

@@ -20,9 +20,11 @@ namespace OpenRA.Mods.Common.Traits
[Desc("Add to a building to expose a move cursor that triggers Transforms and issues an enter tunnel order to the transformed actor.")]
public class TransformsIntoEntersTunnelsInfo : ConditionalTraitInfo, Requires<TransformsInfo>
{
[CursorReference]
[Desc("Cursor to display when able to enter target tunnel.")]
public readonly string EnterCursor = "enter";
[CursorReference]
[Desc("Cursor to display when unable to enter target tunnel.")]
public readonly string EnterBlockedCursor = "enter-blocked";

View File

@@ -25,9 +25,11 @@ namespace OpenRA.Mods.Common.Traits
[Desc("Locomotor used by the transformed actor. Must be defined on the World actor.")]
public readonly string Locomotor = null;
[CursorReference]
[Desc("Cursor to display when a move order can be issued at target location.")]
public readonly string Cursor = "move";
[CursorReference]
[Desc("Cursor to display when a move order cannot be issued at target location.")]
public readonly string BlockedCursor = "move-blocked";

View File

@@ -33,9 +33,11 @@ namespace OpenRA.Mods.Common.Traits
[Desc("Require the force-move modifier to display the enter cursor.")]
public readonly bool RequiresForceMove = false;
[CursorReference]
[Desc("Cursor to display when able to enter target actor.")]
public readonly string EnterCursor = "enter";
[CursorReference]
[Desc("Cursor to display when unable to enter target actor.")]
public readonly string EnterBlockedCursor = "enter-blocked";

View File

@@ -34,9 +34,11 @@ namespace OpenRA.Mods.Common.Traits
[Desc("Require the force-move modifier to display the enter cursor.")]
public readonly bool RequiresForceMove = false;
[CursorReference]
[Desc("Cursor to display when able to be repaired at target actor.")]
public readonly string EnterCursor = "enter";
[CursorReference]
[Desc("Cursor to display when unable to be repaired at target actor.")]
public readonly string EnterBlockedCursor = "enter-blocked";

View File

@@ -46,12 +46,15 @@ namespace OpenRA.Mods.Common.Traits
[Desc("Relationships that the structure's previous owner needs to have for the capturing player to receive Experience.")]
public readonly PlayerRelationship PlayerExperienceRelationships = PlayerRelationship.Enemy;
[CursorReference]
[Desc("Cursor to display when the health of the target actor is above the sabotage threshold.")]
public readonly string SabotageCursor = "capture";
[CursorReference]
[Desc("Cursor to display when able to capture the target actor.")]
public readonly string EnterCursor = "enter";
[CursorReference]
[Desc("Cursor to display when unable to capture the target actor.")]
public readonly string EnterBlockedCursor = "enter-blocked";

View File

@@ -60,9 +60,11 @@ namespace OpenRA.Mods.Common.Traits
[Desc("Delay (in ticks) before continuing after unloading a passenger.")]
public readonly int AfterUnloadDelay = 25;
[CursorReference]
[Desc("Cursor to display when able to unload the passengers.")]
public readonly string UnloadCursor = "deploy";
[CursorReference]
[Desc("Cursor to display when unable to unload the passengers.")]
public readonly string UnloadBlockedCursor = "deploy-blocked";

View File

@@ -39,21 +39,26 @@ namespace OpenRA.Mods.Common.Traits
[Desc("Radius around the target drop location that are considered if the target tile is blocked.")]
public readonly WDist DropRange = WDist.FromCells(5);
[CursorReference]
[Desc("Cursor to display when able to unload the passengers.")]
public readonly string UnloadCursor = "deploy";
[CursorReference]
[Desc("Cursor to display when unable to unload the passengers.")]
public readonly string UnloadBlockedCursor = "deploy-blocked";
[Desc("Allow moving and unloading with one order using force-move")]
public readonly bool AllowDropOff = false;
[CursorReference]
[Desc("Cursor to display when able to drop off the passengers at location.")]
public readonly string DropOffCursor = "ability";
[CursorReference]
[Desc("Cursor to display when unable to drop off the passengers at location.")]
public readonly string DropOffBlockedCursor = "move-blocked";
[CursorReference]
[Desc("Cursor to display when picking up the passengers.")]
public readonly string PickUpCursor = "ability";

View File

@@ -37,9 +37,11 @@ namespace OpenRA.Mods.Common.Traits
[Desc("Can this actor deploy on slopes?")]
public readonly bool CanDeployOnRamps = false;
[CursorReference]
[Desc("Cursor to display when able to (un)deploy the actor.")]
public readonly string DeployCursor = "deploy";
[CursorReference]
[Desc("Cursor to display when unable to (un)deploy the actor.")]
public readonly string DeployBlockedCursor = "deploy-blocked";

View File

@@ -32,6 +32,7 @@ namespace OpenRA.Mods.Common.Traits
[Desc("Sound to play when delivering cash")]
public readonly string[] Sounds = { };
[CursorReference]
[Desc("Cursor to display when hovering over a valid actor to deliver cash to.")]
public readonly string Cursor = "enter";

View File

@@ -26,6 +26,7 @@ namespace OpenRA.Mods.Common.Traits
[Desc("Identifier checked against AcceptsDeliveredExperience.ValidTypes. Only needed if the latter is not empty.")]
public readonly string Type = null;
[CursorReference]
[Desc("Cursor to display when hovering over a valid actor to deliver experience to.")]
public readonly string Cursor = "enter";

View File

@@ -50,6 +50,7 @@ namespace OpenRA.Mods.Common.Traits
public readonly PlayerRelationship TargetRelationships = PlayerRelationship.Enemy | PlayerRelationship.Neutral;
public readonly PlayerRelationship ForceTargetRelationships = PlayerRelationship.Enemy | PlayerRelationship.Neutral | PlayerRelationship.Ally;
[CursorReference]
[Desc("Cursor to display when hovering over a demolishable target.")]
public readonly string Cursor = "c4";

View File

@@ -39,9 +39,11 @@ namespace OpenRA.Mods.Common.Traits
[Desc("Sound to play when repairing is done.")]
public readonly string RepairSound = null;
[CursorReference]
[Desc("Cursor to display when hovering over a valid actor to repair.")]
public readonly string Cursor = "goldwrench";
[CursorReference]
[Desc("Cursor to display when target actor has full health so it can't be repaired.")]
public readonly string RepairBlockedCursor = "goldwrench-blocked";

View File

@@ -22,9 +22,11 @@ namespace OpenRA.Mods.Common.Traits
[Desc("This actor can interact with TunnelEntrances to move through TerrainTunnels.")]
public class EntersTunnelsInfo : TraitInfo, Requires<IMoveInfo>, IObservesVariablesInfo
{
[CursorReference]
[Desc("Cursor to display when able to enter target tunnel.")]
public readonly string EnterCursor = "enter";
[CursorReference]
[Desc("Cursor to display when unable to enter target tunnel.")]
public readonly string EnterBlockedCursor = "enter-blocked";

View File

@@ -90,9 +90,11 @@ namespace OpenRA.Mods.Common.Traits
[Desc("Color to use for the target line of harvest orders.")]
public readonly Color DeliverLineColor = Color.Green;
[CursorReference]
[Desc("Cursor to display when able to unload at target actor.")]
public readonly string EnterCursor = "enter";
[CursorReference]
[Desc("Cursor to display when unable to unload at target actor.")]
public readonly string EnterBlockedCursor = "enter-blocked";

View File

@@ -40,9 +40,11 @@ namespace OpenRA.Mods.Common.Traits
[Desc("If set to true, this unit will always turn in place instead of following a curved trajectory (like infantry).")]
public readonly bool AlwaysTurnInPlace = false;
[CursorReference]
[Desc("Cursor to display when a move order can be issued at target location.")]
public readonly string Cursor = "move";
[CursorReference]
[Desc("Cursor to display when a move order cannot be issued at target location.")]
public readonly string BlockedCursor = "move-blocked";

View File

@@ -50,9 +50,11 @@ namespace OpenRA.Mods.Common.Traits
[Desc("Boolean expression defining the condition under which the regular (non-force) enter cursor is disabled.")]
public readonly BooleanExpression RequireForceMoveCondition = null;
[CursorReference]
[Desc("Cursor to display when able to enter target actor.")]
public readonly string EnterCursor = "enter";
[CursorReference]
[Desc("Cursor to display when unable to enter target actor.")]
public readonly string EnterBlockedCursor = "enter-blocked";

View File

@@ -35,9 +35,11 @@ namespace OpenRA.Mods.Common.Traits
[Desc("Boolean expression defining the condition under which the regular (non-force) enter cursor is disabled.")]
public readonly BooleanExpression RequireForceMoveCondition = null;
[CursorReference]
[Desc("Cursor to display when able to be repaired at target actor.")]
public readonly string EnterCursor = "enter";
[CursorReference]
[Desc("Cursor to display when unable to be repaired at target actor.")]
public readonly string EnterBlockedCursor = "enter-blocked";

View File

@@ -33,9 +33,11 @@ namespace OpenRA.Mods.Common.Traits
[Desc("Boolean expression defining the condition under which the regular (non-force) enter cursor is disabled.")]
public readonly BooleanExpression RequireForceMoveCondition = null;
[CursorReference]
[Desc("Cursor to display when able to be repaired near target actor.")]
public readonly string EnterCursor = "enter";
[CursorReference]
[Desc("Cursor to display when unable to be repaired near target actor.")]
public readonly string EnterBlockedCursor = "enter-blocked";

View File

@@ -30,9 +30,11 @@ namespace OpenRA.Mods.Common.Traits
"Possible values are Exit, Suicide, Dispose.")]
public readonly EnterBehaviour EnterBehaviour = EnterBehaviour.Dispose;
[CursorReference]
[Desc("Cursor to display when targeting an unrepaired bridge.")]
public readonly string TargetCursor = "goldwrench";
[CursorReference]
[Desc("Cursor to display when repairing is denied.")]
public readonly string TargetBlockedCursor = "goldwrench-blocked";

View File

@@ -39,6 +39,7 @@ namespace OpenRA.Mods.Common.Traits
[Desc("Skip playing (reversed) make animation.")]
public readonly bool SkipMakeAnimation = false;
[CursorReference]
[Desc("Cursor to display when the sell order generator hovers over this actor.")]
public readonly string Cursor = "sell";

View File

@@ -47,6 +47,7 @@ namespace OpenRA.Mods.Common.Traits
"This requires the actor to have the WithSpriteBody trait or one of its derivatives.")]
public readonly string Sequence = "active";
[CursorReference]
[Desc("Cursor to display when there are no units to apply the condition in range.")]
public readonly string BlockedCursor = "move-blocked";

View File

@@ -38,6 +38,7 @@ namespace OpenRA.Mods.Common.Traits
[Desc("Allow this to be used only once.")]
public readonly bool OneShot = false;
[CursorReference]
[Desc("Cursor to display for using this support power.")]
public readonly string Cursor = "ability";

View File

@@ -45,9 +45,11 @@ namespace OpenRA.Mods.Common.Traits
[Desc("Notification to play when the transformation is blocked.")]
public readonly string NoTransformNotification = null;
[CursorReference]
[Desc("Cursor to display when able to (un)deploy the actor.")]
public readonly string DeployCursor = "deploy";
[CursorReference]
[Desc("Cursor to display when unable to (un)deploy the actor.")]
public readonly string DeployBlockedCursor = "deploy-blocked";