1
0
mirror of https://github.com/ppy/osu.git synced 2024-09-22 09:27:34 +08:00

Use more regions

This commit is contained in:
Dean Herbert 2020-02-14 18:28:58 +09:00
parent b69d1ad678
commit 2808f8167d

View File

@ -81,8 +81,6 @@ namespace osu.Game.Screens.Play
private IdleTracker idleTracker; private IdleTracker idleTracker;
private Bindable<bool> muteWarningShownOnce;
private ScheduledDelegate scheduledPushPlayer; private ScheduledDelegate scheduledPushPlayer;
[Resolved(CanBeNull = true)] [Resolved(CanBeNull = true)]
@ -142,6 +140,8 @@ namespace osu.Game.Screens.Play
inputManager = GetContainingInputManager(); inputManager = GetContainingInputManager();
} }
#region Screen handling
public override void OnEntering(IScreen last) public override void OnEntering(IScreen last)
{ {
base.OnEntering(last); base.OnEntering(last);
@ -156,15 +156,7 @@ namespace osu.Game.Screens.Play
MetadataInfo.Delay(750).FadeIn(500); MetadataInfo.Delay(750).FadeIn(500);
this.Delay(1800).Schedule(pushWhenLoaded); this.Delay(1800).Schedule(pushWhenLoaded);
if (!muteWarningShownOnce.Value) showMuteWarningIfNeeded();
{
//Checks if the notification has not been shown yet and also if master volume is muted, track/music volume is muted or if the whole game is muted.
if (volumeOverlay?.IsMuted.Value == true || audioManager.Volume.Value <= audioManager.Volume.MinValue || audioManager.VolumeTrack.Value <= audioManager.VolumeTrack.MinValue)
{
notificationOverlay?.Post(new MutedNotification());
muteWarningShownOnce.Value = true;
}
}
} }
public override void OnResuming(IScreen last) public override void OnResuming(IScreen last)
@ -227,6 +219,8 @@ namespace osu.Game.Screens.Play
content.StopTracking(); content.StopTracking();
} }
#endregion
protected override void Update() protected override void Update()
{ {
base.Update(); base.Update();
@ -351,6 +345,23 @@ namespace osu.Game.Screens.Play
#endregion #endregion
#region Mute warning
private Bindable<bool> muteWarningShownOnce;
private void showMuteWarningIfNeeded()
{
if (!muteWarningShownOnce.Value)
{
//Checks if the notification has not been shown yet and also if master volume is muted, track/music volume is muted or if the whole game is muted.
if (volumeOverlay?.IsMuted.Value == true || audioManager.Volume.Value <= audioManager.Volume.MinValue || audioManager.VolumeTrack.Value <= audioManager.VolumeTrack.MinValue)
{
notificationOverlay?.Post(new MutedNotification());
muteWarningShownOnce.Value = true;
}
}
}
private class MutedNotification : SimpleNotification private class MutedNotification : SimpleNotification
{ {
public override bool IsImportant => true; public override bool IsImportant => true;
@ -378,5 +389,7 @@ namespace osu.Game.Screens.Play
}; };
} }
} }
#endregion
} }
} }