Add a PixelDouble preference for rendering at 2x zoom. Allowing arbitrary zoom levels leads to too many rendering artifacts.
This commit is contained in:
@@ -58,7 +58,8 @@ namespace OpenRA.GameRules
|
|||||||
public WindowMode Mode = WindowMode.PseudoFullscreen;
|
public WindowMode Mode = WindowMode.PseudoFullscreen;
|
||||||
public int2 FullscreenSize = new int2(0,0);
|
public int2 FullscreenSize = new int2(0,0);
|
||||||
public int2 WindowedSize = new int2(1024, 768);
|
public int2 WindowedSize = new int2(1024, 768);
|
||||||
|
public bool PixelDouble = false;
|
||||||
|
|
||||||
public int BatchSize = 8192;
|
public int BatchSize = 8192;
|
||||||
public int NumTempBuffers = 8;
|
public int NumTempBuffers = 8;
|
||||||
public int SheetSize = 2048;
|
public int SheetSize = 2048;
|
||||||
|
|||||||
@@ -30,9 +30,10 @@ namespace OpenRA.Graphics
|
|||||||
public class Viewport
|
public class Viewport
|
||||||
{
|
{
|
||||||
readonly int2 screenSize;
|
readonly int2 screenSize;
|
||||||
int2 scrollPosition;
|
|
||||||
readonly Renderer renderer;
|
readonly Renderer renderer;
|
||||||
readonly Rectangle scrollLimits;
|
readonly Rectangle mapBounds;
|
||||||
|
Rectangle scrollLimits;
|
||||||
|
int2 scrollPosition;
|
||||||
|
|
||||||
// Top-left of the viewport, in world-px units
|
// Top-left of the viewport, in world-px units
|
||||||
public float2 Location { get { return scrollPosition; } }
|
public float2 Location { get { return scrollPosition; } }
|
||||||
@@ -51,7 +52,31 @@ namespace OpenRA.Graphics
|
|||||||
|
|
||||||
public int Width { get { return screenSize.X; } }
|
public int Width { get { return screenSize.X; } }
|
||||||
public int Height { get { return screenSize.Y; } }
|
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;
|
float cursorFrame = 0f;
|
||||||
|
|
||||||
@@ -94,16 +119,9 @@ namespace OpenRA.Graphics
|
|||||||
{
|
{
|
||||||
this.screenSize = screenSize;
|
this.screenSize = screenSize;
|
||||||
this.renderer = renderer;
|
this.renderer = renderer;
|
||||||
|
this.mapBounds = mapBounds;
|
||||||
|
|
||||||
var viewTL = (Game.CellSize*new float2(mapBounds.Left, mapBounds.Top)).ToInt2();
|
Zoom = Game.Settings.Graphics.PixelDouble ? 2 : 1;
|
||||||
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);
|
|
||||||
|
|
||||||
scrollPosition = new int2(scrollLimits.Location) + new int2(scrollLimits.Size)/2;
|
scrollPosition = new int2(scrollLimits.Location) + new int2(scrollLimits.Size)/2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user