mirror of
https://github.com/ppy/osu.git
synced 2025-01-26 22:23:22 +08:00
Merge pull request #21163 from frenzibyte/always-show-cursor-on-focus-loss
Always display menu cursor when game is not focused
This commit is contained in:
commit
49f530910c
@ -70,7 +70,8 @@ namespace osu.Game.Graphics.Cursor
|
|||||||
private OsuGame? game { get; set; }
|
private OsuGame? game { get; set; }
|
||||||
|
|
||||||
private readonly IBindable<bool> lastInputWasMouse = new BindableBool();
|
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()
|
protected override void LoadComplete()
|
||||||
{
|
{
|
||||||
@ -81,8 +82,11 @@ namespace osu.Game.Graphics.Cursor
|
|||||||
|
|
||||||
if (game != null)
|
if (game != null)
|
||||||
{
|
{
|
||||||
isIdle.BindTo(game.IsIdle);
|
gameIdle.BindTo(game.IsIdle);
|
||||||
isIdle.BindValueChanged(_ => updateState());
|
gameIdle.BindValueChanged(_ => updateState());
|
||||||
|
|
||||||
|
gameActive.BindTo(game.IsActive);
|
||||||
|
gameActive.BindValueChanged(_ => updateState());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -90,7 +94,7 @@ namespace osu.Game.Graphics.Cursor
|
|||||||
|
|
||||||
private void updateState()
|
private void updateState()
|
||||||
{
|
{
|
||||||
bool combinedVisibility = State.Value == Visibility.Visible && (lastInputWasMouse.Value || !hideCursorOnNonMouseInput) && !isIdle.Value;
|
bool combinedVisibility = getCursorVisibility();
|
||||||
|
|
||||||
if (visible == combinedVisibility)
|
if (visible == combinedVisibility)
|
||||||
return;
|
return;
|
||||||
@ -103,6 +107,27 @@ namespace osu.Game.Graphics.Cursor
|
|||||||
PopOut();
|
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()
|
protected override void Update()
|
||||||
{
|
{
|
||||||
base.Update();
|
base.Update();
|
||||||
|
Loading…
Reference in New Issue
Block a user