Use RgbaColorRenderer in SelectionBoxRenderable.
This commit is contained in:
@@ -17,18 +17,16 @@ namespace OpenRA.Mods.Common.Graphics
|
|||||||
public struct SelectionBoxRenderable : IRenderable, IFinalizedRenderable
|
public struct SelectionBoxRenderable : IRenderable, IFinalizedRenderable
|
||||||
{
|
{
|
||||||
readonly WPos pos;
|
readonly WPos pos;
|
||||||
readonly float scale;
|
|
||||||
readonly Rectangle visualBounds;
|
readonly Rectangle visualBounds;
|
||||||
readonly Color color;
|
readonly Color color;
|
||||||
|
|
||||||
public SelectionBoxRenderable(Actor actor, Color color)
|
public SelectionBoxRenderable(Actor actor, Color color)
|
||||||
: this(actor.CenterPosition, actor.VisualBounds, 1f, color) { }
|
: this(actor.CenterPosition, actor.VisualBounds, color) { }
|
||||||
|
|
||||||
public SelectionBoxRenderable(WPos pos, Rectangle visualBounds, float scale, Color color)
|
public SelectionBoxRenderable(WPos pos, Rectangle visualBounds, Color color)
|
||||||
{
|
{
|
||||||
this.pos = pos;
|
this.pos = pos;
|
||||||
this.visualBounds = visualBounds;
|
this.visualBounds = visualBounds;
|
||||||
this.scale = scale;
|
|
||||||
this.color = color;
|
this.color = color;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -40,30 +38,26 @@ namespace OpenRA.Mods.Common.Graphics
|
|||||||
|
|
||||||
public IRenderable WithPalette(PaletteReference newPalette) { return this; }
|
public IRenderable WithPalette(PaletteReference newPalette) { return this; }
|
||||||
public IRenderable WithZOffset(int newOffset) { return this; }
|
public IRenderable WithZOffset(int newOffset) { return this; }
|
||||||
public IRenderable OffsetBy(WVec vec) { return new SelectionBoxRenderable(pos + vec, visualBounds, scale, color); }
|
public IRenderable OffsetBy(WVec vec) { return new SelectionBoxRenderable(pos + vec, visualBounds, color); }
|
||||||
public IRenderable AsDecoration() { return this; }
|
public IRenderable AsDecoration() { return this; }
|
||||||
|
|
||||||
public IFinalizedRenderable PrepareRender(WorldRenderer wr) { return this; }
|
public IFinalizedRenderable PrepareRender(WorldRenderer wr) { return this; }
|
||||||
public void Render(WorldRenderer wr)
|
public void Render(WorldRenderer wr)
|
||||||
{
|
{
|
||||||
|
var iz = 1 / wr.Viewport.Zoom;
|
||||||
var screenPos = wr.ScreenPxPosition(pos);
|
var screenPos = wr.ScreenPxPosition(pos);
|
||||||
var tl = screenPos + scale * new float2(visualBounds.Left, visualBounds.Top);
|
var tl = screenPos + new float2(visualBounds.Left, visualBounds.Top);
|
||||||
var br = screenPos + scale * new float2(visualBounds.Right, visualBounds.Bottom);
|
var br = screenPos + new float2(visualBounds.Right, visualBounds.Bottom);
|
||||||
var tr = new float2(br.X, tl.Y);
|
var tr = new float2(br.X, tl.Y);
|
||||||
var bl = new float2(tl.X, br.Y);
|
var bl = new float2(tl.X, br.Y);
|
||||||
var u = new float2(4f / wr.Viewport.Zoom, 0);
|
var u = new float2(4 * iz, 0);
|
||||||
var v = new float2(0, 4f / wr.Viewport.Zoom);
|
var v = new float2(0, 4 * iz);
|
||||||
|
|
||||||
var wlr = Game.Renderer.WorldLineRenderer;
|
var wcr = Game.Renderer.WorldRgbaColorRenderer;
|
||||||
wlr.DrawLine(tl + u, tl, color);
|
wcr.DrawLine(new[] { tl + u, tl, tl + v }, iz, color, true);
|
||||||
wlr.DrawLine(tl, tl + v, color);
|
wcr.DrawLine(new[] { tr - u, tr, tr + v }, iz, color, true);
|
||||||
wlr.DrawLine(tr, tr - u, color);
|
wcr.DrawLine(new[] { br - u, br, br - v }, iz, color, true);
|
||||||
wlr.DrawLine(tr, tr + v, color);
|
wcr.DrawLine(new[] { bl + u, bl, bl - v }, iz, color, true);
|
||||||
|
|
||||||
wlr.DrawLine(bl, bl + u, color);
|
|
||||||
wlr.DrawLine(bl, bl - v, color);
|
|
||||||
wlr.DrawLine(br, br - u, color);
|
|
||||||
wlr.DrawLine(br, br - v, color);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void RenderDebugGeometry(WorldRenderer wr) { }
|
public void RenderDebugGeometry(WorldRenderer wr) { }
|
||||||
|
|||||||
Reference in New Issue
Block a user