Changed: Made GenericSelectTarget & GenericSelectTargetWithBuilding more generic (now it accepts an optional 'expected' mouse button) default => left (as it was hardcoded)
This commit is contained in:
@@ -20,31 +20,44 @@ namespace OpenRA.Orders
|
|||||||
readonly IEnumerable<Actor> subjects;
|
readonly IEnumerable<Actor> subjects;
|
||||||
readonly string order;
|
readonly string order;
|
||||||
readonly string cursor;
|
readonly string cursor;
|
||||||
|
readonly MouseButton expectedButton;
|
||||||
|
|
||||||
public GenericSelectTarget(IEnumerable<Actor> subjects, string order, string cursor)
|
public GenericSelectTarget(IEnumerable<Actor> subjects, string order, string cursor, MouseButton button)
|
||||||
{
|
{
|
||||||
this.subjects = subjects;
|
this.subjects = subjects;
|
||||||
this.order = order;
|
this.order = order;
|
||||||
this.cursor = cursor;
|
this.cursor = cursor;
|
||||||
|
expectedButton = button;
|
||||||
|
}
|
||||||
|
|
||||||
|
public GenericSelectTarget(IEnumerable<Actor> subjects, string order, string cursor)
|
||||||
|
: this(subjects, order, cursor, MouseButton.Left)
|
||||||
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public GenericSelectTarget(Actor subject, string order, string cursor)
|
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> Order(World world, int2 xy, MouseInput mi)
|
public IEnumerable<Order> Order(World world, int2 xy, MouseInput mi)
|
||||||
{
|
{
|
||||||
if (mi.Button == MouseButton.Right)
|
if (mi.Button != expectedButton)
|
||||||
world.CancelInputMode();
|
world.CancelInputMode();
|
||||||
return OrderInner(world, xy, mi);
|
return OrderInner(world, xy, mi);
|
||||||
}
|
}
|
||||||
|
|
||||||
IEnumerable<Order> OrderInner(World world, int2 xy, MouseInput mi)
|
IEnumerable<Order> 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();
|
world.CancelInputMode();
|
||||||
foreach (var subject in subjects)
|
foreach (var subject in subjects)
|
||||||
@@ -84,6 +97,9 @@ namespace OpenRA.Orders
|
|||||||
public GenericSelectTargetWithBuilding(Actor subject, string order, string cursor)
|
public GenericSelectTargetWithBuilding(Actor subject, string order, string cursor)
|
||||||
: base(subject, order, 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)
|
public override void Tick(World world)
|
||||||
{
|
{
|
||||||
var hasStructure = world.Queries.OwnedBy[world.LocalPlayer]
|
var hasStructure = world.Queries.OwnedBy[world.LocalPlayer]
|
||||||
|
|||||||
Reference in New Issue
Block a user