mirror of
https://github.com/ppy/osu
synced 2024-12-17 04:15:37 +00:00
Merge branch 'master' into fix-new-inspections
This commit is contained in:
commit
8bc313fb33
@ -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,6 +71,11 @@ namespace osu.Game.Screens.Play.HUD
|
||||
return base.OnMouseMove(e);
|
||||
}
|
||||
|
||||
public bool PauseOnFocusLost
|
||||
{
|
||||
set => button.PauseOnFocusLost = value;
|
||||
}
|
||||
|
||||
protected override void Update()
|
||||
{
|
||||
base.Update();
|
||||
@ -93,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);
|
||||
|
||||
@ -135,6 +143,14 @@ namespace osu.Game.Screens.Play.HUD
|
||||
};
|
||||
|
||||
bind();
|
||||
|
||||
gameActive.BindTo(game.IsActive);
|
||||
}
|
||||
|
||||
protected override void LoadComplete()
|
||||
{
|
||||
base.LoadComplete();
|
||||
gameActive.BindValueChanged(_ => updateActive(), true);
|
||||
}
|
||||
|
||||
private void bind()
|
||||
@ -184,6 +200,31 @@ namespace osu.Game.Screens.Play.HUD
|
||||
base.OnHoverLost(e);
|
||||
}
|
||||
|
||||
private bool pauseOnFocusLost = true;
|
||||
|
||||
public bool PauseOnFocusLost
|
||||
{
|
||||
set
|
||||
{
|
||||
if (pauseOnFocusLost == value)
|
||||
return;
|
||||
|
||||
pauseOnFocusLost = value;
|
||||
if (IsLoaded)
|
||||
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 && !Game.IsActive.Value)
|
||||
Pause();
|
||||
}
|
||||
|
||||
public void Pause()
|
||||
{
|
||||
if (!canPause) return;
|
||||
|
Loading…
Reference in New Issue
Block a user