new hotkey to center your view on the current selection

This commit is contained in:
Matthias Mailänder
2013-03-02 11:53:45 +01:00
parent 336076c248
commit c0a702a386
3 changed files with 21 additions and 7 deletions

View File

@@ -125,7 +125,8 @@ namespace OpenRA.GameRules
public string PauseKey = "f3"; public string PauseKey = "f3";
public string CycleBaseKey = "backspace"; public string CycleBaseKey = "backspace";
public string GotoLastEventKey = "space"; public string ToLastEventKey = "space";
public string ToSelectionKey = "home";
public string SellKey = "v"; public string SellKey = "v";
public string PowerDownKey = "b"; public string PowerDownKey = "b";
public string RepairKey = "n"; public string RepairKey = "n";

View File

@@ -137,9 +137,13 @@ namespace OpenRA.Mods.RA.Widgets.Logic
specialHotkeyList.AddChild(viewportToBase); specialHotkeyList.AddChild(viewportToBase);
var lastEventKey = ScrollItemWidget.Setup(specialHotkeyTemplate, () => false, () => {}); 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); 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, () => {}); var sellKey = ScrollItemWidget.Setup(specialHotkeyTemplate, () => false, () => {});
SetupKeyBinding(sellKey, "Switch to Sell-Cursor:", () => keyConfig.SellKey, k => keyConfig.SellKey = k); SetupKeyBinding(sellKey, "Switch to Sell-Cursor:", () => keyConfig.SellKey, k => keyConfig.SellKey = k);
specialHotkeyList.AddChild(sellKey); specialHotkeyList.AddChild(sellKey);

View File

@@ -47,8 +47,11 @@ namespace OpenRA.Mods.RA.Widgets
if (e.KeyName == Game.Settings.Keys.CycleBaseKey) if (e.KeyName == Game.Settings.Keys.CycleBaseKey)
return CycleBases(); return CycleBases();
if (e.KeyName == Game.Settings.Keys.GotoLastEventKey) if (e.KeyName == Game.Settings.Keys.ToLastEventKey)
return GotoLastEvent(); return ToLastEvent();
if (e.KeyName == Game.Settings.Keys.ToSelectionKey)
return ToSelection();
if (e.KeyName == Game.Settings.Keys.SellKey) if (e.KeyName == Game.Settings.Keys.SellKey)
return PerformSwitchToSellMode(); return PerformSwitchToSellMode();
@@ -168,11 +171,11 @@ namespace OpenRA.Mods.RA.Widgets
next = bases.Select(b => b.Actor).First(); next = bases.Select(b => b.Actor).First();
World.Selection.Combine(World, new Actor[] { next }, false, true); 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) if (World.LocalPlayer == null)
return true; return true;
@@ -188,6 +191,12 @@ namespace OpenRA.Mods.RA.Widgets
return true; return true;
} }
bool ToSelection()
{
Game.viewport.Center(World.Selection.Actors);
return true;
}
bool PerformSwitchToSellMode() bool PerformSwitchToSellMode()
{ {
World.ToggleInputMode<SellOrderGenerator>(); World.ToggleInputMode<SellOrderGenerator>();