Add check if game is muted by MuteButton

This commit is contained in:
Craftplacer 2019-09-15 16:32:23 +02:00
parent 0afb5c5bb0
commit 00e46fdefe
1 changed files with 8 additions and 3 deletions

View File

@ -7,6 +7,7 @@
using System.Threading.Tasks;
using osu.Framework.Allocation;
using osu.Framework.Audio;
using osu.Framework.Bindables;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Sprites;
@ -57,10 +58,13 @@ public class PlayerLoader : ScreenWithBeatmapBackground
private InputManager inputManager;
private IdleTracker idleTracker;
[Resolved]
private NotificationOverlay notificationOverlay { get; set; }
private IdleTracker idleTracker;
[Resolved]
private VolumeOverlay volumeOverlay { get; set; }
public PlayerLoader(Func<Player> createPlayer)
{
@ -155,7 +159,7 @@ private void contentOut()
private void checkVolume(AudioManager audio)
{
if (audio.Volume.Value <= audio.Volume.MinValue || audio.VolumeTrack.Value <= audio.VolumeTrack.MinValue)
if (volumeOverlay.IsMuted || audio.Volume.Value <= audio.Volume.MinValue || audio.VolumeTrack.Value <= audio.VolumeTrack.MinValue)
notificationOverlay.Post(new MutedNotification());
}
@ -500,7 +504,7 @@ public MutedNotification()
public override bool RequestsFocus => true;
[BackgroundDependencyLoader]
private void load(OsuColour colours, AudioManager audioManager, NotificationOverlay notificationOverlay)
private void load(OsuColour colours, AudioManager audioManager, NotificationOverlay notificationOverlay, VolumeOverlay volumeOverlay)
{
Icon = FontAwesome.Solid.VolumeMute;
IconBackgound.Colour = colours.RedDark;
@ -509,6 +513,7 @@ private void load(OsuColour colours, AudioManager audioManager, NotificationOver
{
notificationOverlay.Hide();
volumeOverlay.IsMuted = false;
audioManager.Volume.SetDefault();
audioManager.VolumeTrack.SetDefault();