killed PrepareOverlay

This commit is contained in:
Chris Forbes
2009-10-31 23:24:39 +13:00
parent a3dba77f99
commit dbef9e4a45
7 changed files with 10 additions and 38 deletions

View File

@@ -94,6 +94,8 @@ namespace OpenRa.Game
} }
} }
public float2 MousePosition { get { return dragEnd; } }
public Cursor ChooseCursor() public Cursor ChooseCursor()
{ {
var c = (orderGenerator is UnitOrderGenerator) ? orderGenerator.Order(dragEnd.ToInt2(), false) var c = (orderGenerator is UnitOrderGenerator) ? orderGenerator.Order(dragEnd.ToInt2(), false)

View File

@@ -7,7 +7,6 @@ namespace OpenRa.Game
interface IOrderGenerator interface IOrderGenerator
{ {
IEnumerable<Order> Order( int2 xy, bool lmb ); IEnumerable<Order> Order( int2 xy, bool lmb );
void PrepareOverlay( int2 xy );
void Tick(); void Tick();
} }
} }

View File

@@ -118,10 +118,6 @@ namespace OpenRa.Game
Event = MouseInputEvent.Move, Event = MouseInputEvent.Move,
Location = new int2(e.Location) 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) protected override void OnMouseUp(MouseEventArgs e)

View File

@@ -37,18 +37,9 @@ namespace OpenRa.Game
} }
else // rmb else // rmb
{ {
Game.world.AddFrameEndTask( _ => Game.world.AddFrameEndTask( _ => { Game.controller.orderGenerator = null; } );
{
Game.controller.orderGenerator = null;
Game.worldRenderer.uiOverlay.KillOverlay();
} );
} }
} }
public void PrepareOverlay(int2 xy)
{
Game.worldRenderer.uiOverlay.SetCurrentOverlay(xy, Name);
}
public void Tick() { } public void Tick() { }
} }

View File

@@ -39,11 +39,14 @@ namespace OpenRa.Game
for (var j = 0; j < 128; j++) for (var j = 0; j < 128; j++)
for (var i = 0; i < 128; i++) for (var i = 0; i < 128; i++)
if (Game.UnitInfluence.GetUnitAt(new int2(i, j)) != null) 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[placeBuilding.Name];
var bi = (UnitInfo.BuildingInfo)Rules.UnitInfo[name];
var maxDistance = bi.Adjacent + 2; /* real-ra is weird. this is 1 GAP. */ var maxDistance = bi.Adjacent + 2; /* real-ra is weird. this is 1 GAP. */
var tooFarFromBase = !Footprint.Tiles(bi, position).Any( var tooFarFromBase = !Footprint.Tiles(bi, position).Any(
@@ -56,21 +59,5 @@ namespace OpenRa.Game
spriteRenderer.Flush(); 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;
}
} }
} }

View File

@@ -28,7 +28,5 @@ namespace OpenRa.Game
{ {
selection.RemoveAll(a => a.IsDead); selection.RemoveAll(a => a.IsDead);
} }
public void PrepareOverlay(int2 xy) {}
} }
} }

View File

@@ -61,7 +61,6 @@ namespace OpenRa.Game
Game.world.Add( new Actor( building.Name, order.TargetLocation - GameRules.Footprint.AdjustForBuildingSize( building.Name ), order.Player ) ); Game.world.Add( new Actor( building.Name, order.TargetLocation - GameRules.Footprint.AdjustForBuildingSize( building.Name ), order.Player ) );
Game.controller.orderGenerator = null; Game.controller.orderGenerator = null;
Game.worldRenderer.uiOverlay.KillOverlay();
order.Player.FinishProduction(Rules.UnitCategory[building.Name]); order.Player.FinishProduction(Rules.UnitCategory[building.Name]);
} ); } );