From e74fe68c9656947476ed88e6ef859b7a75de8c60 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 3 Jun 2021 15:04:07 +0900 Subject: [PATCH] Use new platform actions instead of hardcoded keys --- osu.Game/Overlays/ChatOverlay.cs | 50 ++++++++++++++++---------------- 1 file changed, 25 insertions(+), 25 deletions(-) diff --git a/osu.Game/Overlays/ChatOverlay.cs b/osu.Game/Overlays/ChatOverlay.cs index 84653226cc..0aa6108815 100644 --- a/osu.Game/Overlays/ChatOverlay.cs +++ b/osu.Game/Overlays/ChatOverlay.cs @@ -24,13 +24,15 @@ using osu.Game.Overlays.Chat.Tabs; using osuTK.Input; using osu.Framework.Graphics.Sprites; using osu.Framework.Graphics.Textures; +using osu.Framework.Input; +using osu.Framework.Input.Bindings; using osu.Framework.Localisation; using osu.Game.Localisation; using osu.Game.Online; namespace osu.Game.Overlays { - public class ChatOverlay : OsuFocusedOverlayContainer, INamedOverlayComponent + public class ChatOverlay : OsuFocusedOverlayContainer, INamedOverlayComponent, IKeyBindingHandler { public string IconTexture => "Icons/Hexacons/messaging"; public LocalisableString Title => ChatStrings.HeaderTitle; @@ -367,33 +369,31 @@ namespace osu.Game.Overlays } } - if (e.ControlPressed) - { - if (e.ShiftPressed) - { - switch (e.Key) - { - case Key.T: - channelManager.JoinLastClosedChannel(); - return true; - } - } - else - { - switch (e.Key) - { - case Key.W: - channelManager.LeaveChannel(channelManager.CurrentChannel.Value); - return true; + return base.OnKeyDown(e); + } - case Key.T: - ChannelTabControl.SelectChannelSelectorTab(); - return true; - } - } + public bool OnPressed(PlatformAction action) + { + switch (action.ActionType) + { + case PlatformActionType.TabNew: + ChannelTabControl.SelectChannelSelectorTab(); + return true; + + case PlatformActionType.TabRestore: + channelManager.JoinLastClosedChannel(); + return true; + + case PlatformActionType.DocumentClose: + channelManager.LeaveChannel(channelManager.CurrentChannel.Value); + return true; } - return base.OnKeyDown(e); + return false; + } + + public void OnReleased(PlatformAction action) + { } public override bool AcceptsFocus => true;