1
0
mirror of https://github.com/ppy/osu.git synced 2024-09-22 03:27:24 +08:00

Merge pull request #9285 from Joehuu/home-shortcut

Add shortcut to go home
This commit is contained in:
Dean Herbert 2020-06-15 16:40:38 +09:00 committed by GitHub
commit 7e206ad2bd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 32 additions and 2 deletions

View File

@ -39,6 +39,8 @@ namespace osu.Game.Input.Bindings
new KeyBinding(InputKey.Escape, GlobalAction.Back),
new KeyBinding(InputKey.ExtraMouseButton1, GlobalAction.Back),
new KeyBinding(new[] { InputKey.Alt, InputKey.Home }, GlobalAction.Home),
new KeyBinding(InputKey.Up, GlobalAction.SelectPrevious),
new KeyBinding(InputKey.Down, GlobalAction.SelectNext),
@ -152,5 +154,8 @@ namespace osu.Game.Input.Bindings
[Description("Next Selection")]
SelectNext,
[Description("Home")]
Home,
}
}

View File

@ -62,6 +62,7 @@ namespace osu.Game.Overlays.Toolbar
protected ConstrainedIconContainer IconContainer;
protected SpriteText DrawableText;
protected Box HoverBackground;
private readonly Box flashBackground;
private readonly FillFlowContainer tooltipContainer;
private readonly SpriteText tooltip1;
private readonly SpriteText tooltip2;
@ -82,6 +83,13 @@ namespace osu.Game.Overlays.Toolbar
Blending = BlendingParameters.Additive,
Alpha = 0,
},
flashBackground = new Box
{
RelativeSizeAxes = Axes.Both,
Alpha = 0,
Colour = Color4.White.Opacity(100),
Blending = BlendingParameters.Additive,
},
Flow = new FillFlowContainer
{
Direction = FillDirection.Horizontal,
@ -139,7 +147,7 @@ namespace osu.Game.Overlays.Toolbar
protected override bool OnClick(ClickEvent e)
{
HoverBackground.FlashColour(Color4.White.Opacity(100), 500, Easing.OutQuint);
flashBackground.FadeOutFromOne(800, Easing.OutQuint);
tooltipContainer.FadeOut(100);
return base.OnClick(e);
}

View File

@ -2,10 +2,12 @@
// See the LICENCE file in the repository root for full licence text.
using osu.Framework.Graphics.Sprites;
using osu.Framework.Input.Bindings;
using osu.Game.Input.Bindings;
namespace osu.Game.Overlays.Toolbar
{
public class ToolbarHomeButton : ToolbarButton
public class ToolbarHomeButton : ToolbarButton, IKeyBindingHandler<GlobalAction>
{
public ToolbarHomeButton()
{
@ -13,5 +15,20 @@ namespace osu.Game.Overlays.Toolbar
TooltipMain = "Home";
TooltipSub = "Return to the main menu";
}
public bool OnPressed(GlobalAction action)
{
if (action == GlobalAction.Home)
{
Click();
return true;
}
return false;
}
public void OnReleased(GlobalAction action)
{
}
}
}