Rework global music hotkey bindings.

This commit is contained in:
Paul Chote
2017-09-07 18:20:36 +00:00
committed by reaperrr
parent 08aaa998aa
commit 7459050af9
9 changed files with 29 additions and 46 deletions

View File

@@ -559,7 +559,7 @@
<Compile Include="UtilityCommands\ExtractZeroBraneStudioLuaAPI.cs" />
<Compile Include="UtilityCommands\ExtractTraitDocsCommand.cs" />
<Compile Include="UtilityCommands\ExtractWeaponDocsCommand.cs" />
<Compile Include="Widgets\Logic\Ingame\MusicControllerLogic.cs" />
<Compile Include="Widgets\Logic\MusicHotkeyLogic.cs" />
<Compile Include="WorldExtensions.cs" />
<Compile Include="UtilityCommands\GetMapHashCommand.cs" />
<Compile Include="UtilityCommands\Glob.cs" />

View File

@@ -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<string, MiniYaml> logicArgs)
public MusicHotkeyLogic(Widget widget, World world, Dictionary<string, MiniYaml> logicArgs)
{
musicPlaylist = world.WorldActor.Trait<MusicPlaylist>();
@@ -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<LogicKeyListenerWidget>("MUSICCONTROLLER_KEYHANDLER");
keyhandler.OnKeyPress = e =>
var keyhandler = widget.Get<LogicKeyListenerWidget>("GLOBAL_KEYHANDLER");
keyhandler.OnKeyPress += e =>
{
if (e.Event == KeyInputEvent.Down)
{