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,6 +58,7 @@ 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;
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user