On orders, the mouse button is now considered part on issuing the order, not resolving it.

This commit is contained in:
Bob
2009-10-24 19:42:54 +13:00
parent d25bd8550a
commit 78c9ae53df
11 changed files with 85 additions and 92 deletions

View File

@@ -20,11 +20,11 @@ namespace OpenRa.Game
if (mi.Button == MouseButtons.Left && mi.Event == MouseInputEvent.Down)
{
if (!(orderGenerator is PlaceBuilding))
dragStart = dragEnd = xy;
if (orderGenerator != null)
foreach (var order in orderGenerator.Order(xy.ToInt2()))
order.Apply(true);
dragStart = dragEnd = xy;
if (orderGenerator != null)
foreach (var order in orderGenerator.Order(xy.ToInt2(), true))
order.Apply();
}
if (mi.Button == MouseButtons.Left && mi.Event == MouseInputEvent.Move)
@@ -40,53 +40,53 @@ namespace OpenRa.Game
else
orderGenerator = new UnitOrderGenerator(
Game.SelectUnitOrBuilding( Game.CellSize * xy ) );
}
}
dragStart = dragEnd = xy;
}
if (mi.Button == MouseButtons.None && mi.Event == MouseInputEvent.Move)
{
/* update the cursor to reflect the thing under us - note this
* needs to also happen when the *thing* changes, so per-frame hook */
* needs to also happen when the *thing* changes, so per-frame hook */
dragStart = dragEnd = xy;
}
if( mi.Button == MouseButtons.Right && mi.Event == MouseInputEvent.Down )
if( orderGenerator != null )
foreach( var order in orderGenerator.Order( xy.ToInt2() ) )
order.Apply( false );
foreach( var order in orderGenerator.Order( xy.ToInt2(), false ) )
order.Apply();
}
public Pair<float2, float2>? SelectionBox
{
get
{
if (dragStart == dragEnd) return null;
return Pair.New(Game.CellSize * dragStart, Game.CellSize * dragEnd);
{
get
{
if (dragStart == dragEnd) return null;
return Pair.New(Game.CellSize * dragStart, Game.CellSize * dragEnd);
}
}
public Cursor ChooseCursor()
{
var uog = orderGenerator as UnitOrderGenerator;
if (uog != null)
uog.selection.RemoveAll(a => a.IsDead);
if (uog != null && uog.selection.Count > 0
&& uog.selection.Any(a => a.traits.Contains<Traits.Mobile>())
&& uog.selection.All( a => a.Owner == Game.LocalPlayer ))
{
if (!Game.IsCellBuildable(dragEnd.ToInt2(), UnitMovementType.Wheel))
return Cursor.MoveBlocked; /* todo: handle non-wheel movement behavior */
return Cursor.Move;
}
if (Game.SelectUnitOrBuilding(Game.CellSize * dragEnd).Any())
return Cursor.Select;
return Cursor.Default;
}
public Cursor ChooseCursor()
{
var uog = orderGenerator as UnitOrderGenerator;
if (uog != null)
uog.selection.RemoveAll(a => a.IsDead);
if (uog != null && uog.selection.Count > 0
&& uog.selection.Any(a => a.traits.Contains<Traits.Mobile>())
&& uog.selection.All( a => a.Owner == Game.LocalPlayer ))
{
if (!Game.IsCellBuildable(dragEnd.ToInt2(), UnitMovementType.Wheel))
return Cursor.MoveBlocked; /* todo: handle non-wheel movement behavior */
return Cursor.Move;
}
if (Game.SelectUnitOrBuilding(Game.CellSize * dragEnd).Any())
return Cursor.Select;
return Cursor.Default;
}
}
}