removed needless cursor indirection
This commit is contained in:
@@ -132,7 +132,7 @@ namespace OpenRa
|
||||
|
||||
public float2 MousePosition { get { return dragEnd; } }
|
||||
|
||||
public Cursor ChooseCursor( World world )
|
||||
public string ChooseCursor( World world )
|
||||
{
|
||||
int sync = world.SyncHash();
|
||||
|
||||
|
||||
@@ -5,36 +5,12 @@ namespace OpenRa
|
||||
public class Cursor
|
||||
{
|
||||
CursorSequence sequence;
|
||||
Cursor(string cursor)
|
||||
public Cursor(string cursor)
|
||||
{
|
||||
sequence = SequenceProvider.GetCursorSequence(cursor);
|
||||
}
|
||||
|
||||
public Sprite GetSprite(int frame) { return sequence.GetSprite(frame); }
|
||||
public int2 GetHotspot() { return sequence.Hotspot; }
|
||||
|
||||
public static Cursor None { get { return null; } }
|
||||
public static Cursor Default { get { return new Cursor("default"); } }
|
||||
public static Cursor Move { get { return new Cursor("move"); } }
|
||||
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 AttackMove { get { return new Cursor("attackmove"); } }
|
||||
public static Cursor Deploy { get { return new Cursor("deploy"); } }
|
||||
public static Cursor Enter { get { return new Cursor("enter"); } }
|
||||
public static Cursor DeployBlocked { get { return new Cursor("deploy-blocked"); } }
|
||||
public static Cursor Chronoshift { get { return new Cursor("chrono-target"); } }
|
||||
public static Cursor ChronoshiftSelect { get { return new Cursor("chrono-select"); } }
|
||||
public static Cursor Nuke { get { return new Cursor("nuke"); } }
|
||||
public static Cursor Ability { get { return new Cursor("ability"); } }
|
||||
public static Cursor C4 { get { return new Cursor("c4"); } }
|
||||
public static Cursor Capture { get { return new Cursor("capture"); } }
|
||||
public static Cursor Heal { get { return new Cursor("heal"); } }
|
||||
public static Cursor Sell { get { return new Cursor("sell"); } }
|
||||
public static Cursor SellBlocked { get { return new Cursor("sell-blocked"); } }
|
||||
public static Cursor Repair { get { return new Cursor("repair"); } }
|
||||
public static Cursor RepairBlocked { get { return new Cursor("repair-blocked"); } }
|
||||
public static Cursor PowerDown { get { return new Cursor("powerdown"); } }
|
||||
public static Cursor PowerDownBlocked { get { return new Cursor("powerdown-blocked"); } }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -79,7 +79,8 @@ namespace OpenRa.Graphics
|
||||
}
|
||||
}
|
||||
|
||||
var c = Game.chrome.HitTest(mousePos) ? Cursor.Default : Game.controller.ChooseCursor( world );
|
||||
var cursorName = Game.chrome.HitTest(mousePos) ? "default" : Game.controller.ChooseCursor( world );
|
||||
var c = new Cursor(cursorName);
|
||||
cursorRenderer.DrawSprite(c.GetSprite((int)cursorFrame), mousePos + Location - c.GetHotspot(), "cursor");
|
||||
cursorRenderer.Flush();
|
||||
|
||||
|
||||
@@ -7,6 +7,6 @@ namespace OpenRa
|
||||
IEnumerable<Order> Order( World world, int2 xy, MouseInput mi );
|
||||
void Tick( World world );
|
||||
void Render( World world );
|
||||
Cursor GetCursor( World world, int2 xy, MouseInput mi );
|
||||
string GetCursor( World world, int2 xy, MouseInput mi );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -53,9 +53,6 @@ namespace OpenRa.Orders
|
||||
world.WorldRenderer.uiOverlay.DrawBuildingGrid( world, Building, BuildingInfo );
|
||||
}
|
||||
|
||||
public Cursor GetCursor(World world, int2 xy, MouseInput mi)
|
||||
{
|
||||
return Cursor.Default;
|
||||
}
|
||||
public string GetCursor(World world, int2 xy, MouseInput mi) { return "default"; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -34,11 +34,11 @@ namespace OpenRa.Orders
|
||||
public void Tick( World world ) { }
|
||||
public void Render( World world ) { }
|
||||
|
||||
public Cursor GetCursor(World world, int2 xy, MouseInput mi)
|
||||
public string GetCursor(World world, int2 xy, MouseInput mi)
|
||||
{
|
||||
mi.Button = MouseButton.Left;
|
||||
return OrderInner(world, xy, mi).Any()
|
||||
? Cursor.PowerDown : Cursor.PowerDownBlocked;
|
||||
? "powerdown" : "powerdown-blocked";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -48,11 +48,11 @@ namespace OpenRa.Orders
|
||||
|
||||
public void Render( World world ) {}
|
||||
|
||||
public Cursor GetCursor(World world, int2 xy, MouseInput mi)
|
||||
public string GetCursor(World world, int2 xy, MouseInput mi)
|
||||
{
|
||||
mi.Button = MouseButton.Left;
|
||||
return OrderInner(world, xy, mi).Any()
|
||||
? Cursor.Repair : Cursor.RepairBlocked;
|
||||
? "repair" : "repair-blocked";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -36,11 +36,11 @@ namespace OpenRa.Orders
|
||||
public void Tick( World world ) {}
|
||||
public void Render( World world ) {}
|
||||
|
||||
public Cursor GetCursor(World world, int2 xy, MouseInput mi)
|
||||
public string GetCursor(World world, int2 xy, MouseInput mi)
|
||||
{
|
||||
mi.Button = MouseButton.Left;
|
||||
return OrderInner(world, xy, mi).Any()
|
||||
? Cursor.Sell : Cursor.SellBlocked;
|
||||
? "sell" : "sell-blocked";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -36,12 +36,12 @@ namespace OpenRa.Orders
|
||||
world.WorldRenderer.DrawSelectionBox( a, Color.White, true );
|
||||
}
|
||||
|
||||
public Cursor GetCursor( World world, int2 xy, MouseInput mi )
|
||||
public string GetCursor( World world, int2 xy, MouseInput mi )
|
||||
{
|
||||
return ChooseCursor(world, mi);
|
||||
}
|
||||
|
||||
Cursor ChooseCursor( World world, MouseInput mi )
|
||||
string ChooseCursor( World world, MouseInput mi )
|
||||
{
|
||||
var p = Game.controller.MousePosition;
|
||||
var c = Order(world, p.ToInt2(), mi)
|
||||
@@ -51,22 +51,22 @@ namespace OpenRa.Orders
|
||||
return c ??
|
||||
(world.SelectActorsInBox(Game.CellSize * p,
|
||||
Game.CellSize * p).Any()
|
||||
? Cursor.Select : Cursor.Default);
|
||||
? "select" : "default");
|
||||
}
|
||||
|
||||
Cursor CursorForOrderString(string s, Actor a, int2 location)
|
||||
string CursorForOrderString(string s, Actor a, int2 location)
|
||||
{
|
||||
var movement = a.traits.GetOrDefault<IMovement>();
|
||||
switch (s)
|
||||
{
|
||||
case "Attack": return Cursor.Attack;
|
||||
case "Heal": return Cursor.Heal;
|
||||
case "C4": return Cursor.C4;
|
||||
case "Attack": return "attack";
|
||||
case "Heal": return "heal";
|
||||
case "C4": return "c4";
|
||||
case "Move":
|
||||
if (movement.CanEnterCell(location))
|
||||
return Cursor.Move;
|
||||
return "move";
|
||||
else
|
||||
return Cursor.MoveBlocked;
|
||||
return "move-blocked";
|
||||
case "DeployTransform":
|
||||
var depInfo = a.Info.Traits.Get<TransformsOnDeployInfo>();
|
||||
var transInfo = Rules.Info[depInfo.TransformsInto];
|
||||
@@ -74,18 +74,18 @@ namespace OpenRa.Orders
|
||||
{
|
||||
var bi = transInfo.Traits.Get<BuildingInfo>();
|
||||
if (!a.World.CanPlaceBuilding(depInfo.TransformsInto, bi, a.Location + new int2(depInfo.Offset[0], depInfo.Offset[1]), a))
|
||||
return Cursor.DeployBlocked;
|
||||
return "deploy-blocked";
|
||||
}
|
||||
return Cursor.Deploy;
|
||||
return "deploy";
|
||||
|
||||
case "Deploy": return Cursor.Deploy;
|
||||
case "Enter": return Cursor.Enter;
|
||||
case "EnterTransport": return Cursor.Enter;
|
||||
case "Deliver": return Cursor.Enter;
|
||||
case "Infiltrate": return Cursor.Enter;
|
||||
case "Capture": return Cursor.Capture;
|
||||
case "Harvest": return Cursor.AttackMove;
|
||||
case "Steal" : return Cursor.Enter;
|
||||
case "Deploy": return "deploy";
|
||||
case "Enter": return "enter";
|
||||
case "EnterTransport": return "enter";
|
||||
case "Deliver": return "enter";
|
||||
case "Infiltrate": return "enter";
|
||||
case "Capture": return "capture";
|
||||
case "Harvest": return "attackmove";
|
||||
case "Steal" : return "enter";
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -112,11 +112,11 @@ namespace OpenRa.Traits
|
||||
|
||||
public void Render( World world ) { }
|
||||
|
||||
public Cursor GetCursor(World world, int2 xy, MouseInput mi)
|
||||
public string GetCursor(World world, int2 xy, MouseInput mi)
|
||||
{
|
||||
mi.Button = MouseButton.Left;
|
||||
return OrderInner(world, xy, mi).Any()
|
||||
? Cursor.ChronoshiftSelect : Cursor.MoveBlocked;
|
||||
? "chrono-select" : "move-blocked";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -153,13 +153,13 @@ namespace OpenRa.Traits
|
||||
world.WorldRenderer.DrawSelectionBox(self, Color.Red, true);
|
||||
}
|
||||
|
||||
public Cursor GetCursor(World world, int2 xy, MouseInput mi)
|
||||
public string GetCursor(World world, int2 xy, MouseInput mi)
|
||||
{
|
||||
if (!world.LocalPlayer.Shroud.IsExplored(xy))
|
||||
return Cursor.MoveBlocked;
|
||||
return "move-blocked";
|
||||
|
||||
var movement = self.traits.GetOrDefault<IMovement>();
|
||||
return (movement.CanEnterCell(xy)) ? Cursor.Chronoshift : Cursor.MoveBlocked;
|
||||
return (movement.CanEnterCell(xy)) ? "chrono-target" : "move-blocked";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -59,11 +59,11 @@ namespace OpenRa.Traits
|
||||
|
||||
public void Render(World world) { }
|
||||
|
||||
public Cursor GetCursor(World world, int2 xy, MouseInput mi)
|
||||
public string GetCursor(World world, int2 xy, MouseInput mi)
|
||||
{
|
||||
mi.Button = MouseButton.Left;
|
||||
return OrderInner(world, xy, mi).Any()
|
||||
? Cursor.Ability : Cursor.MoveBlocked;
|
||||
? "ability" : "move-blocked";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -62,9 +62,7 @@ namespace OpenRa.Traits
|
||||
IEnumerable<Order> OrderInner(World world, int2 xy, MouseInput mi)
|
||||
{
|
||||
if (mi.Button == MouseButton.Left)
|
||||
{
|
||||
yield return new Order("NuclearMissile", world.LocalPlayer.PlayerActor, xy);
|
||||
}
|
||||
|
||||
yield break;
|
||||
}
|
||||
@@ -80,7 +78,7 @@ namespace OpenRa.Traits
|
||||
}
|
||||
|
||||
public void Render(World world) { }
|
||||
public Cursor GetCursor(World world, int2 xy, MouseInput mi) { return Cursor.Nuke; }
|
||||
public string GetCursor(World world, int2 xy, MouseInput mi) { return "nuke"; }
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -30,13 +30,13 @@ namespace OpenRa.Mods.Aftermath.Orders
|
||||
world.WorldRenderer.DrawSelectionBox(self, Color.White, true);
|
||||
}
|
||||
|
||||
public Cursor GetCursor(World world, int2 xy, MouseInput mi)
|
||||
public string GetCursor(World world, int2 xy, MouseInput mi)
|
||||
{
|
||||
if (!world.LocalPlayer.Shroud.IsExplored(xy))
|
||||
return Cursor.MoveBlocked;
|
||||
return "move-blocked";
|
||||
|
||||
var movement = self.traits.GetOrDefault<IMovement>();
|
||||
return (movement.CanEnterCell(xy)) ? Cursor.Chronoshift : Cursor.MoveBlocked;
|
||||
return (movement.CanEnterCell(xy)) ? "chrono-target" : "move-blocked";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -84,11 +84,11 @@ namespace OpenRa.Mods.RA
|
||||
|
||||
public void Render(World world) { }
|
||||
|
||||
public Cursor GetCursor(World world, int2 xy, MouseInput mi)
|
||||
public string GetCursor(World world, int2 xy, MouseInput mi)
|
||||
{
|
||||
mi.Button = MouseButton.Left;
|
||||
return OrderInner(world, xy, mi).Any()
|
||||
? Cursor.Ability : Cursor.MoveBlocked;
|
||||
? "ability" : "move-blocked";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,9 +31,9 @@ namespace OpenRa.Mods.RA
|
||||
public void Tick(World world) {}
|
||||
public void Render(World world) {}
|
||||
|
||||
public Cursor GetCursor(World world, int2 xy, MouseInput mi)
|
||||
public string GetCursor(World world, int2 xy, MouseInput mi)
|
||||
{
|
||||
return Cursor.Ability;
|
||||
return "ability";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -60,7 +60,7 @@ namespace OpenRa.Mods.RA
|
||||
public void Tick(World world) {}
|
||||
public void Render(World world) {}
|
||||
|
||||
public Cursor GetCursor(World world, int2 xy, MouseInput mi) { return Cursor.Ability; }
|
||||
public string GetCursor(World world, int2 xy, MouseInput mi) { return "ability"; }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user