Merge branch 'master' into host-enqueue-2

This commit is contained in:
Dean Herbert 2021-12-10 14:09:19 +09:00 committed by GitHub
commit 50bf2f368d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 17 additions and 7 deletions

View File

@ -251,7 +251,12 @@ public void TestMutedNotificationTrackVolume()
[Test]
public void TestMutedNotificationMuteButton()
{
addVolumeSteps("mute button", () => volumeOverlay.IsMuted.Value = true, () => !volumeOverlay.IsMuted.Value);
addVolumeSteps("mute button", () =>
{
// Importantly, in the case the volume is muted but the user has a volume level set, it should be retained.
audioManager.VolumeTrack.Value = 0.5f;
volumeOverlay.IsMuted.Value = true;
}, () => !volumeOverlay.IsMuted.Value && audioManager.VolumeTrack.Value == 0.5f);
}
/// <remarks>

View File

@ -20,11 +20,10 @@
using osu.Game.Screens.OnlinePlay;
using osu.Game.Screens.OnlinePlay.Multiplayer.Match.Playlist;
using osu.Game.Tests.Resources;
using osu.Game.Tests.Visual.Multiplayer;
using osuTK;
using osuTK.Input;
namespace osu.Game.Tests.Visual.Online
namespace osu.Game.Tests.Visual.Multiplayer
{
public class TestSceneMultiplayerQueueList : MultiplayerTestScene
{

View File

@ -468,12 +468,14 @@ protected override void Dispose(bool isDisposing)
private int restartCount;
private const double volume_requirement = 0.05;
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)
if (volumeOverlay?.IsMuted.Value == true || audioManager.Volume.Value <= volume_requirement || audioManager.VolumeTrack.Value <= volume_requirement)
{
notificationOverlay?.Post(new MutedNotification());
muteWarningShownOnce.Value = true;
@ -487,7 +489,7 @@ private class MutedNotification : SimpleNotification
public MutedNotification()
{
Text = "Your music volume is set to 0%! Click here to restore it.";
Text = "Your game volume is too low to hear anything! Click here to restore it.";
}
[BackgroundDependencyLoader]
@ -501,8 +503,12 @@ private void load(OsuColour colours, AudioManager audioManager, NotificationOver
notificationOverlay.Hide();
volumeOverlay.IsMuted.Value = false;
audioManager.Volume.SetDefault();
audioManager.VolumeTrack.SetDefault();
// Check values before resetting, as the user may have only had mute enabled, in which case we might not need to adjust volumes.
if (audioManager.Volume.Value <= volume_requirement)
audioManager.Volume.SetDefault();
if (audioManager.VolumeTrack.Value <= volume_requirement)
audioManager.VolumeTrack.SetDefault();
return true;
};