From 7459050af992c891b9d486ed15c6c1190851339e Mon Sep 17 00:00:00 2001 From: Paul Chote Date: Thu, 7 Sep 2017 18:20:36 +0000 Subject: [PATCH] Rework global music hotkey bindings. --- OpenRA.Mods.Common/OpenRA.Mods.Common.csproj | 2 +- ...usicControllerLogic.cs => MusicHotkeyLogic.cs} | 15 ++++++--------- mods/cnc/chrome/editor.yaml | 14 ++++++-------- mods/cnc/chrome/ingame.yaml | 6 ++---- mods/cnc/chrome/mainmenu.yaml | 6 ++---- mods/common/chrome/editor.yaml | 14 ++++++-------- mods/common/chrome/ingame.yaml | 6 ++---- mods/common/chrome/mainmenu.yaml | 6 ++---- mods/d2k/chrome/mainmenu.yaml | 6 ++---- 9 files changed, 29 insertions(+), 46 deletions(-) rename OpenRA.Mods.Common/Widgets/Logic/{Ingame/MusicControllerLogic.cs => MusicHotkeyLogic.cs} (85%) diff --git a/OpenRA.Mods.Common/OpenRA.Mods.Common.csproj b/OpenRA.Mods.Common/OpenRA.Mods.Common.csproj index e43725e035..18c5b554ec 100644 --- a/OpenRA.Mods.Common/OpenRA.Mods.Common.csproj +++ b/OpenRA.Mods.Common/OpenRA.Mods.Common.csproj @@ -559,7 +559,7 @@ - + diff --git a/OpenRA.Mods.Common/Widgets/Logic/Ingame/MusicControllerLogic.cs b/OpenRA.Mods.Common/Widgets/Logic/MusicHotkeyLogic.cs similarity index 85% rename from OpenRA.Mods.Common/Widgets/Logic/Ingame/MusicControllerLogic.cs rename to OpenRA.Mods.Common/Widgets/Logic/MusicHotkeyLogic.cs index cd850e40da..e3e0410b53 100644 --- a/OpenRA.Mods.Common/Widgets/Logic/Ingame/MusicControllerLogic.cs +++ b/OpenRA.Mods.Common/Widgets/Logic/MusicHotkeyLogic.cs @@ -9,23 +9,20 @@ */ #endregion -using System.Collections.Generic; -using System.Linq; -using OpenRA.GameRules; -using OpenRA.Graphics; +using System.Collections.Generic; using OpenRA.Mods.Common.Lint; using OpenRA.Mods.Common.Traits; using OpenRA.Widgets; -namespace OpenRA.Mods.Common.Widgets.Logic.Ingame +namespace OpenRA.Mods.Common.Widgets.Logic { [ChromeLogicArgsHotkeys("StopMusicKey", "PauseMusicKey", "PrevMusicKey", "NextMusicKey")] - public class MusicControllerLogic : ChromeLogic + public class MusicHotkeyLogic : ChromeLogic { readonly MusicPlaylist musicPlaylist; [ObjectCreator.UseCtor] - public MusicControllerLogic(Widget widget, World world, Dictionary logicArgs) + public MusicHotkeyLogic(Widget widget, World world, Dictionary logicArgs) { musicPlaylist = world.WorldActor.Trait(); @@ -48,8 +45,8 @@ namespace OpenRA.Mods.Common.Widgets.Logic.Ingame if (logicArgs.TryGetValue("NextMusicKey", out yaml)) nextKey = new NamedHotkey(yaml.Value, ks); - var keyhandler = widget.Get("MUSICCONTROLLER_KEYHANDLER"); - keyhandler.OnKeyPress = e => + var keyhandler = widget.Get("GLOBAL_KEYHANDLER"); + keyhandler.OnKeyPress += e => { if (e.Event == KeyInputEvent.Down) { diff --git a/mods/cnc/chrome/editor.yaml b/mods/cnc/chrome/editor.yaml index d21283593b..c712df1f58 100644 --- a/mods/cnc/chrome/editor.yaml +++ b/mods/cnc/chrome/editor.yaml @@ -5,14 +5,6 @@ Container@NEW_MAP_BG: Width: 300 Height: 125 Children: - Container@MUSICBUTTONS: - Logic: MusicControllerLogic - StopMusicKey: StopMusic - PauseMusicKey: PauseMusic - PrevMusicKey: PrevMusic - NextMusicKey: NextMusic - Children: - LogicKeyListener@MUSICCONTROLLER_KEYHANDLER: Label@TITLE: Text: New Map Width: PARENT_RIGHT @@ -199,6 +191,12 @@ ScrollPanel@MAP_SAVE_VISIBILITY_PANEL: Container@EDITOR_ROOT: Logic: LoadMapEditorLogic Children: + LogicKeyListener@GLOBAL_KEYHANDLER: + Logic: MusicHotkeyLogic + StopMusicKey: StopMusic + PauseMusicKey: PauseMusic + PrevMusicKey: PrevMusic + NextMusicKey: NextMusic Container@WORLD_ROOT: Container@MENU_ROOT: TooltipContainer@TOOLTIP_CONTAINER: diff --git a/mods/cnc/chrome/ingame.yaml b/mods/cnc/chrome/ingame.yaml index 405e1b4cc3..9be148daf0 100644 --- a/mods/cnc/chrome/ingame.yaml +++ b/mods/cnc/chrome/ingame.yaml @@ -1,14 +1,12 @@ Container@INGAME_ROOT: Logic: LoadIngamePlayerOrObserverUILogic Children: - Container@MUSICBUTTONS: - Logic: MusicControllerLogic + LogicKeyListener@GLOBAL_KEYHANDLER: + Logic: MusicHotkeyLogic StopMusicKey: StopMusic PauseMusicKey: PauseMusic PrevMusicKey: PrevMusic NextMusicKey: NextMusic - Children: - LogicKeyListener@MUSICCONTROLLER_KEYHANDLER: Container@WORLD_ROOT: Logic: LoadIngamePerfLogic Children: diff --git a/mods/cnc/chrome/mainmenu.yaml b/mods/cnc/chrome/mainmenu.yaml index 864c2f0329..d69f5def47 100644 --- a/mods/cnc/chrome/mainmenu.yaml +++ b/mods/cnc/chrome/mainmenu.yaml @@ -3,14 +3,12 @@ Container@MENU_BACKGROUND: Height: WINDOW_BOTTOM Logic: MainMenuLogic Children: - Container@MUSICBUTTONS: - Logic: MusicControllerLogic + LogicKeyListener@GLOBAL_KEYHANDLER: + Logic: MusicHotkeyLogic StopMusicKey: StopMusic PauseMusicKey: PauseMusic PrevMusicKey: PrevMusic NextMusicKey: NextMusic - Children: - LogicKeyListener@MUSICCONTROLLER_KEYHANDLER: Container@SHELLMAP_DECORATIONS: Children: Image@NOD: diff --git a/mods/common/chrome/editor.yaml b/mods/common/chrome/editor.yaml index 4234ed1396..bfe6ef8bb6 100644 --- a/mods/common/chrome/editor.yaml +++ b/mods/common/chrome/editor.yaml @@ -5,14 +5,6 @@ Background@NEW_MAP_BG: Width: 300 Height: 185 Children: - Container@MUSICBUTTONS: - Logic: MusicControllerLogic - StopMusicKey: StopMusic - PauseMusicKey: PauseMusic - PrevMusicKey: PrevMusic - NextMusicKey: NextMusic - Children: - LogicKeyListener@MUSICCONTROLLER_KEYHANDLER: Label@LABEL_TITLE: X: 0 Y: 20 @@ -190,6 +182,12 @@ ScrollPanel@MAP_SAVE_VISIBILITY_PANEL: Container@EDITOR_ROOT: Logic: LoadMapEditorLogic Children: + LogicKeyListener@GLOBAL_KEYHANDLER: + Logic: MusicHotkeyLogic + StopMusicKey: StopMusic + PauseMusicKey: PauseMusic + PrevMusicKey: PrevMusic + NextMusicKey: NextMusic Container@WORLD_ROOT: Container@MENU_ROOT: TooltipContainer@TOOLTIP_CONTAINER: diff --git a/mods/common/chrome/ingame.yaml b/mods/common/chrome/ingame.yaml index e74531f5d0..e5f4b1c3a8 100644 --- a/mods/common/chrome/ingame.yaml +++ b/mods/common/chrome/ingame.yaml @@ -1,14 +1,12 @@ Container@INGAME_ROOT: Logic: LoadIngamePlayerOrObserverUILogic Children: - Container@MUSICBUTTONS: - Logic: MusicControllerLogic + LogicKeyListener@GLOBAL_KEYHANDLER: + Logic: MusicHotkeyLogic StopMusicKey: StopMusic PauseMusicKey: PauseMusic PrevMusicKey: PrevMusic NextMusicKey: NextMusic - Children: - LogicKeyListener@MUSICCONTROLLER_KEYHANDLER: Container@WORLD_ROOT: Logic: LoadIngamePerfLogic Children: diff --git a/mods/common/chrome/mainmenu.yaml b/mods/common/chrome/mainmenu.yaml index 1fdc23af25..5fa5a99b85 100644 --- a/mods/common/chrome/mainmenu.yaml +++ b/mods/common/chrome/mainmenu.yaml @@ -1,14 +1,12 @@ Container@MAINMENU: Logic: MainMenuLogic Children: - Container@MUSICBUTTONS: - Logic: MusicControllerLogic + LogicKeyListener@GLOBAL_KEYHANDLER: + Logic: MusicHotkeyLogic StopMusicKey: StopMusic PauseMusicKey: PauseMusic PrevMusicKey: PrevMusic NextMusicKey: NextMusic - Children: - LogicKeyListener@MUSICCONTROLLER_KEYHANDLER: Background@BORDER: Background: mainmenu-border X: 0 - 15 diff --git a/mods/d2k/chrome/mainmenu.yaml b/mods/d2k/chrome/mainmenu.yaml index c122d02d91..97769d87d2 100644 --- a/mods/d2k/chrome/mainmenu.yaml +++ b/mods/d2k/chrome/mainmenu.yaml @@ -1,14 +1,12 @@ Container@MAINMENU: Logic: MainMenuLogic Children: - Container@MUSICBUTTONS: - Logic: MusicControllerLogic + LogicKeyListener@GLOBAL_KEYHANDLER: + Logic: MusicHotkeyLogic StopMusicKey: StopMusic PauseMusicKey: PauseMusic PrevMusicKey: PrevMusic NextMusicKey: NextMusic - Children: - LogicKeyListener@MUSICCONTROLLER_KEYHANDLER: Label@VERSION_LABEL: X: WINDOW_RIGHT - 10 Y: WINDOW_BOTTOM - 20