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