diff --git a/OpenRA.Game/Traits/TraitsInterfaces.cs b/OpenRA.Game/Traits/TraitsInterfaces.cs index d7fdf31cb0..ebfa13c103 100755 --- a/OpenRA.Game/Traits/TraitsInterfaces.cs +++ b/OpenRA.Game/Traits/TraitsInterfaces.cs @@ -229,7 +229,6 @@ namespace OpenRA.Traits bool TargetableBy(Actor self, Actor byActor); } - public interface INotifyKeyPress { bool KeyPressed(Actor self, KeyInput e); } public interface INotifyStanceChanged { void StanceChanged(Actor self, Player a, Player b, Stance oldStance, Stance newStance); } } diff --git a/OpenRA.Game/Widgets/WorldInteractionControllerWidget.cs b/OpenRA.Game/Widgets/WorldInteractionControllerWidget.cs index eef8a786cc..6558a90602 100644 --- a/OpenRA.Game/Widgets/WorldInteractionControllerWidget.cs +++ b/OpenRA.Game/Widgets/WorldInteractionControllerWidget.cs @@ -134,9 +134,6 @@ namespace OpenRA.Widgets bool handled = false; - foreach (var t in world.WorldActor.TraitsImplementing()) - handled = (t.KeyPressed(world.WorldActor, e)) ? true : handled; - if (handled) return true; } return false; diff --git a/OpenRA.Mods.RA/Widgets/WorldCommandWidget.cs b/OpenRA.Mods.RA/Widgets/WorldCommandWidget.cs index 3d5d20a011..25b67d59a7 100644 --- a/OpenRA.Mods.RA/Widgets/WorldCommandWidget.cs +++ b/OpenRA.Mods.RA/Widgets/WorldCommandWidget.cs @@ -43,6 +43,9 @@ namespace OpenRA.Mods.RA.Widgets if (e.Modifiers == Modifiers.None) { + if (e.KeyChar == '\b' || e.KeyChar == (char)127) + return CycleBases(); + if (e.KeyChar == AttackMoveKey) return PerformAttackMove(); @@ -95,5 +98,24 @@ namespace OpenRA.Mods.RA.Widgets PerformKeyboardOrderOnSelection(a => new Order("Unload", a, false)); return true; } + + bool CycleBases() + { + var bases = World.Queries.OwnedBy[World.LocalPlayer].WithTrait().ToArray(); + if (!bases.Any()) return true; + + var next = bases + .Select(b => b.Actor) + .SkipWhile(b => !World.Selection.Actors.Contains(b)) + .Skip(1) + .FirstOrDefault(); + + if (next == null) + next = bases.Select(b => b.Actor).First(); + + World.Selection.Combine(World, new Actor[] { next }, false, true); + Game.viewport.Center(World.Selection.Actors); + return true; + } } } \ No newline at end of file diff --git a/OpenRA.Mods.RA/World/GotoNextBase.cs b/OpenRA.Mods.RA/World/GotoNextBase.cs deleted file mode 100644 index fe77db1715..0000000000 --- a/OpenRA.Mods.RA/World/GotoNextBase.cs +++ /dev/null @@ -1,44 +0,0 @@ -using System.Linq; -using OpenRA.Traits; - -namespace OpenRA.Mods.RA -{ - public class GotoNextBaseInfo : TraitInfo - { - - } - - public class GotoNextBase : INotifyKeyPress - { - public bool KeyPressed(Actor self, KeyInput e) - { - if (self.World.LocalPlayer == null) return false; - - if (e.KeyChar == '\b' || e.KeyChar == (char)127) - { - CycleBases(self.World); - return true; - } - - return false; - } - - public static void CycleBases(World world) - { - var bases = world.Queries.OwnedBy[world.LocalPlayer].WithTrait().ToArray(); - if (!bases.Any()) return; - - var next = bases - .Select(b => b.Actor) - .SkipWhile(b => !world.Selection.Actors.Contains(b)) - .Skip(1) - .FirstOrDefault(); - - if (next == null) - next = bases.Select(b => b.Actor).First(); - - world.Selection.Combine(world, new Actor[] { next }, false, true); - Game.viewport.Center(world.Selection.Actors); - } - } -} diff --git a/mods/cnc/rules/system.yaml b/mods/cnc/rules/system.yaml index e9bd6f072e..c5c907a713 100644 --- a/mods/cnc/rules/system.yaml +++ b/mods/cnc/rules/system.yaml @@ -151,7 +151,6 @@ World: WaterChance: 0 PathFinder: ValidateOrder: - GotoNextBase: CRATE: Tooltip: diff --git a/mods/ra/rules/system.yaml b/mods/ra/rules/system.yaml index a4fbce3cc6..8f3bb6c32e 100644 --- a/mods/ra/rules/system.yaml +++ b/mods/ra/rules/system.yaml @@ -195,7 +195,6 @@ World: Shroud: PathFinder: ValidateOrder: - GotoNextBase: MINP: Mine: