From c0a702a386cf6482704010c867ffb80a4bdd7a20 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20Mail=C3=A4nder?= Date: Sat, 2 Mar 2013 11:53:45 +0100 Subject: [PATCH] new hotkey to center your view on the current selection --- OpenRA.Game/GameRules/Settings.cs | 3 ++- .../Widgets/Logic/SettingsMenuLogic.cs | 6 +++++- OpenRA.Mods.RA/Widgets/WorldCommandWidget.cs | 19 ++++++++++++++----- 3 files changed, 21 insertions(+), 7 deletions(-) diff --git a/OpenRA.Game/GameRules/Settings.cs b/OpenRA.Game/GameRules/Settings.cs index bb8d3fc0ed..a0b6b7793e 100644 --- a/OpenRA.Game/GameRules/Settings.cs +++ b/OpenRA.Game/GameRules/Settings.cs @@ -125,7 +125,8 @@ namespace OpenRA.GameRules public string PauseKey = "f3"; public string CycleBaseKey = "backspace"; - public string GotoLastEventKey = "space"; + public string ToLastEventKey = "space"; + public string ToSelectionKey = "home"; public string SellKey = "v"; public string PowerDownKey = "b"; public string RepairKey = "n"; diff --git a/OpenRA.Mods.RA/Widgets/Logic/SettingsMenuLogic.cs b/OpenRA.Mods.RA/Widgets/Logic/SettingsMenuLogic.cs index 5846ddd6ce..37a4b443af 100644 --- a/OpenRA.Mods.RA/Widgets/Logic/SettingsMenuLogic.cs +++ b/OpenRA.Mods.RA/Widgets/Logic/SettingsMenuLogic.cs @@ -137,9 +137,13 @@ namespace OpenRA.Mods.RA.Widgets.Logic specialHotkeyList.AddChild(viewportToBase); var lastEventKey = ScrollItemWidget.Setup(specialHotkeyTemplate, () => false, () => {}); - SetupKeyBinding(lastEventKey, "Move Viewport to Last Event:", () => keyConfig.GotoLastEventKey, k => keyConfig.GotoLastEventKey = k); + SetupKeyBinding(lastEventKey, "Move Viewport to Last Event:", () => keyConfig.ToLastEventKey, k => keyConfig.ToLastEventKey = k); specialHotkeyList.AddChild(lastEventKey); + var viewportToSelectionKey = ScrollItemWidget.Setup(specialHotkeyTemplate, () => false, () => {}); + SetupKeyBinding(viewportToSelectionKey, "Move Viewport to Selection:", () => keyConfig.ToSelectionKey, k => keyConfig.ToSelectionKey = k); + specialHotkeyList.AddChild(viewportToSelectionKey); + var sellKey = ScrollItemWidget.Setup(specialHotkeyTemplate, () => false, () => {}); SetupKeyBinding(sellKey, "Switch to Sell-Cursor:", () => keyConfig.SellKey, k => keyConfig.SellKey = k); specialHotkeyList.AddChild(sellKey); diff --git a/OpenRA.Mods.RA/Widgets/WorldCommandWidget.cs b/OpenRA.Mods.RA/Widgets/WorldCommandWidget.cs index b40b9f6890..1aea04de56 100644 --- a/OpenRA.Mods.RA/Widgets/WorldCommandWidget.cs +++ b/OpenRA.Mods.RA/Widgets/WorldCommandWidget.cs @@ -47,8 +47,11 @@ namespace OpenRA.Mods.RA.Widgets if (e.KeyName == Game.Settings.Keys.CycleBaseKey) return CycleBases(); - if (e.KeyName == Game.Settings.Keys.GotoLastEventKey) - return GotoLastEvent(); + if (e.KeyName == Game.Settings.Keys.ToLastEventKey) + return ToLastEvent(); + + if (e.KeyName == Game.Settings.Keys.ToSelectionKey) + return ToSelection(); if (e.KeyName == Game.Settings.Keys.SellKey) return PerformSwitchToSellMode(); @@ -168,11 +171,11 @@ namespace OpenRA.Mods.RA.Widgets next = bases.Select(b => b.Actor).First(); World.Selection.Combine(World, new Actor[] { next }, false, true); - Game.viewport.Center(World.Selection.Actors); - return true; + + return ToSelection(); } - bool GotoLastEvent() + bool ToLastEvent() { if (World.LocalPlayer == null) return true; @@ -188,6 +191,12 @@ namespace OpenRA.Mods.RA.Widgets return true; } + bool ToSelection() + { + Game.viewport.Center(World.Selection.Actors); + return true; + } + bool PerformSwitchToSellMode() { World.ToggleInputMode();