mirror of
https://github.com/ppy/osu.git
synced 2024-12-14 13:22:55 +08:00
Expose mute adjustment instead
This commit is contained in:
parent
4c5a5c449a
commit
94d0b06493
@ -209,28 +209,28 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
||||
start(new[] { PLAYER_1_ID, PLAYER_2_ID });
|
||||
loadSpectateScreen();
|
||||
|
||||
assertVolume(PLAYER_1_ID, 0);
|
||||
assertVolume(PLAYER_2_ID, 0);
|
||||
assertMuted(PLAYER_1_ID, true);
|
||||
assertMuted(PLAYER_2_ID, true);
|
||||
|
||||
sendFrames(PLAYER_1_ID, 10);
|
||||
sendFrames(PLAYER_2_ID, 20);
|
||||
assertVolume(PLAYER_1_ID, 1);
|
||||
assertVolume(PLAYER_2_ID, 0);
|
||||
assertMuted(PLAYER_1_ID, false);
|
||||
assertMuted(PLAYER_2_ID, true);
|
||||
|
||||
checkPaused(PLAYER_1_ID, true);
|
||||
assertVolume(PLAYER_1_ID, 0);
|
||||
assertVolume(PLAYER_2_ID, 1);
|
||||
assertMuted(PLAYER_1_ID, true);
|
||||
assertMuted(PLAYER_2_ID, false);
|
||||
|
||||
sendFrames(PLAYER_1_ID, 100);
|
||||
waitForCatchup(PLAYER_1_ID);
|
||||
checkPaused(PLAYER_2_ID, true);
|
||||
assertVolume(PLAYER_1_ID, 1);
|
||||
assertVolume(PLAYER_2_ID, 0);
|
||||
assertMuted(PLAYER_1_ID, false);
|
||||
assertMuted(PLAYER_2_ID, true);
|
||||
|
||||
sendFrames(PLAYER_2_ID, 100);
|
||||
waitForCatchup(PLAYER_2_ID);
|
||||
assertVolume(PLAYER_1_ID, 1);
|
||||
assertVolume(PLAYER_2_ID, 0);
|
||||
assertMuted(PLAYER_1_ID, false);
|
||||
assertMuted(PLAYER_2_ID, true);
|
||||
}
|
||||
|
||||
private void loadSpectateScreen(bool waitForPlayerLoad = true)
|
||||
@ -292,8 +292,8 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
||||
private void checkPausedInstant(int userId, bool state)
|
||||
=> AddAssert($"{userId} is {(state ? "paused" : "playing")}", () => getPlayer(userId).ChildrenOfType<GameplayClockContainer>().First().GameplayClock.IsRunning != state);
|
||||
|
||||
private void assertVolume(int userId, double volume)
|
||||
=> AddAssert($"{userId} volume is {volume}", () => getInstance(userId).Volume.Value == volume);
|
||||
private void assertMuted(int userId, bool muted)
|
||||
=> AddAssert($"{userId} {(muted ? "is" : "is not")} muted", () => getInstance(userId).Mute == muted);
|
||||
|
||||
private void waitForCatchup(int userId)
|
||||
=> AddUntilStep($"{userId} not catching up", () => !getInstance(userId).GameplayClock.IsCatchingUp);
|
||||
|
@ -111,7 +111,7 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer.Spectate
|
||||
.FirstOrDefault();
|
||||
|
||||
foreach (var instance in instances)
|
||||
instance.Volume.Value = instance == currentAudioSource ? 1 : 0;
|
||||
instance.Mute = instance != currentAudioSource;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -23,7 +23,7 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer.Spectate
|
||||
/// <summary>
|
||||
/// Provides an area for and manages the hierarchy of a spectated player within a <see cref="MultiSpectatorScreen"/>.
|
||||
/// </summary>
|
||||
public class PlayerArea : CompositeDrawable, IAdjustableAudioComponent
|
||||
public class PlayerArea : CompositeDrawable
|
||||
{
|
||||
/// <summary>
|
||||
/// Whether a <see cref="Player"/> is loaded in the area.
|
||||
@ -50,9 +50,9 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer.Spectate
|
||||
[Resolved]
|
||||
private BeatmapManager beatmapManager { get; set; }
|
||||
|
||||
private readonly BindableDouble volumeAdjustment = new BindableDouble();
|
||||
private readonly Container gameplayContent;
|
||||
private readonly LoadingLayer loadingLayer;
|
||||
private readonly AudioContainer audioContainer;
|
||||
private OsuScreenStack stack;
|
||||
|
||||
public PlayerArea(int userId, IFrameBasedClock masterClock)
|
||||
@ -62,6 +62,7 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer.Spectate
|
||||
RelativeSizeAxes = Axes.Both;
|
||||
Masking = true;
|
||||
|
||||
AudioContainer audioContainer;
|
||||
InternalChildren = new Drawable[]
|
||||
{
|
||||
audioContainer = new AudioContainer
|
||||
@ -72,6 +73,8 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer.Spectate
|
||||
loadingLayer = new LoadingLayer(true) { State = { Value = Visibility.Visible } }
|
||||
};
|
||||
|
||||
audioContainer.AddAdjustment(AdjustableProperty.Volume, volumeAdjustment);
|
||||
|
||||
GameplayClock.Source = masterClock;
|
||||
}
|
||||
|
||||
@ -92,55 +95,22 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer.Spectate
|
||||
loadingLayer.Hide();
|
||||
}
|
||||
|
||||
private bool mute = true;
|
||||
|
||||
public bool Mute
|
||||
{
|
||||
get => mute;
|
||||
set
|
||||
{
|
||||
mute = value;
|
||||
volumeAdjustment.Value = value ? 0 : 1;
|
||||
}
|
||||
}
|
||||
|
||||
// Player interferes with global input, so disable input for now.
|
||||
public override bool PropagatePositionalInputSubTree => false;
|
||||
public override bool PropagateNonPositionalInputSubTree => false;
|
||||
|
||||
#region IAdjustableAudioComponent
|
||||
|
||||
public IBindable<double> AggregateVolume => audioContainer.AggregateVolume;
|
||||
|
||||
public IBindable<double> AggregateBalance => audioContainer.AggregateBalance;
|
||||
|
||||
public IBindable<double> AggregateFrequency => audioContainer.AggregateFrequency;
|
||||
|
||||
public IBindable<double> AggregateTempo => audioContainer.AggregateTempo;
|
||||
|
||||
public void BindAdjustments(IAggregateAudioAdjustment component)
|
||||
{
|
||||
audioContainer.BindAdjustments(component);
|
||||
}
|
||||
|
||||
public void UnbindAdjustments(IAggregateAudioAdjustment component)
|
||||
{
|
||||
audioContainer.UnbindAdjustments(component);
|
||||
}
|
||||
|
||||
public void AddAdjustment(AdjustableProperty type, IBindable<double> adjustBindable)
|
||||
{
|
||||
audioContainer.AddAdjustment(type, adjustBindable);
|
||||
}
|
||||
|
||||
public void RemoveAdjustment(AdjustableProperty type, IBindable<double> adjustBindable)
|
||||
{
|
||||
audioContainer.RemoveAdjustment(type, adjustBindable);
|
||||
}
|
||||
|
||||
public void RemoveAllAdjustments(AdjustableProperty type)
|
||||
{
|
||||
audioContainer.RemoveAllAdjustments(type);
|
||||
}
|
||||
|
||||
public BindableNumber<double> Volume => audioContainer.Volume;
|
||||
|
||||
public BindableNumber<double> Balance => audioContainer.Balance;
|
||||
|
||||
public BindableNumber<double> Frequency => audioContainer.Frequency;
|
||||
|
||||
public BindableNumber<double> Tempo => audioContainer.Tempo;
|
||||
|
||||
#endregion
|
||||
|
||||
private class PlayerIsolationContainer : Container
|
||||
{
|
||||
[Cached]
|
||||
|
Loading…
Reference in New Issue
Block a user