mirror of
https://github.com/ppy/osu
synced 2025-01-05 13:50:03 +00:00
Always display menu cursor when game is not focused
This commit is contained in:
parent
cb6b9898c1
commit
7ee9018a94
@ -70,7 +70,8 @@ namespace osu.Game.Graphics.Cursor
|
||||
private OsuGame? game { get; set; }
|
||||
|
||||
private readonly IBindable<bool> lastInputWasMouse = new BindableBool();
|
||||
private readonly IBindable<bool> isIdle = new BindableBool();
|
||||
private readonly IBindable<bool> gameActive = new BindableBool(true);
|
||||
private readonly IBindable<bool> gameIdle = new BindableBool();
|
||||
|
||||
protected override void LoadComplete()
|
||||
{
|
||||
@ -81,8 +82,11 @@ namespace osu.Game.Graphics.Cursor
|
||||
|
||||
if (game != null)
|
||||
{
|
||||
isIdle.BindTo(game.IsIdle);
|
||||
isIdle.BindValueChanged(_ => updateState());
|
||||
gameIdle.BindTo(game.IsIdle);
|
||||
gameIdle.BindValueChanged(_ => updateState());
|
||||
|
||||
gameActive.BindTo(game.IsActive);
|
||||
gameActive.BindValueChanged(_ => updateState());
|
||||
}
|
||||
}
|
||||
|
||||
@ -90,7 +94,7 @@ namespace osu.Game.Graphics.Cursor
|
||||
|
||||
private void updateState()
|
||||
{
|
||||
bool combinedVisibility = State.Value == Visibility.Visible && (lastInputWasMouse.Value || !hideCursorOnNonMouseInput) && !isIdle.Value;
|
||||
bool combinedVisibility = getCursorVisibility();
|
||||
|
||||
if (visible == combinedVisibility)
|
||||
return;
|
||||
@ -103,6 +107,27 @@ namespace osu.Game.Graphics.Cursor
|
||||
PopOut();
|
||||
}
|
||||
|
||||
private bool getCursorVisibility()
|
||||
{
|
||||
// do not display when explicitly set to hidden state.
|
||||
if (State.Value == Visibility.Hidden)
|
||||
return false;
|
||||
|
||||
// only hide cursor when game is focused, otherwise it should always be displayed.
|
||||
if (gameActive.Value)
|
||||
{
|
||||
// do not display when last input is not mouse.
|
||||
if (hideCursorOnNonMouseInput && !lastInputWasMouse.Value)
|
||||
return false;
|
||||
|
||||
// do not display when game is idle.
|
||||
if (gameIdle.Value)
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
protected override void Update()
|
||||
{
|
||||
base.Update();
|
||||
|
Loading…
Reference in New Issue
Block a user