diff --git a/OpenRA.Game/Graphics/Viewport.cs b/OpenRA.Game/Graphics/Viewport.cs index e1dd2f3948..93aa963343 100755 --- a/OpenRA.Game/Graphics/Viewport.cs +++ b/OpenRA.Game/Graphics/Viewport.cs @@ -149,9 +149,8 @@ namespace OpenRA.Graphics return (CPos)( (1f / Game.CellSize) * (1f/Zoom*loc.ToFloat2() + Location) ).ToInt2(); } - public PPos ViewToWorldPx(int2 loc) { return (PPos)(1f/Zoom*loc.ToFloat2() + Location).ToInt2(); } - public PPos ViewToWorldPx(MouseInput mi) { return ViewToWorldPx(mi.Location); } - public int2 WorldToViewPx(PPos loc) { return (Zoom * (loc.ToFloat2() - Location)).ToInt2(); } + public int2 ViewToWorldPx(int2 loc) { return (1f/Zoom*loc.ToFloat2() + Location).ToInt2(); } + public int2 WorldToViewPx(int2 loc) { return (Zoom * (loc.ToFloat2() - Location)).ToInt2(); } public void Center(float2 loc) { diff --git a/OpenRA.Game/Graphics/WorldRenderer.cs b/OpenRA.Game/Graphics/WorldRenderer.cs index 56c2f10c9b..de977cff7d 100644 --- a/OpenRA.Game/Graphics/WorldRenderer.cs +++ b/OpenRA.Game/Graphics/WorldRenderer.cs @@ -75,8 +75,8 @@ namespace OpenRA.Graphics { var comparer = new RenderableComparer(this); var vb = Game.viewport.ViewBounds(world); - var tl = Game.viewport.ViewToWorldPx(new int2(vb.Left, vb.Top)).ToInt2(); - var br = Game.viewport.ViewToWorldPx(new int2(vb.Right, vb.Bottom)).ToInt2(); + var tl = Game.viewport.ViewToWorldPx(new int2(vb.Left, vb.Top)); + var br = Game.viewport.ViewToWorldPx(new int2(vb.Right, vb.Bottom)); var actors = world.ScreenMap.ActorsInBox(tl, br) .Append(world.WorldActor) .ToList(); diff --git a/OpenRA.Game/Traits/World/ScreenMap.cs b/OpenRA.Game/Traits/World/ScreenMap.cs index 684a60c365..283440b8e9 100755 --- a/OpenRA.Game/Traits/World/ScreenMap.cs +++ b/OpenRA.Game/Traits/World/ScreenMap.cs @@ -127,9 +127,6 @@ namespace OpenRA.Traits .Select(kv => kv.Key); } - // Legacy fallback - public IEnumerable ActorsAt(PPos pxPos) { return ActorsAt(pxPos.ToInt2()); } - public IEnumerable ActorsInBox(int2 a, int2 b) { return ActorsInBox(Rectangle.FromLTRB(Math.Min(a.X, b.X), Math.Min(a.Y, b.Y), Math.Max(a.X, b.X), Math.Max(a.Y, b.Y))); diff --git a/OpenRA.Game/Widgets/WorldInteractionControllerWidget.cs b/OpenRA.Game/Widgets/WorldInteractionControllerWidget.cs index d58e682a35..4d122e5ebc 100644 --- a/OpenRA.Game/Widgets/WorldInteractionControllerWidget.cs +++ b/OpenRA.Game/Widgets/WorldInteractionControllerWidget.cs @@ -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? SelectionBox + public Pair? 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 SelectActorsInBox(World world, PPos a, PPos b, Func cond) + IEnumerable SelectActorsInBox(World world, int2 a, int2 b, Func cond) { - return world.ScreenMap.ActorsInBox(a.ToInt2(), b.ToInt2()) + return world.ScreenMap.ActorsInBox(a, b) .Where(x => x.HasTrait() && x.Trait().Info.Selectable && !world.FogObscures(x) && cond(x)) .GroupBy(x => x.GetSelectionPriority()) .OrderByDescending(g => g.Key) diff --git a/OpenRA.Game/WorldUtils.cs b/OpenRA.Game/WorldUtils.cs index df54b6d96b..19450fe65f 100755 --- a/OpenRA.Game/WorldUtils.cs +++ b/OpenRA.Game/WorldUtils.cs @@ -27,7 +27,7 @@ namespace OpenRA if (world.RenderPlayer == null) return NoFrozenActors; - return world.ScreenMap.FrozenActorsAt(world.RenderPlayer, Game.viewport.ViewToWorldPx(mouseLocation).ToInt2()); + return world.ScreenMap.FrozenActorsAt(world.RenderPlayer, Game.viewport.ViewToWorldPx(mouseLocation)); } public static IEnumerable FindActorsInBox(this World world, CPos tl, CPos br)