diff --git a/OpenRa.Game/Controller.cs b/OpenRa.Game/Controller.cs index 086526860c..c92cfc9629 100644 --- a/OpenRa.Game/Controller.cs +++ b/OpenRa.Game/Controller.cs @@ -94,6 +94,8 @@ namespace OpenRa.Game } } + public float2 MousePosition { get { return dragEnd; } } + public Cursor ChooseCursor() { var c = (orderGenerator is UnitOrderGenerator) ? orderGenerator.Order(dragEnd.ToInt2(), false) diff --git a/OpenRa.Game/IOrderGenerator.cs b/OpenRa.Game/IOrderGenerator.cs index 91b4e913b9..46facb49ba 100644 --- a/OpenRa.Game/IOrderGenerator.cs +++ b/OpenRa.Game/IOrderGenerator.cs @@ -7,7 +7,6 @@ namespace OpenRa.Game interface IOrderGenerator { IEnumerable Order( int2 xy, bool lmb ); - void PrepareOverlay( int2 xy ); void Tick(); } } diff --git a/OpenRa.Game/MainWindow.cs b/OpenRa.Game/MainWindow.cs index d8a0498712..e326fc9916 100755 --- a/OpenRa.Game/MainWindow.cs +++ b/OpenRa.Game/MainWindow.cs @@ -118,10 +118,6 @@ namespace OpenRa.Game Event = MouseInputEvent.Move, Location = new int2(e.Location) }); - - if (Game.controller.orderGenerator != null) - Game.controller.orderGenerator.PrepareOverlay( - ((1 / 24f) * (new float2(e.Location) + Game.viewport.Location)).ToInt2()); } protected override void OnMouseUp(MouseEventArgs e) diff --git a/OpenRa.Game/PlaceBuilding.cs b/OpenRa.Game/PlaceBuilding.cs index e8ed8766e7..795a255870 100644 --- a/OpenRa.Game/PlaceBuilding.cs +++ b/OpenRa.Game/PlaceBuilding.cs @@ -37,18 +37,9 @@ namespace OpenRa.Game } else // rmb { - Game.world.AddFrameEndTask( _ => - { - Game.controller.orderGenerator = null; - Game.worldRenderer.uiOverlay.KillOverlay(); - } ); + Game.world.AddFrameEndTask( _ => { Game.controller.orderGenerator = null; } ); } } - - public void PrepareOverlay(int2 xy) - { - Game.worldRenderer.uiOverlay.SetCurrentOverlay(xy, Name); - } public void Tick() { } } diff --git a/OpenRa.Game/UiOverlay.cs b/OpenRa.Game/UiOverlay.cs index c1e12c2b83..6a58a4d7d3 100644 --- a/OpenRa.Game/UiOverlay.cs +++ b/OpenRa.Game/UiOverlay.cs @@ -39,11 +39,14 @@ namespace OpenRa.Game for (var j = 0; j < 128; j++) for (var i = 0; i < 128; i++) if (Game.UnitInfluence.GetUnitAt(new int2(i, j)) != null) - spriteRenderer.DrawSprite(unitDebug, Game.CellSize * new float2(i, j), 0); + spriteRenderer.DrawSprite(unitDebug, Game.CellSize * new float2(i, j), 0); + + var placeBuilding = Game.controller.orderGenerator as PlaceBuilding; + if (placeBuilding == null) return; + + var position = Game.controller.MousePosition.ToInt2(); - if (!hasOverlay) return; - - var bi = (UnitInfo.BuildingInfo)Rules.UnitInfo[name]; + var bi = (UnitInfo.BuildingInfo)Rules.UnitInfo[placeBuilding.Name]; var maxDistance = bi.Adjacent + 2; /* real-ra is weird. this is 1 GAP. */ var tooFarFromBase = !Footprint.Tiles(bi, position).Any( @@ -56,21 +59,5 @@ namespace OpenRa.Game spriteRenderer.Flush(); } - - bool hasOverlay; - int2 position; - string name; - - public void KillOverlay() - { - hasOverlay = false; - } - - public void SetCurrentOverlay(int2 cell, string name) - { - hasOverlay = true; - position = cell; - this.name = name; - } } } diff --git a/OpenRa.Game/UnitOrderGenerator.cs b/OpenRa.Game/UnitOrderGenerator.cs index 14950bed02..c861e6779c 100755 --- a/OpenRa.Game/UnitOrderGenerator.cs +++ b/OpenRa.Game/UnitOrderGenerator.cs @@ -28,7 +28,5 @@ namespace OpenRa.Game { selection.RemoveAll(a => a.IsDead); } - - public void PrepareOverlay(int2 xy) {} } } diff --git a/OpenRa.Game/UnitOrders.cs b/OpenRa.Game/UnitOrders.cs index 821f391eab..0eb187d92e 100755 --- a/OpenRa.Game/UnitOrders.cs +++ b/OpenRa.Game/UnitOrders.cs @@ -61,7 +61,6 @@ namespace OpenRa.Game Game.world.Add( new Actor( building.Name, order.TargetLocation - GameRules.Footprint.AdjustForBuildingSize( building.Name ), order.Player ) ); Game.controller.orderGenerator = null; - Game.worldRenderer.uiOverlay.KillOverlay(); order.Player.FinishProduction(Rules.UnitCategory[building.Name]); } );