mirror of
https://github.com/osukey/osukey.git
synced 2025-08-07 16:43:52 +09:00
Refactor PlayerLoader changes
This commit is contained in:
@ -58,9 +58,19 @@ namespace osu.Game.Screens.Play
|
|||||||
private Task loadTask;
|
private Task loadTask;
|
||||||
|
|
||||||
private InputManager inputManager;
|
private InputManager inputManager;
|
||||||
|
|
||||||
private IdleTracker idleTracker;
|
private IdleTracker idleTracker;
|
||||||
|
|
||||||
|
[Resolved(CanBeNull = true)]
|
||||||
|
private NotificationOverlay notificationOverlay { get; set; }
|
||||||
|
|
||||||
|
[Resolved(CanBeNull = true)]
|
||||||
|
private VolumeOverlay volumeOverlay { get; set; }
|
||||||
|
|
||||||
|
[Resolved]
|
||||||
|
private AudioManager audioManager { get; set; }
|
||||||
|
|
||||||
|
private Bindable<bool> muteWarningShownOnce;
|
||||||
|
|
||||||
public PlayerLoader(Func<Player> createPlayer)
|
public PlayerLoader(Func<Player> createPlayer)
|
||||||
{
|
{
|
||||||
this.createPlayer = createPlayer;
|
this.createPlayer = createPlayer;
|
||||||
@ -110,7 +120,22 @@ namespace osu.Game.Screens.Play
|
|||||||
loadNewPlayer();
|
loadNewPlayer();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void playerLoaded(Player player) => info.Loading = false;
|
protected override void LoadComplete()
|
||||||
|
{
|
||||||
|
base.LoadComplete();
|
||||||
|
|
||||||
|
inputManager = GetContainingInputManager();
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public override void OnResuming(IScreen last)
|
public override void OnResuming(IScreen last)
|
||||||
{
|
{
|
||||||
@ -134,7 +159,7 @@ namespace osu.Game.Screens.Play
|
|||||||
player.RestartCount = restartCount;
|
player.RestartCount = restartCount;
|
||||||
player.RestartRequested = restartRequested;
|
player.RestartRequested = restartRequested;
|
||||||
|
|
||||||
loadTask = LoadComponentAsync(player, playerLoaded);
|
loadTask = LoadComponentAsync(player, _ => info.Loading = false);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void contentIn()
|
private void contentIn()
|
||||||
@ -152,30 +177,6 @@ namespace osu.Game.Screens.Play
|
|||||||
content.FadeOut(250);
|
content.FadeOut(250);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Resolved(CanBeNull = true)]
|
|
||||||
private NotificationOverlay notificationOverlay { get; set; }
|
|
||||||
|
|
||||||
[Resolved(CanBeNull = true)]
|
|
||||||
private VolumeOverlay volumeOverlay { get; set; }
|
|
||||||
|
|
||||||
[Resolved]
|
|
||||||
private AudioManager audioManager { get; set; }
|
|
||||||
|
|
||||||
private Bindable<bool> muteWarningShownOnce;
|
|
||||||
|
|
||||||
private void checkVolume()
|
|
||||||
{
|
|
||||||
if (muteWarningShownOnce.Value)
|
|
||||||
return;
|
|
||||||
|
|
||||||
//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 OnEntering(IScreen last)
|
public override void OnEntering(IScreen last)
|
||||||
{
|
{
|
||||||
base.OnEntering(last);
|
base.OnEntering(last);
|
||||||
@ -216,14 +217,6 @@ namespace osu.Game.Screens.Play
|
|||||||
content.StopTracking();
|
content.StopTracking();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void LoadComplete()
|
|
||||||
{
|
|
||||||
inputManager = GetContainingInputManager();
|
|
||||||
base.LoadComplete();
|
|
||||||
|
|
||||||
checkVolume();
|
|
||||||
}
|
|
||||||
|
|
||||||
private ScheduledDelegate pushDebounce;
|
private ScheduledDelegate pushDebounce;
|
||||||
protected VisualSettings VisualSettings;
|
protected VisualSettings VisualSettings;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user