Add smooth scrolling
This commit is contained in:
@@ -49,14 +49,13 @@ namespace OpenRA.Graphics
|
||||
readonly Size tileSize;
|
||||
|
||||
// Viewport geometry (world-px)
|
||||
public int2 CenterLocation { get; private set; }
|
||||
public float2 CenterLocation { get; private set; }
|
||||
|
||||
public WPos CenterPosition => worldRenderer.ProjectedPosition(CenterLocation);
|
||||
public WPos CenterPosition => worldRenderer.ProjectedPosition(CenterLocation.ToInt2());
|
||||
|
||||
public Rectangle Rectangle => new(TopLeft, new Size(viewportSize.X, viewportSize.Y));
|
||||
public int2 TopLeft => CenterLocation - viewportSize / 2;
|
||||
public int2 BottomRight => CenterLocation + viewportSize / 2;
|
||||
int2 viewportSize;
|
||||
public int2 TopLeft => CenterLocation.ToInt2() - ViewportSize.ToInt2() / 2;
|
||||
public int2 BottomRight => CenterLocation.ToInt2() + ViewportSize.ToInt2() / 2;
|
||||
public Size ViewportSize { get; private set; }
|
||||
ProjectedCellRegion cells;
|
||||
bool cellsDirty = true;
|
||||
|
||||
@@ -79,7 +78,7 @@ namespace OpenRA.Graphics
|
||||
private set
|
||||
{
|
||||
zoom = value;
|
||||
viewportSize = (1f / zoom * new float2(Game.Renderer.NativeResolution)).ToInt2();
|
||||
ViewportSize = Size.FromInt2((1f / zoom * new float2(Game.Renderer.NativeResolution)).ToInt2());
|
||||
cellsDirty = true;
|
||||
allCellsDirty = true;
|
||||
}
|
||||
@@ -341,7 +340,7 @@ namespace OpenRA.Graphics
|
||||
public void Scroll(float2 delta, bool ignoreBorders)
|
||||
{
|
||||
// Convert scroll delta from world-px to viewport-px
|
||||
CenterLocation += (1f / Zoom * delta).ToInt2();
|
||||
CenterLocation += 1f / Zoom * delta;
|
||||
cellsDirty = true;
|
||||
allCellsDirty = true;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user