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()
{
var c = (orderGenerator is UnitOrderGenerator) ? orderGenerator.Order(dragEnd.ToInt2(), false)

View File

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

View File

@@ -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)

View File

@@ -37,19 +37,10 @@ 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() { }
}
}

View File

@@ -41,9 +41,12 @@ namespace OpenRa.Game
if (Game.UnitInfluence.GetUnitAt(new int2(i, j)) != null)
spriteRenderer.DrawSprite(unitDebug, Game.CellSize * new float2(i, j), 0);
if (!hasOverlay) return;
var placeBuilding = Game.controller.orderGenerator as PlaceBuilding;
if (placeBuilding == null) return;
var bi = (UnitInfo.BuildingInfo)Rules.UnitInfo[name];
var position = Game.controller.MousePosition.ToInt2();
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;
}
}
}

View File

@@ -28,7 +28,5 @@ namespace OpenRa.Game
{
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.controller.orderGenerator = null;
Game.worldRenderer.uiOverlay.KillOverlay();
order.Player.FinishProduction(Rules.UnitCategory[building.Name]);
} );