diff --git a/OpenRA.Game/GameRules/Settings.cs b/OpenRA.Game/GameRules/Settings.cs index ab385b6d5b..3f769b38b4 100755 --- a/OpenRA.Game/GameRules/Settings.cs +++ b/OpenRA.Game/GameRules/Settings.cs @@ -58,7 +58,8 @@ namespace OpenRA.GameRules public WindowMode Mode = WindowMode.PseudoFullscreen; public int2 FullscreenSize = new int2(0,0); public int2 WindowedSize = new int2(1024, 768); - + public bool PixelDouble = false; + public int BatchSize = 8192; public int NumTempBuffers = 8; public int SheetSize = 2048; diff --git a/OpenRA.Game/Graphics/Viewport.cs b/OpenRA.Game/Graphics/Viewport.cs index 2ff82d6554..c1dc071cd6 100755 --- a/OpenRA.Game/Graphics/Viewport.cs +++ b/OpenRA.Game/Graphics/Viewport.cs @@ -30,9 +30,10 @@ namespace OpenRA.Graphics public class Viewport { readonly int2 screenSize; - int2 scrollPosition; readonly Renderer renderer; - readonly Rectangle scrollLimits; + readonly Rectangle mapBounds; + Rectangle scrollLimits; + int2 scrollPosition; // Top-left of the viewport, in world-px units public float2 Location { get { return scrollPosition; } } @@ -51,7 +52,31 @@ namespace OpenRA.Graphics public int Width { get { return screenSize.X; } } public int Height { get { return screenSize.Y; } } - public float Zoom = 1f; + + float zoom = 1f; + public float Zoom + { + get + { + return zoom; + } + set + { + var oldCenter = CenterLocation; + zoom = value; + + // Update scroll limits + var viewTL = (Game.CellSize*new float2(mapBounds.Left, mapBounds.Top)).ToInt2(); + var viewBR = (Game.CellSize*new float2(mapBounds.Right, mapBounds.Bottom)).ToInt2(); + var border = (.5f/Zoom * screenSize.ToFloat2()).ToInt2(); + scrollLimits = Rectangle.FromLTRB(viewTL.X - border.X, + viewTL.Y - border.Y, + viewBR.X - border.X, + viewBR.Y - border.Y); + // Re-center viewport + scrollPosition = NormalizeScrollPosition((oldCenter - 0.5f / Zoom * screenSize.ToFloat2()).ToInt2()); + } + } float cursorFrame = 0f; @@ -94,16 +119,9 @@ namespace OpenRA.Graphics { this.screenSize = screenSize; this.renderer = renderer; + this.mapBounds = mapBounds; - var viewTL = (Game.CellSize*new float2(mapBounds.Left, mapBounds.Top)).ToInt2(); - var viewBR = (Game.CellSize*new float2(mapBounds.Right, mapBounds.Bottom)).ToInt2(); - - var border = (.5f/Zoom * screenSize.ToFloat2()).ToInt2(); - scrollLimits = Rectangle.FromLTRB(viewTL.X - border.X, - viewTL.Y - border.Y, - viewBR.X - border.X, - viewBR.Y - border.Y); - + Zoom = Game.Settings.Graphics.PixelDouble ? 2 : 1; scrollPosition = new int2(scrollLimits.Location) + new int2(scrollLimits.Size)/2; }