mirror of
https://github.com/ppy/osu.git
synced 2025-02-26 14:23:00 +08:00
Allow multiple ducks with same parameters
This commit is contained in:
parent
aa36a844be
commit
3650f3c479
@ -56,6 +56,45 @@ namespace osu.Game.Tests.Visual.Menus
|
|||||||
AddUntilStep("wait for restore to complete", () => Game.Audio.Tracks.AggregateVolume.Value, () => Is.EqualTo(normalVolume).Within(0.01));
|
AddUntilStep("wait for restore to complete", () => Game.Audio.Tracks.AggregateVolume.Value, () => Is.EqualTo(normalVolume).Within(0.01));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestMultipleDucksSameParameters()
|
||||||
|
{
|
||||||
|
var duckParameters = new DuckParameters
|
||||||
|
{
|
||||||
|
DuckVolumeTo = 0.5,
|
||||||
|
};
|
||||||
|
|
||||||
|
IDisposable duckOp1 = null!;
|
||||||
|
IDisposable duckOp2 = null!;
|
||||||
|
|
||||||
|
double normalVolume = 1;
|
||||||
|
|
||||||
|
AddStep("get initial volume", () =>
|
||||||
|
{
|
||||||
|
normalVolume = Game.Audio.Tracks.AggregateVolume.Value;
|
||||||
|
});
|
||||||
|
|
||||||
|
AddStep("duck one", () =>
|
||||||
|
{
|
||||||
|
duckOp1 = Game.MusicController.Duck(duckParameters);
|
||||||
|
});
|
||||||
|
|
||||||
|
AddUntilStep("wait for duck to complete", () => Game.Audio.Tracks.AggregateVolume.Value, () => Is.EqualTo(normalVolume * 0.5f).Within(0.01));
|
||||||
|
|
||||||
|
AddStep("duck two", () =>
|
||||||
|
{
|
||||||
|
duckOp2 = Game.MusicController.Duck(duckParameters);
|
||||||
|
});
|
||||||
|
|
||||||
|
AddUntilStep("wait for duck to complete", () => Game.Audio.Tracks.AggregateVolume.Value, () => Is.EqualTo(normalVolume * 0.5f).Within(0.01));
|
||||||
|
|
||||||
|
AddStep("restore two", () => duckOp2.Dispose());
|
||||||
|
AddUntilStep("wait for restore to complete", () => Game.Audio.Tracks.AggregateVolume.Value, () => Is.EqualTo(normalVolume * 0.5f).Within(0.01));
|
||||||
|
|
||||||
|
AddStep("restore one", () => duckOp1.Dispose());
|
||||||
|
AddUntilStep("wait for restore to complete", () => Game.Audio.Tracks.AggregateVolume.Value, () => Is.EqualTo(normalVolume).Within(0.01));
|
||||||
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void TestMultipleDucksReverseOrder()
|
public void TestMultipleDucksReverseOrder()
|
||||||
{
|
{
|
||||||
|
@ -268,9 +268,6 @@ namespace osu.Game.Overlays
|
|||||||
{
|
{
|
||||||
parameters ??= new DuckParameters();
|
parameters ??= new DuckParameters();
|
||||||
|
|
||||||
if (duckOperations.Contains(parameters))
|
|
||||||
throw new ArgumentException("Ducking has already been applied for the provided parameters.", nameof(parameters));
|
|
||||||
|
|
||||||
duckOperations.Add(parameters);
|
duckOperations.Add(parameters);
|
||||||
|
|
||||||
DuckParameters volumeOperation = duckOperations.MinBy(p => p.DuckVolumeTo)!;
|
DuckParameters volumeOperation = duckOperations.MinBy(p => p.DuckVolumeTo)!;
|
||||||
|
Loading…
Reference in New Issue
Block a user