diff --git a/OpenRa.Game/Controller.cs b/OpenRa.Game/Controller.cs index da78566662..20f41b566f 100644 --- a/OpenRa.Game/Controller.cs +++ b/OpenRa.Game/Controller.cs @@ -96,29 +96,36 @@ namespace OpenRa.Game public Cursor ChooseCursor() { - var uog = orderGenerator as UnitOrderGenerator; + var c = (orderGenerator != null) ? orderGenerator.Order(dragEnd.ToInt2(), false) + .Select(a => a.Cursor) + .FirstOrDefault(a => a != null) : null; - if (uog != null) - uog.selection.RemoveAll(a => a.IsDead); + return c ?? (Game.SelectUnitOrBuilding(Game.CellSize * dragEnd).Any() ? Cursor.Select : Cursor.Default); - if (uog != null && uog.selection.Count > 0 - && uog.selection.Any(a => a.traits.Contains()) - && uog.selection.All(a => a.Owner == Game.LocalPlayer)) - { - var umts = uog.selection.Select(a => a.traits.GetOrDefault()) - .Where(m => m != null) - .Select(m => m.GetMovementType()) - .Distinct(); + //foreach( var o in + //var uog = orderGenerator as UnitOrderGenerator; - if (!umts.Any(umt => Game.IsCellBuildable(dragEnd.ToInt2(), umt))) - return Cursor.MoveBlocked; - return Cursor.Move; - } + //if (uog != null) + // uog.selection.RemoveAll(a => a.IsDead); - if (Game.SelectUnitOrBuilding(Game.CellSize * dragEnd).Any()) - return Cursor.Select; + //if (uog != null && uog.selection.Count > 0 + // && uog.selection.Any(a => a.traits.Contains()) + // && uog.selection.All(a => a.Owner == Game.LocalPlayer)) + //{ + // var umts = uog.selection.Select(a => a.traits.GetOrDefault()) + // .Where(m => m != null) + // .Select(m => m.GetMovementType()) + // .Distinct(); - return Cursor.Default; + // if (!umts.Any(umt => Game.IsCellBuildable(dragEnd.ToInt2(), umt))) + // return Cursor.MoveBlocked; + // return Cursor.Move; + //} + + //if (Game.SelectUnitOrBuilding(Game.CellSize * dragEnd).Any()) + // return Cursor.Select; + + //return Cursor.Default; } } } diff --git a/OpenRa.Game/Cursor.cs b/OpenRa.Game/Cursor.cs index c139600a68..811720a8d8 100644 --- a/OpenRa.Game/Cursor.cs +++ b/OpenRa.Game/Cursor.cs @@ -23,5 +23,6 @@ namespace OpenRa.Game public static Cursor Select { get { return new Cursor("select"); } } public static Cursor MoveBlocked { get { return new Cursor("move-blocked"); } } public static Cursor Attack { get { return new Cursor("attack"); } } + public static Cursor Deploy { get { return new Cursor("deploy"); } } } } diff --git a/OpenRa.Game/Order.cs b/OpenRa.Game/Order.cs index b309384b7b..05301ac383 100644 --- a/OpenRa.Game/Order.cs +++ b/OpenRa.Game/Order.cs @@ -15,8 +15,9 @@ namespace OpenRa.Game public readonly Actor TargetActor; public readonly int2 TargetLocation; public readonly string TargetString; + public readonly Cursor Cursor; - private Order(Player player, string orderString, Actor subject, Actor targetActor, int2 targetLocation, string targetString) + Order(Player player, string orderString, Actor subject, Actor targetActor, int2 targetLocation, string targetString, Cursor cursor) { this.Player = player; this.OrderString = orderString; @@ -24,6 +25,7 @@ namespace OpenRa.Game this.TargetActor = targetActor; this.TargetLocation = targetLocation; this.TargetString = targetString; + this.Cursor = cursor; } public byte[] Serialize() @@ -72,7 +74,7 @@ namespace OpenRa.Game var targetString = null as string; if (r.ReadBoolean()) targetString = r.ReadString(); - return new Order(player, order, subject, targetActor, targetLocation, targetString); + return new Order(player, order, subject, targetActor, targetLocation, targetString, null); } default: throw new NotImplementedException(); @@ -87,27 +89,27 @@ namespace OpenRa.Game public static Order Attack(Actor subject, Actor target) { - return new Order(subject.Owner, "Attack", subject, target, int2.Zero, null); + return new Order(subject.Owner, "Attack", subject, target, int2.Zero, null, Cursor.Attack); } public static Order Move(Actor subject, int2 target) { - return new Order(subject.Owner, "Move", subject, null, target, null); + return new Order(subject.Owner, "Move", subject, null, target, null, Cursor.Move); } public static Order DeployMcv(Actor subject) { - return new Order(subject.Owner, "DeployMcv", subject, null, int2.Zero, null); + return new Order(subject.Owner, "DeployMcv", subject, null, int2.Zero, null, Cursor.Deploy); } public static Order PlaceBuilding(Player subject, int2 target, string buildingName) { - return new Order(subject, "PlaceBuilding", null, null, target, buildingName); + return new Order(subject, "PlaceBuilding", null, null, target, buildingName, Cursor.Default); } public static Order BuildUnit(Player subject, string unitName) { - return new Order(subject, "BuildUnit", null, null, int2.Zero, unitName); + return new Order(subject, "BuildUnit", null, null, int2.Zero, unitName, Cursor.Default); } } } diff --git a/sequences.xml b/sequences.xml index 44148f2de2..c7445cd24d 100644 --- a/sequences.xml +++ b/sequences.xml @@ -361,14 +361,14 @@ - + - - - - + + + + @@ -376,14 +376,14 @@ - + - +