mirror of
https://github.com/ppy/osu.git
synced 2025-01-12 17:43:05 +08:00
Remove GlobalHotkeys
This commit is contained in:
parent
641b3bd27e
commit
a93a92a2bb
@ -1,23 +0,0 @@
|
||||
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
|
||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||
|
||||
using System.ComponentModel;
|
||||
|
||||
namespace osu.Game.Input
|
||||
{
|
||||
public enum GlobalAction
|
||||
{
|
||||
[Description("Toggle chat overlay")]
|
||||
ToggleChat,
|
||||
[Description("Toggle social overlay")]
|
||||
ToggleSocial,
|
||||
[Description("Reset input settings")]
|
||||
ResetInputSettings,
|
||||
[Description("Toggle toolbar")]
|
||||
ToggleToolbar,
|
||||
[Description("Toggle settings")]
|
||||
ToggleSettings,
|
||||
[Description("Toggle osu!direct")]
|
||||
ToggleDirect,
|
||||
}
|
||||
}
|
@ -3,11 +3,23 @@
|
||||
|
||||
using OpenTK.Input;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Input;
|
||||
|
||||
namespace osu.Game.Input
|
||||
{
|
||||
public class GlobalActionMappingInputManager : ActionMappingInputManager<GlobalAction>
|
||||
{
|
||||
private readonly Drawable handler;
|
||||
|
||||
public GlobalActionMappingInputManager(OsuGameBase game)
|
||||
{
|
||||
if (game is IHandleActions<GlobalAction>)
|
||||
handler = game;
|
||||
}
|
||||
|
||||
protected override IDictionary<KeyCombination, GlobalAction> CreateDefaultMappings() => new Dictionary<KeyCombination, GlobalAction>
|
||||
{
|
||||
{ Key.F8, GlobalAction.ToggleChat },
|
||||
@ -17,5 +29,39 @@ namespace osu.Game.Input
|
||||
{ new[] { Key.LControl, Key.O }, GlobalAction.ToggleSettings },
|
||||
{ new[] { Key.LControl, Key.D }, GlobalAction.ToggleDirect },
|
||||
};
|
||||
|
||||
protected override bool PropagateKeyDown(IEnumerable<Drawable> drawables, InputState state, KeyDownEventArgs args)
|
||||
{
|
||||
if (handler != null)
|
||||
drawables = new[] { handler }.Concat(drawables);
|
||||
|
||||
// always handle ourselves before all children.
|
||||
return base.PropagateKeyDown(drawables, state, args);
|
||||
}
|
||||
|
||||
protected override bool PropagateKeyUp(IEnumerable<Drawable> drawables, InputState state, KeyUpEventArgs args)
|
||||
{
|
||||
if (handler != null)
|
||||
drawables = new[] { handler }.Concat(drawables);
|
||||
|
||||
// always handle ourselves before all children.
|
||||
return base.PropagateKeyUp(drawables, state, args);
|
||||
}
|
||||
}
|
||||
|
||||
public enum GlobalAction
|
||||
{
|
||||
[Description("Toggle chat overlay")]
|
||||
ToggleChat,
|
||||
[Description("Toggle social overlay")]
|
||||
ToggleSocial,
|
||||
[Description("Reset input settings")]
|
||||
ResetInputSettings,
|
||||
[Description("Toggle toolbar")]
|
||||
ToggleToolbar,
|
||||
[Description("Toggle settings")]
|
||||
ToggleSettings,
|
||||
[Description("Toggle osu!direct")]
|
||||
ToggleDirect,
|
||||
}
|
||||
}
|
||||
|
@ -1,24 +0,0 @@
|
||||
using System;
|
||||
using osu.Framework.Graphics;
|
||||
|
||||
namespace osu.Game.Input
|
||||
{
|
||||
/// <summary>
|
||||
/// A simple placeholder container which allows handling keyboard input at a higher level than otherwise possible.
|
||||
/// </summary>
|
||||
public class GlobalHotkeys : Drawable, IHandleActions<GlobalAction>
|
||||
{
|
||||
public Func<GlobalAction, bool> Handler;
|
||||
|
||||
public override bool HandleInput => true;
|
||||
|
||||
public GlobalHotkeys()
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both;
|
||||
}
|
||||
|
||||
public bool OnPressed(GlobalAction action) => Handler(action);
|
||||
|
||||
public bool OnReleased(GlobalAction action) => false;
|
||||
}
|
||||
}
|
@ -29,7 +29,7 @@ using osu.Game.Input;
|
||||
|
||||
namespace osu.Game
|
||||
{
|
||||
public class OsuGame : OsuGameBase
|
||||
public class OsuGame : OsuGameBase, IHandleActions<GlobalAction>
|
||||
{
|
||||
public Toolbar Toolbar;
|
||||
|
||||
@ -168,10 +168,6 @@ namespace osu.Game
|
||||
volume = new VolumeControl(),
|
||||
overlayContent = new Container { RelativeSizeAxes = Axes.Both },
|
||||
new OnScreenDisplay(),
|
||||
new Input.GlobalHotkeys //exists because UserInputManager is at a level below us.
|
||||
{
|
||||
Handler = globalHotkeyPressed
|
||||
}
|
||||
});
|
||||
|
||||
LoadComponentAsync(screenStack = new Loader(), d =>
|
||||
@ -251,7 +247,7 @@ namespace osu.Game
|
||||
Cursor.State = Visibility.Hidden;
|
||||
}
|
||||
|
||||
private bool globalHotkeyPressed(GlobalAction action)
|
||||
public bool OnPressed(GlobalAction action)
|
||||
{
|
||||
if (intro == null) return false;
|
||||
|
||||
@ -286,6 +282,8 @@ namespace osu.Game
|
||||
return false;
|
||||
}
|
||||
|
||||
public bool OnReleased(GlobalAction action) => false;
|
||||
|
||||
public event Action<Screen> ScreenChanged;
|
||||
|
||||
private Container mainContent;
|
||||
|
@ -187,7 +187,7 @@ namespace osu.Game
|
||||
Children = new Drawable[]
|
||||
{
|
||||
Cursor = new MenuCursor(),
|
||||
new GlobalActionMappingInputManager
|
||||
new GlobalActionMappingInputManager(this)
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Child = new OsuTooltipContainer(Cursor)
|
||||
|
@ -94,10 +94,8 @@
|
||||
<Compile Include="Graphics\UserInterface\OsuContextMenuItem.cs" />
|
||||
<Compile Include="Input\Binding.cs" />
|
||||
<Compile Include="Input\BindingStore.cs" />
|
||||
<Compile Include="Input\GlobalHotkeys.cs" />
|
||||
<Compile Include="Input\IHandleActions.cs" />
|
||||
<Compile Include="Input\KeyCombination.cs" />
|
||||
<Compile Include="Input\GlobalAction.cs" />
|
||||
<Compile Include="Input\GlobalActionMappingInputManager.cs" />
|
||||
<Compile Include="IO\FileStore.cs" />
|
||||
<Compile Include="IO\FileInfo.cs" />
|
||||
|
Loading…
Reference in New Issue
Block a user