diff --git a/OpenRA.Game/Widgets/MapPreviewWidget.cs b/OpenRA.Game/Widgets/MapPreviewWidget.cs index 234cca020e..6800059485 100644 --- a/OpenRA.Game/Widgets/MapPreviewWidget.cs +++ b/OpenRA.Game/Widgets/MapPreviewWidget.cs @@ -20,8 +20,8 @@ namespace OpenRA.Widgets { public Func Map = () => null; public Func> SpawnColors = () => new Dictionary(); - static Cache PreviewCache = new Cache(stub => Minimap.RenderMapPreview( new Map( stub.Path ))); - + Cache PreviewCache = new Cache(stub => Minimap.RenderMapPreview( new Map( stub.Path ))); + public MapPreviewWidget() : base() { } protected MapPreviewWidget(MapPreviewWidget other) : base(other) @@ -42,16 +42,9 @@ namespace OpenRA.Widgets Map lastMap; Rectangle MapRect; float PreviewScale = 0; - static Sprite UnownedSpawn = null; - static Sprite OwnedSpawn = null; public override void DrawInner() { - if (UnownedSpawn == null) - UnownedSpawn = ChromeProvider.GetImage("spawnpoints", "unowned"); - if (OwnedSpawn == null) - OwnedSpawn = ChromeProvider.GetImage("spawnpoints", "owned"); - var map = Map(); if( map == null ) return; @@ -83,16 +76,14 @@ namespace OpenRA.Widgets var colors = SpawnColors(); foreach (var p in map.SpawnPoints) { + var owned = colors.ContainsKey(p); var pos = ConvertToPreview(map, p); - var sprite = UnownedSpawn; - var offset = new int2(-UnownedSpawn.bounds.Width/2, -UnownedSpawn.bounds.Height/2); + var sprite = ChromeProvider.GetImage("spawnpoints", owned ? "owned" : "unowned"); + var offset = new int2(-sprite.bounds.Width/2, -sprite.bounds.Height/2); - if (colors.ContainsKey(p)) - { - sprite = OwnedSpawn; - offset = new int2(-OwnedSpawn.bounds.Width/2, -OwnedSpawn.bounds.Height/2); + if (owned) WidgetUtils.FillRectWithColor(new Rectangle(pos.X + offset.X + 2, pos.Y + offset.Y + 2, 12, 12), colors[p]); - } + Game.Renderer.RgbaSpriteRenderer.DrawSprite(sprite, pos + offset); } }