Introduce IMouseBounds and split/rework mouse rectangles.

The render bounds for an actor now include the area covered
by bibs, shadows, and any other widgets. In many cases this
area is much larger than we really want to consider for
tooltips and mouse selection.

An optional Margin is added to Selectable to support cases
like infantry, where we want the mouse area of the actor
to be larger than the drawn selection box.
This commit is contained in:
Paul Chote
2017-12-07 23:15:07 +00:00
committed by reaperrr
parent 8fcc80b05a
commit 6f5d035e79
25 changed files with 349 additions and 117 deletions

View File

@@ -128,6 +128,7 @@ namespace OpenRA.Mods.Common.Traits
{
IRenderable[] renderables = null;
Rectangle[] bounds = null;
Rectangle mouseBounds = Rectangle.Empty;
for (var playerIndex = 0; playerIndex < frozenStates.Count; playerIndex++)
{
var frozen = frozenStates[playerIndex].FrozenActor;
@@ -139,6 +140,7 @@ namespace OpenRA.Mods.Common.Traits
isRendering = true;
renderables = self.Render(wr).ToArray();
bounds = self.ScreenBounds(wr).ToArray();
mouseBounds = self.MouseBounds(wr);
isRendering = false;
}
@@ -146,6 +148,7 @@ namespace OpenRA.Mods.Common.Traits
frozen.NeedRenderables = false;
frozen.Renderables = renderables;
frozen.ScreenBounds = bounds;
frozen.MouseBounds = mouseBounds;
self.World.ScreenMap.AddOrUpdate(self.World.Players[playerIndex], frozen);
}
}