Fixed building placement input behaviour.
This commit is contained in:
@@ -27,7 +27,11 @@ namespace OpenRa.Game
|
|||||||
if (mi.Button == MouseButtons.Left && mi.Event == MouseInputEvent.Down)
|
if (mi.Button == MouseButtons.Left && mi.Event == MouseInputEvent.Down)
|
||||||
{
|
{
|
||||||
if (!(orderGenerator is PlaceBuilding))
|
if (!(orderGenerator is PlaceBuilding))
|
||||||
dragStart = dragEnd = xy;
|
dragStart = dragEnd = xy;
|
||||||
|
|
||||||
|
if (orderGenerator != null)
|
||||||
|
foreach (var order in orderGenerator.Order(game, xy.ToInt2()))
|
||||||
|
order.Apply(game, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mi.Button == MouseButtons.Left && mi.Event == MouseInputEvent.Move)
|
if (mi.Button == MouseButtons.Left && mi.Event == MouseInputEvent.Move)
|
||||||
@@ -55,7 +59,7 @@ namespace OpenRa.Game
|
|||||||
if( mi.Button == MouseButtons.Right && mi.Event == MouseInputEvent.Down )
|
if( mi.Button == MouseButtons.Right && mi.Event == MouseInputEvent.Down )
|
||||||
if( orderGenerator != null )
|
if( orderGenerator != null )
|
||||||
foreach( var order in orderGenerator.Order( game, xy.ToInt2() ) )
|
foreach( var order in orderGenerator.Order( game, xy.ToInt2() ) )
|
||||||
order.Apply( game );
|
order.Apply( game, false );
|
||||||
}
|
}
|
||||||
|
|
||||||
public Pair<float2, float2>? SelectionBox
|
public Pair<float2, float2>? SelectionBox
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ namespace OpenRa.Game
|
|||||||
{
|
{
|
||||||
abstract class Order
|
abstract class Order
|
||||||
{
|
{
|
||||||
public abstract void Apply( Game game );
|
public abstract void Apply( Game game, bool leftMButton );
|
||||||
}
|
}
|
||||||
|
|
||||||
class MoveOrder : Order
|
class MoveOrder : Order
|
||||||
@@ -20,8 +20,9 @@ namespace OpenRa.Game
|
|||||||
this.Destination = destination;
|
this.Destination = destination;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Apply( Game game )
|
public override void Apply( Game game, bool leftMouseButton )
|
||||||
{
|
{
|
||||||
|
if (leftMouseButton) return;
|
||||||
Unit.traits.Get<Traits.Mobile>().destination = Destination;
|
Unit.traits.Get<Traits.Mobile>().destination = Destination;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -37,8 +38,9 @@ namespace OpenRa.Game
|
|||||||
Location = location;
|
Location = location;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Apply( Game game )
|
public override void Apply( Game game, bool leftMouseButton )
|
||||||
{
|
{
|
||||||
|
if (leftMouseButton) return;
|
||||||
Unit.traits.Get<Traits.McvDeploy>().DeployLocation = Location;
|
Unit.traits.Get<Traits.McvDeploy>().DeployLocation = Location;
|
||||||
var mobile = Unit.traits.Get<Traits.Mobile>();
|
var mobile = Unit.traits.Get<Traits.Mobile>();
|
||||||
mobile.destination = mobile.toCell;
|
mobile.destination = mobile.toCell;
|
||||||
|
|||||||
@@ -207,16 +207,27 @@ namespace OpenRa.Game
|
|||||||
this.xy = xy;
|
this.xy = xy;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Apply(Game game)
|
public override void Apply(Game game, bool leftMouseButton)
|
||||||
{
|
{
|
||||||
game.world.AddFrameEndTask(_ =>
|
if (leftMouseButton)
|
||||||
{
|
{
|
||||||
Log.Write( "Player \"{0}\" builds {1}", building.Owner.PlayerName, building.Name );
|
game.world.AddFrameEndTask(_ =>
|
||||||
game.world.Add( new Actor( building.Name, xy, building.Owner ) );
|
{
|
||||||
|
Log.Write("Player \"{0}\" builds {1}", building.Owner.PlayerName, building.Name);
|
||||||
game.controller.orderGenerator = null;
|
game.world.Add(new Actor(building.Name, xy, building.Owner));
|
||||||
game.worldRenderer.uiOverlay.KillOverlay();
|
|
||||||
});
|
game.controller.orderGenerator = null;
|
||||||
|
game.worldRenderer.uiOverlay.KillOverlay();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
game.world.AddFrameEndTask(_ =>
|
||||||
|
{
|
||||||
|
game.controller.orderGenerator = null;
|
||||||
|
game.worldRenderer.uiOverlay.KillOverlay();
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user