mirror of
https://github.com/osukey/osukey.git
synced 2025-05-30 01:47:30 +09: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 });
|
start(new[] { PLAYER_1_ID, PLAYER_2_ID });
|
||||||
loadSpectateScreen();
|
loadSpectateScreen();
|
||||||
|
|
||||||
assertVolume(PLAYER_1_ID, 0);
|
assertMuted(PLAYER_1_ID, true);
|
||||||
assertVolume(PLAYER_2_ID, 0);
|
assertMuted(PLAYER_2_ID, true);
|
||||||
|
|
||||||
sendFrames(PLAYER_1_ID, 10);
|
sendFrames(PLAYER_1_ID, 10);
|
||||||
sendFrames(PLAYER_2_ID, 20);
|
sendFrames(PLAYER_2_ID, 20);
|
||||||
assertVolume(PLAYER_1_ID, 1);
|
assertMuted(PLAYER_1_ID, false);
|
||||||
assertVolume(PLAYER_2_ID, 0);
|
assertMuted(PLAYER_2_ID, true);
|
||||||
|
|
||||||
checkPaused(PLAYER_1_ID, true);
|
checkPaused(PLAYER_1_ID, true);
|
||||||
assertVolume(PLAYER_1_ID, 0);
|
assertMuted(PLAYER_1_ID, true);
|
||||||
assertVolume(PLAYER_2_ID, 1);
|
assertMuted(PLAYER_2_ID, false);
|
||||||
|
|
||||||
sendFrames(PLAYER_1_ID, 100);
|
sendFrames(PLAYER_1_ID, 100);
|
||||||
waitForCatchup(PLAYER_1_ID);
|
waitForCatchup(PLAYER_1_ID);
|
||||||
checkPaused(PLAYER_2_ID, true);
|
checkPaused(PLAYER_2_ID, true);
|
||||||
assertVolume(PLAYER_1_ID, 1);
|
assertMuted(PLAYER_1_ID, false);
|
||||||
assertVolume(PLAYER_2_ID, 0);
|
assertMuted(PLAYER_2_ID, true);
|
||||||
|
|
||||||
sendFrames(PLAYER_2_ID, 100);
|
sendFrames(PLAYER_2_ID, 100);
|
||||||
waitForCatchup(PLAYER_2_ID);
|
waitForCatchup(PLAYER_2_ID);
|
||||||
assertVolume(PLAYER_1_ID, 1);
|
assertMuted(PLAYER_1_ID, false);
|
||||||
assertVolume(PLAYER_2_ID, 0);
|
assertMuted(PLAYER_2_ID, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void loadSpectateScreen(bool waitForPlayerLoad = true)
|
private void loadSpectateScreen(bool waitForPlayerLoad = true)
|
||||||
@ -292,8 +292,8 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
|||||||
private void checkPausedInstant(int userId, bool state)
|
private void checkPausedInstant(int userId, bool state)
|
||||||
=> AddAssert($"{userId} is {(state ? "paused" : "playing")}", () => getPlayer(userId).ChildrenOfType<GameplayClockContainer>().First().GameplayClock.IsRunning != state);
|
=> AddAssert($"{userId} is {(state ? "paused" : "playing")}", () => getPlayer(userId).ChildrenOfType<GameplayClockContainer>().First().GameplayClock.IsRunning != state);
|
||||||
|
|
||||||
private void assertVolume(int userId, double volume)
|
private void assertMuted(int userId, bool muted)
|
||||||
=> AddAssert($"{userId} volume is {volume}", () => getInstance(userId).Volume.Value == volume);
|
=> AddAssert($"{userId} {(muted ? "is" : "is not")} muted", () => getInstance(userId).Mute == muted);
|
||||||
|
|
||||||
private void waitForCatchup(int userId)
|
private void waitForCatchup(int userId)
|
||||||
=> AddUntilStep($"{userId} not catching up", () => !getInstance(userId).GameplayClock.IsCatchingUp);
|
=> AddUntilStep($"{userId} not catching up", () => !getInstance(userId).GameplayClock.IsCatchingUp);
|
||||||
|
@ -111,7 +111,7 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer.Spectate
|
|||||||
.FirstOrDefault();
|
.FirstOrDefault();
|
||||||
|
|
||||||
foreach (var instance in instances)
|
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>
|
/// <summary>
|
||||||
/// Provides an area for and manages the hierarchy of a spectated player within a <see cref="MultiSpectatorScreen"/>.
|
/// Provides an area for and manages the hierarchy of a spectated player within a <see cref="MultiSpectatorScreen"/>.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class PlayerArea : CompositeDrawable, IAdjustableAudioComponent
|
public class PlayerArea : CompositeDrawable
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Whether a <see cref="Player"/> is loaded in the area.
|
/// Whether a <see cref="Player"/> is loaded in the area.
|
||||||
@ -50,9 +50,9 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer.Spectate
|
|||||||
[Resolved]
|
[Resolved]
|
||||||
private BeatmapManager beatmapManager { get; set; }
|
private BeatmapManager beatmapManager { get; set; }
|
||||||
|
|
||||||
|
private readonly BindableDouble volumeAdjustment = new BindableDouble();
|
||||||
private readonly Container gameplayContent;
|
private readonly Container gameplayContent;
|
||||||
private readonly LoadingLayer loadingLayer;
|
private readonly LoadingLayer loadingLayer;
|
||||||
private readonly AudioContainer audioContainer;
|
|
||||||
private OsuScreenStack stack;
|
private OsuScreenStack stack;
|
||||||
|
|
||||||
public PlayerArea(int userId, IFrameBasedClock masterClock)
|
public PlayerArea(int userId, IFrameBasedClock masterClock)
|
||||||
@ -62,6 +62,7 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer.Spectate
|
|||||||
RelativeSizeAxes = Axes.Both;
|
RelativeSizeAxes = Axes.Both;
|
||||||
Masking = true;
|
Masking = true;
|
||||||
|
|
||||||
|
AudioContainer audioContainer;
|
||||||
InternalChildren = new Drawable[]
|
InternalChildren = new Drawable[]
|
||||||
{
|
{
|
||||||
audioContainer = new AudioContainer
|
audioContainer = new AudioContainer
|
||||||
@ -72,6 +73,8 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer.Spectate
|
|||||||
loadingLayer = new LoadingLayer(true) { State = { Value = Visibility.Visible } }
|
loadingLayer = new LoadingLayer(true) { State = { Value = Visibility.Visible } }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
audioContainer.AddAdjustment(AdjustableProperty.Volume, volumeAdjustment);
|
||||||
|
|
||||||
GameplayClock.Source = masterClock;
|
GameplayClock.Source = masterClock;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -92,55 +95,22 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer.Spectate
|
|||||||
loadingLayer.Hide();
|
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.
|
// Player interferes with global input, so disable input for now.
|
||||||
public override bool PropagatePositionalInputSubTree => false;
|
public override bool PropagatePositionalInputSubTree => false;
|
||||||
public override bool PropagateNonPositionalInputSubTree => 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
|
private class PlayerIsolationContainer : Container
|
||||||
{
|
{
|
||||||
[Cached]
|
[Cached]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user