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:
@@ -97,11 +97,12 @@ namespace OpenRA.Mods.Common.Traits.Render
|
||||
}
|
||||
}
|
||||
|
||||
public readonly RenderVoxelsInfo Info;
|
||||
|
||||
readonly List<ModelAnimation> components = new List<ModelAnimation>();
|
||||
readonly Dictionary<ModelAnimation, AnimationWrapper> wrappers = new Dictionary<ModelAnimation, AnimationWrapper>();
|
||||
|
||||
readonly Actor self;
|
||||
readonly RenderVoxelsInfo info;
|
||||
readonly BodyOrientation body;
|
||||
readonly WRot camera;
|
||||
readonly WRot lightSource;
|
||||
@@ -109,7 +110,7 @@ namespace OpenRA.Mods.Common.Traits.Render
|
||||
public RenderVoxels(Actor self, RenderVoxelsInfo info)
|
||||
{
|
||||
this.self = self;
|
||||
this.info = info;
|
||||
Info = info;
|
||||
body = self.Trait<BodyOrientation>();
|
||||
camera = new WRot(WAngle.Zero, body.CameraPitch - new WAngle(256), new WAngle(256));
|
||||
lightSource = new WRot(WAngle.Zero, new WAngle(256) - info.LightPitch, info.LightYaw);
|
||||
@@ -133,16 +134,16 @@ namespace OpenRA.Mods.Common.Traits.Render
|
||||
{
|
||||
if (initializePalettes)
|
||||
{
|
||||
var paletteName = info.Palette ?? info.PlayerPalette + self.Owner.InternalName;
|
||||
var paletteName = Info.Palette ?? Info.PlayerPalette + self.Owner.InternalName;
|
||||
colorPalette = wr.Palette(paletteName);
|
||||
normalsPalette = wr.Palette(info.NormalsPalette);
|
||||
shadowPalette = wr.Palette(info.ShadowPalette);
|
||||
normalsPalette = wr.Palette(Info.NormalsPalette);
|
||||
shadowPalette = wr.Palette(Info.ShadowPalette);
|
||||
initializePalettes = false;
|
||||
}
|
||||
|
||||
return new IRenderable[] { new ModelRenderable(
|
||||
components, self.CenterPosition, 0, camera, info.Scale,
|
||||
lightSource, info.LightAmbientColor, info.LightDiffuseColor,
|
||||
components, self.CenterPosition, 0, camera, Info.Scale,
|
||||
lightSource, Info.LightAmbientColor, Info.LightDiffuseColor,
|
||||
colorPalette, normalsPalette, shadowPalette) };
|
||||
}
|
||||
|
||||
@@ -151,10 +152,10 @@ namespace OpenRA.Mods.Common.Traits.Render
|
||||
var pos = self.CenterPosition;
|
||||
foreach (var c in components)
|
||||
if (c.IsVisible)
|
||||
yield return c.ScreenBounds(pos, wr, info.Scale);
|
||||
yield return c.ScreenBounds(pos, wr, Info.Scale);
|
||||
}
|
||||
|
||||
public string Image { get { return info.Image ?? self.Info.Name; } }
|
||||
public string Image { get { return Info.Image ?? self.Info.Name; } }
|
||||
public void Add(ModelAnimation m)
|
||||
{
|
||||
components.Add(m);
|
||||
|
||||
Reference in New Issue
Block a user