From 4cbc2ee6f308d46114affd3576ed23aa72e31a68 Mon Sep 17 00:00:00 2001 From: Paul Chote Date: Wed, 15 Nov 2017 17:45:14 +0000 Subject: [PATCH] Add support for custom sell cursors. --- OpenRA.Mods.Common/Orders/GlobalButtonOrderGenerator.cs | 9 ++++++++- OpenRA.Mods.Common/Traits/Sellable.cs | 3 +++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/OpenRA.Mods.Common/Orders/GlobalButtonOrderGenerator.cs b/OpenRA.Mods.Common/Orders/GlobalButtonOrderGenerator.cs index eee0b9b613..1e782c47f1 100644 --- a/OpenRA.Mods.Common/Orders/GlobalButtonOrderGenerator.cs +++ b/OpenRA.Mods.Common/Orders/GlobalButtonOrderGenerator.cs @@ -83,7 +83,14 @@ namespace OpenRA.Mods.Common.Orders public override string GetCursor(World world, CPos cell, int2 worldPixel, MouseInput mi) { mi.Button = MouseButton.Left; - return OrderInner(world, mi).Any() ? "sell" : "sell-blocked"; + + var cursor = OrderInner(world, mi) + .SelectMany(o => o.Subject.TraitsImplementing()) + .Where(Exts.IsTraitEnabled) + .Select(si => si.Info.Cursor) + .FirstOrDefault(); + + return cursor ?? "sell-blocked"; } } } diff --git a/OpenRA.Mods.Common/Traits/Sellable.cs b/OpenRA.Mods.Common/Traits/Sellable.cs index 216ece8bf8..78a7fd4fc1 100644 --- a/OpenRA.Mods.Common/Traits/Sellable.cs +++ b/OpenRA.Mods.Common/Traits/Sellable.cs @@ -27,6 +27,9 @@ namespace OpenRA.Mods.Common.Traits [Desc("Skip playing (reversed) make animation.")] public readonly bool SkipMakeAnimation = false; + [Desc("Cursor type to use when the sell order generator hovers over this actor.")] + public readonly string Cursor = "sell"; + public override object Create(ActorInitializer init) { return new Sellable(init.Self, this); } }