Make all range circles fully configurable.
This commit is contained in:
committed by
Paul Chote
parent
214aa64ce3
commit
14fc0254c6
@@ -23,10 +23,12 @@ namespace OpenRA.Mods.Common.Graphics
|
||||
readonly WAngle trailSeparation;
|
||||
readonly WAngle trailAngle;
|
||||
readonly Color color;
|
||||
readonly Color contrastColor;
|
||||
readonly float width;
|
||||
readonly Color borderColor;
|
||||
readonly float borderWidth;
|
||||
|
||||
public DetectionCircleAnnotationRenderable(WPos centerPosition, WDist radius, int zOffset,
|
||||
int lineTrails, WAngle trailSeparation, WAngle trailAngle, Color color, Color contrastColor)
|
||||
int lineTrails, WAngle trailSeparation, WAngle trailAngle, Color color, float width, Color borderColor, float borderWidth)
|
||||
{
|
||||
this.centerPosition = centerPosition;
|
||||
this.radius = radius;
|
||||
@@ -35,7 +37,9 @@ namespace OpenRA.Mods.Common.Graphics
|
||||
this.trailSeparation = trailSeparation;
|
||||
this.trailAngle = trailAngle;
|
||||
this.color = color;
|
||||
this.contrastColor = contrastColor;
|
||||
this.width = width;
|
||||
this.borderColor = borderColor;
|
||||
this.borderWidth = borderWidth;
|
||||
}
|
||||
|
||||
public WPos Pos { get { return centerPosition; } }
|
||||
@@ -46,19 +50,19 @@ namespace OpenRA.Mods.Common.Graphics
|
||||
public IRenderable WithPalette(PaletteReference newPalette)
|
||||
{
|
||||
return new DetectionCircleAnnotationRenderable(centerPosition, radius, zOffset,
|
||||
trailCount, trailSeparation, trailAngle, color, contrastColor);
|
||||
trailCount, trailSeparation, trailAngle, color, width, borderColor, borderWidth);
|
||||
}
|
||||
|
||||
public IRenderable WithZOffset(int newOffset)
|
||||
{
|
||||
return new DetectionCircleAnnotationRenderable(centerPosition, radius, newOffset,
|
||||
trailCount, trailSeparation, trailAngle, color, contrastColor);
|
||||
trailCount, trailSeparation, trailAngle, color, width, borderColor, borderWidth);
|
||||
}
|
||||
|
||||
public IRenderable OffsetBy(WVec vec)
|
||||
{
|
||||
return new DetectionCircleAnnotationRenderable(centerPosition + vec, radius, zOffset,
|
||||
trailCount, trailSeparation, trailAngle, color, contrastColor);
|
||||
trailCount, trailSeparation, trailAngle, color, width, borderColor, borderWidth);
|
||||
}
|
||||
|
||||
public IRenderable AsDecoration() { return this; }
|
||||
@@ -75,11 +79,11 @@ namespace OpenRA.Mods.Common.Graphics
|
||||
var length = radius.Length * new WVec(angle.Cos(), angle.Sin(), 0) / 1024;
|
||||
var end = wr.Viewport.WorldToViewPx(wr.Screen3DPosition(centerPosition + length));
|
||||
var alpha = color.A - i * color.A / trailCount;
|
||||
cr.DrawLine(center, end, 3, Color.FromArgb(alpha, contrastColor));
|
||||
cr.DrawLine(center, end, 1, Color.FromArgb(alpha, color));
|
||||
cr.DrawLine(center, end, borderWidth, Color.FromArgb(alpha, borderColor));
|
||||
cr.DrawLine(center, end, width, Color.FromArgb(alpha, color));
|
||||
}
|
||||
|
||||
RangeCircleAnnotationRenderable.DrawRangeCircle(wr, centerPosition, radius, 1, color, 3, contrastColor);
|
||||
RangeCircleAnnotationRenderable.DrawRangeCircle(wr, centerPosition, radius, width, color, borderWidth, borderColor);
|
||||
}
|
||||
|
||||
public void RenderDebugGeometry(WorldRenderer wr) { }
|
||||
|
||||
@@ -24,15 +24,19 @@ namespace OpenRA.Mods.Common.Graphics
|
||||
readonly WDist radius;
|
||||
readonly int zOffset;
|
||||
readonly Color color;
|
||||
readonly Color contrastColor;
|
||||
readonly float width;
|
||||
readonly Color borderColor;
|
||||
readonly float borderWidth;
|
||||
|
||||
public RangeCircleAnnotationRenderable(WPos centerPosition, WDist radius, int zOffset, Color color, Color contrastColor)
|
||||
public RangeCircleAnnotationRenderable(WPos centerPosition, WDist radius, int zOffset, Color color, float width, Color borderColor, float borderWidth)
|
||||
{
|
||||
this.centerPosition = centerPosition;
|
||||
this.radius = radius;
|
||||
this.zOffset = zOffset;
|
||||
this.color = color;
|
||||
this.contrastColor = contrastColor;
|
||||
this.width = width;
|
||||
this.borderColor = borderColor;
|
||||
this.borderWidth = borderWidth;
|
||||
}
|
||||
|
||||
public WPos Pos { get { return centerPosition; } }
|
||||
@@ -40,19 +44,19 @@ namespace OpenRA.Mods.Common.Graphics
|
||||
public int ZOffset { get { return zOffset; } }
|
||||
public bool IsDecoration { get { return true; } }
|
||||
|
||||
public IRenderable WithPalette(PaletteReference newPalette) { return new RangeCircleAnnotationRenderable(centerPosition, radius, zOffset, color, contrastColor); }
|
||||
public IRenderable WithZOffset(int newOffset) { return new RangeCircleAnnotationRenderable(centerPosition, radius, newOffset, color, contrastColor); }
|
||||
public IRenderable OffsetBy(WVec vec) { return new RangeCircleAnnotationRenderable(centerPosition + vec, radius, zOffset, color, contrastColor); }
|
||||
public IRenderable WithPalette(PaletteReference newPalette) { return new RangeCircleAnnotationRenderable(centerPosition, radius, zOffset, color, width, borderColor, borderWidth); }
|
||||
public IRenderable WithZOffset(int newOffset) { return new RangeCircleAnnotationRenderable(centerPosition, radius, newOffset, color, width, borderColor, borderWidth); }
|
||||
public IRenderable OffsetBy(WVec vec) { return new RangeCircleAnnotationRenderable(centerPosition + vec, radius, zOffset, color, width, borderColor, borderWidth); }
|
||||
public IRenderable AsDecoration() { return this; }
|
||||
|
||||
public IFinalizedRenderable PrepareRender(WorldRenderer wr) { return this; }
|
||||
public void Render(WorldRenderer wr)
|
||||
{
|
||||
DrawRangeCircle(wr, centerPosition, radius, 1, color, 3, contrastColor);
|
||||
DrawRangeCircle(wr, centerPosition, radius, width, color, borderWidth, borderColor);
|
||||
}
|
||||
|
||||
public static void DrawRangeCircle(WorldRenderer wr, WPos centerPosition, WDist radius,
|
||||
float width, Color color, float contrastWidth, Color contrastColor)
|
||||
float width, Color color, float borderWidth, Color borderColor)
|
||||
{
|
||||
var cr = Game.Renderer.RgbaColorRenderer;
|
||||
var offset = new WVec(radius.Length, 0, 0);
|
||||
@@ -61,8 +65,8 @@ namespace OpenRA.Mods.Common.Graphics
|
||||
var a = wr.Viewport.WorldToViewPx(wr.ScreenPosition(centerPosition + offset.Rotate(ref RangeCircleStartRotations[i])));
|
||||
var b = wr.Viewport.WorldToViewPx(wr.ScreenPosition(centerPosition + offset.Rotate(ref RangeCircleEndRotations[i])));
|
||||
|
||||
if (contrastWidth > 0)
|
||||
cr.DrawLine(a, b, contrastWidth, contrastColor);
|
||||
if (borderWidth > 0)
|
||||
cr.DrawLine(a, b, borderWidth, borderColor);
|
||||
|
||||
if (width > 0)
|
||||
cr.DrawLine(a, b, width, color);
|
||||
|
||||
Reference in New Issue
Block a user