diff --git a/OpenRA.Game/Orders/UnitOrderGenerator.cs b/OpenRA.Game/Orders/UnitOrderGenerator.cs index 0a94727ec0..6095444fec 100644 --- a/OpenRA.Game/Orders/UnitOrderGenerator.cs +++ b/OpenRA.Game/Orders/UnitOrderGenerator.cs @@ -96,10 +96,10 @@ namespace OpenRA.Orders var o = OrderForUnit(underCursor, target, mi); - if (o == null || o.Trait is IMove) - return true; + if (o != null && o.Order.OverrideSelection) + return false; - return false; + return true; } static UnitOrderResult OrderForUnit(Actor self, Target target, MouseInput mi) diff --git a/OpenRA.Game/Traits/TraitsInterfaces.cs b/OpenRA.Game/Traits/TraitsInterfaces.cs index fd0091d7ba..9edb9b8932 100644 --- a/OpenRA.Game/Traits/TraitsInterfaces.cs +++ b/OpenRA.Game/Traits/TraitsInterfaces.cs @@ -79,6 +79,7 @@ namespace OpenRA.Traits int OrderPriority { get; } bool CanTarget(Actor self, Target target, List othersAtTarget, TargetModifiers modifiers, ref string cursor); bool IsQueued { get; } + bool OverrideSelection { get; } } public interface IResolveOrder { void ResolveOrder(Actor self, Order order); } diff --git a/OpenRA.Game/Widgets/WorldInteractionControllerWidget.cs b/OpenRA.Game/Widgets/WorldInteractionControllerWidget.cs index bd9f61814c..c6ec62f6fc 100644 --- a/OpenRA.Game/Widgets/WorldInteractionControllerWidget.cs +++ b/OpenRA.Game/Widgets/WorldInteractionControllerWidget.cs @@ -68,9 +68,15 @@ namespace OpenRA.Widgets dragStart = xy; - // Place buildings - if (!useClassicMouseStyle || !World.Selection.Actors.Any()) + // Place buildings, use support powers, and other non-unit things + if (!(World.OrderGenerator is UnitOrderGenerator)) + { ApplyOrders(World, xy, mi); + dragStart = dragEnd = null; + YieldMouseFocus(mi); + lastMousePosition = xy; + return true; + } } if (mi.Button == MouseButton.Left && mi.Event == MouseInputEvent.Move && dragStart.HasValue) @@ -114,8 +120,6 @@ namespace OpenRA.Widgets World.Selection.Combine(World, newSelection, mi.Modifiers.HasModifier(Modifiers.Shift), dragStart == xy); } } - else if (useClassicMouseStyle) - ApplyOrders(World, xy, mi); dragStart = dragEnd = null; YieldMouseFocus(mi); diff --git a/OpenRA.Mods.Cnc/Traits/SupportPowers/IonCannonPower.cs b/OpenRA.Mods.Cnc/Traits/SupportPowers/IonCannonPower.cs index 567f41baeb..b7c9af5e59 100644 --- a/OpenRA.Mods.Cnc/Traits/SupportPowers/IonCannonPower.cs +++ b/OpenRA.Mods.Cnc/Traits/SupportPowers/IonCannonPower.cs @@ -45,6 +45,10 @@ namespace OpenRA.Mods.Cnc.Traits public override IOrderGenerator OrderGenerator(string order, SupportPowerManager manager) { + // Clear selection if using Left-Click Orders + if (Game.Settings.Game.UseClassicMouseStyle) + manager.Self.World.Selection.Clear(); + Sound.PlayToPlayer(manager.Self.Owner, Info.SelectTargetSound); var info = Info as IonCannonPowerInfo; return new SelectGenericPowerTarget(order, manager, info.Cursor, MouseButton.Left); diff --git a/OpenRA.Mods.Common/Orders/DeployOrderTargeter.cs b/OpenRA.Mods.Common/Orders/DeployOrderTargeter.cs index 605c017ee8..5450883ed4 100644 --- a/OpenRA.Mods.Common/Orders/DeployOrderTargeter.cs +++ b/OpenRA.Mods.Common/Orders/DeployOrderTargeter.cs @@ -32,6 +32,7 @@ namespace OpenRA.Mods.Common.Orders public string OrderID { get; private set; } public int OrderPriority { get; private set; } + public bool OverrideSelection { get { return true; } } public bool CanTarget(Actor self, Target target, List othersAtTarget, TargetModifiers modifiers, ref string cursor) { diff --git a/OpenRA.Mods.Common/Orders/PlaceBuildingOrderGenerator.cs b/OpenRA.Mods.Common/Orders/PlaceBuildingOrderGenerator.cs index 606a00accd..b4571b498e 100644 --- a/OpenRA.Mods.Common/Orders/PlaceBuildingOrderGenerator.cs +++ b/OpenRA.Mods.Common/Orders/PlaceBuildingOrderGenerator.cs @@ -34,6 +34,10 @@ namespace OpenRA.Mods.Common.Orders producer = queue.Actor; building = name; + // Clear selection if using Left-Click Orders + if (Game.Settings.Game.UseClassicMouseStyle) + producer.World.Selection.Clear(); + var map = producer.World.Map; var tileset = producer.World.TileSet.Id.ToLowerInvariant(); buildingInfo = map.Rules.Actors[building].Traits.Get(); diff --git a/OpenRA.Mods.Common/Orders/UnitOrderTargeter.cs b/OpenRA.Mods.Common/Orders/UnitOrderTargeter.cs index 02bcb33995..13ac615446 100644 --- a/OpenRA.Mods.Common/Orders/UnitOrderTargeter.cs +++ b/OpenRA.Mods.Common/Orders/UnitOrderTargeter.cs @@ -31,6 +31,7 @@ namespace OpenRA.Mods.Common.Orders public string OrderID { get; private set; } public int OrderPriority { get; private set; } public bool? ForceAttack = null; + public bool OverrideSelection { get { return true; } } public abstract bool CanTargetActor(Actor self, Actor target, TargetModifiers modifiers, ref string cursor); public abstract bool CanTargetFrozenActor(Actor self, FrozenActor target, TargetModifiers modifiers, ref string cursor); diff --git a/OpenRA.Mods.Common/Traits/Air/Aircraft.cs b/OpenRA.Mods.Common/Traits/Air/Aircraft.cs index 9adb07ed5e..bf679bed0e 100644 --- a/OpenRA.Mods.Common/Traits/Air/Aircraft.cs +++ b/OpenRA.Mods.Common/Traits/Air/Aircraft.cs @@ -302,6 +302,7 @@ namespace OpenRA.Mods.Common.Traits { public string OrderID { get { return "Move"; } } public int OrderPriority { get { return 4; } } + public bool OverrideSelection { get { return false; } } readonly AircraftInfo info; diff --git a/OpenRA.Mods.Common/Traits/Attack/AttackBase.cs b/OpenRA.Mods.Common/Traits/Attack/AttackBase.cs index 6f53c583ad..d91c486af3 100644 --- a/OpenRA.Mods.Common/Traits/Attack/AttackBase.cs +++ b/OpenRA.Mods.Common/Traits/Attack/AttackBase.cs @@ -194,6 +194,7 @@ namespace OpenRA.Mods.Common.Traits public string OrderID { get; private set; } public int OrderPriority { get; private set; } + public bool OverrideSelection { get { return true; } } bool CanTargetActor(Actor self, Target target, TargetModifiers modifiers, ref string cursor) { diff --git a/OpenRA.Mods.Common/Traits/Buildings/RallyPoint.cs b/OpenRA.Mods.Common/Traits/Buildings/RallyPoint.cs index 40bb681cc0..98e65ccea0 100644 --- a/OpenRA.Mods.Common/Traits/Buildings/RallyPoint.cs +++ b/OpenRA.Mods.Common/Traits/Buildings/RallyPoint.cs @@ -56,6 +56,7 @@ namespace OpenRA.Mods.Common.Traits { public string OrderID { get { return "SetRallyPoint"; } } public int OrderPriority { get { return 0; } } + public bool OverrideSelection { get { return true; } } public bool CanTarget(Actor self, Target target, List othersAtTarget, TargetModifiers modifiers, ref string cursor) { diff --git a/OpenRA.Mods.Common/Traits/Harvester.cs b/OpenRA.Mods.Common/Traits/Harvester.cs index 568d36e1c0..42e672e4ea 100644 --- a/OpenRA.Mods.Common/Traits/Harvester.cs +++ b/OpenRA.Mods.Common/Traits/Harvester.cs @@ -445,6 +445,7 @@ namespace OpenRA.Mods.Common.Traits public string OrderID { get { return "Harvest"; } } public int OrderPriority { get { return 10; } } public bool IsQueued { get; protected set; } + public bool OverrideSelection { get { return true; } } public bool CanTarget(Actor self, Target target, List othersAtTarget, TargetModifiers modifiers, ref string cursor) { diff --git a/OpenRA.Mods.Common/Traits/Mobile.cs b/OpenRA.Mods.Common/Traits/Mobile.cs index 64e520218d..fd50b2b4bc 100644 --- a/OpenRA.Mods.Common/Traits/Mobile.cs +++ b/OpenRA.Mods.Common/Traits/Mobile.cs @@ -619,6 +619,7 @@ namespace OpenRA.Mods.Common.Traits { readonly MobileInfo unitType; readonly bool rejectMove; + public bool OverrideSelection { get { return false; } } public MoveOrderTargeter(Actor self, MobileInfo unitType) { diff --git a/OpenRA.Mods.Common/Traits/SupportPowers/GrantUpgradePower.cs b/OpenRA.Mods.Common/Traits/SupportPowers/GrantUpgradePower.cs index 71eeb15d39..76080d3239 100644 --- a/OpenRA.Mods.Common/Traits/SupportPowers/GrantUpgradePower.cs +++ b/OpenRA.Mods.Common/Traits/SupportPowers/GrantUpgradePower.cs @@ -102,6 +102,10 @@ namespace OpenRA.Mods.Common.Traits public SelectTarget(World world, string order, SupportPowerManager manager, GrantUpgradePower power) { + // Clear selection if using Left-Click Orders + if (Game.Settings.Game.UseClassicMouseStyle) + manager.Self.World.Selection.Clear(); + this.manager = manager; this.order = order; this.power = power; diff --git a/OpenRA.Mods.Common/Traits/SupportPowers/SupportPowerManager.cs b/OpenRA.Mods.Common/Traits/SupportPowers/SupportPowerManager.cs index 85f123158e..395833905e 100644 --- a/OpenRA.Mods.Common/Traits/SupportPowers/SupportPowerManager.cs +++ b/OpenRA.Mods.Common/Traits/SupportPowers/SupportPowerManager.cs @@ -239,6 +239,10 @@ namespace OpenRA.Mods.Common.Traits public SelectGenericPowerTarget(string order, SupportPowerManager manager, string cursor, MouseButton button) { + // Clear selection if using Left-Click Orders + if (Game.Settings.Game.UseClassicMouseStyle) + manager.Self.World.Selection.Clear(); + this.manager = manager; this.order = order; this.cursor = cursor; diff --git a/OpenRA.Mods.RA/Traits/Minelayer.cs b/OpenRA.Mods.RA/Traits/Minelayer.cs index 706cebe9cc..fda7ea187b 100644 --- a/OpenRA.Mods.RA/Traits/Minelayer.cs +++ b/OpenRA.Mods.RA/Traits/Minelayer.cs @@ -197,6 +197,7 @@ namespace OpenRA.Mods.RA.Traits { public string OrderID { get { return "BeginMinefield"; } } public int OrderPriority { get { return 5; } } + public bool OverrideSelection { get { return true; } } public bool CanTarget(Actor self, Target target, List othersAtTarget, TargetModifiers modifiers, ref string cursor) { diff --git a/OpenRA.Mods.RA/Traits/PortableChrono.cs b/OpenRA.Mods.RA/Traits/PortableChrono.cs index 510d74f8d5..5c7328f66a 100644 --- a/OpenRA.Mods.RA/Traits/PortableChrono.cs +++ b/OpenRA.Mods.RA/Traits/PortableChrono.cs @@ -119,6 +119,7 @@ namespace OpenRA.Mods.RA.Traits public string OrderID { get { return "PortableChronoTeleport"; } } public int OrderPriority { get { return 5; } } public bool IsQueued { get; protected set; } + public bool OverrideSelection { get { return true; } } public bool CanTarget(Actor self, Target target, List othersAtTarget, TargetModifiers modifiers, ref string cursor) { diff --git a/OpenRA.Mods.RA/Traits/SupportPowers/ChronoshiftPower.cs b/OpenRA.Mods.RA/Traits/SupportPowers/ChronoshiftPower.cs index da1481c69d..ea433fbbdc 100644 --- a/OpenRA.Mods.RA/Traits/SupportPowers/ChronoshiftPower.cs +++ b/OpenRA.Mods.RA/Traits/SupportPowers/ChronoshiftPower.cs @@ -101,6 +101,10 @@ namespace OpenRA.Mods.RA.Traits public SelectTarget(World world, string order, SupportPowerManager manager, ChronoshiftPower power) { + // Clear selection if using Left-Click Orders + if (Game.Settings.Game.UseClassicMouseStyle) + manager.Self.World.Selection.Clear(); + this.manager = manager; this.order = order; this.power = power;