diff --git a/OpenRA.Game/Graphics/Viewport.cs b/OpenRA.Game/Graphics/Viewport.cs index 1327be6359..6db5205c21 100755 --- a/OpenRA.Game/Graphics/Viewport.cs +++ b/OpenRA.Game/Graphics/Viewport.cs @@ -38,6 +38,17 @@ namespace OpenRA.Graphics public float2 Location { get { return scrollPosition; } } public float2 CenterLocation { get { return scrollPosition + 0.5f/Zoom*screenSize.ToFloat2(); } } + public Rectangle WorldRect + { + get + { + return new Rectangle(scrollPosition.X / Game.CellSize, + scrollPosition.Y / Game.CellSize, + (int)(screenSize.X / Zoom / Game.CellSize), + (int)(screenSize.Y / Zoom / Game.CellSize)); + } + } + public int Width { get { return screenSize.X; } } public int Height { get { return screenSize.Y; } } public float Zoom = 1f; diff --git a/OpenRA.Mods.RA/Widgets/RadarBinWidget.cs b/OpenRA.Mods.RA/Widgets/RadarBinWidget.cs index 29c927148b..e9b5676ece 100755 --- a/OpenRA.Mods.RA/Widgets/RadarBinWidget.cs +++ b/OpenRA.Mods.RA/Widgets/RadarBinWidget.cs @@ -148,8 +148,10 @@ namespace OpenRA.Mods.RA.Widgets // Draw viewport rect if (radarAnimationFrame == radarSlideAnimationLength + radarActivateAnimationLength) { - var tl = CellToMinimapPixel(new int2((int)(Game.viewport.Location.X/Game.CellSize), (int)(Game.viewport.Location.Y/Game.CellSize))); - var br = CellToMinimapPixel(new int2((int)((Game.viewport.Location.X + Game.viewport.Width)/Game.CellSize), (int)((Game.viewport.Location.Y + Game.viewport.Height)/Game.CellSize))); + var wr = Game.viewport.WorldRect; + var wro = new int2(wr.X, wr.Y); + var tl = CellToMinimapPixel(wro); + var br = CellToMinimapPixel(wro + new int2(wr.Width, wr.Height)); Game.Renderer.EnableScissor((int)mapRect.Left, (int)mapRect.Top, (int)mapRect.Width, (int)mapRect.Height); Game.Renderer.LineRenderer.DrawRect(tl, br, Color.White); diff --git a/OpenRA.Mods.RA/Widgets/RadarWidget.cs b/OpenRA.Mods.RA/Widgets/RadarWidget.cs index 1a785a6bd4..493a79bdf4 100755 --- a/OpenRA.Mods.RA/Widgets/RadarWidget.cs +++ b/OpenRA.Mods.RA/Widgets/RadarWidget.cs @@ -138,8 +138,11 @@ namespace OpenRA.Mods.RA.Widgets // Draw viewport rect if (hasRadar && !Animating) { - var tl = CellToMinimapPixel(new int2((int)(Game.viewport.Location.X/Game.CellSize), (int)(Game.viewport.Location.Y/Game.CellSize))); - var br = CellToMinimapPixel(new int2((int)((Game.viewport.Location.X + Game.viewport.Width)/Game.CellSize), (int)((Game.viewport.Location.Y + Game.viewport.Height)/Game.CellSize))); + var wr = Game.viewport.WorldRect; + var wro = new int2(wr.X, wr.Y); + var tl = CellToMinimapPixel(wro); + var br = CellToMinimapPixel(wro + new int2(wr.Width, wr.Height)); + Game.Renderer.EnableScissor((int)mapRect.Left, (int)mapRect.Top, (int)mapRect.Width, (int)mapRect.Height); Game.Renderer.LineRenderer.DrawRect(tl, br, Color.White); Game.Renderer.DisableScissor();