Move DrawTargetMarker to TargetLineRenderable.

This commit is contained in:
Paul Chote
2015-12-10 16:01:25 +00:00
parent c7a9d024b0
commit 0f1fcdaca4
3 changed files with 21 additions and 19 deletions

View File

@@ -48,13 +48,29 @@ namespace OpenRA.Graphics
foreach (var b in waypoints.Skip(1).Select(pos => wr.ScreenPxPosition(pos))) foreach (var b in waypoints.Skip(1).Select(pos => wr.ScreenPxPosition(pos)))
{ {
Game.Renderer.WorldLineRenderer.DrawLine(a, b, color); Game.Renderer.WorldLineRenderer.DrawLine(a, b, color);
wr.DrawTargetMarker(color, b); DrawTargetMarker(wr, color, b);
a = b; a = b;
} }
wr.DrawTargetMarker(color, first); DrawTargetMarker(wr, color, first);
} }
public static void DrawTargetMarker(WorldRenderer wr, Color c, float2 location)
{
var miz = -1 / wr.Viewport.Zoom;
var tl = new float2(miz, miz);
var br = -tl;
var bl = new float2(tl.X, br.Y);
var tr = new float2(br.X, tl.Y);
var wlr = Game.Renderer.WorldLineRenderer;
wlr.DrawLine(location + tl, location + tr, c);
wlr.DrawLine(location + tr, location + br, c);
wlr.DrawLine(location + br, location + bl, c);
wlr.DrawLine(location + bl, location + tl, c);
}
public void RenderDebugGeometry(WorldRenderer wr) { } public void RenderDebugGeometry(WorldRenderer wr) { }
public Rectangle ScreenBounds(WorldRenderer wr) { return Rectangle.Empty; } public Rectangle ScreenBounds(WorldRenderer wr) { return Rectangle.Empty; }
} }

View File

@@ -210,20 +210,6 @@ namespace OpenRA.Graphics
new SelectionBarsRenderable(unit, true, true).Render(this); new SelectionBarsRenderable(unit, true, true).Render(this);
} }
public void DrawTargetMarker(Color c, float2 location)
{
var tl = new float2(-1 / Viewport.Zoom, -1 / Viewport.Zoom);
var br = new float2(1 / Viewport.Zoom, 1 / Viewport.Zoom);
var bl = new float2(tl.X, br.Y);
var tr = new float2(br.X, tl.Y);
var wlr = Game.Renderer.WorldLineRenderer;
wlr.DrawLine(location + tl, location + tr, c);
wlr.DrawLine(location + tr, location + br, c);
wlr.DrawLine(location + br, location + bl, c);
wlr.DrawLine(location + bl, location + tl, c);
}
public void RefreshPalette() public void RefreshPalette()
{ {
palette.ApplyModifiers(World.WorldActor.TraitsImplementing<IPaletteModifier>()); palette.ApplyModifiers(World.WorldActor.TraitsImplementing<IPaletteModifier>());

View File

@@ -61,8 +61,8 @@ namespace OpenRA.Mods.Common.Traits
var ha = wr.ScreenPosition(self.CenterPosition); var ha = wr.ScreenPosition(self.CenterPosition);
var hb = wr.ScreenPosition(self.CenterPosition + height); var hb = wr.ScreenPosition(self.CenterPosition + height);
wlr.DrawLine(ha, hb, hc); wlr.DrawLine(ha, hb, hc);
wr.DrawTargetMarker(hc, ha); TargetLineRenderable.DrawTargetMarker(wr, hc, ha);
wr.DrawTargetMarker(hc, hb); TargetLineRenderable.DrawTargetMarker(wr, hc, hb);
} }
// No armaments to draw // No armaments to draw
@@ -102,7 +102,7 @@ namespace OpenRA.Mods.Common.Traits
var sm = wr.ScreenPosition(muzzle); var sm = wr.ScreenPosition(muzzle);
var sd = wr.ScreenPosition(muzzle + dirOffset); var sd = wr.ScreenPosition(muzzle + dirOffset);
wlr.DrawLine(sm, sd, c); wlr.DrawLine(sm, sd, c);
wr.DrawTargetMarker(c, sm); TargetLineRenderable.DrawTargetMarker(wr, c, sm);
} }
} }
} }