Replace DecorationPosition with mod-defined string ids.
This commit is contained in:
@@ -32,20 +32,38 @@ namespace OpenRA.Mods.Common.Traits.Render
|
||||
selectable = self.Trait<IsometricSelectable>();
|
||||
}
|
||||
|
||||
protected override int2 GetDecorationPosition(Actor self, WorldRenderer wr, DecorationPosition pos)
|
||||
int2 GetDecorationPosition(Actor self, WorldRenderer wr, string pos)
|
||||
{
|
||||
var bounds = selectable.DecorationBounds(self, wr);
|
||||
switch (pos)
|
||||
{
|
||||
case DecorationPosition.TopLeft: return bounds.Vertices[1];
|
||||
case DecorationPosition.TopRight: return bounds.Vertices[5];
|
||||
case DecorationPosition.BottomLeft: return bounds.Vertices[2];
|
||||
case DecorationPosition.BottomRight: return bounds.Vertices[4];
|
||||
case DecorationPosition.Top: return new int2((bounds.Vertices[1].X + bounds.Vertices[5].X) / 2, bounds.Vertices[1].Y);
|
||||
case "TopLeft": return bounds.Vertices[1];
|
||||
case "TopRight": return bounds.Vertices[5];
|
||||
case "BottomLeft": return bounds.Vertices[2];
|
||||
case "BottomRight": return bounds.Vertices[4];
|
||||
case "Top": return new int2((bounds.Vertices[1].X + bounds.Vertices[5].X) / 2, bounds.Vertices[1].Y);
|
||||
default: return bounds.BoundingRect.TopLeft + new int2(bounds.BoundingRect.Size.Width / 2, bounds.BoundingRect.Size.Height / 2);
|
||||
}
|
||||
}
|
||||
|
||||
static int2 GetDecorationMargin(string pos, int2 margin)
|
||||
{
|
||||
switch (pos)
|
||||
{
|
||||
case "TopLeft": return margin;
|
||||
case "TopRight": return new int2(-margin.X, margin.Y);
|
||||
case "BottomLeft": return new int2(margin.X, -margin.Y);
|
||||
case "BottomRight": return -margin;
|
||||
case "Top": return new int2(0, margin.Y);
|
||||
default: return int2.Zero;
|
||||
}
|
||||
}
|
||||
|
||||
protected override int2 GetDecorationOrigin(Actor self, WorldRenderer wr, string pos, int2 margin)
|
||||
{
|
||||
return wr.Viewport.WorldToViewPx(GetDecorationPosition(self, wr, pos)) + GetDecorationMargin(pos, margin);
|
||||
}
|
||||
|
||||
protected override IEnumerable<IRenderable> RenderSelectionBox(Actor self, WorldRenderer wr, Color color)
|
||||
{
|
||||
var bounds = selectable.DecorationBounds(self, wr);
|
||||
|
||||
Reference in New Issue
Block a user