Remove unnecessary int2 -> PPos -> int2 conversions.

This commit is contained in:
Paul Chote
2013-09-24 18:18:44 +12:00
parent b335d67ce3
commit 0dc50c65f5
5 changed files with 12 additions and 16 deletions

View File

@@ -23,6 +23,7 @@ namespace OpenRA.Widgets
{
protected readonly World world;
readonly WorldRenderer worldRenderer;
int2 dragStart, dragEnd;
[ObjectCreator.UseCtor]
public WorldInteractionControllerWidget(World world, WorldRenderer worldRenderer)
@@ -47,11 +48,10 @@ namespace OpenRA.Widgets
worldRenderer.DrawRollover(u);
}
PPos dragStart, dragEnd;
public override bool HandleMouseInput(MouseInput mi)
{
var xy = Game.viewport.ViewToWorldPx(mi);
var xy = Game.viewport.ViewToWorldPx(mi.Location);
var UseClassicMouseStyle = Game.Settings.Game.UseClassicMouseStyle;
@@ -127,7 +127,7 @@ namespace OpenRA.Widgets
}
public Pair<PPos, PPos>? SelectionBox
public Pair<int2, int2>? SelectionBox
{
get
{
@@ -136,11 +136,11 @@ namespace OpenRA.Widgets
}
}
public void ApplyOrders(World world, PPos xy, MouseInput mi)
public void ApplyOrders(World world, int2 xy, MouseInput mi)
{
if (world.OrderGenerator == null) return;
var orders = world.OrderGenerator.Order(world, xy.ToCPos(), mi).ToArray();
var orders = world.OrderGenerator.Order(world, ((PPos)xy).ToCPos(), mi).ToArray();
orders.Do(o => world.IssueOrder(o));
world.PlayVoiceForOrders(orders);
@@ -183,9 +183,9 @@ namespace OpenRA.Widgets
}
static readonly Actor[] NoActors = {};
IEnumerable<Actor> SelectActorsInBox(World world, PPos a, PPos b, Func<Actor, bool> cond)
IEnumerable<Actor> SelectActorsInBox(World world, int2 a, int2 b, Func<Actor, bool> cond)
{
return world.ScreenMap.ActorsInBox(a.ToInt2(), b.ToInt2())
return world.ScreenMap.ActorsInBox(a, b)
.Where(x => x.HasTrait<Selectable>() && x.Trait<Selectable>().Info.Selectable && !world.FogObscures(x) && cond(x))
.GroupBy(x => x.GetSelectionPriority())
.OrderByDescending(g => g.Key)