1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-27 11:12:59 +08:00

Hide menu cursor when non-mouse input is applied

This commit is contained in:
Salman Ahmed 2022-10-11 16:23:24 +03:00
parent 60c92c8744
commit 0a97ee71a9

View File

@ -14,6 +14,7 @@ using osu.Framework.Graphics.Textures;
using osu.Framework.Input.Events; using osu.Framework.Input.Events;
using osu.Framework.Utils; using osu.Framework.Utils;
using osu.Game.Configuration; using osu.Game.Configuration;
using osu.Game.Input;
using osuTK; using osuTK;
namespace osu.Game.Graphics.Cursor namespace osu.Game.Graphics.Cursor
@ -27,14 +28,22 @@ namespace osu.Game.Graphics.Cursor
private Cursor activeCursor = null!; private Cursor activeCursor = null!;
private readonly Container fadeContainer;
protected override Container<Drawable> Content => fadeContainer;
private DragRotationState dragRotationState; private DragRotationState dragRotationState;
private Vector2 positionMouseDown; private Vector2 positionMouseDown;
private Vector2 lastMovePosition; private Vector2 lastMovePosition;
private Bindable<bool> cursorRotate = null!; private Bindable<bool> cursorRotate = null!;
private Sample tapSample = null!; private Sample tapSample = null!;
public MenuCursorContainer()
{
InternalChild = fadeContainer = new Container { RelativeSizeAxes = Axes.Both };
}
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load(OsuConfigManager config, ScreenshotManager? screenshotManager, AudioManager audio) private void load(OsuConfigManager config, ScreenshotManager? screenshotManager, AudioManager audio)
{ {
@ -46,6 +55,19 @@ namespace osu.Game.Graphics.Cursor
tapSample = audio.Samples.Get(@"UI/cursor-tap"); tapSample = audio.Samples.Get(@"UI/cursor-tap");
} }
[Resolved]
private OsuUserInputManager inputManager { get; set; } = null!;
private IBindable<bool> mouseInputSource = null!;
protected override void LoadComplete()
{
base.LoadComplete();
mouseInputSource = inputManager.IsMouseInputSource.GetBoundCopy();
mouseInputSource.BindValueChanged(m => updateInternalVisibilityState(m.NewValue), true);
}
protected override void Update() protected override void Update()
{ {
base.Update(); base.Update();
@ -146,6 +168,8 @@ namespace osu.Game.Graphics.Cursor
activeCursor.ScaleTo(0.6f, 250, Easing.In); activeCursor.ScaleTo(0.6f, 250, Easing.In);
} }
private void updateInternalVisibilityState(bool show) => fadeContainer.FadeTo(show ? 1 : 0, 120, Easing.OutQuint);
private void playTapSample(double baseFrequency = 1f) private void playTapSample(double baseFrequency = 1f)
{ {
const float random_range = 0.02f; const float random_range = 0.02f;