diff --git a/OpenRa.Game/Controller.cs b/OpenRa.Game/Controller.cs index 91961c9e07..62b0e6047d 100644 --- a/OpenRa.Game/Controller.cs +++ b/OpenRa.Game/Controller.cs @@ -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(); diff --git a/OpenRa.Game/Cursor.cs b/OpenRa.Game/Cursor.cs index 96c9c613c5..8ce46232d8 100644 --- a/OpenRa.Game/Cursor.cs +++ b/OpenRa.Game/Cursor.cs @@ -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"); } } } } diff --git a/OpenRa.Game/Graphics/Viewport.cs b/OpenRa.Game/Graphics/Viewport.cs index 48a5343e69..e374de6e7f 100644 --- a/OpenRa.Game/Graphics/Viewport.cs +++ b/OpenRa.Game/Graphics/Viewport.cs @@ -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(); diff --git a/OpenRa.Game/Orders/IOrderGenerator.cs b/OpenRa.Game/Orders/IOrderGenerator.cs index 6d6bf57294..1dfaeacc28 100644 --- a/OpenRa.Game/Orders/IOrderGenerator.cs +++ b/OpenRa.Game/Orders/IOrderGenerator.cs @@ -7,6 +7,6 @@ namespace OpenRa IEnumerable 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 ); } } diff --git a/OpenRa.Game/Orders/PlaceBuildingOrderGenerator.cs b/OpenRa.Game/Orders/PlaceBuildingOrderGenerator.cs index d815352edd..44c623fb6e 100644 --- a/OpenRa.Game/Orders/PlaceBuildingOrderGenerator.cs +++ b/OpenRa.Game/Orders/PlaceBuildingOrderGenerator.cs @@ -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"; } } } diff --git a/OpenRa.Game/Orders/PowerDownOrderGenerator.cs b/OpenRa.Game/Orders/PowerDownOrderGenerator.cs index 130dd9307b..3e5869e278 100644 --- a/OpenRa.Game/Orders/PowerDownOrderGenerator.cs +++ b/OpenRa.Game/Orders/PowerDownOrderGenerator.cs @@ -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"; } } } diff --git a/OpenRa.Game/Orders/RepairOrderGenerator.cs b/OpenRa.Game/Orders/RepairOrderGenerator.cs index 8d977a9155..042bf3e62e 100644 --- a/OpenRa.Game/Orders/RepairOrderGenerator.cs +++ b/OpenRa.Game/Orders/RepairOrderGenerator.cs @@ -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"; } } } diff --git a/OpenRa.Game/Orders/SellOrderGenerator.cs b/OpenRa.Game/Orders/SellOrderGenerator.cs index 895810ef9e..acced26243 100644 --- a/OpenRa.Game/Orders/SellOrderGenerator.cs +++ b/OpenRa.Game/Orders/SellOrderGenerator.cs @@ -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"; } } } diff --git a/OpenRa.Game/Orders/UnitOrderGenerator.cs b/OpenRa.Game/Orders/UnitOrderGenerator.cs index fae7bcba92..2821664a0a 100644 --- a/OpenRa.Game/Orders/UnitOrderGenerator.cs +++ b/OpenRa.Game/Orders/UnitOrderGenerator.cs @@ -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(); 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(); var transInfo = Rules.Info[depInfo.TransformsInto]; @@ -74,18 +74,18 @@ namespace OpenRa.Orders { var bi = transInfo.Traits.Get(); 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; } diff --git a/OpenRa.Game/Traits/ChronoshiftPower.cs b/OpenRa.Game/Traits/ChronoshiftPower.cs index 2116b96bf4..3312df1baa 100644 --- a/OpenRa.Game/Traits/ChronoshiftPower.cs +++ b/OpenRa.Game/Traits/ChronoshiftPower.cs @@ -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(); - return (movement.CanEnterCell(xy)) ? Cursor.Chronoshift : Cursor.MoveBlocked; + return (movement.CanEnterCell(xy)) ? "chrono-target" : "move-blocked"; } } } diff --git a/OpenRa.Game/Traits/CrateSpawnPower.cs b/OpenRa.Game/Traits/CrateSpawnPower.cs index d9b7857ecd..c316d042fb 100644 --- a/OpenRa.Game/Traits/CrateSpawnPower.cs +++ b/OpenRa.Game/Traits/CrateSpawnPower.cs @@ -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"; } } } diff --git a/OpenRa.Game/Traits/NukePower.cs b/OpenRa.Game/Traits/NukePower.cs index 7c5800022e..61a1def0db 100644 --- a/OpenRa.Game/Traits/NukePower.cs +++ b/OpenRa.Game/Traits/NukePower.cs @@ -62,9 +62,7 @@ namespace OpenRa.Traits IEnumerable 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"; } } } diff --git a/OpenRa.Mods.Aftermath/Orders/SetChronoTankDestination.cs b/OpenRa.Mods.Aftermath/Orders/SetChronoTankDestination.cs index 6be3b3e0ba..8c4490b8a2 100644 --- a/OpenRa.Mods.Aftermath/Orders/SetChronoTankDestination.cs +++ b/OpenRa.Mods.Aftermath/Orders/SetChronoTankDestination.cs @@ -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(); - return (movement.CanEnterCell(xy)) ? Cursor.Chronoshift : Cursor.MoveBlocked; + return (movement.CanEnterCell(xy)) ? "chrono-target" : "move-blocked"; } } } diff --git a/OpenRa.Mods.RA/IronCurtainPower.cs b/OpenRa.Mods.RA/IronCurtainPower.cs index 0b746ff47a..94987f77c3 100644 --- a/OpenRa.Mods.RA/IronCurtainPower.cs +++ b/OpenRa.Mods.RA/IronCurtainPower.cs @@ -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"; } } } diff --git a/OpenRa.Mods.RA/ParatroopersPower.cs b/OpenRa.Mods.RA/ParatroopersPower.cs index 32115b7651..7c73768425 100644 --- a/OpenRa.Mods.RA/ParatroopersPower.cs +++ b/OpenRa.Mods.RA/ParatroopersPower.cs @@ -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"; } } diff --git a/OpenRa.Mods.RA/SpyPlanePower.cs b/OpenRa.Mods.RA/SpyPlanePower.cs index dc7eef7a72..d83a2719b3 100644 --- a/OpenRa.Mods.RA/SpyPlanePower.cs +++ b/OpenRa.Mods.RA/SpyPlanePower.cs @@ -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"; } } } }