mirror of
https://github.com/osukey/osukey.git
synced 2025-05-07 14:47:22 +09:00
Fix multiplayer spectator not getting gameplay adjustments applied
This commit is contained in:
parent
fa15502384
commit
1be3b74ff3
@ -53,6 +53,15 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer.Spectate
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected override GameplayClockContainer CreateGameplayClockContainer(WorkingBeatmap beatmap, double gameplayStart)
|
protected override GameplayClockContainer CreateGameplayClockContainer(WorkingBeatmap beatmap, double gameplayStart)
|
||||||
=> new GameplayClockContainer(spectatorPlayerClock);
|
{
|
||||||
|
var gameplayClockContainer = new GameplayClockContainer(spectatorPlayerClock);
|
||||||
|
|
||||||
|
// Directionality is important, as BindAdjustments is... not actually a bidirectional bind...
|
||||||
|
// We want to ensure that any adjustments applied by the Player instance are applied to the SpectatorPlayerClock
|
||||||
|
// so they can be consumed by the spectator screen (and applied to the master clock / track).
|
||||||
|
spectatorPlayerClock.GameplayAdjustments.BindAdjustments(gameplayClockContainer.GameplayAdjustments);
|
||||||
|
|
||||||
|
return gameplayClockContainer;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
|
using osu.Framework.Audio;
|
||||||
using osu.Framework.Extensions.ObjectExtensions;
|
using osu.Framework.Extensions.ObjectExtensions;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
@ -43,6 +44,8 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer.Spectate
|
|||||||
[Resolved]
|
[Resolved]
|
||||||
private MultiplayerClient multiplayerClient { get; set; } = null!;
|
private MultiplayerClient multiplayerClient { get; set; } = null!;
|
||||||
|
|
||||||
|
private AudioAdjustments? boundAdjustments;
|
||||||
|
|
||||||
private readonly PlayerArea[] instances;
|
private readonly PlayerArea[] instances;
|
||||||
private MasterGameplayClockContainer masterClockContainer = null!;
|
private MasterGameplayClockContainer masterClockContainer = null!;
|
||||||
private SpectatorSyncManager syncManager = null!;
|
private SpectatorSyncManager syncManager = null!;
|
||||||
@ -157,6 +160,9 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer.Spectate
|
|||||||
base.LoadComplete();
|
base.LoadComplete();
|
||||||
|
|
||||||
masterClockContainer.Reset();
|
masterClockContainer.Reset();
|
||||||
|
|
||||||
|
// Start with adjustments from the first player to keep a sane state.
|
||||||
|
bindAudioAdjustments(instances.First());
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void Update()
|
protected override void Update()
|
||||||
@ -169,11 +175,24 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer.Spectate
|
|||||||
.OrderBy(i => Math.Abs(i.SpectatorPlayerClock.CurrentTime - syncManager.CurrentMasterTime))
|
.OrderBy(i => Math.Abs(i.SpectatorPlayerClock.CurrentTime - syncManager.CurrentMasterTime))
|
||||||
.FirstOrDefault();
|
.FirstOrDefault();
|
||||||
|
|
||||||
|
// Only bind adjustments if there's actually a valid source, else just use the previous ones to ensure no sudden changes to audio.
|
||||||
|
if (currentAudioSource != null)
|
||||||
|
bindAudioAdjustments(currentAudioSource);
|
||||||
|
|
||||||
foreach (var instance in instances)
|
foreach (var instance in instances)
|
||||||
instance.Mute = instance != currentAudioSource;
|
instance.Mute = instance != currentAudioSource;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void bindAudioAdjustments(PlayerArea first)
|
||||||
|
{
|
||||||
|
if (boundAdjustments != null)
|
||||||
|
masterClockContainer.GameplayAdjustments.UnbindAdjustments(boundAdjustments);
|
||||||
|
|
||||||
|
boundAdjustments = first.SpectatorPlayerClock.GameplayAdjustments;
|
||||||
|
masterClockContainer.GameplayAdjustments.BindAdjustments(boundAdjustments);
|
||||||
|
}
|
||||||
|
|
||||||
private bool isCandidateAudioSource(SpectatorPlayerClock? clock)
|
private bool isCandidateAudioSource(SpectatorPlayerClock? clock)
|
||||||
=> clock?.IsRunning == true && !clock.IsCatchingUp && !clock.WaitingOnFrames;
|
=> clock?.IsRunning == true && !clock.IsCatchingUp && !clock.WaitingOnFrames;
|
||||||
|
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
// See the LICENCE file in the repository root for full licence text.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
|
using osu.Framework.Audio;
|
||||||
using osu.Framework.Timing;
|
using osu.Framework.Timing;
|
||||||
using osu.Game.Screens.Play;
|
using osu.Game.Screens.Play;
|
||||||
|
|
||||||
@ -19,6 +20,8 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer.Spectate
|
|||||||
|
|
||||||
private readonly GameplayClockContainer masterClock;
|
private readonly GameplayClockContainer masterClock;
|
||||||
|
|
||||||
|
public readonly AudioAdjustments GameplayAdjustments = new AudioAdjustments();
|
||||||
|
|
||||||
public double CurrentTime { get; private set; }
|
public double CurrentTime { get; private set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user