diff --git a/OpenRa.Game/Sidebar.cs b/OpenRa.Game/Sidebar.cs index 8dbe2fbb80..e10a6b50b5 100644 --- a/OpenRa.Game/Sidebar.cs +++ b/OpenRa.Game/Sidebar.cs @@ -52,16 +52,16 @@ namespace OpenRa.Game p.Y += 48; } - void Fill(Size clientSize, float2 p) + void Fill(float height, float2 p) { - while (p.Y < clientSize.Height) + while (p.Y < height) DrawSprite(blank, ref p); } public void Paint() { - float2 buildPos = viewport.Location + new float2(viewport.ClientSize.Width - 128, 0); - float2 unitPos = viewport.Location + new float2(viewport.ClientSize.Width - 64, 0); + float2 buildPos = viewport.Location + new float2(viewport.Size.X - 128, 0); + float2 unitPos = viewport.Location + new float2(viewport.Size.X - 64, 0); foreach (Item i in techTree.BuildableItems) { @@ -74,8 +74,8 @@ namespace OpenRa.Game DrawSprite( sprite, ref unitPos ); } - Fill(viewport.ClientSize, buildPos); - Fill(viewport.ClientSize, unitPos); + Fill(viewport.Size.Y, buildPos); + Fill(viewport.Size.Y, unitPos); spriteRenderer.Flush(); } diff --git a/OpenRa.Game/TerrainRenderer.cs b/OpenRa.Game/TerrainRenderer.cs index 3a50a7d280..d18946bf5a 100644 --- a/OpenRa.Game/TerrainRenderer.cs +++ b/OpenRa.Game/TerrainRenderer.cs @@ -63,9 +63,9 @@ namespace OpenRa.Game int indicesPerRow = map.Width * 6; int verticesPerRow = map.Width * 4; - int visibleRows = (int)(viewport.ClientSize.Height / 24.0f + 2); + int visibleRows = (int)(viewport.Size.Y / 24.0f + 2); - int firstRow = (int)(viewport.ScrollPosition.Y / 24.0f); + int firstRow = (int)(viewport.Location.Y / 24.0f); int lastRow = firstRow + visibleRows; if (lastRow < 0 || firstRow > map.Height) diff --git a/OpenRa.Game/Viewport.cs b/OpenRa.Game/Viewport.cs index 32f8380f07..3b0730cc79 100644 --- a/OpenRa.Game/Viewport.cs +++ b/OpenRa.Game/Viewport.cs @@ -14,15 +14,15 @@ namespace OpenRa.Game float2 scrollPosition; readonly Renderer renderer; - public PointF ScrollPosition { get { return scrollPosition.ToPointF(); } } public Size ClientSize { get { return clientSize; } } public float2 Location { get { return scrollPosition; } } - public float2 Size { get { return scrollPosition + new float2(ClientSize); } } + public float2 Size { get { return new float2(ClientSize); } } public void Scroll(float2 delta) { - scrollPosition = (scrollPosition + delta).Constrain(new Range(float2.Zero, mapSize)); + scrollPosition = (scrollPosition + delta).Constrain( + new Range(float2.Zero, mapSize)); } public Viewport(Size clientSize, float2 mapSize, Renderer renderer) @@ -56,7 +56,7 @@ namespace OpenRa.Game public void DrawRegions() { - float2 r1 = new float2(2.0f / clientSize.Width, -2.0f / clientSize.Height); + float2 r1 = new float2(2, -2) / Size; float2 r2 = new float2(-1, 1); renderer.BeginFrame(r1, r2, scrollPosition);