Merge pull request #11081 from pchote/fix-left-click-orders
Fix left click orders
This commit is contained in:
@@ -58,5 +58,11 @@ namespace OpenRA.Orders
|
|||||||
{
|
{
|
||||||
return world.Map.Contains(cell) ? Cursor : "generic-blocked";
|
return world.Map.Contains(cell) ? Cursor : "generic-blocked";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override bool InputOverridesSelection(World world, int2 xy, MouseInput mi)
|
||||||
|
{
|
||||||
|
// Custom order generators always override selection
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -83,7 +83,7 @@ namespace OpenRA.Orders
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Used for classic mouse orders, determines whether or not action at xy is move or select
|
// Used for classic mouse orders, determines whether or not action at xy is move or select
|
||||||
public static bool InputOverridesSelection(World world, int2 xy, MouseInput mi)
|
public virtual bool InputOverridesSelection(World world, int2 xy, MouseInput mi)
|
||||||
{
|
{
|
||||||
var actor = world.ScreenMap.ActorsAt(xy).WithHighestSelectionPriority(xy);
|
var actor = world.ScreenMap.ActorsAt(xy).WithHighestSelectionPriority(xy);
|
||||||
if (actor == null)
|
if (actor == null)
|
||||||
@@ -95,10 +95,21 @@ namespace OpenRA.Orders
|
|||||||
var underCursor = world.Selection.Actors.WithHighestSelectionPriority(xy);
|
var underCursor = world.Selection.Actors.WithHighestSelectionPriority(xy);
|
||||||
|
|
||||||
var o = OrderForUnit(underCursor, target, actorsAt, cell, mi);
|
var o = OrderForUnit(underCursor, target, actorsAt, cell, mi);
|
||||||
if (o != null && o.Order.OverrideSelection)
|
if (o != null)
|
||||||
return false;
|
{
|
||||||
|
var modifiers = TargetModifiers.None;
|
||||||
|
if (mi.Modifiers.HasModifier(Modifiers.Ctrl))
|
||||||
|
modifiers |= TargetModifiers.ForceAttack;
|
||||||
|
if (mi.Modifiers.HasModifier(Modifiers.Shift))
|
||||||
|
modifiers |= TargetModifiers.ForceQueue;
|
||||||
|
if (mi.Modifiers.HasModifier(Modifiers.Alt))
|
||||||
|
modifiers |= TargetModifiers.ForceMove;
|
||||||
|
|
||||||
return true;
|
if (o.Order.TargetOverridesSelection(modifiers))
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
@@ -108,7 +108,7 @@ namespace OpenRA.Traits
|
|||||||
int OrderPriority { get; }
|
int OrderPriority { get; }
|
||||||
bool CanTarget(Actor self, Target target, List<Actor> othersAtTarget, ref TargetModifiers modifiers, ref string cursor);
|
bool CanTarget(Actor self, Target target, List<Actor> othersAtTarget, ref TargetModifiers modifiers, ref string cursor);
|
||||||
bool IsQueued { get; }
|
bool IsQueued { get; }
|
||||||
bool OverrideSelection { get; }
|
bool TargetOverridesSelection(TargetModifiers modifiers);
|
||||||
}
|
}
|
||||||
|
|
||||||
public interface IResolveOrder { void ResolveOrder(Actor self, Order order); }
|
public interface IResolveOrder { void ResolveOrder(Actor self, Order order); }
|
||||||
|
|||||||
@@ -103,10 +103,8 @@ namespace OpenRA.Widgets
|
|||||||
var selectableActor = World.ScreenMap.ActorsAt(mousePos).Any(x =>
|
var selectableActor = World.ScreenMap.ActorsAt(mousePos).Any(x =>
|
||||||
x.Info.HasTraitInfo<SelectableInfo>() && (x.Owner.IsAlliedWith(World.RenderPlayer) || !World.FogObscures(x)));
|
x.Info.HasTraitInfo<SelectableInfo>() && (x.Owner.IsAlliedWith(World.RenderPlayer) || !World.FogObscures(x)));
|
||||||
|
|
||||||
var ignoreSelection = mi.Modifiers.HasModifier(Modifiers.Ctrl) || mi.Modifiers.HasModifier(Modifiers.Alt) ||
|
var uog = (UnitOrderGenerator)World.OrderGenerator;
|
||||||
UnitOrderGenerator.InputOverridesSelection(World, mousePos, mi);
|
if (!selectableActor || uog.InputOverridesSelection(World, mousePos, mi))
|
||||||
|
|
||||||
if (ignoreSelection || !selectableActor)
|
|
||||||
{
|
{
|
||||||
// Order units instead of selecting
|
// Order units instead of selecting
|
||||||
ApplyOrders(World, mi);
|
ApplyOrders(World, mi);
|
||||||
|
|||||||
@@ -19,7 +19,10 @@ namespace OpenRA.Mods.Common.Orders
|
|||||||
{
|
{
|
||||||
public string OrderID { get { return "Move"; } }
|
public string OrderID { get { return "Move"; } }
|
||||||
public int OrderPriority { get { return 4; } }
|
public int OrderPriority { get { return 4; } }
|
||||||
public bool OverrideSelection { get { return false; } }
|
public bool TargetOverridesSelection(TargetModifiers modifiers)
|
||||||
|
{
|
||||||
|
return modifiers.HasModifier(TargetModifiers.ForceMove);
|
||||||
|
}
|
||||||
|
|
||||||
readonly AircraftInfo info;
|
readonly AircraftInfo info;
|
||||||
|
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ namespace OpenRA.Mods.Common.Orders
|
|||||||
|
|
||||||
public string OrderID { get; private set; }
|
public string OrderID { get; private set; }
|
||||||
public int OrderPriority { get; private set; }
|
public int OrderPriority { get; private set; }
|
||||||
public bool OverrideSelection { get { return true; } }
|
public bool TargetOverridesSelection(TargetModifiers modifiers) { return true; }
|
||||||
|
|
||||||
public bool CanTarget(Actor self, Target target, List<Actor> othersAtTarget, ref TargetModifiers modifiers, ref string cursor)
|
public bool CanTarget(Actor self, Target target, List<Actor> othersAtTarget, ref TargetModifiers modifiers, ref string cursor)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ namespace OpenRA.Mods.Common.Orders
|
|||||||
public string OrderID { get; private set; }
|
public string OrderID { get; private set; }
|
||||||
public int OrderPriority { get; private set; }
|
public int OrderPriority { get; private set; }
|
||||||
public bool? ForceAttack = null;
|
public bool? ForceAttack = null;
|
||||||
public bool OverrideSelection { get { return true; } }
|
public bool TargetOverridesSelection(TargetModifiers modifiers) { return true; }
|
||||||
|
|
||||||
public abstract bool CanTargetActor(Actor self, Actor target, TargetModifiers modifiers, ref string cursor);
|
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);
|
public abstract bool CanTargetFrozenActor(Actor self, FrozenActor target, TargetModifiers modifiers, ref string cursor);
|
||||||
|
|||||||
@@ -309,7 +309,7 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
|
|
||||||
public string OrderID { get; private set; }
|
public string OrderID { get; private set; }
|
||||||
public int OrderPriority { get; private set; }
|
public int OrderPriority { get; private set; }
|
||||||
public bool OverrideSelection { get { return true; } }
|
public bool TargetOverridesSelection(TargetModifiers modifiers) { return true; }
|
||||||
|
|
||||||
bool CanTargetActor(Actor self, Target target, ref TargetModifiers modifiers, ref string cursor)
|
bool CanTargetActor(Actor self, Target target, ref TargetModifiers modifiers, ref string cursor)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -88,7 +88,7 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
{
|
{
|
||||||
public string OrderID { get { return "SetRallyPoint"; } }
|
public string OrderID { get { return "SetRallyPoint"; } }
|
||||||
public int OrderPriority { get { return 0; } }
|
public int OrderPriority { get { return 0; } }
|
||||||
public bool OverrideSelection { get { return true; } }
|
public bool TargetOverridesSelection(TargetModifiers modifiers) { return true; }
|
||||||
|
|
||||||
public bool CanTarget(Actor self, Target target, List<Actor> othersAtTarget, ref TargetModifiers modifiers, ref string cursor)
|
public bool CanTarget(Actor self, Target target, List<Actor> othersAtTarget, ref TargetModifiers modifiers, ref string cursor)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -452,7 +452,7 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
public string OrderID { get { return "Harvest"; } }
|
public string OrderID { get { return "Harvest"; } }
|
||||||
public int OrderPriority { get { return 10; } }
|
public int OrderPriority { get { return 10; } }
|
||||||
public bool IsQueued { get; protected set; }
|
public bool IsQueued { get; protected set; }
|
||||||
public bool OverrideSelection { get { return true; } }
|
public bool TargetOverridesSelection(TargetModifiers modifiers) { return true; }
|
||||||
|
|
||||||
public bool CanTarget(Actor self, Target target, List<Actor> othersAtTarget, ref TargetModifiers modifiers, ref string cursor)
|
public bool CanTarget(Actor self, Target target, List<Actor> othersAtTarget, ref TargetModifiers modifiers, ref string cursor)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -720,7 +720,10 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
{
|
{
|
||||||
readonly Mobile mobile;
|
readonly Mobile mobile;
|
||||||
readonly bool rejectMove;
|
readonly bool rejectMove;
|
||||||
public bool OverrideSelection { get { return false; } }
|
public bool TargetOverridesSelection(TargetModifiers modifiers)
|
||||||
|
{
|
||||||
|
return modifiers.HasModifier(TargetModifiers.ForceMove);
|
||||||
|
}
|
||||||
|
|
||||||
public MoveOrderTargeter(Actor self, Mobile unit)
|
public MoveOrderTargeter(Actor self, Mobile unit)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -201,7 +201,7 @@ namespace OpenRA.Mods.RA.Traits
|
|||||||
{
|
{
|
||||||
public string OrderID { get { return "BeginMinefield"; } }
|
public string OrderID { get { return "BeginMinefield"; } }
|
||||||
public int OrderPriority { get { return 5; } }
|
public int OrderPriority { get { return 5; } }
|
||||||
public bool OverrideSelection { get { return true; } }
|
public bool TargetOverridesSelection(TargetModifiers modifiers) { return true; }
|
||||||
|
|
||||||
public bool CanTarget(Actor self, Target target, List<Actor> othersAtTarget, ref TargetModifiers modifiers, ref string cursor)
|
public bool CanTarget(Actor self, Target target, List<Actor> othersAtTarget, ref TargetModifiers modifiers, ref string cursor)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -119,7 +119,7 @@ namespace OpenRA.Mods.RA.Traits
|
|||||||
public string OrderID { get { return "PortableChronoTeleport"; } }
|
public string OrderID { get { return "PortableChronoTeleport"; } }
|
||||||
public int OrderPriority { get { return 5; } }
|
public int OrderPriority { get { return 5; } }
|
||||||
public bool IsQueued { get; protected set; }
|
public bool IsQueued { get; protected set; }
|
||||||
public bool OverrideSelection { get { return true; } }
|
public bool TargetOverridesSelection(TargetModifiers modifiers) { return true; }
|
||||||
|
|
||||||
public bool CanTarget(Actor self, Target target, List<Actor> othersAtTarget, ref TargetModifiers modifiers, ref string cursor)
|
public bool CanTarget(Actor self, Target target, List<Actor> othersAtTarget, ref TargetModifiers modifiers, ref string cursor)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user