Unhardcode support power blocked cursor.

This commit is contained in:
Matthias Mailänder
2024-04-14 13:27:46 +02:00
committed by Gustas
parent fc4ebf332d
commit 69d9bbb400
11 changed files with 53 additions and 14 deletions

View File

@@ -47,10 +47,6 @@ 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";
public readonly string FootprintImage = "overlay";
[SequenceReference(nameof(FootprintImage))]

View File

@@ -219,7 +219,7 @@ namespace OpenRA.Mods.Common.Traits
readonly NukePowerInfo info;
public SelectNukePowerTarget(string order, SupportPowerManager manager, NukePowerInfo info, MouseButton button)
: base(order, manager, info.Cursor, button)
: base(order, manager, info, button)
{
this.info = info;
}

View File

@@ -116,7 +116,7 @@ namespace OpenRA.Mods.Common.Traits
string IOrderGenerator.GetCursor(World world, CPos cell, int2 worldPixel, MouseInput mi)
{
return world.Map.Contains(cell) ? cursor : "generic-blocked";
return world.Map.Contains(cell) ? info.Cursor : info.BlockedCursor;
}
bool IOrderGenerator.HandleKeyPress(KeyInput e) { return false; }

View File

@@ -46,9 +46,6 @@ namespace OpenRA.Mods.Common.Traits
[PaletteReference]
public readonly string EffectPalette = null;
[Desc("Cursor to display when the location is unsuitable.")]
public readonly string BlockedCursor = "move-blocked";
public override object Create(ActorInitializer init) { return new SpawnActorPower(init.Self, this); }
}

View File

@@ -46,6 +46,10 @@ namespace OpenRA.Mods.Common.Traits
[Desc("Cursor to display for using this support power.")]
public readonly string Cursor = "ability";
[CursorReference]
[Desc("Cursor when unable to activate on this position. ")]
public readonly string BlockedCursor = "generic-blocked";
[Desc("If set to true, the support power will be fully charged when it becomes available. " +
"Normal rules apply for subsequent charges.")]
public readonly bool StartFullyCharged = false;
@@ -209,7 +213,7 @@ namespace OpenRA.Mods.Common.Traits
public virtual void SelectTarget(Actor self, string order, SupportPowerManager manager)
{
self.World.OrderGenerator = new SelectGenericPowerTarget(order, manager, info.Cursor, MouseButton.Left);
self.World.OrderGenerator = new SelectGenericPowerTarget(order, manager, info, MouseButton.Left);
}
public virtual void Activate(Actor self, Order order, SupportPowerManager manager)

View File

@@ -283,12 +283,12 @@ namespace OpenRA.Mods.Common.Traits
public class SelectGenericPowerTarget : OrderGenerator
{
readonly SupportPowerManager manager;
readonly string cursor;
readonly SupportPowerInfo info;
readonly MouseButton expectedButton;
public string OrderKey { get; }
public SelectGenericPowerTarget(string order, SupportPowerManager manager, string cursor, MouseButton button)
public SelectGenericPowerTarget(string order, SupportPowerManager manager, SupportPowerInfo info, MouseButton button)
{
// Clear selection if using Left-Click Orders
if (Game.Settings.Game.UseClassicMouseStyle)
@@ -296,7 +296,7 @@ namespace OpenRA.Mods.Common.Traits
this.manager = manager;
OrderKey = order;
this.cursor = cursor;
this.info = info;
expectedButton = button;
}
@@ -319,7 +319,7 @@ namespace OpenRA.Mods.Common.Traits
protected override IEnumerable<IRenderable> RenderAnnotations(WorldRenderer wr, World world) { yield break; }
protected override string GetCursor(World world, CPos cell, int2 worldPixel, MouseInput mi)
{
return world.Map.Contains(cell) ? cursor : "generic-blocked";
return world.Map.Contains(cell) ? info.Cursor : info.BlockedCursor;
}
}
}