mirror of
https://github.com/ppy/osu.git
synced 2024-11-06 06:17:23 +08:00
Use more local bindables
This commit is contained in:
parent
b9a39fb788
commit
3e3f12f277
@ -196,9 +196,10 @@ namespace osu.Game.Tests.Visual.Gameplay
|
||||
|
||||
public bool PauseOverlayVisible => PauseOverlay.State == Visibility.Visible;
|
||||
|
||||
public PausePlayer()
|
||||
protected override void LoadComplete()
|
||||
{
|
||||
PauseOnFocusLost = false;
|
||||
base.LoadComplete();
|
||||
HUDOverlay.HoldToQuit.PauseOnFocusLost = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -4,6 +4,7 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
@ -70,9 +71,9 @@ namespace osu.Game.Screens.Play.HUD
|
||||
return base.OnMouseMove(e);
|
||||
}
|
||||
|
||||
public bool GameInactive
|
||||
public bool PauseOnFocusLost
|
||||
{
|
||||
set => button.GameInactive = value;
|
||||
set => button.PauseOnFocusLost = value;
|
||||
}
|
||||
|
||||
protected override void Update()
|
||||
@ -98,8 +99,10 @@ namespace osu.Game.Screens.Play.HUD
|
||||
public Action HoverGained;
|
||||
public Action HoverLost;
|
||||
|
||||
private readonly IBindable<bool> gameActive = new Bindable<bool>(true);
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(OsuColour colours)
|
||||
private void load(OsuColour colours, Framework.Game game)
|
||||
{
|
||||
Size = new Vector2(60);
|
||||
|
||||
@ -140,6 +143,9 @@ namespace osu.Game.Screens.Play.HUD
|
||||
};
|
||||
|
||||
bind();
|
||||
|
||||
gameActive.BindValueChanged(_ => updateActive());
|
||||
gameActive.BindTo(game.IsActive);
|
||||
}
|
||||
|
||||
private void bind()
|
||||
@ -189,25 +195,30 @@ namespace osu.Game.Screens.Play.HUD
|
||||
base.OnHoverLost(e);
|
||||
}
|
||||
|
||||
private bool gameInactive;
|
||||
private bool pauseOnFocusLost;
|
||||
|
||||
public bool GameInactive
|
||||
public bool PauseOnFocusLost
|
||||
{
|
||||
get => gameInactive;
|
||||
set
|
||||
{
|
||||
if (gameInactive == value)
|
||||
if (pauseOnFocusLost == value)
|
||||
return;
|
||||
|
||||
gameInactive = value;
|
||||
|
||||
if (gameInactive)
|
||||
BeginConfirm();
|
||||
else
|
||||
AbortConfirm();
|
||||
pauseOnFocusLost = value;
|
||||
updateActive();
|
||||
}
|
||||
}
|
||||
|
||||
private void updateActive()
|
||||
{
|
||||
if (!pauseOnFocusLost) return;
|
||||
|
||||
if (gameActive.Value)
|
||||
AbortConfirm();
|
||||
else
|
||||
BeginConfirm();
|
||||
}
|
||||
|
||||
public bool OnPressed(GlobalAction action)
|
||||
{
|
||||
switch (action)
|
||||
|
@ -44,8 +44,6 @@ namespace osu.Game.Screens.Play
|
||||
|
||||
public bool HasFailed { get; private set; }
|
||||
|
||||
public bool PauseOnFocusLost { get; set; } = true;
|
||||
|
||||
private Bindable<bool> mouseWheelDisabled;
|
||||
|
||||
private readonly Bindable<bool> storyboardReplacesBackground = new Bindable<bool>();
|
||||
@ -388,15 +386,6 @@ namespace osu.Game.Screens.Play
|
||||
// already resuming
|
||||
&& !IsResuming;
|
||||
|
||||
protected override void Update()
|
||||
{
|
||||
base.Update();
|
||||
|
||||
// eagerly pause when we lose window focus (if we are locally playing).
|
||||
if (PauseOnFocusLost)
|
||||
HUDOverlay.HoldToQuit.GameInactive = !Game.IsActive.Value;
|
||||
}
|
||||
|
||||
public void Pause()
|
||||
{
|
||||
if (!canPause) return;
|
||||
|
Loading…
Reference in New Issue
Block a user