1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-26 12:45:09 +08:00

Handle global action in toolbar instead of osugame

This commit is contained in:
Joehu 2020-11-09 14:45:20 -08:00
parent d0644221ff
commit 6c0734a09f
2 changed files with 20 additions and 6 deletions

View File

@ -885,10 +885,6 @@ namespace osu.Game
frameworkConfig.GetBindable<ConfineMouseMode>(FrameworkSetting.ConfineMouseMode).SetDefault();
return true;
case GlobalAction.ToggleToolbar:
Toolbar.ToggleVisibility();
return true;
case GlobalAction.ToggleGameplayMouseButtons:
LocalConfig.Set(OsuSetting.MouseDisableButtons, !LocalConfig.Get<bool>(OsuSetting.MouseDisableButtons));
return true;

View File

@ -13,10 +13,12 @@ using osu.Framework.Allocation;
using osu.Framework.Bindables;
using osu.Framework.Input.Events;
using osu.Game.Rulesets;
using osu.Framework.Input.Bindings;
using osu.Game.Input.Bindings;
namespace osu.Game.Overlays.Toolbar
{
public class Toolbar : VisibilityContainer
public class Toolbar : VisibilityContainer, IKeyBindingHandler<GlobalAction>
{
public const float HEIGHT = 40;
public const float TOOLTIP_HEIGHT = 30;
@ -30,7 +32,7 @@ namespace osu.Game.Overlays.Toolbar
protected readonly IBindable<OverlayActivation> OverlayActivationMode = new Bindable<OverlayActivation>(OverlayActivation.All);
// Toolbar components like RulesetSelector should receive keyboard input events even when the toolbar is hidden.
// Toolbar and its components need keyboard input even when hidden.
public override bool PropagateNonPositionalInputSubTree => true;
public Toolbar()
@ -164,5 +166,21 @@ namespace osu.Game.Overlays.Toolbar
this.MoveToY(-DrawSize.Y, transition_time, Easing.OutQuint);
this.FadeOut(transition_time, Easing.InQuint);
}
public bool OnPressed(GlobalAction action)
{
switch (action)
{
case GlobalAction.ToggleToolbar:
ToggleVisibility();
return true;
}
return false;
}
public void OnReleased(GlobalAction action)
{
}
}
}