don't hardcode SHIFT modifier for backwards tab cycle

closes #4144
This commit is contained in:
Matthias Mailänder
2013-12-07 11:44:01 +01:00
parent 28cf6d36f4
commit bcba26a04e
4 changed files with 35 additions and 26 deletions

View File

@@ -155,7 +155,8 @@ namespace OpenRA.GameRules
public Hotkey PowerDownKey = new Hotkey(Keycode.F11, Modifiers.None); public Hotkey PowerDownKey = new Hotkey(Keycode.F11, Modifiers.None);
public Hotkey RepairKey = new Hotkey(Keycode.F12, Modifiers.None); public Hotkey RepairKey = new Hotkey(Keycode.F12, Modifiers.None);
public Hotkey CycleTabsKey = new Hotkey(Keycode.TAB, Modifiers.None); public Hotkey NextProductionTabKey = new Hotkey(Keycode.PAGEDOWN, Modifiers.None);
public Hotkey PreviousProductionTabKey = new Hotkey(Keycode.PAGEUP, Modifiers.None);
public Hotkey ToggleStatusBarsKey = new Hotkey(Keycode.INSERT, Modifiers.None); public Hotkey ToggleStatusBarsKey = new Hotkey(Keycode.INSERT, Modifiers.None);

20
OpenRA.Mods.Cnc/Widgets/ProductionTabsWidget.cs Executable file → Normal file
View File

@@ -89,10 +89,12 @@ namespace OpenRA.Mods.Cnc.Widgets
paletteWidget = Lazy.New(() => Ui.Root.Get<ProductionPaletteWidget>(PaletteWidget)); paletteWidget = Lazy.New(() => Ui.Root.Get<ProductionPaletteWidget>(PaletteWidget));
} }
public void SelectNextTab(bool reverse) public bool SelectNextTab(bool reverse)
{ {
if (queueGroup == null) if (queueGroup == null)
return; return true;
Sound.PlayNotification(null, "Sounds", "ClickSound", null);
// Prioritize alerted queues // Prioritize alerted queues
var queues = Groups[queueGroup].Tabs.Select(t => t.Queue) var queues = Groups[queueGroup].Tabs.Select(t => t.Queue)
@@ -103,6 +105,8 @@ namespace OpenRA.Mods.Cnc.Widgets
CurrentQueue = queues.SkipWhile(q => q != CurrentQueue) CurrentQueue = queues.SkipWhile(q => q != CurrentQueue)
.Skip(1).FirstOrDefault() ?? queues.FirstOrDefault(); .Skip(1).FirstOrDefault() ?? queues.FirstOrDefault();
return true;
} }
public string QueueGroup public string QueueGroup
@@ -277,12 +281,12 @@ namespace OpenRA.Mods.Cnc.Widgets
if (e.Event != KeyInputEvent.Down) if (e.Event != KeyInputEvent.Down)
return false; return false;
if (Hotkey.FromKeyInput(e) == Game.Settings.Keys.CycleTabsKey) var hotkey = Hotkey.FromKeyInput(e);
{
Sound.PlayNotification(null, "Sounds", "ClickSound", null); if (hotkey == Game.Settings.Keys.NextProductionTabKey)
SelectNextTab(e.Modifiers.HasModifier(Modifiers.Shift)); return SelectNextTab(false);
return true; else if (hotkey == Game.Settings.Keys.PreviousProductionTabKey)
} return SelectNextTab(true);
return false; return false;
} }

View File

@@ -149,11 +149,13 @@ namespace OpenRA.Mods.RA.Widgets
if (e.Event == KeyInputEvent.Up) if (e.Event == KeyInputEvent.Up)
return false; return false;
if (Hotkey.FromKeyInput(e) == Game.Settings.Keys.CycleTabsKey) var hotkey = Hotkey.FromKeyInput(e);
{
TabChange(e.Modifiers.HasModifier(Modifiers.Shift)); if (hotkey == Game.Settings.Keys.NextProductionTabKey)
return true; return ChangeTab(false);
} else if (hotkey == Game.Settings.Keys.PreviousProductionTabKey)
return ChangeTab(true);
return DoBuildingHotkey(e, world); return DoBuildingHotkey(e, world);
} }
@@ -164,15 +166,10 @@ namespace OpenRA.Mods.RA.Widgets
return true; return true;
if (mi.Button == MouseButton.WheelDown) if (mi.Button == MouseButton.WheelDown)
{ return ChangeTab(false);
TabChange(false);
return true;
}
if (mi.Button == MouseButton.WheelUp) if (mi.Button == MouseButton.WheelUp)
{ return ChangeTab(true);
TabChange(true);
return true;
}
var action = tabs.Where(a => a.First.Contains(mi.Location)) var action = tabs.Where(a => a.First.Contains(mi.Location))
.Select(a => a.Second).FirstOrDefault(); .Select(a => a.Second).FirstOrDefault();
@@ -515,14 +512,20 @@ namespace OpenRA.Mods.RA.Widgets
return false; return false;
} }
void TabChange(bool shift) // NOTE: Always return true here to prevent mouse events from passing through the sidebar and interacting with the world behind it.
bool ChangeTab(bool reverse)
{ {
var queues = VisibleQueues.Concat(VisibleQueues); var queues = VisibleQueues.Concat(VisibleQueues);
if (shift) queues = queues.Reverse(); if (reverse)
queues = queues.Reverse();
var nextQueue = queues.SkipWhile(q => q != CurrentQueue) var nextQueue = queues.SkipWhile(q => q != CurrentQueue)
.ElementAtOrDefault(1); .ElementAtOrDefault(1);
if (nextQueue != null) if (nextQueue != null)
{
SetCurrentTab(nextQueue); SetCurrentTab(nextQueue);
return true;
}
return true;
} }
} }
} }

View File

@@ -257,9 +257,10 @@ namespace OpenRA.Mods.RA.Widgets.Logic
{ "PowerDownKey", "Power-down mode" }, { "PowerDownKey", "Power-down mode" },
{ "RepairKey", "Repair mode" }, { "RepairKey", "Repair mode" },
{ "CycleTabsKey", "Cycle production tabs" }, { "NextProductionTabKey", "Next production tab" },
{ "PreviousProductionTabKey", "Previous production tab" },
{ "ToggleStatusBarsKey", "Toggle status bars" } { "ToggleStatusBarsKey", "Toggle status bars" },
}; };
var unitHotkeys = new Dictionary<string, string>() var unitHotkeys = new Dictionary<string, string>()