#93 shift selection
This commit is contained in:
@@ -93,8 +93,14 @@ namespace OpenRa.Game
|
|||||||
{
|
{
|
||||||
if (!(orderGenerator is PlaceBuilding))
|
if (!(orderGenerator is PlaceBuilding))
|
||||||
{
|
{
|
||||||
orderGenerator = new UnitOrderGenerator(
|
var newSelection = Game.SelectActorsInBox(Game.CellSize * dragStart, Game.CellSize * xy);
|
||||||
Game.SelectActorsInBox(Game.CellSize * dragStart, Game.CellSize * xy));
|
var oldSelection = (orderGenerator is UnitOrderGenerator)
|
||||||
|
? (orderGenerator as UnitOrderGenerator).selection : new Actor[] { }.AsEnumerable();
|
||||||
|
|
||||||
|
if (dragStart == xy)
|
||||||
|
orderGenerator = new UnitOrderGenerator(mi.Modifiers.HasModifier(Keys.Shift) ? oldSelection.SymmetricDifference(newSelection) : newSelection);
|
||||||
|
else
|
||||||
|
orderGenerator = new UnitOrderGenerator(mi.Modifiers.HasModifier(Keys.Shift) ? oldSelection.Union(newSelection) : newSelection);
|
||||||
|
|
||||||
var voicedUnit = ((UnitOrderGenerator)orderGenerator).selection
|
var voicedUnit = ((UnitOrderGenerator)orderGenerator).selection
|
||||||
.Where(a => a.traits.Contains<Unit>()
|
.Where(a => a.traits.Contains<Unit>()
|
||||||
|
|||||||
@@ -1,4 +1,8 @@
|
|||||||
|
|
||||||
|
using System.Windows.Forms;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
|
||||||
namespace OpenRa.Game
|
namespace OpenRa.Game
|
||||||
{
|
{
|
||||||
static class Exts
|
static class Exts
|
||||||
@@ -7,5 +11,16 @@ namespace OpenRa.Game
|
|||||||
{
|
{
|
||||||
return string.Format(fmt, args);
|
return string.Format(fmt, args);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static bool HasModifier(this Keys k, Keys mod)
|
||||||
|
{
|
||||||
|
return (k & mod) == mod;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static IEnumerable<T> SymmetricDifference<T>(this IEnumerable<T> xs, IEnumerable<T> ys)
|
||||||
|
{
|
||||||
|
// this is probably a shockingly-slow way to do this, but it's concise.
|
||||||
|
return xs.Except(ys).Concat(ys.Except(xs));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -88,7 +88,8 @@ namespace OpenRa.Game
|
|||||||
{
|
{
|
||||||
Button = e.Button,
|
Button = e.Button,
|
||||||
Event = MouseInputEvent.Down,
|
Event = MouseInputEvent.Down,
|
||||||
Location = new int2(e.Location)
|
Location = new int2(e.Location),
|
||||||
|
Modifiers = ModifierKeys,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -107,7 +108,8 @@ namespace OpenRa.Game
|
|||||||
{
|
{
|
||||||
Button = e.Button,
|
Button = e.Button,
|
||||||
Event = MouseInputEvent.Move,
|
Event = MouseInputEvent.Move,
|
||||||
Location = new int2(e.Location)
|
Location = new int2(e.Location),
|
||||||
|
Modifiers = ModifierKeys,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -119,7 +121,8 @@ namespace OpenRa.Game
|
|||||||
{
|
{
|
||||||
Button = e.Button,
|
Button = e.Button,
|
||||||
Event = MouseInputEvent.Up,
|
Event = MouseInputEvent.Up,
|
||||||
Location = new int2(e.Location)
|
Location = new int2(e.Location),
|
||||||
|
Modifiers = ModifierKeys,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -154,6 +157,7 @@ namespace OpenRa.Game
|
|||||||
public MouseInputEvent Event;
|
public MouseInputEvent Event;
|
||||||
public int2 Location;
|
public int2 Location;
|
||||||
public MouseButtons Button;
|
public MouseButtons Button;
|
||||||
|
public Keys Modifiers;
|
||||||
}
|
}
|
||||||
|
|
||||||
enum MouseInputEvent { Down, Move, Up };
|
enum MouseInputEvent { Down, Move, Up };
|
||||||
|
|||||||
Reference in New Issue
Block a user