mirror of
https://github.com/ppy/osu.git
synced 2025-01-14 17:52:56 +08:00
Allow top-level menu key pressed to progress the osu! logo
This commit is contained in:
parent
cdf29b0952
commit
fc1d49631a
@ -31,6 +31,8 @@ namespace osu.Game.Screens.Menu
|
||||
{
|
||||
public event Action<ButtonState> StateChanged;
|
||||
|
||||
public readonly Key TriggerKey;
|
||||
|
||||
private readonly Container iconText;
|
||||
private readonly Container box;
|
||||
private readonly Box boxHoverLayer;
|
||||
@ -43,7 +45,6 @@ namespace osu.Game.Screens.Menu
|
||||
public ButtonSystemState VisibleState = ButtonSystemState.TopLevel;
|
||||
|
||||
private readonly Action clickAction;
|
||||
private readonly Key triggerKey;
|
||||
private SampleChannel sampleClick;
|
||||
private SampleChannel sampleHover;
|
||||
|
||||
@ -53,7 +54,7 @@ namespace osu.Game.Screens.Menu
|
||||
{
|
||||
this.sampleName = sampleName;
|
||||
this.clickAction = clickAction;
|
||||
this.triggerKey = triggerKey;
|
||||
TriggerKey = triggerKey;
|
||||
|
||||
AutoSizeAxes = Axes.Both;
|
||||
Alpha = 0;
|
||||
@ -210,7 +211,7 @@ namespace osu.Game.Screens.Menu
|
||||
if (e.Repeat || e.ControlPressed || e.ShiftPressed || e.AltPressed)
|
||||
return false;
|
||||
|
||||
if (triggerKey == e.Key && triggerKey != Key.Unknown)
|
||||
if (TriggerKey == e.Key && TriggerKey != Key.Unknown)
|
||||
{
|
||||
trigger();
|
||||
return true;
|
||||
|
@ -14,6 +14,7 @@ using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Sprites;
|
||||
using osu.Framework.Input.Bindings;
|
||||
using osu.Framework.Input.Events;
|
||||
using osu.Framework.Logging;
|
||||
using osu.Framework.Platform;
|
||||
using osu.Framework.Threading;
|
||||
@ -180,6 +181,20 @@ namespace osu.Game.Screens.Menu
|
||||
State = ButtonSystemState.Initial;
|
||||
}
|
||||
|
||||
protected override bool OnKeyDown(KeyDownEvent e)
|
||||
{
|
||||
if (State == ButtonSystemState.Initial)
|
||||
{
|
||||
if (buttonsTopLevel.Any(b => e.PressedKeys.Contains(b.TriggerKey)))
|
||||
{
|
||||
logo.Click();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return base.OnKeyDown(e);
|
||||
}
|
||||
|
||||
public bool OnPressed(GlobalAction action)
|
||||
{
|
||||
switch (action)
|
||||
|
Loading…
Reference in New Issue
Block a user