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

Hide menu cursor when user is idle

This commit is contained in:
Salman Ahmed 2022-10-12 17:50:31 +03:00
parent 8305d886e6
commit a44cfe2901
3 changed files with 16 additions and 3 deletions

View File

@ -49,7 +49,11 @@ namespace osu.Game.Graphics.Cursor
[Resolved] [Resolved]
private OsuUserInputManager inputManager { get; set; } = null!; private OsuUserInputManager inputManager { get; set; } = null!;
[Resolved]
private OsuGame? game { get; set; }
private readonly IBindable<bool> mouseInputSource = new BindableBool(); private readonly IBindable<bool> mouseInputSource = new BindableBool();
private readonly IBindable<bool> isIdle = new BindableBool();
private readonly Bindable<Visibility> internalState = new Bindable<Visibility>(); private readonly Bindable<Visibility> internalState = new Bindable<Visibility>();
@ -62,6 +66,11 @@ namespace osu.Game.Graphics.Cursor
mouseInputSource.BindTo(inputManager.IsMouseInputSource); mouseInputSource.BindTo(inputManager.IsMouseInputSource);
mouseInputSource.BindValueChanged(_ => updateInternalVisibility(), true); mouseInputSource.BindValueChanged(_ => updateInternalVisibility(), true);
if (game != null)
{
isIdle.BindTo(game.IsIdle);
isIdle.BindValueChanged(_ => updateInternalVisibility());
}
} }
private void updateInternalVisibility() private void updateInternalVisibility()

View File

@ -70,6 +70,7 @@ namespace osu.Game
/// The full osu! experience. Builds on top of <see cref="OsuGameBase"/> to add menus and binding logic /// The full osu! experience. Builds on top of <see cref="OsuGameBase"/> to add menus and binding logic
/// for initial components that are generally retrieved via DI. /// for initial components that are generally retrieved via DI.
/// </summary> /// </summary>
[Cached(typeof(OsuGame))]
public class OsuGame : OsuGameBase, IKeyBindingHandler<GlobalAction>, ILocalUserPlayInfo, IPerformFromScreenRunner, IOverlayManager, ILinkHandler public class OsuGame : OsuGameBase, IKeyBindingHandler<GlobalAction>, ILocalUserPlayInfo, IPerformFromScreenRunner, IOverlayManager, ILinkHandler
{ {
/// <summary> /// <summary>
@ -136,6 +137,11 @@ namespace osu.Game
private IdleTracker idleTracker; private IdleTracker idleTracker;
/// <summary>
/// Whether the user is currently in an idle state.
/// </summary>
public IBindable<bool> IsIdle => idleTracker.IsIdle;
/// <summary> /// <summary>
/// Whether overlays should be able to be opened game-wide. Value is sourced from the current active screen. /// Whether overlays should be able to be opened game-wide. Value is sourced from the current active screen.
/// </summary> /// </summary>
@ -266,8 +272,6 @@ namespace osu.Game
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load() private void load()
{ {
dependencies.CacheAs(this);
SentryLogger.AttachUser(API.LocalUser); SentryLogger.AttachUser(API.LocalUser);
dependencies.Cache(osuLogo = new OsuLogo { Alpha = 0 }); dependencies.Cache(osuLogo = new OsuLogo { Alpha = 0 });

View File

@ -62,6 +62,7 @@ namespace osu.Game
/// Unlike <see cref="OsuGame"/>, this class will not load any kind of UI, allowing it to be used /// Unlike <see cref="OsuGame"/>, this class will not load any kind of UI, allowing it to be used
/// for provide dependencies to test cases without interfering with them. /// for provide dependencies to test cases without interfering with them.
/// </summary> /// </summary>
[Cached(typeof(OsuGameBase))]
public partial class OsuGameBase : Framework.Game, ICanAcceptFiles, IBeatSyncProvider public partial class OsuGameBase : Framework.Game, ICanAcceptFiles, IBeatSyncProvider
{ {
public static readonly string[] VIDEO_EXTENSIONS = { ".mp4", ".mov", ".avi", ".flv" }; public static readonly string[] VIDEO_EXTENSIONS = { ".mp4", ".mov", ".avi", ".flv" };
@ -253,7 +254,6 @@ namespace osu.Game
largeStore.AddTextureSource(Host.CreateTextureLoaderStore(new OnlineStore())); largeStore.AddTextureSource(Host.CreateTextureLoaderStore(new OnlineStore()));
dependencies.Cache(largeStore); dependencies.Cache(largeStore);
dependencies.CacheAs(this);
dependencies.CacheAs(LocalConfig); dependencies.CacheAs(LocalConfig);
InitialiseFonts(); InitialiseFonts();