mirror of
https://github.com/ppy/osu.git
synced 2024-12-14 19:22:54 +08:00
Merge pull request #2472 from UselessToucan/back_mouse_button_support
Add ability to bind "back" action; add default mouse binding
This commit is contained in:
commit
cdd43f7909
@ -37,6 +37,9 @@ namespace osu.Game.Input.Bindings
|
|||||||
new KeyBinding(InputKey.Down, GlobalAction.DecreaseVolume),
|
new KeyBinding(InputKey.Down, GlobalAction.DecreaseVolume),
|
||||||
new KeyBinding(InputKey.MouseWheelDown, GlobalAction.DecreaseVolume),
|
new KeyBinding(InputKey.MouseWheelDown, GlobalAction.DecreaseVolume),
|
||||||
new KeyBinding(InputKey.F4, GlobalAction.ToggleMute),
|
new KeyBinding(InputKey.F4, GlobalAction.ToggleMute),
|
||||||
|
|
||||||
|
new KeyBinding(InputKey.Escape, GlobalAction.Back),
|
||||||
|
new KeyBinding(InputKey.MouseButton1, GlobalAction.Back)
|
||||||
};
|
};
|
||||||
|
|
||||||
public IEnumerable<KeyBinding> InGameKeyBindings => new[]
|
public IEnumerable<KeyBinding> InGameKeyBindings => new[]
|
||||||
@ -80,5 +83,8 @@ namespace osu.Game.Input.Bindings
|
|||||||
TakeScreenshot,
|
TakeScreenshot,
|
||||||
[Description("Toggle gameplay mouse buttons")]
|
[Description("Toggle gameplay mouse buttons")]
|
||||||
ToggleGameplayMouseButtons,
|
ToggleGameplayMouseButtons,
|
||||||
|
|
||||||
|
[Description("Go back")]
|
||||||
|
Back
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -6,9 +6,11 @@ using osu.Framework.Allocation;
|
|||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
using osu.Framework.Input;
|
using osu.Framework.Input;
|
||||||
|
using osu.Framework.Input.Bindings;
|
||||||
using osu.Game.Graphics;
|
using osu.Game.Graphics;
|
||||||
using osu.Game.Graphics.Containers;
|
using osu.Game.Graphics.Containers;
|
||||||
using osu.Game.Graphics.Sprites;
|
using osu.Game.Graphics.Sprites;
|
||||||
|
using osu.Game.Input.Bindings;
|
||||||
using osu.Game.Overlays.Settings;
|
using osu.Game.Overlays.Settings;
|
||||||
using osu.Game.Overlays.Settings.Sections;
|
using osu.Game.Overlays.Settings.Sections;
|
||||||
using osu.Game.Screens.Ranking;
|
using osu.Game.Screens.Ranking;
|
||||||
@ -96,7 +98,7 @@ namespace osu.Game.Overlays
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private class BackButton : OsuClickableContainer
|
private class BackButton : OsuClickableContainer, IKeyBindingHandler<GlobalAction>
|
||||||
{
|
{
|
||||||
private AspectContainer aspect;
|
private AspectContainer aspect;
|
||||||
|
|
||||||
@ -146,6 +148,20 @@ namespace osu.Game.Overlays
|
|||||||
aspect.ScaleTo(1, 1000, Easing.OutElastic);
|
aspect.ScaleTo(1, 1000, Easing.OutElastic);
|
||||||
return base.OnMouseUp(state, args);
|
return base.OnMouseUp(state, args);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public bool OnPressed(GlobalAction action)
|
||||||
|
{
|
||||||
|
switch (action)
|
||||||
|
{
|
||||||
|
case GlobalAction.Back:
|
||||||
|
TriggerOnClick();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool OnReleased(GlobalAction action) => false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -19,6 +19,8 @@ namespace osu.Game.Screens
|
|||||||
|
|
||||||
public override bool ShowOverlaysOnEnter => false;
|
public override bool ShowOverlaysOnEnter => false;
|
||||||
|
|
||||||
|
protected override bool AllowBackButton => false;
|
||||||
|
|
||||||
public Loader()
|
public Loader()
|
||||||
{
|
{
|
||||||
ValidForResume = false;
|
ValidForResume = false;
|
||||||
|
@ -6,22 +6,24 @@ using System.Collections.Generic;
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using osu.Framework;
|
using osu.Framework;
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
|
using osu.Framework.Audio;
|
||||||
|
using osu.Framework.Audio.Sample;
|
||||||
|
using osu.Framework.Configuration;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
using osu.Framework.Graphics.Shapes;
|
using osu.Framework.Graphics.Shapes;
|
||||||
using osu.Framework.Input;
|
using osu.Framework.Input;
|
||||||
|
using osu.Framework.Input.Bindings;
|
||||||
|
using osu.Framework.Threading;
|
||||||
using osu.Game.Graphics;
|
using osu.Game.Graphics;
|
||||||
|
using osu.Game.Input.Bindings;
|
||||||
using OpenTK;
|
using OpenTK;
|
||||||
using OpenTK.Graphics;
|
using OpenTK.Graphics;
|
||||||
using OpenTK.Input;
|
using OpenTK.Input;
|
||||||
using osu.Framework.Audio.Sample;
|
|
||||||
using osu.Framework.Audio;
|
|
||||||
using osu.Framework.Configuration;
|
|
||||||
using osu.Framework.Threading;
|
|
||||||
|
|
||||||
namespace osu.Game.Screens.Menu
|
namespace osu.Game.Screens.Menu
|
||||||
{
|
{
|
||||||
public class ButtonSystem : Container, IStateful<MenuState>
|
public class ButtonSystem : Container, IStateful<MenuState>, IKeyBindingHandler<GlobalAction>
|
||||||
{
|
{
|
||||||
public event Action<MenuState> StateChanged;
|
public event Action<MenuState> StateChanged;
|
||||||
|
|
||||||
@ -146,7 +148,16 @@ namespace osu.Game.Screens.Menu
|
|||||||
case Key.Space:
|
case Key.Space:
|
||||||
logo?.TriggerOnClick(state);
|
logo?.TriggerOnClick(state);
|
||||||
return true;
|
return true;
|
||||||
case Key.Escape:
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool OnPressed(GlobalAction action)
|
||||||
|
{
|
||||||
|
switch (action)
|
||||||
|
{
|
||||||
|
case GlobalAction.Back:
|
||||||
switch (State)
|
switch (State)
|
||||||
{
|
{
|
||||||
case MenuState.TopLevel:
|
case MenuState.TopLevel:
|
||||||
@ -155,13 +166,24 @@ namespace osu.Game.Screens.Menu
|
|||||||
case MenuState.Play:
|
case MenuState.Play:
|
||||||
backButton.TriggerOnClick();
|
backButton.TriggerOnClick();
|
||||||
return true;
|
return true;
|
||||||
}
|
default:
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
default:
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool OnReleased(GlobalAction action)
|
||||||
|
{
|
||||||
|
switch (action)
|
||||||
|
{
|
||||||
|
case GlobalAction.Back:
|
||||||
|
return true;
|
||||||
|
default:
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void onPlay()
|
private void onPlay()
|
||||||
{
|
{
|
||||||
@ -337,6 +359,7 @@ namespace osu.Game.Screens.Menu
|
|||||||
logo.ScaleTo(0.5f, 200, Easing.OutQuint);
|
logo.ScaleTo(0.5f, 200, Easing.OutQuint);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case MenuState.EnteringMode:
|
case MenuState.EnteringMode:
|
||||||
logoTracking = true;
|
logoTracking = true;
|
||||||
|
@ -26,6 +26,8 @@ namespace osu.Game.Screens.Menu
|
|||||||
|
|
||||||
public override bool ShowOverlaysOnEnter => buttons.State != MenuState.Initial;
|
public override bool ShowOverlaysOnEnter => buttons.State != MenuState.Initial;
|
||||||
|
|
||||||
|
protected override bool AllowBackButton => buttons.State != MenuState.Initial;
|
||||||
|
|
||||||
private readonly BackgroundScreenDefault background;
|
private readonly BackgroundScreenDefault background;
|
||||||
private Screen songSelect;
|
private Screen songSelect;
|
||||||
|
|
||||||
|
@ -3,25 +3,29 @@
|
|||||||
|
|
||||||
using System;
|
using System;
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
|
using osu.Framework.Audio;
|
||||||
|
using osu.Framework.Audio.Sample;
|
||||||
using osu.Framework.Configuration;
|
using osu.Framework.Configuration;
|
||||||
|
using osu.Framework.Graphics;
|
||||||
|
using osu.Framework.Input;
|
||||||
|
using osu.Framework.Input.Bindings;
|
||||||
using osu.Framework.Screens;
|
using osu.Framework.Screens;
|
||||||
using osu.Game.Beatmaps;
|
using osu.Game.Beatmaps;
|
||||||
using osu.Game.Graphics.Containers;
|
using osu.Game.Graphics.Containers;
|
||||||
using OpenTK;
|
using osu.Game.Input.Bindings;
|
||||||
using osu.Framework.Audio.Sample;
|
|
||||||
using osu.Framework.Audio;
|
|
||||||
using osu.Framework.Graphics;
|
|
||||||
using osu.Game.Rulesets;
|
using osu.Game.Rulesets;
|
||||||
using osu.Game.Screens.Menu;
|
using osu.Game.Screens.Menu;
|
||||||
using osu.Framework.Input;
|
using OpenTK;
|
||||||
using OpenTK.Input;
|
using OpenTK.Input;
|
||||||
|
|
||||||
namespace osu.Game.Screens
|
namespace osu.Game.Screens
|
||||||
{
|
{
|
||||||
public abstract class OsuScreen : Screen
|
public abstract class OsuScreen : Screen, IKeyBindingHandler<GlobalAction>
|
||||||
{
|
{
|
||||||
public BackgroundScreen Background { get; private set; }
|
public BackgroundScreen Background { get; private set; }
|
||||||
|
|
||||||
|
protected virtual bool AllowBackButton => true;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Override to create a BackgroundMode for the current screen.
|
/// Override to create a BackgroundMode for the current screen.
|
||||||
/// Note that the instance created may not be the used instance if it matches the BackgroundMode equality clause.
|
/// Note that the instance created may not be the used instance if it matches the BackgroundMode equality clause.
|
||||||
@ -90,6 +94,19 @@ namespace osu.Game.Screens
|
|||||||
sampleExit = audio.Sample.Get(@"UI/screen-back");
|
sampleExit = audio.Sample.Get(@"UI/screen-back");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public bool OnPressed(GlobalAction action)
|
||||||
|
{
|
||||||
|
if (action == GlobalAction.Back && AllowBackButton)
|
||||||
|
{
|
||||||
|
Exit();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool OnReleased(GlobalAction action) => action == GlobalAction.Back && AllowBackButton;
|
||||||
|
|
||||||
protected override bool OnKeyDown(InputState state, KeyDownEventArgs args)
|
protected override bool OnKeyDown(InputState state, KeyDownEventArgs args)
|
||||||
{
|
{
|
||||||
if (args.Repeat || !IsCurrentScreen) return false;
|
if (args.Repeat || !IsCurrentScreen) return false;
|
||||||
|
@ -45,6 +45,8 @@ namespace osu.Game.Screens.Play
|
|||||||
public bool AllowLeadIn { get; set; } = true;
|
public bool AllowLeadIn { get; set; } = true;
|
||||||
public bool AllowResults { get; set; } = true;
|
public bool AllowResults { get; set; } = true;
|
||||||
|
|
||||||
|
protected override bool AllowBackButton => false;
|
||||||
|
|
||||||
private Bindable<bool> mouseWheelDisabled;
|
private Bindable<bool> mouseWheelDisabled;
|
||||||
private Bindable<double> userAudioOffset;
|
private Bindable<double> userAudioOffset;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user