Remove legacy DIY view -> world conversions.

This commit is contained in:
Paul Chote
2015-03-27 23:25:36 +00:00
parent 2630537daf
commit 49624e335c
3 changed files with 11 additions and 13 deletions

View File

@@ -494,7 +494,7 @@ namespace OpenRA
if (worldRenderer != null) if (worldRenderer != null)
{ {
Renderer.BeginFrame(worldRenderer.Viewport.TopLeft, worldRenderer.Viewport.Zoom); Renderer.BeginFrame(worldRenderer.Viewport.TopLeft, worldRenderer.Viewport.Zoom);
Sound.SetListenerPosition(worldRenderer.Position(worldRenderer.Viewport.CenterLocation)); Sound.SetListenerPosition(worldRenderer.Viewport.CenterPosition);
worldRenderer.Draw(); worldRenderer.Draw();
} }
else else

View File

@@ -73,7 +73,7 @@ namespace OpenRA.Traits
float GetIntensity() float GetIntensity()
{ {
var cp = worldRenderer.Position(worldRenderer.Viewport.CenterLocation); var cp = worldRenderer.Viewport.CenterPosition;
var intensity = 100 * 1024 * 1024 * shakeEffects.Sum( var intensity = 100 * 1024 * 1024 * shakeEffects.Sum(
e => (float)e.Intensity / (e.Position - cp).LengthSquared); e => (float)e.Intensity / (e.Position - cp).LengthSquared);

View File

@@ -71,7 +71,7 @@ namespace OpenRA.Widgets
// Place buildings, use support powers, and other non-unit things // Place buildings, use support powers, and other non-unit things
if (!(World.OrderGenerator is UnitOrderGenerator)) if (!(World.OrderGenerator is UnitOrderGenerator))
{ {
ApplyOrders(World, xy, mi); ApplyOrders(World, mi);
dragStart = dragEnd = null; dragStart = dragEnd = null;
YieldMouseFocus(mi); YieldMouseFocus(mi);
lastMousePosition = xy; lastMousePosition = xy;
@@ -95,7 +95,7 @@ namespace OpenRA.Widgets
!mi.Modifiers.HasModifier(Modifiers.Alt) && UnitOrderGenerator.InputOverridesSelection(World, xy, mi))) !mi.Modifiers.HasModifier(Modifiers.Alt) && UnitOrderGenerator.InputOverridesSelection(World, xy, mi)))
{ {
// Order units instead of selecting // Order units instead of selecting
ApplyOrders(World, xy, mi); ApplyOrders(World, mi);
dragStart = dragEnd = null; dragStart = dragEnd = null;
YieldMouseFocus(mi); YieldMouseFocus(mi);
lastMousePosition = xy; lastMousePosition = xy;
@@ -133,7 +133,7 @@ namespace OpenRA.Widgets
if (useClassicMouseStyle) if (useClassicMouseStyle)
World.Selection.Clear(); 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) if (world.OrderGenerator == null)
return; return;
var pos = worldRenderer.Position(xy); var cell = worldRenderer.Viewport.ViewToWorld(mi.Location);
var orders = world.OrderGenerator.Order(world, world.Map.CellContaining(pos), mi).ToArray(); var orders = world.OrderGenerator.Order(world, cell, mi).ToArray();
world.PlayVoiceForOrders(orders); world.PlayVoiceForOrders(orders);
var flashed = false; var flashed = false;
@@ -184,8 +184,8 @@ namespace OpenRA.Widgets
} }
else if (o.TargetLocation != CPos.Zero) else if (o.TargetLocation != CPos.Zero)
{ {
world.AddFrameEndTask(w => w.Add( var pos = world.Map.CenterOfCell(cell);
new SpriteEffect(worldRenderer.Position(worldRenderer.Viewport.ViewToWorldPx(mi.Location)), world, "moveflsh", "moveflash"))); world.AddFrameEndTask(w => w.Add(new SpriteEffect(pos, world, "moveflsh", "moveflash")));
flashed = true; flashed = true;
} }
} }
@@ -202,9 +202,7 @@ namespace OpenRA.Widgets
if (SelectionBox != null) if (SelectionBox != null)
return null; return null;
var xy = worldRenderer.Viewport.ViewToWorldPx(screenPos); var cell = worldRenderer.Viewport.ViewToWorld(screenPos);
var pos = worldRenderer.Position(xy);
var cell = World.Map.CellContaining(pos);
var mi = new MouseInput var mi = new MouseInput
{ {