Merge pull request #8646 from pchote/radar-cleanup
Remove unused/duplicated minimap code.
This commit is contained in:
@@ -96,106 +96,6 @@ namespace OpenRA.Graphics
|
|||||||
return terrain;
|
return terrain;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Bitmap CustomTerrainBitmap(World world)
|
|
||||||
{
|
|
||||||
var map = world.Map;
|
|
||||||
var b = map.Bounds;
|
|
||||||
|
|
||||||
var size = Exts.NextPowerOf2(Math.Max(b.Width, b.Height));
|
|
||||||
var bitmap = new Bitmap(size, size);
|
|
||||||
var bitmapData = bitmap.LockBits(bitmap.Bounds(),
|
|
||||||
ImageLockMode.ReadWrite, PixelFormat.Format32bppArgb);
|
|
||||||
|
|
||||||
unsafe
|
|
||||||
{
|
|
||||||
var colors = (int*)bitmapData.Scan0;
|
|
||||||
var stride = bitmapData.Stride / 4;
|
|
||||||
for (var y = 0; y < b.Height; y++)
|
|
||||||
{
|
|
||||||
for (var x = 0; x < b.Width; x++)
|
|
||||||
{
|
|
||||||
var mapX = x + b.Left;
|
|
||||||
var mapY = y + b.Top;
|
|
||||||
var custom = map.CustomTerrain[new MPos(mapX, mapY)];
|
|
||||||
if (custom == byte.MaxValue)
|
|
||||||
continue;
|
|
||||||
colors[y * stride + x] = world.TileSet[custom].Color.ToArgb();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
bitmap.UnlockBits(bitmapData);
|
|
||||||
return bitmap;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Bitmap ActorsBitmap(World world)
|
|
||||||
{
|
|
||||||
var map = world.Map;
|
|
||||||
var b = map.Bounds;
|
|
||||||
|
|
||||||
var size = Exts.NextPowerOf2(Math.Max(b.Width, b.Height));
|
|
||||||
var bitmap = new Bitmap(size, size);
|
|
||||||
var bitmapData = bitmap.LockBits(bitmap.Bounds(),
|
|
||||||
ImageLockMode.ReadWrite, PixelFormat.Format32bppArgb);
|
|
||||||
|
|
||||||
unsafe
|
|
||||||
{
|
|
||||||
var colors = (int*)bitmapData.Scan0;
|
|
||||||
var stride = bitmapData.Stride / 4;
|
|
||||||
foreach (var t in world.ActorsWithTrait<IRadarSignature>())
|
|
||||||
{
|
|
||||||
if (!t.Actor.IsInWorld || world.FogObscures(t.Actor))
|
|
||||||
continue;
|
|
||||||
|
|
||||||
foreach (var cell in t.Trait.RadarSignatureCells(t.Actor))
|
|
||||||
{
|
|
||||||
var uv = cell.First.ToMPos(map);
|
|
||||||
if (b.Contains(uv.U, uv.V))
|
|
||||||
colors[(uv.V - b.Top) * stride + uv.U - b.Left] = cell.Second.ToArgb();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
bitmap.UnlockBits(bitmapData);
|
|
||||||
return bitmap;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Bitmap ShroudBitmap(World world)
|
|
||||||
{
|
|
||||||
var map = world.Map;
|
|
||||||
var b = map.Bounds;
|
|
||||||
|
|
||||||
var size = Exts.NextPowerOf2(Math.Max(b.Width, b.Height));
|
|
||||||
var bitmap = new Bitmap(size, size);
|
|
||||||
if (world.RenderPlayer == null)
|
|
||||||
return bitmap;
|
|
||||||
|
|
||||||
var bitmapData = bitmap.LockBits(bitmap.Bounds(),
|
|
||||||
ImageLockMode.ReadWrite, PixelFormat.Format32bppArgb);
|
|
||||||
|
|
||||||
var shroud = Color.Black.ToArgb();
|
|
||||||
var fog = Color.FromArgb(128, Color.Black).ToArgb();
|
|
||||||
|
|
||||||
unsafe
|
|
||||||
{
|
|
||||||
var colors = (int*)bitmapData.Scan0;
|
|
||||||
var stride = bitmapData.Stride / 4;
|
|
||||||
var shroudObscured = world.ShroudObscuresTest;
|
|
||||||
var fogObscured = world.FogObscuresTest;
|
|
||||||
foreach (var uv in map.CellsInsideBounds.MapCoords)
|
|
||||||
{
|
|
||||||
var bitmapXy = new int2(uv.U - b.Left, uv.V - b.Top);
|
|
||||||
if (shroudObscured(uv))
|
|
||||||
colors[bitmapXy.Y * stride + bitmapXy.X] = shroud;
|
|
||||||
else if (fogObscured(uv))
|
|
||||||
colors[bitmapXy.Y * stride + bitmapXy.X] = fog;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
bitmap.UnlockBits(bitmapData);
|
|
||||||
return bitmap;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Bitmap RenderMapPreview(TileSet tileset, Map map, bool actualSize)
|
public static Bitmap RenderMapPreview(TileSet tileset, Map map, bool actualSize)
|
||||||
{
|
{
|
||||||
return RenderMapPreview(tileset, map, map.Rules, actualSize);
|
return RenderMapPreview(tileset, map, map.Rules, actualSize);
|
||||||
|
|||||||
@@ -290,15 +290,12 @@ namespace OpenRA.Mods.Common.Widgets
|
|||||||
if (newRenderShroud != null)
|
if (newRenderShroud != null)
|
||||||
{
|
{
|
||||||
// Redraw the full shroud sprite
|
// Redraw the full shroud sprite
|
||||||
using (var bitmap = Minimap.ShroudBitmap(world))
|
MarkShroudDirty(world.Map.CellsInsideBounds);
|
||||||
OpenRA.Graphics.Util.FastCopyIntoSprite(shroudSprite, bitmap);
|
|
||||||
|
|
||||||
// Update the notification binding
|
// Update the notification binding
|
||||||
newRenderShroud.CellsChanged += MarkShroudDirty;
|
newRenderShroud.CellsChanged += MarkShroudDirty;
|
||||||
}
|
}
|
||||||
|
|
||||||
dirtyShroudCells.Clear();
|
|
||||||
|
|
||||||
renderShroud = newRenderShroud;
|
renderShroud = newRenderShroud;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user