1
0
mirror of https://github.com/ppy/osu.git synced 2026-05-21 03:39:53 +08:00

Ensure BindValueChanged is run after LoadComplete

This commit is contained in:
Dean Herbert
2025-03-19 19:56:27 +09:00
Unverified
parent d6a06f2af6
commit c1604a797f
+11 -6
View File
@@ -34,9 +34,9 @@ namespace osu.Game.Screens.Play
OnResume?.Invoke();
};
private IBindable<bool>? windowActive;
private readonly IBindable<bool> windowActive = new Bindable<bool>(true);
private float targetVolume => windowActive?.Value != false && State.Value == Visibility.Visible ? 1.0f : 0;
private float targetVolume => windowActive.Value && State.Value == Visibility.Visible ? 1.0f : 0;
[BackgroundDependencyLoader]
private void load(GameHost? host)
@@ -48,10 +48,15 @@ namespace osu.Game.Screens.Play
});
if (host != null)
{
windowActive = host.IsActive.GetBoundCopy();
windowActive.BindValueChanged(_ => Schedule(() => pauseLoop.VolumeTo(targetVolume, 1000, Easing.Out)));
}
windowActive.BindTo(host.IsActive);
}
protected override void LoadComplete()
{
base.LoadComplete();
// Schedule required because host.IsActive doesn't seem to always run on the update thread.
windowActive.BindValueChanged(_ => Schedule(() => pauseLoop.VolumeTo(targetVolume, 1000, Easing.Out)));
}
public void StopAllSamples()