Add UnionRectangles extension method.
This commit is contained in:
@@ -324,12 +324,7 @@ namespace OpenRA.Mods.Common.Graphics
|
||||
if (ShadowStart > 0)
|
||||
boundSprites = boundSprites.Concat(SpriteBounds(sprites, Frames, ShadowStart, Facings, Length, Stride, transpose));
|
||||
|
||||
if (boundSprites.Any())
|
||||
{
|
||||
Bounds = boundSprites.First();
|
||||
foreach (var b in boundSprites.Skip(1))
|
||||
Bounds = Rectangle.Union(Bounds, b);
|
||||
}
|
||||
Bounds = boundSprites.Union();
|
||||
}
|
||||
catch (FormatException f)
|
||||
{
|
||||
|
||||
@@ -92,12 +92,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
// If this is a problem, then we may need to fetch the area from somewhere else
|
||||
var r = previews.SelectMany(p => p.ScreenBounds(worldRenderer, CenterPosition));
|
||||
|
||||
if (r.Any())
|
||||
{
|
||||
Bounds = r.First();
|
||||
foreach (var rr in r.Skip(1))
|
||||
Bounds = Rectangle.Union(Bounds, rr);
|
||||
}
|
||||
Bounds = r.Union();
|
||||
|
||||
SelectionBox = new SelectionBoxRenderable(new WPos(CenterPosition.X, CenterPosition.Y, 8192),
|
||||
new Rectangle(Bounds.X, Bounds.Y, Bounds.Width, Bounds.Height), Color.White);
|
||||
|
||||
@@ -53,20 +53,10 @@ namespace OpenRA.Mods.Common.Widgets
|
||||
.ToArray();
|
||||
|
||||
// Calculate the preview bounds
|
||||
PreviewOffset = int2.Zero;
|
||||
IdealPreviewSize = int2.Zero;
|
||||
|
||||
var r = preview.SelectMany(p => p.ScreenBounds(worldRenderer, WPos.Zero));
|
||||
|
||||
if (r.Any())
|
||||
{
|
||||
var b = r.First();
|
||||
foreach (var rr in r.Skip(1))
|
||||
b = Rectangle.Union(b, rr);
|
||||
|
||||
IdealPreviewSize = new int2(b.Width, b.Height);
|
||||
PreviewOffset = -new int2(b.Left, b.Top) - IdealPreviewSize / 2;
|
||||
}
|
||||
var b = r.Union();
|
||||
IdealPreviewSize = new int2(b.Width, b.Height);
|
||||
PreviewOffset = -new int2(b.Left, b.Top) - IdealPreviewSize / 2;
|
||||
}
|
||||
|
||||
IFinalizedRenderable[] renderables;
|
||||
|
||||
@@ -425,7 +425,7 @@ namespace OpenRA.Mods.Common.Widgets
|
||||
DisplayedIconCount++;
|
||||
}
|
||||
|
||||
eventBounds = icons.Any() ? icons.Keys.Aggregate(Rectangle.Union) : Rectangle.Empty;
|
||||
eventBounds = icons.Keys.Union();
|
||||
|
||||
if (oldIconCount != DisplayedIconCount)
|
||||
OnIconCountChanged(oldIconCount, DisplayedIconCount);
|
||||
|
||||
@@ -154,7 +154,7 @@ namespace OpenRA.Mods.Common.Widgets
|
||||
IconCount++;
|
||||
}
|
||||
|
||||
eventBounds = icons.Any() ? icons.Keys.Aggregate(Rectangle.Union) : Rectangle.Empty;
|
||||
eventBounds = icons.Keys.Union();
|
||||
|
||||
if (oldIconCount != IconCount)
|
||||
OnIconCountChanged(oldIconCount, IconCount);
|
||||
|
||||
Reference in New Issue
Block a user