From 9e93edf3368ff3ec8715809e177a6d38021e8ce0 Mon Sep 17 00:00:00 2001 From: geckosoft Date: Wed, 10 Nov 2010 07:23:18 +0100 Subject: [PATCH] Changed: Made GenericSelectTarget & GenericSelectTargetWithBuilding more generic (now it accepts an optional 'expected' mouse button) default => left (as it was hardcoded) --- OpenRA.Game/Orders/GenericSelectTarget.cs | 28 ++++++++++++++++++----- 1 file changed, 22 insertions(+), 6 deletions(-) diff --git a/OpenRA.Game/Orders/GenericSelectTarget.cs b/OpenRA.Game/Orders/GenericSelectTarget.cs index 8d5fd6e88d..39c6c77beb 100644 --- a/OpenRA.Game/Orders/GenericSelectTarget.cs +++ b/OpenRA.Game/Orders/GenericSelectTarget.cs @@ -20,31 +20,44 @@ namespace OpenRA.Orders readonly IEnumerable subjects; readonly string order; readonly string cursor; + readonly MouseButton expectedButton; - public GenericSelectTarget(IEnumerable subjects, string order, string cursor) + public GenericSelectTarget(IEnumerable subjects, string order, string cursor, MouseButton button) { this.subjects = subjects; this.order = order; this.cursor = cursor; + expectedButton = button; + } + + public GenericSelectTarget(IEnumerable subjects, string order, string cursor) + : this(subjects, order, cursor, MouseButton.Left) + { + } public GenericSelectTarget(Actor subject, string order, string cursor) + : this(new Actor[] { subject }, order, cursor) { - this.subjects = new Actor[] { subject }; - this.order = order; - this.cursor = cursor; + + } + + public GenericSelectTarget(Actor subject, string order, string cursor, MouseButton button) + : this(new Actor[] { subject }, order, cursor, button) + { + } public IEnumerable Order(World world, int2 xy, MouseInput mi) { - if (mi.Button == MouseButton.Right) + if (mi.Button != expectedButton) world.CancelInputMode(); return OrderInner(world, xy, mi); } IEnumerable OrderInner(World world, int2 xy, MouseInput mi) { - if (mi.Button == MouseButton.Left && world.Map.IsInMap(xy)) + if (mi.Button == expectedButton && world.Map.IsInMap(xy)) { world.CancelInputMode(); foreach (var subject in subjects) @@ -84,6 +97,9 @@ namespace OpenRA.Orders public GenericSelectTargetWithBuilding(Actor subject, string order, string cursor) : base(subject, order, cursor) { } + public GenericSelectTargetWithBuilding(Actor subject, string order, string cursor, MouseButton button) + : base(subject, order, cursor, button) { } + public override void Tick(World world) { var hasStructure = world.Queries.OwnedBy[world.LocalPlayer]