Allow left click to cancel AttackMove without clearing selected units.

This commit is contained in:
Paul Chote
2019-08-10 10:32:41 +00:00
committed by abcdefg30
parent ad099b5c98
commit 292196e2d6
4 changed files with 62 additions and 59 deletions

View File

@@ -68,5 +68,7 @@ namespace OpenRA.Orders
// Custom order generators always override selection
return true;
}
public override bool ClearSelectionOnLeftClick { get { return false; } }
}
}

View File

@@ -204,5 +204,7 @@ namespace OpenRA.Orders
Target = target;
}
}
public virtual bool ClearSelectionOnLeftClick { get { return true; } }
}
}

View File

@@ -148,5 +148,7 @@ namespace OpenRA.Mods.Common.Traits
// Custom order generators always override selection
return true;
}
public override bool ClearSelectionOnLeftClick { get { return false; } }
}
}

View File

@@ -82,8 +82,9 @@ namespace OpenRA.Mods.Common.Widgets
var useClassicMouseStyle = Game.Settings.Game.UseClassicMouseStyle;
var multiClick = mi.MultiTapCount >= 2;
var uog = World.OrderGenerator as UnitOrderGenerator;
if (!(World.OrderGenerator is UnitOrderGenerator))
if (uog == null)
{
ApplyOrders(World, mi);
isDragging = false;
@@ -101,8 +102,6 @@ namespace OpenRA.Mods.Common.Widgets
}
if (mi.Button == MouseButton.Left && mi.Event == MouseInputEvent.Up)
{
if (World.OrderGenerator is UnitOrderGenerator)
{
if (useClassicMouseStyle && HasMouseFocus)
{
@@ -111,7 +110,6 @@ namespace OpenRA.Mods.Common.Widgets
var selectableActor = World.ScreenMap.ActorsAtMouse(mousePos).Select(a => a.Actor).Any(x =>
x.Info.HasTraitInfo<SelectableInfo>() && (x.Owner.IsAlliedWith(World.RenderPlayer) || !World.FogObscures(x)));
var uog = (UnitOrderGenerator)World.OrderGenerator;
if (!selectableActor || uog.InputOverridesSelection(worldRenderer, World, mousePos, mi))
{
// Order units instead of selecting
@@ -157,7 +155,7 @@ namespace OpenRA.Mods.Common.Widgets
// World.CancelInputMode. If we did check it, actor de-selection would not be possible by just clicking somewhere,
// only by dragging an empty selection box.
*/
if (isDragging && (!(World.OrderGenerator is GenericSelectTarget) || IsValidDragbox))
if (isDragging && (uog.ClearSelectionOnLeftClick || IsValidDragbox))
{
var newSelection = SelectActorsInBoxWithDeadzone(World, dragStart, mousePos, mi.Modifiers);
World.Selection.Combine(World, newSelection, mi.Modifiers.HasModifier(Modifiers.Shift), dragStart == mousePos);
@@ -165,7 +163,6 @@ namespace OpenRA.Mods.Common.Widgets
}
World.CancelInputMode();
}
isDragging = false;
YieldMouseFocus(mi);