Use new platform actions instead of hardcoded keys

This commit is contained in:
Dean Herbert
2021-06-03 15:04:07 +09:00
parent a91015302e
commit e74fe68c96

View File

@ -24,13 +24,15 @@ using osu.Game.Overlays.Chat.Tabs;
using osuTK.Input; using osuTK.Input;
using osu.Framework.Graphics.Sprites; using osu.Framework.Graphics.Sprites;
using osu.Framework.Graphics.Textures; using osu.Framework.Graphics.Textures;
using osu.Framework.Input;
using osu.Framework.Input.Bindings;
using osu.Framework.Localisation; using osu.Framework.Localisation;
using osu.Game.Localisation; using osu.Game.Localisation;
using osu.Game.Online; using osu.Game.Online;
namespace osu.Game.Overlays namespace osu.Game.Overlays
{ {
public class ChatOverlay : OsuFocusedOverlayContainer, INamedOverlayComponent public class ChatOverlay : OsuFocusedOverlayContainer, INamedOverlayComponent, IKeyBindingHandler<PlatformAction>
{ {
public string IconTexture => "Icons/Hexacons/messaging"; public string IconTexture => "Icons/Hexacons/messaging";
public LocalisableString Title => ChatStrings.HeaderTitle; public LocalisableString Title => ChatStrings.HeaderTitle;
@ -367,33 +369,31 @@ namespace osu.Game.Overlays
} }
} }
if (e.ControlPressed) return base.OnKeyDown(e);
{ }
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;
case Key.T: public bool OnPressed(PlatformAction action)
ChannelTabControl.SelectChannelSelectorTab(); {
return true; 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; public override bool AcceptsFocus => true;