Add sanity to minimap; part 0
This commit is contained in:
@@ -24,7 +24,7 @@ namespace OpenRA.Widgets
|
||||
public Func<MapStub> Map = () => null;
|
||||
public Action<int> OnSpawnClick = spawn => {};
|
||||
public Func<Dictionary<int2, Color>> SpawnColors = () => new Dictionary<int2, Color>();
|
||||
static Cache<MapStub,Bitmap> PreviewCache = new Cache<MapStub, Bitmap>(stub => Minimap.RenderMapPreview(stub));
|
||||
static Cache<MapStub,Bitmap> PreviewCache = new Cache<MapStub, Bitmap>(stub => Minimap.RenderMapPreview(stub.Map));
|
||||
|
||||
public MapPreviewWidget() : base() { }
|
||||
protected MapPreviewWidget(MapPreviewWidget other)
|
||||
|
||||
@@ -28,16 +28,15 @@ namespace OpenRA.Widgets
|
||||
bool hasRadar = false;
|
||||
|
||||
string radarCollection;
|
||||
Minimap Minimap = null;
|
||||
public override string GetCursor(int2 pos)
|
||||
{
|
||||
if (Minimap == null)
|
||||
if (minimap == null)
|
||||
return "default";
|
||||
|
||||
var mapRect = new RectangleF(radarOrigin.X + 9, radarOrigin.Y + (192 - radarMinimapHeight) / 2,
|
||||
192, radarMinimapHeight);
|
||||
|
||||
var loc = Minimap.MinimapPixelToCell(mapRect, pos);
|
||||
var loc = Minimap.MinimapPixelToCell(Game.world.Map, mapRect, pos);
|
||||
|
||||
var mi = new MouseInput
|
||||
{
|
||||
@@ -60,10 +59,10 @@ namespace OpenRA.Widgets
|
||||
var mapRect = new RectangleF(radarOrigin.X + 9, radarOrigin.Y + (192 - radarMinimapHeight) / 2,
|
||||
192, radarMinimapHeight);
|
||||
|
||||
if (!mapRect.Contains(mi.Location.ToPointF()) || Minimap == null)
|
||||
if (!mapRect.Contains(mi.Location.ToPointF()) || minimap == null)
|
||||
return false;
|
||||
|
||||
var loc = Minimap.MinimapPixelToCell(mapRect, mi.Location);
|
||||
var loc = Minimap.MinimapPixelToCell(Game.world.Map, mapRect, mi.Location);
|
||||
|
||||
if ((mi.Event == MouseInputEvent.Down || mi.Event == MouseInputEvent.Move) && mi.Button == MouseButton.Left)
|
||||
Game.viewport.Center(loc);
|
||||
@@ -95,6 +94,7 @@ namespace OpenRA.Widgets
|
||||
192, (int)radarMinimapHeight);}
|
||||
}
|
||||
|
||||
Minimap minimap = null;
|
||||
public override void DrawInner(World world)
|
||||
{
|
||||
radarCollection = "radar-" + world.LocalPlayer.Country.Race;
|
||||
@@ -117,20 +117,20 @@ namespace OpenRA.Widgets
|
||||
|
||||
Game.Renderer.RgbaSpriteRenderer.Flush();
|
||||
|
||||
if (Minimap == null)
|
||||
Minimap = new Minimap(world);
|
||||
if (minimap == null)
|
||||
minimap = new Minimap(world);
|
||||
|
||||
if (radarAnimationFrame >= radarSlideAnimationLength)
|
||||
{
|
||||
var mapRect = new RectangleF(radarOrigin.X + 9, radarOrigin.Y + (192 - radarMinimapHeight) / 2, 192, radarMinimapHeight);
|
||||
Minimap.Draw(mapRect);
|
||||
minimap.Draw(mapRect);
|
||||
}
|
||||
}
|
||||
|
||||
public override void Tick(World world)
|
||||
{
|
||||
if (world.LocalPlayer != null && Minimap != null)
|
||||
Minimap.Update();
|
||||
if (world.LocalPlayer != null && minimap != null)
|
||||
minimap.Update();
|
||||
|
||||
if (!radarAnimating)
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user