diff --git a/OpenRA.Game/Graphics/WorldRenderer.cs b/OpenRA.Game/Graphics/WorldRenderer.cs index 5360073c0d..06df9af6a6 100644 --- a/OpenRA.Game/Graphics/WorldRenderer.cs +++ b/OpenRA.Game/Graphics/WorldRenderer.cs @@ -123,28 +123,35 @@ namespace OpenRA.Graphics Game.Renderer.LineRenderer.DrawLine(a + b, a + b + c, color, color); Game.Renderer.LineRenderer.DrawLine(a + b + c, a + c, color, color); Game.Renderer.LineRenderer.DrawLine(a, a + c, color, color); + } + + public void DrawSelectionBox(Actor selectedUnit, Color c) + { + var bounds = selectedUnit.GetBounds(false); + + var xy = new float2(bounds.Left, bounds.Top); + var Xy = new float2(bounds.Right, bounds.Top); + var xY = new float2(bounds.Left, bounds.Bottom); + var XY = new float2(bounds.Right, bounds.Bottom); + + Game.Renderer.LineRenderer.DrawLine(xy, xy + new float2(4, 0), c, c); + Game.Renderer.LineRenderer.DrawLine(xy, xy + new float2(0, 4), c, c); + Game.Renderer.LineRenderer.DrawLine(Xy, Xy + new float2(-4, 0), c, c); + Game.Renderer.LineRenderer.DrawLine(Xy, Xy + new float2(0, 4), c, c); + + Game.Renderer.LineRenderer.DrawLine(xY, xY + new float2(4, 0), c, c); + Game.Renderer.LineRenderer.DrawLine(xY, xY + new float2(0, -4), c, c); + Game.Renderer.LineRenderer.DrawLine(XY, XY + new float2(-4, 0), c, c); + Game.Renderer.LineRenderer.DrawLine(XY, XY + new float2(0, -4), c, c); + } + + public void DrawRollover(Actor unit) + { + var selectable = unit.TraitOrDefault(); + if (selectable != null) + selectable.DrawRollover(this, unit); } - public void DrawSelectionBox(Actor selectedUnit, Color c) - { - var bounds = selectedUnit.GetBounds(false); - - var xy = new float2(bounds.Left, bounds.Top); - var Xy = new float2(bounds.Right, bounds.Top); - var xY = new float2(bounds.Left, bounds.Bottom); - var XY = new float2(bounds.Right, bounds.Bottom); - - Game.Renderer.LineRenderer.DrawLine(xy, xy + new float2(4, 0), c, c); - Game.Renderer.LineRenderer.DrawLine(xy, xy + new float2(0, 4), c, c); - Game.Renderer.LineRenderer.DrawLine(Xy, Xy + new float2(-4, 0), c, c); - Game.Renderer.LineRenderer.DrawLine(Xy, Xy + new float2(0, 4), c, c); - - Game.Renderer.LineRenderer.DrawLine(xY, xY + new float2(4, 0), c, c); - Game.Renderer.LineRenderer.DrawLine(xY, xY + new float2(0, -4), c, c); - Game.Renderer.LineRenderer.DrawLine(XY, XY + new float2(-4, 0), c, c); - Game.Renderer.LineRenderer.DrawLine(XY, XY + new float2(0, -4), c, c); - } - public void DrawLocus(Color c, int2[] cells) { var dict = cells.ToDictionary(a => a, a => 0); diff --git a/OpenRA.Game/Traits/Selectable.cs b/OpenRA.Game/Traits/Selectable.cs index 6f88851916..af4cf50cdd 100644 --- a/OpenRA.Game/Traits/Selectable.cs +++ b/OpenRA.Game/Traits/Selectable.cs @@ -50,7 +50,24 @@ namespace OpenRA.Traits DrawPips(wr, self, xY); DrawTags(wr, self, new float2(.5f * (bounds.Left + bounds.Right), bounds.Top)); DrawUnitPath(self); + DrawExtraBars(self, xy, Xy); + } + public void DrawRollover(WorldRenderer wr, Actor self) + { + var bounds = self.GetBounds(false); + + var xy = new float2(bounds.Left, bounds.Top); + var Xy = new float2(bounds.Right, bounds.Top); + var xY = new float2(bounds.Left, bounds.Bottom); + var XY = new float2(bounds.Right, bounds.Bottom); + + DrawHealthBar(self, xy, Xy); + DrawExtraBars(self, xy, Xy); + } + + void DrawExtraBars(Actor self, float2 xy, float2 Xy) + { foreach (var extraBar in self.TraitsImplementing()) { var value = extraBar.GetValue(); @@ -60,7 +77,7 @@ namespace OpenRA.Traits Xy.Y += 4; DrawSelectionBar(self, xy, Xy, extraBar.GetValue(), extraBar.GetColor()); } - } + } } void DrawSelectionBox(Actor self, float2 xy, float2 Xy, float2 xY, float2 XY, Color c) diff --git a/OpenRA.Game/Widgets/WorldInteractionControllerWidget.cs b/OpenRA.Game/Widgets/WorldInteractionControllerWidget.cs index 76dc6cc834..9a8641b6d4 100644 --- a/OpenRA.Game/Widgets/WorldInteractionControllerWidget.cs +++ b/OpenRA.Game/Widgets/WorldInteractionControllerWidget.cs @@ -31,6 +31,9 @@ namespace OpenRA.Widgets public override void DrawInner() { + foreach( var u in SelectActorsInBox(world, Game.CellSize * dragStart, Game.CellSize * dragStart )) + worldRenderer.DrawRollover( u ); + var selbox = SelectionBox; if (selbox == null) return;