better cursor handling
This commit is contained in:
@@ -96,29 +96,36 @@ namespace OpenRa.Game
|
|||||||
|
|
||||||
public Cursor ChooseCursor()
|
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)
|
return c ?? (Game.SelectUnitOrBuilding(Game.CellSize * dragEnd).Any() ? Cursor.Select : Cursor.Default);
|
||||||
uog.selection.RemoveAll(a => a.IsDead);
|
|
||||||
|
|
||||||
if (uog != null && uog.selection.Count > 0
|
//foreach( var o in
|
||||||
&& uog.selection.Any(a => a.traits.Contains<Traits.Mobile>())
|
//var uog = orderGenerator as UnitOrderGenerator;
|
||||||
&& uog.selection.All(a => a.Owner == Game.LocalPlayer))
|
|
||||||
{
|
|
||||||
var umts = uog.selection.Select(a => a.traits.GetOrDefault<Mobile>())
|
|
||||||
.Where(m => m != null)
|
|
||||||
.Select(m => m.GetMovementType())
|
|
||||||
.Distinct();
|
|
||||||
|
|
||||||
if (!umts.Any(umt => Game.IsCellBuildable(dragEnd.ToInt2(), umt)))
|
//if (uog != null)
|
||||||
return Cursor.MoveBlocked;
|
// uog.selection.RemoveAll(a => a.IsDead);
|
||||||
return Cursor.Move;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (Game.SelectUnitOrBuilding(Game.CellSize * dragEnd).Any())
|
//if (uog != null && uog.selection.Count > 0
|
||||||
return Cursor.Select;
|
// && uog.selection.Any(a => a.traits.Contains<Traits.Mobile>())
|
||||||
|
// && uog.selection.All(a => a.Owner == Game.LocalPlayer))
|
||||||
|
//{
|
||||||
|
// var umts = uog.selection.Select(a => a.traits.GetOrDefault<Mobile>())
|
||||||
|
// .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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,5 +23,6 @@ namespace OpenRa.Game
|
|||||||
public static Cursor Select { get { return new Cursor("select"); } }
|
public static Cursor Select { get { return new Cursor("select"); } }
|
||||||
public static Cursor MoveBlocked { get { return new Cursor("move-blocked"); } }
|
public static Cursor MoveBlocked { get { return new Cursor("move-blocked"); } }
|
||||||
public static Cursor Attack { get { return new Cursor("attack"); } }
|
public static Cursor Attack { get { return new Cursor("attack"); } }
|
||||||
|
public static Cursor Deploy { get { return new Cursor("deploy"); } }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,8 +15,9 @@ namespace OpenRa.Game
|
|||||||
public readonly Actor TargetActor;
|
public readonly Actor TargetActor;
|
||||||
public readonly int2 TargetLocation;
|
public readonly int2 TargetLocation;
|
||||||
public readonly string TargetString;
|
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.Player = player;
|
||||||
this.OrderString = orderString;
|
this.OrderString = orderString;
|
||||||
@@ -24,6 +25,7 @@ namespace OpenRa.Game
|
|||||||
this.TargetActor = targetActor;
|
this.TargetActor = targetActor;
|
||||||
this.TargetLocation = targetLocation;
|
this.TargetLocation = targetLocation;
|
||||||
this.TargetString = targetString;
|
this.TargetString = targetString;
|
||||||
|
this.Cursor = cursor;
|
||||||
}
|
}
|
||||||
|
|
||||||
public byte[] Serialize()
|
public byte[] Serialize()
|
||||||
@@ -72,7 +74,7 @@ namespace OpenRa.Game
|
|||||||
var targetString = null as string;
|
var targetString = null as string;
|
||||||
if (r.ReadBoolean())
|
if (r.ReadBoolean())
|
||||||
targetString = r.ReadString();
|
targetString = r.ReadString();
|
||||||
return new Order(player, order, subject, targetActor, targetLocation, targetString);
|
return new Order(player, order, subject, targetActor, targetLocation, targetString, null);
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
throw new NotImplementedException();
|
throw new NotImplementedException();
|
||||||
@@ -87,27 +89,27 @@ namespace OpenRa.Game
|
|||||||
|
|
||||||
public static Order Attack(Actor subject, Actor target)
|
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)
|
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)
|
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)
|
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)
|
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -361,14 +361,14 @@
|
|||||||
<sequence name="attack" start="21" length="8" x="12" y="12" />
|
<sequence name="attack" start="21" length="8" x="12" y="12" />
|
||||||
<sequence name="move-minimap" start="29" length="6" />
|
<sequence name="move-minimap" start="29" length="6" />
|
||||||
<sequence name="repair" start="35" length="24" />
|
<sequence name="repair" start="35" length="24" />
|
||||||
<sequence name="deploy" start="59" length="9" />
|
<sequence name="deploy" start="59" length="9" x="12" y="12"/>
|
||||||
<sequence name="sell" start="68" length="12" />
|
<sequence name="sell" start="68" length="12" />
|
||||||
<sequence name="default-minimap" start="80" length="1" />
|
<sequence name="default-minimap" start="80" length="1" />
|
||||||
<sequence name="ability" start="82" length="8" />
|
<sequence name="ability" start="82" length="8" />
|
||||||
<sequence name="nuke" start="90" length="7" />
|
<sequence name="nuke" start="90" length="7" x="12" y="12" />
|
||||||
<sequence name="chrono" start="105" length="8" />
|
<sequence name="chrono" start="105" length="8" x="12" y="12" />
|
||||||
<sequence name="enter" start="113" length="3" />
|
<sequence name="enter" start="113" length="3" x="12" y="12" />
|
||||||
<sequence name="c4" start="116" length="3" />
|
<sequence name="c4" start="116" length="3" x="12" y="12" />
|
||||||
<sequence name="sell-blocked" start="119" length="1" />
|
<sequence name="sell-blocked" start="119" length="1" />
|
||||||
<sequence name="repair-blocked" start="120" length="1" />
|
<sequence name="repair-blocked" start="120" length="1" />
|
||||||
<sequence name="c4-minimap" start="121" length="3" />
|
<sequence name="c4-minimap" start="121" length="3" />
|
||||||
@@ -376,14 +376,14 @@
|
|||||||
<sequence name="attack-minimap" start="134" length="8" />
|
<sequence name="attack-minimap" start="134" length="8" />
|
||||||
<sequence name="enter-minimap" start="142" length="3" />
|
<sequence name="enter-minimap" start="142" length="3" />
|
||||||
<sequence name="guard-minimap" start="146" length="1" />
|
<sequence name="guard-minimap" start="146" length="1" />
|
||||||
<sequence name="guard" start="147" length="1" />
|
<sequence name="guard" start="147" length="1" x="12" y="12" />
|
||||||
<sequence name="sell-vehicle" start="148" length="12" />
|
<sequence name="sell-vehicle" start="148" length="12" />
|
||||||
<sequence name="heal" start="160" length="4" />
|
<sequence name="heal" start="160" length="4" />
|
||||||
<sequence name="capture" start="164" length="3" />
|
<sequence name="capture" start="164" length="3" />
|
||||||
<sequence name="capture-minimap" start="167" length="3" />
|
<sequence name="capture-minimap" start="167" length="3" />
|
||||||
<sequence name="repair2" start="170" length="24" />
|
<sequence name="repair2" start="170" length="24" />
|
||||||
<sequence name="heal-minimap" start="194" length="1" />
|
<sequence name="heal-minimap" start="194" length="1" />
|
||||||
<sequence name="attack2" start="195" length="8" />
|
<sequence name="attack2" start="195" length="8" x="12" y="12" />
|
||||||
<sequence name="attack2-minimap" start="203" length="8" />
|
<sequence name="attack2-minimap" start="203" length="8" />
|
||||||
<sequence name="deploy-blocked" start="211" length="1" />
|
<sequence name="deploy-blocked" start="211" length="1" />
|
||||||
<sequence name="enter-blocked" start="212" length="1" />
|
<sequence name="enter-blocked" start="212" length="1" />
|
||||||
|
|||||||
Reference in New Issue
Block a user