From 1728f9d6625ea90c5c88eef665f39360a11c4369 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Honza=20Vr=C3=A1tn=C3=ADk?= Date: Thu, 17 Mar 2016 11:27:55 +0100 Subject: [PATCH] Added support for pause/play/speed hotkeys in replays --- OpenRA.Game/Settings.cs | 5 +++++ .../Widgets/Logic/Ingame/ReplayControlBarLogic.cs | 6 ++++++ OpenRA.Mods.Common/Widgets/Logic/SettingsLogic.cs | 7 ++++++- 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/OpenRA.Game/Settings.cs b/OpenRA.Game/Settings.cs index 88556965b8..ce24c64b20 100644 --- a/OpenRA.Game/Settings.cs +++ b/OpenRA.Game/Settings.cs @@ -269,6 +269,11 @@ namespace OpenRA public Hotkey SupportPower05Key = new Hotkey(Keycode.UNKNOWN, Modifiers.None); public Hotkey SupportPower06Key = new Hotkey(Keycode.UNKNOWN, Modifiers.None); + public Hotkey ReplaySpeedSlowKey = new Hotkey(Keycode.F5, Modifiers.None); + public Hotkey ReplaySpeedRegularKey = new Hotkey(Keycode.F6, Modifiers.None); + public Hotkey ReplaySpeedFastKey = new Hotkey(Keycode.F7, Modifiers.None); + public Hotkey ReplaySpeedMaxKey = new Hotkey(Keycode.F8, Modifiers.None); + static readonly Func[] ProductionKeys = GetKeys(24, "Production"); static readonly Func[] SupportPowerKeys = GetKeys(6, "SupportPower"); diff --git a/OpenRA.Mods.Common/Widgets/Logic/Ingame/ReplayControlBarLogic.cs b/OpenRA.Mods.Common/Widgets/Logic/Ingame/ReplayControlBarLogic.cs index dd88839752..bc997b8083 100644 --- a/OpenRA.Mods.Common/Widgets/Logic/Ingame/ReplayControlBarLogic.cs +++ b/OpenRA.Mods.Common/Widgets/Logic/Ingame/ReplayControlBarLogic.cs @@ -46,15 +46,18 @@ namespace OpenRA.Mods.Common.Widgets.Logic var originalTimestep = world.Timestep; var pauseButton = widget.Get("BUTTON_PAUSE"); + pauseButton.GetKey = _ => Game.Settings.Keys.PauseKey; pauseButton.IsVisible = () => world.Timestep != 0 && orderManager.NetFrameNumber < replayNetTicks; pauseButton.OnClick = () => world.Timestep = 0; var playButton = widget.Get("BUTTON_PLAY"); + playButton.GetKey = _ => Game.Settings.Keys.PauseKey; playButton.IsVisible = () => world.Timestep == 0 || orderManager.NetFrameNumber >= replayNetTicks; playButton.OnClick = () => world.Timestep = (int)Math.Ceiling(originalTimestep * multipliers[speed]); playButton.IsDisabled = () => orderManager.NetFrameNumber >= replayNetTicks; var slowButton = widget.Get("BUTTON_SLOW"); + slowButton.GetKey = _ => Game.Settings.Keys.ReplaySpeedSlowKey; slowButton.IsHighlighted = () => speed == PlaybackSpeed.Slow; slowButton.IsDisabled = () => orderManager.NetFrameNumber >= replayNetTicks; slowButton.OnClick = () => @@ -65,6 +68,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic }; var normalSpeedButton = widget.Get("BUTTON_REGULAR"); + normalSpeedButton.GetKey = _ => Game.Settings.Keys.ReplaySpeedRegularKey; normalSpeedButton.IsHighlighted = () => speed == PlaybackSpeed.Regular; normalSpeedButton.IsDisabled = () => orderManager.NetFrameNumber >= replayNetTicks; normalSpeedButton.OnClick = () => @@ -75,6 +79,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic }; var fastButton = widget.Get("BUTTON_FAST"); + fastButton.GetKey = _ => Game.Settings.Keys.ReplaySpeedFastKey; fastButton.IsHighlighted = () => speed == PlaybackSpeed.Fast; fastButton.IsDisabled = () => orderManager.NetFrameNumber >= replayNetTicks; fastButton.OnClick = () => @@ -85,6 +90,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic }; var maximumButton = widget.Get("BUTTON_MAXIMUM"); + maximumButton.GetKey = _ => Game.Settings.Keys.ReplaySpeedMaxKey; maximumButton.IsHighlighted = () => speed == PlaybackSpeed.Maximum; maximumButton.IsDisabled = () => orderManager.NetFrameNumber >= replayNetTicks; maximumButton.OnClick = () => diff --git a/OpenRA.Mods.Common/Widgets/Logic/SettingsLogic.cs b/OpenRA.Mods.Common/Widgets/Logic/SettingsLogic.cs index 4e2ea3d110..b12b650657 100644 --- a/OpenRA.Mods.Common/Widgets/Logic/SettingsLogic.cs +++ b/OpenRA.Mods.Common/Widgets/Logic/SettingsLogic.cs @@ -467,7 +467,12 @@ namespace OpenRA.Mods.Common.Widgets.Logic var hotkeys = new Dictionary() { { "ObserverCombinedView", "All Players" }, - { "ObserverWorldView", "Disable Shroud" } + { "ObserverWorldView", "Disable Shroud" }, + { "PauseKey", "Pause/Play" }, + { "ReplaySpeedSlowKey", "Slow speed" }, + { "ReplaySpeedRegularKey", "Regular speed" }, + { "ReplaySpeedFastKey", "Fast speed" }, + { "ReplaySpeedMaxKey", "Maximum speed" } }; var header = ScrollItemWidget.Setup(hotkeyHeader, returnTrue, doNothing);