Merge pull request #10203 from pchote/widelines2
Rewrite line renderer: Part 2 (remove LineRenderer plus other cleanups)
This commit is contained in:
@@ -66,6 +66,7 @@ namespace OpenRA.Mods.Common.Effects
|
||||
public readonly Color ContrailColor = Color.White;
|
||||
public readonly bool ContrailUsePlayerColor = false;
|
||||
public readonly int ContrailDelay = 1;
|
||||
public readonly WDist ContrailWidth = new WDist(64);
|
||||
|
||||
public IEffect Create(ProjectileArgs args) { return new Bullet(this, args); }
|
||||
}
|
||||
@@ -127,7 +128,7 @@ namespace OpenRA.Mods.Common.Effects
|
||||
if (info.ContrailLength > 0)
|
||||
{
|
||||
var color = info.ContrailUsePlayerColor ? ContrailRenderable.ChooseColor(args.SourceActor) : info.ContrailColor;
|
||||
contrail = new ContrailRenderable(world, color, info.ContrailLength, info.ContrailDelay, 0);
|
||||
contrail = new ContrailRenderable(world, color, info.ContrailWidth, info.ContrailLength, info.ContrailDelay, 0);
|
||||
}
|
||||
|
||||
trailPalette = info.TrailPalette;
|
||||
|
||||
@@ -23,9 +23,12 @@ namespace OpenRA.Mods.Common.Effects
|
||||
[Desc("Position relative to body")]
|
||||
public readonly WVec Offset = WVec.Zero;
|
||||
|
||||
[Desc("Measured in pixels.")]
|
||||
[Desc("Length of the trail (in ticks).")]
|
||||
public readonly int TrailLength = 25;
|
||||
|
||||
[Desc("Width of the trail.")]
|
||||
public readonly WDist TrailWidth = new WDist(64);
|
||||
|
||||
[Desc("RGB color of the contrail.")]
|
||||
public readonly Color Color = Color.White;
|
||||
|
||||
@@ -48,7 +51,7 @@ namespace OpenRA.Mods.Common.Effects
|
||||
this.info = info;
|
||||
|
||||
var color = info.UsePlayerColor ? ContrailRenderable.ChooseColor(self) : info.Color;
|
||||
trail = new ContrailRenderable(self.World, color, info.TrailLength, 0, 0);
|
||||
trail = new ContrailRenderable(self.World, color, info.TrailWidth, info.TrailLength, 0, 0);
|
||||
|
||||
body = self.Trait<BodyOrientation>();
|
||||
}
|
||||
|
||||
@@ -105,6 +105,8 @@ namespace OpenRA.Mods.Common.Effects
|
||||
|
||||
public readonly int ContrailLength = 0;
|
||||
|
||||
public readonly WDist ContrailWidth = new WDist(64);
|
||||
|
||||
public readonly Color ContrailColor = Color.White;
|
||||
|
||||
public readonly bool ContrailUsePlayerColor = false;
|
||||
@@ -209,7 +211,7 @@ namespace OpenRA.Mods.Common.Effects
|
||||
if (info.ContrailLength > 0)
|
||||
{
|
||||
var color = info.ContrailUsePlayerColor ? ContrailRenderable.ChooseColor(args.SourceActor) : info.ContrailColor;
|
||||
contrail = new ContrailRenderable(world, color, info.ContrailLength, info.ContrailDelay, 0);
|
||||
contrail = new ContrailRenderable(world, color, info.ContrailWidth, info.ContrailLength, info.ContrailDelay, 0);
|
||||
}
|
||||
|
||||
trailPalette = info.TrailPalette;
|
||||
|
||||
@@ -24,17 +24,19 @@ namespace OpenRA.Mods.Common.Graphics
|
||||
|
||||
// Store trail positions in a circular buffer
|
||||
readonly WPos[] trail;
|
||||
readonly WDist width;
|
||||
int next;
|
||||
int length;
|
||||
int skip;
|
||||
|
||||
public ContrailRenderable(World world, Color color, int length, int skip, int zOffset)
|
||||
: this(world, new WPos[length], 0, 0, skip, color, zOffset) { }
|
||||
public ContrailRenderable(World world, Color color, WDist width, int length, int skip, int zOffset)
|
||||
: this(world, new WPos[length], width, 0, 0, skip, color, zOffset) { }
|
||||
|
||||
ContrailRenderable(World world, WPos[] trail, int next, int length, int skip, Color color, int zOffset)
|
||||
ContrailRenderable(World world, WPos[] trail, WDist width, int next, int length, int skip, Color color, int zOffset)
|
||||
{
|
||||
this.world = world;
|
||||
this.trail = trail;
|
||||
this.width = width;
|
||||
this.next = next;
|
||||
this.length = length;
|
||||
this.skip = skip;
|
||||
@@ -47,9 +49,9 @@ namespace OpenRA.Mods.Common.Graphics
|
||||
public int ZOffset { get { return zOffset; } }
|
||||
public bool IsDecoration { get { return true; } }
|
||||
|
||||
public IRenderable WithPalette(PaletteReference newPalette) { return new ContrailRenderable(world, (WPos[])trail.Clone(), next, length, skip, color, zOffset); }
|
||||
public IRenderable WithZOffset(int newOffset) { return new ContrailRenderable(world, (WPos[])trail.Clone(), next, length, skip, color, newOffset); }
|
||||
public IRenderable OffsetBy(WVec vec) { return new ContrailRenderable(world, trail.Select(pos => pos + vec).ToArray(), next, length, skip, color, zOffset); }
|
||||
public IRenderable WithPalette(PaletteReference newPalette) { return new ContrailRenderable(world, (WPos[])trail.Clone(), width, next, length, skip, color, zOffset); }
|
||||
public IRenderable WithZOffset(int newOffset) { return new ContrailRenderable(world, (WPos[])trail.Clone(), width, next, length, skip, color, newOffset); }
|
||||
public IRenderable OffsetBy(WVec vec) { return new ContrailRenderable(world, trail.Select(pos => pos + vec).ToArray(), width, next, length, skip, color, zOffset); }
|
||||
public IRenderable AsDecoration() { return this; }
|
||||
|
||||
public IFinalizedRenderable PrepareRender(WorldRenderer wr) { return this; }
|
||||
@@ -59,9 +61,8 @@ namespace OpenRA.Mods.Common.Graphics
|
||||
if (length - skip < 4)
|
||||
return;
|
||||
|
||||
var wlr = Game.Renderer.WorldLineRenderer;
|
||||
var oldWidth = wlr.LineWidth;
|
||||
wlr.LineWidth = wr.Viewport.Zoom;
|
||||
var screenWidth = wr.ScreenVector(new WVec(width, WDist.Zero, WDist.Zero))[0];
|
||||
var wcr = Game.Renderer.WorldRgbaColorRenderer;
|
||||
|
||||
// Start of the first line segment is the tail of the list - don't smooth it.
|
||||
var curPos = trail[Index(next - skip - 1)];
|
||||
@@ -73,13 +74,11 @@ namespace OpenRA.Mods.Common.Graphics
|
||||
var nextColor = Exts.ColorLerp(i * 1f / (length - 4), color, Color.Transparent);
|
||||
|
||||
if (!world.FogObscures(curPos) && !world.FogObscures(nextPos))
|
||||
wlr.DrawLine(wr.ScreenPosition(curPos), wr.ScreenPosition(nextPos), curColor, nextColor);
|
||||
wcr.DrawLine(wr.ScreenPosition(curPos), wr.ScreenPosition(nextPos), screenWidth, curColor, nextColor);
|
||||
|
||||
curPos = nextPos;
|
||||
curColor = nextColor;
|
||||
}
|
||||
|
||||
wlr.LineWidth = oldWidth;
|
||||
}
|
||||
|
||||
public void RenderDebugGeometry(WorldRenderer wr) { }
|
||||
|
||||
@@ -17,18 +17,16 @@ namespace OpenRA.Mods.Common.Graphics
|
||||
public struct SelectionBoxRenderable : IRenderable, IFinalizedRenderable
|
||||
{
|
||||
readonly WPos pos;
|
||||
readonly float scale;
|
||||
readonly Rectangle visualBounds;
|
||||
readonly 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.visualBounds = visualBounds;
|
||||
this.scale = scale;
|
||||
this.color = color;
|
||||
}
|
||||
|
||||
@@ -40,30 +38,26 @@ namespace OpenRA.Mods.Common.Graphics
|
||||
|
||||
public IRenderable WithPalette(PaletteReference newPalette) { 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 IFinalizedRenderable PrepareRender(WorldRenderer wr) { return this; }
|
||||
public void Render(WorldRenderer wr)
|
||||
{
|
||||
var iz = 1 / wr.Viewport.Zoom;
|
||||
var screenPos = wr.ScreenPxPosition(pos);
|
||||
var tl = screenPos + scale * new float2(visualBounds.Left, visualBounds.Top);
|
||||
var br = screenPos + scale * new float2(visualBounds.Right, visualBounds.Bottom);
|
||||
var tl = screenPos + new float2(visualBounds.Left, visualBounds.Top);
|
||||
var br = screenPos + new float2(visualBounds.Right, visualBounds.Bottom);
|
||||
var tr = new float2(br.X, tl.Y);
|
||||
var bl = new float2(tl.X, br.Y);
|
||||
var u = new float2(4f / wr.Viewport.Zoom, 0);
|
||||
var v = new float2(0, 4f / wr.Viewport.Zoom);
|
||||
var u = new float2(4 * iz, 0);
|
||||
var v = new float2(0, 4 * iz);
|
||||
|
||||
var wlr = Game.Renderer.WorldLineRenderer;
|
||||
wlr.DrawLine(tl + u, tl, color);
|
||||
wlr.DrawLine(tl, tl + v, color);
|
||||
wlr.DrawLine(tr, tr - u, color);
|
||||
wlr.DrawLine(tr, tr + v, color);
|
||||
|
||||
wlr.DrawLine(bl, bl + u, color);
|
||||
wlr.DrawLine(bl, bl - v, color);
|
||||
wlr.DrawLine(br, br - u, color);
|
||||
wlr.DrawLine(br, br - v, color);
|
||||
var wcr = Game.Renderer.WorldRgbaColorRenderer;
|
||||
wcr.DrawLine(new[] { tl + u, tl, tl + v }, iz, color, true);
|
||||
wcr.DrawLine(new[] { tr - u, tr, tr + v }, iz, color, true);
|
||||
wcr.DrawLine(new[] { br - u, br, br - v }, iz, color, true);
|
||||
wcr.DrawLine(new[] { bl + u, bl, bl - v }, iz, color, true);
|
||||
}
|
||||
|
||||
public void RenderDebugGeometry(WorldRenderer wr) { }
|
||||
|
||||
@@ -53,7 +53,7 @@ namespace OpenRA.Mods.Common.Graphics
|
||||
{
|
||||
var size = font.Measure(text).ToFloat2();
|
||||
var offset = wr.ScreenPxPosition(pos) - 0.5f * size;
|
||||
Game.Renderer.WorldLineRenderer.DrawRect(offset, offset + size, Color.Red);
|
||||
Game.Renderer.WorldRgbaColorRenderer.DrawRect(offset, offset + size, 1 / wr.Viewport.Zoom, Color.Red);
|
||||
}
|
||||
|
||||
public Rectangle ScreenBounds(WorldRenderer wr) { return Rectangle.Empty; }
|
||||
|
||||
@@ -105,9 +105,7 @@ namespace OpenRA.Mods.Common.Graphics
|
||||
public void Render(WorldRenderer wr)
|
||||
{
|
||||
var groundPos = voxel.pos - new WVec(0, 0, wr.World.Map.DistanceAboveTerrain(voxel.pos).Length);
|
||||
|
||||
var groundZ = wr.World.Map.Grid.TileSize.Height * (groundPos.Z - voxel.pos.Z) / 1024f;
|
||||
|
||||
var pxOrigin = wr.ScreenPosition(voxel.pos);
|
||||
var shadowOrigin = pxOrigin - groundZ * (new float2(renderProxy.ShadowDirection, 1));
|
||||
|
||||
@@ -122,21 +120,27 @@ namespace OpenRA.Mods.Common.Graphics
|
||||
|
||||
public void RenderDebugGeometry(WorldRenderer wr)
|
||||
{
|
||||
var groundPos = voxel.pos - new WVec(0, 0, wr.World.Map.DistanceAboveTerrain(voxel.pos).Length);
|
||||
var groundZ = wr.World.Map.Grid.TileSize.Height * (groundPos.Z - voxel.pos.Z) / 1024f;
|
||||
var pxOrigin = wr.ScreenPosition(voxel.pos);
|
||||
var groundZ = 0.5f * (pxOrigin.Y - wr.ScreenZPosition(voxel.pos, 0));
|
||||
var shadowOrigin = pxOrigin - groundZ * (new float2(renderProxy.ShadowDirection, 1));
|
||||
var iz = 1 / wr.Viewport.Zoom;
|
||||
|
||||
// Draw sprite rect
|
||||
var offset = pxOrigin + renderProxy.Sprite.Offset - 0.5f * renderProxy.Sprite.Size;
|
||||
Game.Renderer.WorldLineRenderer.DrawRect(offset, offset + renderProxy.Sprite.Size, Color.Red);
|
||||
Game.Renderer.WorldRgbaColorRenderer.DrawRect(offset, offset + renderProxy.Sprite.Size, iz, Color.Red);
|
||||
|
||||
// Draw transformed shadow sprite rect
|
||||
var c = Color.Purple;
|
||||
var psb = renderProxy.ProjectedShadowBounds;
|
||||
Game.Renderer.WorldLineRenderer.DrawLine(shadowOrigin + psb[1], shadowOrigin + psb[3], c);
|
||||
Game.Renderer.WorldLineRenderer.DrawLine(shadowOrigin + psb[3], shadowOrigin + psb[0], c);
|
||||
Game.Renderer.WorldLineRenderer.DrawLine(shadowOrigin + psb[0], shadowOrigin + psb[2], c);
|
||||
Game.Renderer.WorldLineRenderer.DrawLine(shadowOrigin + psb[2], shadowOrigin + psb[1], c);
|
||||
|
||||
Game.Renderer.WorldRgbaColorRenderer.DrawPolygon(new[]
|
||||
{
|
||||
shadowOrigin + psb[1],
|
||||
shadowOrigin + psb[3],
|
||||
shadowOrigin + psb[0],
|
||||
shadowOrigin + psb[2]
|
||||
}, iz, c);
|
||||
|
||||
// Draw voxel bounding box
|
||||
var draw = voxel.voxels.Where(v => v.DisableFunc == null || !v.DisableFunc());
|
||||
@@ -153,15 +157,16 @@ namespace OpenRA.Mods.Common.Graphics
|
||||
wr.ScreenVectorComponents(v.OffsetFunc(), out sx, out sy, out sz);
|
||||
var pxPos = pxOrigin + new float2(sx, sy);
|
||||
var screenTransform = Util.MatrixMultiply(cameraTransform, worldTransform);
|
||||
DrawBoundsBox(pxPos, screenTransform, bounds, Color.Yellow);
|
||||
DrawBoundsBox(pxPos, screenTransform, bounds, iz, Color.Yellow);
|
||||
}
|
||||
}
|
||||
|
||||
static readonly uint[] CornerXIndex = new uint[] { 0, 0, 0, 0, 3, 3, 3, 3 };
|
||||
static readonly uint[] CornerYIndex = new uint[] { 1, 1, 4, 4, 1, 1, 4, 4 };
|
||||
static readonly uint[] CornerZIndex = new uint[] { 2, 5, 2, 5, 2, 5, 2, 5 };
|
||||
static void DrawBoundsBox(float2 pxPos, float[] transform, float[] bounds, Color c)
|
||||
static void DrawBoundsBox(float2 pxPos, float[] transform, float[] bounds, float width, Color c)
|
||||
{
|
||||
var wcr = Game.Renderer.WorldRgbaColorRenderer;
|
||||
var corners = new float2[8];
|
||||
for (var i = 0; i < 8; i++)
|
||||
{
|
||||
@@ -170,20 +175,17 @@ namespace OpenRA.Mods.Common.Graphics
|
||||
corners[i] = pxPos + new float2(screen[0], screen[1]);
|
||||
}
|
||||
|
||||
Game.Renderer.WorldLineRenderer.DrawLine(corners[0], corners[1], c);
|
||||
Game.Renderer.WorldLineRenderer.DrawLine(corners[1], corners[3], c);
|
||||
Game.Renderer.WorldLineRenderer.DrawLine(corners[3], corners[2], c);
|
||||
Game.Renderer.WorldLineRenderer.DrawLine(corners[2], corners[0], c);
|
||||
// Front face
|
||||
wcr.DrawPolygon(new[] { corners[0], corners[1], corners[3], corners[2] }, width, c);
|
||||
|
||||
Game.Renderer.WorldLineRenderer.DrawLine(corners[4], corners[5], c);
|
||||
Game.Renderer.WorldLineRenderer.DrawLine(corners[5], corners[7], c);
|
||||
Game.Renderer.WorldLineRenderer.DrawLine(corners[7], corners[6], c);
|
||||
Game.Renderer.WorldLineRenderer.DrawLine(corners[6], corners[4], c);
|
||||
// Back face
|
||||
wcr.DrawPolygon(new[] { corners[4], corners[5], corners[7], corners[6] }, width, c);
|
||||
|
||||
Game.Renderer.WorldLineRenderer.DrawLine(corners[0], corners[4], c);
|
||||
Game.Renderer.WorldLineRenderer.DrawLine(corners[1], corners[5], c);
|
||||
Game.Renderer.WorldLineRenderer.DrawLine(corners[2], corners[6], c);
|
||||
Game.Renderer.WorldLineRenderer.DrawLine(corners[3], corners[7], c);
|
||||
// Horizontal edges
|
||||
wcr.DrawLine(corners[0], corners[4], width, c);
|
||||
wcr.DrawLine(corners[1], corners[5], width, c);
|
||||
wcr.DrawLine(corners[2], corners[6], width, c);
|
||||
wcr.DrawLine(corners[3], corners[7], width, c);
|
||||
}
|
||||
|
||||
public Rectangle ScreenBounds(WorldRenderer wr)
|
||||
|
||||
@@ -52,7 +52,8 @@ namespace OpenRA.Mods.Common.Traits
|
||||
RangeCircleRenderable.DrawRangeCircle(wr, self.CenterPosition, healthInfo.Radius,
|
||||
1, Color.Red, 0, Color.Red);
|
||||
|
||||
var wlr = Game.Renderer.WorldLineRenderer;
|
||||
var wcr = Game.Renderer.WorldRgbaColorRenderer;
|
||||
var iz = 1 / wr.Viewport.Zoom;
|
||||
|
||||
if (blockInfo != null)
|
||||
{
|
||||
@@ -60,9 +61,9 @@ namespace OpenRA.Mods.Common.Traits
|
||||
var height = new WVec(0, 0, blockInfo.Height.Length);
|
||||
var ha = wr.ScreenPosition(self.CenterPosition);
|
||||
var hb = wr.ScreenPosition(self.CenterPosition + height);
|
||||
wlr.DrawLine(ha, hb, hc);
|
||||
wr.DrawTargetMarker(hc, ha);
|
||||
wr.DrawTargetMarker(hc, hb);
|
||||
wcr.DrawLine(ha, hb, iz, hc);
|
||||
TargetLineRenderable.DrawTargetMarker(wr, hc, ha);
|
||||
TargetLineRenderable.DrawTargetMarker(wr, hc, hb);
|
||||
}
|
||||
|
||||
// No armaments to draw
|
||||
@@ -85,8 +86,8 @@ namespace OpenRA.Mods.Common.Traits
|
||||
var o = wr.ScreenPosition(pos);
|
||||
var a = wr.ScreenPosition(pos + da * 224 / da.Length);
|
||||
var b = wr.ScreenPosition(pos + db * 224 / db.Length);
|
||||
wlr.DrawLine(o, a, c);
|
||||
wlr.DrawLine(o, b, c);
|
||||
wcr.DrawLine(o, a, iz, c);
|
||||
wcr.DrawLine(o, b, iz, c);
|
||||
}
|
||||
|
||||
return;
|
||||
@@ -101,8 +102,8 @@ namespace OpenRA.Mods.Common.Traits
|
||||
|
||||
var sm = wr.ScreenPosition(muzzle);
|
||||
var sd = wr.ScreenPosition(muzzle + dirOffset);
|
||||
wlr.DrawLine(sm, sd, c);
|
||||
wr.DrawTargetMarker(c, sm);
|
||||
wcr.DrawLine(sm, sd, iz, c);
|
||||
TargetLineRenderable.DrawTargetMarker(wr, c, sm);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -53,7 +53,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
|
||||
var map = wr.World.Map;
|
||||
var tileSet = wr.World.TileSet;
|
||||
var lr = Game.Renderer.WorldLineRenderer;
|
||||
var wcr = Game.Renderer.WorldRgbaColorRenderer;
|
||||
var colors = wr.World.TileSet.HeightDebugColors;
|
||||
var mouseCell = wr.Viewport.ViewToWorld(Viewport.LastMousePos).ToMPos(wr.World.Map);
|
||||
|
||||
@@ -71,22 +71,18 @@ namespace OpenRA.Mods.Common.Traits
|
||||
var color = corners.Select(c => colors[height + c.Z / 512]).ToArray();
|
||||
var pos = map.CenterOfCell(uv.ToCPos(map));
|
||||
var screen = corners.Select(c => wr.ScreenPxPosition(pos + c).ToFloat2()).ToArray();
|
||||
var width = (uv == mouseCell ? 3 : 1) / wr.Viewport.Zoom;
|
||||
|
||||
if (uv == mouseCell)
|
||||
lr.LineWidth = 3;
|
||||
|
||||
// Colors change between points, so render separately
|
||||
for (var i = 0; i < 4; i++)
|
||||
{
|
||||
var j = (i + 1) % 4;
|
||||
lr.DrawLine(screen[i], screen[j], color[i], color[j]);
|
||||
wcr.DrawLine(screen[i], screen[j], width, color[i], color[j]);
|
||||
}
|
||||
|
||||
lr.LineWidth = 1;
|
||||
}
|
||||
|
||||
// Projected cell coordinates for the current cell
|
||||
var projectedCorners = map.CellCorners[0];
|
||||
lr.LineWidth = 3;
|
||||
foreach (var puv in map.ProjectedCellsCovering(mouseCell))
|
||||
{
|
||||
var pos = map.CenterOfCell(((MPos)puv).ToCPos(map));
|
||||
@@ -94,11 +90,9 @@ namespace OpenRA.Mods.Common.Traits
|
||||
for (var i = 0; i < 4; i++)
|
||||
{
|
||||
var j = (i + 1) % 4;
|
||||
lr.DrawLine(screen[i], screen[j], Color.Navy);
|
||||
wcr.DrawLine(screen[i], screen[j], 3 / wr.Viewport.Zoom, Color.Navy);
|
||||
}
|
||||
}
|
||||
|
||||
lr.LineWidth = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -38,7 +38,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
[Desc("Particles are drawn in squares when enabled, otherwise with lines.")]
|
||||
public readonly bool UseSquares = true;
|
||||
|
||||
[Desc("Works only with squares enabled. Size min. and max. value in pixels.")]
|
||||
[Desc("Size / width of the particle in px.")]
|
||||
public readonly int[] ParticleSize = { 1, 3 };
|
||||
|
||||
[Desc("Scatters falling direction on the x-axis. Scatter min. and max. value in px/tick.")]
|
||||
@@ -294,7 +294,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
else
|
||||
{
|
||||
var tempPosTail = new float2(topLeft.X + item.PosX - currentWindXOffset, item.PosY - (item.Gravity * 2 / 3) + topLeft.Y);
|
||||
Game.Renderer.WorldLineRenderer.DrawLine(tempPos, tempPosTail, item.Color, item.TailColor);
|
||||
Game.Renderer.WorldRgbaColorRenderer.DrawLine(tempPos, tempPosTail, item.Size, item.TailColor);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2694,6 +2694,14 @@ namespace OpenRA.Mods.Common.UtilityCommands
|
||||
}
|
||||
}
|
||||
|
||||
// Added width support for line particles
|
||||
if (engineVersion < 20151220 && node.Key == "WeatherOverlay")
|
||||
{
|
||||
var useSquares = node.Value.Nodes.FirstOrDefault(n => n.Key == "UseSquares");
|
||||
if (useSquares != null && !FieldLoader.GetValue<bool>("UseSquares", useSquares.Value.Value))
|
||||
node.Value.Nodes.Add(new MiniYamlNode("ParticleSize", "1, 1"));
|
||||
}
|
||||
|
||||
UpgradeActorRules(engineVersion, ref node.Value.Nodes, node, depth + 1);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -87,6 +87,7 @@ namespace OpenRA.Mods.Common.Widgets
|
||||
|| GetAxisFont == null || GetAxisFont() == null)
|
||||
return;
|
||||
|
||||
var cr = Game.Renderer.RgbaColorRenderer;
|
||||
var rect = RenderBounds;
|
||||
var origin = new float2(rect.Left, rect.Bottom);
|
||||
|
||||
@@ -120,13 +121,13 @@ namespace OpenRA.Mods.Common.Widgets
|
||||
points = points.Reverse().Take(xAxisSize).Reverse();
|
||||
var lastX = 0;
|
||||
var lastPoint = 0f;
|
||||
Game.Renderer.LineRenderer.DrawLineStrip(
|
||||
cr.DrawLine(
|
||||
points.Select((point, x) =>
|
||||
{
|
||||
lastX = x;
|
||||
lastPoint = point;
|
||||
return origin + new float2(x * xStep, -point * scale);
|
||||
}), color);
|
||||
}).ToArray(), 1, color);
|
||||
|
||||
if (lastPoint != 0f)
|
||||
tiny.DrawText(GetValueFormat().F(lastPoint), origin + new float2(lastX * xStep, -lastPoint * scale - 2), color);
|
||||
@@ -139,7 +140,7 @@ namespace OpenRA.Mods.Common.Widgets
|
||||
// TODO: make this stuff not draw outside of the RenderBounds
|
||||
for (int n = pointStart, x = 0; n <= pointEnd; n++, x += xStep)
|
||||
{
|
||||
Game.Renderer.LineRenderer.DrawLine(origin + new float2(x, 0), origin + new float2(x, -5), Color.White);
|
||||
cr.DrawLine(origin + new float2(x, 0), origin + new float2(x, -5), 1, Color.White);
|
||||
tiny.DrawText(GetXAxisValueFormat().F(n), origin + new float2(x, 2), Color.White);
|
||||
}
|
||||
|
||||
@@ -148,16 +149,16 @@ namespace OpenRA.Mods.Common.Widgets
|
||||
for (var y = GetDisplayFirstYAxisValue() ? 0 : yStep; y <= height; y += yStep)
|
||||
{
|
||||
var yValue = y / scale;
|
||||
Game.Renderer.LineRenderer.DrawLine(origin + new float2(width - 5, -y), origin + new float2(width, -y), Color.White);
|
||||
cr.DrawLine(origin + new float2(width - 5, -y), origin + new float2(width, -y), 1, Color.White);
|
||||
tiny.DrawText(GetYAxisValueFormat().F(yValue), origin + new float2(width + 2, -y), Color.White);
|
||||
}
|
||||
|
||||
bold.DrawText(GetYAxisLabel(), origin + new float2(width + 40, -(height / 2)), Color.White);
|
||||
|
||||
Game.Renderer.LineRenderer.DrawLine(origin, origin + new float2(width, 0), Color.White);
|
||||
Game.Renderer.LineRenderer.DrawLine(origin, origin + new float2(0, -height), Color.White);
|
||||
Game.Renderer.LineRenderer.DrawLine(origin + new float2(width, 0), origin + new float2(width, -height), Color.White);
|
||||
Game.Renderer.LineRenderer.DrawLine(origin + new float2(0, -height), origin + new float2(width, -height), Color.White);
|
||||
cr.DrawLine(origin, origin + new float2(width, 0), 1, Color.White);
|
||||
cr.DrawLine(origin, origin + new float2(0, -height), 1, Color.White);
|
||||
cr.DrawLine(origin + new float2(width, 0), origin + new float2(width, -height), 1, Color.White);
|
||||
cr.DrawLine(origin + new float2(0, -height), origin + new float2(width, -height), 1, Color.White);
|
||||
}
|
||||
|
||||
public override Widget Clone()
|
||||
|
||||
@@ -19,30 +19,37 @@ namespace OpenRA.Mods.Common.Widgets
|
||||
{
|
||||
public override void Draw()
|
||||
{
|
||||
var cr = Game.Renderer.RgbaColorRenderer;
|
||||
var rect = RenderBounds;
|
||||
var origin = new float2(rect.Right, rect.Bottom);
|
||||
var basis = new float2(-rect.Width / 100, -rect.Height / 100);
|
||||
|
||||
Game.Renderer.LineRenderer.DrawLine(origin, origin + new float2(100, 0) * basis, Color.White);
|
||||
Game.Renderer.LineRenderer.DrawLine(origin + new float2(100, 0) * basis, origin + new float2(100, 100) * basis, Color.White);
|
||||
cr.DrawLine(new[]
|
||||
{
|
||||
new float2(rect.Left, rect.Top),
|
||||
new float2(rect.Left, rect.Bottom),
|
||||
new float2(rect.Right, rect.Bottom)
|
||||
}, 1, Color.White);
|
||||
|
||||
cr.DrawLine(origin + new float2(100, 0) * basis, origin + new float2(100, 100) * basis, 1, Color.White);
|
||||
|
||||
var k = 0;
|
||||
foreach (var item in PerfHistory.Items.Values)
|
||||
{
|
||||
Game.Renderer.LineRenderer.DrawLineStrip(
|
||||
item.Samples().Select((sample, i) => origin + new float2(i, (float)sample) * basis), item.C);
|
||||
cr.DrawLine(item.Samples()
|
||||
.Select((sample, i) => origin + new float2(i, (float)sample) * basis).ToArray(),
|
||||
1, item.C);
|
||||
|
||||
var u = new float2(rect.Left, rect.Top);
|
||||
|
||||
Game.Renderer.LineRenderer.DrawLine(
|
||||
cr.DrawLine(
|
||||
u + new float2(10, 10 * k + 5),
|
||||
u + new float2(12, 10 * k + 5),
|
||||
item.C);
|
||||
|
||||
Game.Renderer.LineRenderer.DrawLine(
|
||||
1, item.C);
|
||||
cr.DrawLine(
|
||||
u + new float2(10, 10 * k + 4),
|
||||
u + new float2(12, 10 * k + 4),
|
||||
item.C);
|
||||
1, item.C);
|
||||
|
||||
++k;
|
||||
}
|
||||
|
||||
@@ -307,7 +307,7 @@ namespace OpenRA.Mods.Common.Widgets
|
||||
|
||||
Game.Renderer.EnableScissor(mapRect);
|
||||
DrawRadarPings();
|
||||
Game.Renderer.LineRenderer.DrawRect(tl, br, Color.White);
|
||||
Game.Renderer.RgbaColorRenderer.DrawRect(tl, br, 1, Color.White);
|
||||
Game.Renderer.DisableScissor();
|
||||
}
|
||||
}
|
||||
@@ -317,22 +317,15 @@ namespace OpenRA.Mods.Common.Widgets
|
||||
if (radarPings == null)
|
||||
return;
|
||||
|
||||
var lr = Game.Renderer.LineRenderer;
|
||||
var oldWidth = lr.LineWidth;
|
||||
lr.LineWidth = 2;
|
||||
var cr = Game.Renderer.RgbaColorRenderer;
|
||||
|
||||
foreach (var radarPing in radarPings.Pings.Where(e => e.IsVisible()))
|
||||
{
|
||||
var c = radarPing.Color;
|
||||
var pingCell = world.Map.CellContaining(radarPing.Position);
|
||||
var points = radarPing.Points(CellToMinimapPixel(pingCell)).ToArray();
|
||||
|
||||
lr.DrawLine(points[0], points[1], c);
|
||||
lr.DrawLine(points[1], points[2], c);
|
||||
lr.DrawLine(points[2], points[0], c);
|
||||
Game.Renderer.RgbaColorRenderer.DrawPolygon(points, 2, c);
|
||||
}
|
||||
|
||||
lr.LineWidth = oldWidth;
|
||||
}
|
||||
|
||||
public override void Tick()
|
||||
|
||||
@@ -92,7 +92,7 @@ namespace OpenRA.Mods.Common.Widgets
|
||||
top.Y -= 1;
|
||||
}
|
||||
|
||||
Game.Renderer.LineRenderer.DrawLine(bottom, top, color);
|
||||
Game.Renderer.RgbaColorRenderer.DrawLine(bottom, top, 1, color);
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -124,7 +124,7 @@ namespace OpenRA.Mods.Common.Widgets
|
||||
right.X -= 1;
|
||||
}
|
||||
|
||||
Game.Renderer.LineRenderer.DrawLine(left, right, color);
|
||||
Game.Renderer.RgbaColorRenderer.DrawLine(left, right, 1, color);
|
||||
}
|
||||
}
|
||||
else
|
||||
|
||||
Reference in New Issue
Block a user