From 49624e335c8933094ed52525a37af9a477cbb486 Mon Sep 17 00:00:00 2001 From: Paul Chote Date: Fri, 27 Mar 2015 23:25:36 +0000 Subject: [PATCH] Remove legacy DIY view -> world conversions. --- OpenRA.Game/Game.cs | 2 +- OpenRA.Game/Traits/World/ScreenShaker.cs | 2 +- .../WorldInteractionControllerWidget.cs | 20 +++++++++---------- 3 files changed, 11 insertions(+), 13 deletions(-) diff --git a/OpenRA.Game/Game.cs b/OpenRA.Game/Game.cs index b0e86e3d11..1c6a68c82e 100644 --- a/OpenRA.Game/Game.cs +++ b/OpenRA.Game/Game.cs @@ -494,7 +494,7 @@ namespace OpenRA if (worldRenderer != null) { Renderer.BeginFrame(worldRenderer.Viewport.TopLeft, worldRenderer.Viewport.Zoom); - Sound.SetListenerPosition(worldRenderer.Position(worldRenderer.Viewport.CenterLocation)); + Sound.SetListenerPosition(worldRenderer.Viewport.CenterPosition); worldRenderer.Draw(); } else diff --git a/OpenRA.Game/Traits/World/ScreenShaker.cs b/OpenRA.Game/Traits/World/ScreenShaker.cs index 06a82efe0f..ffce699341 100644 --- a/OpenRA.Game/Traits/World/ScreenShaker.cs +++ b/OpenRA.Game/Traits/World/ScreenShaker.cs @@ -73,7 +73,7 @@ namespace OpenRA.Traits float GetIntensity() { - var cp = worldRenderer.Position(worldRenderer.Viewport.CenterLocation); + var cp = worldRenderer.Viewport.CenterPosition; var intensity = 100 * 1024 * 1024 * shakeEffects.Sum( e => (float)e.Intensity / (e.Position - cp).LengthSquared); diff --git a/OpenRA.Game/Widgets/WorldInteractionControllerWidget.cs b/OpenRA.Game/Widgets/WorldInteractionControllerWidget.cs index c16d57a615..07dbabeab8 100644 --- a/OpenRA.Game/Widgets/WorldInteractionControllerWidget.cs +++ b/OpenRA.Game/Widgets/WorldInteractionControllerWidget.cs @@ -71,7 +71,7 @@ namespace OpenRA.Widgets // Place buildings, use support powers, and other non-unit things if (!(World.OrderGenerator is UnitOrderGenerator)) { - ApplyOrders(World, xy, mi); + ApplyOrders(World, mi); dragStart = dragEnd = null; YieldMouseFocus(mi); lastMousePosition = xy; @@ -95,7 +95,7 @@ namespace OpenRA.Widgets !mi.Modifiers.HasModifier(Modifiers.Alt) && UnitOrderGenerator.InputOverridesSelection(World, xy, mi))) { // Order units instead of selecting - ApplyOrders(World, xy, mi); + ApplyOrders(World, mi); dragStart = dragEnd = null; YieldMouseFocus(mi); lastMousePosition = xy; @@ -133,7 +133,7 @@ namespace OpenRA.Widgets if (useClassicMouseStyle) World.Selection.Clear(); - ApplyOrders(World, xy, mi); + ApplyOrders(World, mi); } } @@ -159,13 +159,13 @@ namespace OpenRA.Widgets } } - void ApplyOrders(World world, int2 xy, MouseInput mi) + void ApplyOrders(World world, MouseInput mi) { if (world.OrderGenerator == null) return; - var pos = worldRenderer.Position(xy); - var orders = world.OrderGenerator.Order(world, world.Map.CellContaining(pos), mi).ToArray(); + var cell = worldRenderer.Viewport.ViewToWorld(mi.Location); + var orders = world.OrderGenerator.Order(world, cell, mi).ToArray(); world.PlayVoiceForOrders(orders); var flashed = false; @@ -184,8 +184,8 @@ namespace OpenRA.Widgets } else if (o.TargetLocation != CPos.Zero) { - world.AddFrameEndTask(w => w.Add( - new SpriteEffect(worldRenderer.Position(worldRenderer.Viewport.ViewToWorldPx(mi.Location)), world, "moveflsh", "moveflash"))); + var pos = world.Map.CenterOfCell(cell); + world.AddFrameEndTask(w => w.Add(new SpriteEffect(pos, world, "moveflsh", "moveflash"))); flashed = true; } } @@ -202,9 +202,7 @@ namespace OpenRA.Widgets if (SelectionBox != null) return null; - var xy = worldRenderer.Viewport.ViewToWorldPx(screenPos); - var pos = worldRenderer.Position(xy); - var cell = World.Map.CellContaining(pos); + var cell = worldRenderer.Viewport.ViewToWorld(screenPos); var mi = new MouseInput {