mirror of
https://github.com/ppy/osu.git
synced 2025-01-30 06:52:53 +08:00
remove all test usages of SampleControlPoint
This commit is contained in:
parent
d97daee96b
commit
c6fc180659
@ -138,8 +138,7 @@ namespace osu.Game.Rulesets.Osu.Tests.Editor
|
|||||||
var mergedSlider = (Slider)EditorBeatmap.SelectedHitObjects.First();
|
var mergedSlider = (Slider)EditorBeatmap.SelectedHitObjects.First();
|
||||||
return slider1 is not null && mergedSlider.HeadCircle.Samples.SequenceEqual(slider1.HeadCircle.Samples)
|
return slider1 is not null && mergedSlider.HeadCircle.Samples.SequenceEqual(slider1.HeadCircle.Samples)
|
||||||
&& mergedSlider.TailCircle.Samples.SequenceEqual(slider1.TailCircle.Samples)
|
&& mergedSlider.TailCircle.Samples.SequenceEqual(slider1.TailCircle.Samples)
|
||||||
&& mergedSlider.Samples.SequenceEqual(slider1.Samples)
|
&& mergedSlider.Samples.SequenceEqual(slider1.Samples);
|
||||||
&& mergedSlider.SampleControlPoint.IsRedundant(slider1.SampleControlPoint);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
AddAssert("slider end is at same completion for last slider", () =>
|
AddAssert("slider end is at same completion for last slider", () =>
|
||||||
|
@ -181,10 +181,8 @@ namespace osu.Game.Rulesets.Osu.Tests.Editor
|
|||||||
{
|
{
|
||||||
if (slider is null) return;
|
if (slider is null) return;
|
||||||
|
|
||||||
slider.SampleControlPoint.SampleBank = "soft";
|
sample = new HitSampleInfo("hitwhistle", "soft", volume: 70);
|
||||||
slider.SampleControlPoint.SampleVolume = 70;
|
slider.Samples.Add(sample.With());
|
||||||
sample = new HitSampleInfo("hitwhistle");
|
|
||||||
slider.Samples.Add(sample);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
AddStep("select added slider", () =>
|
AddStep("select added slider", () =>
|
||||||
@ -207,9 +205,7 @@ namespace osu.Game.Rulesets.Osu.Tests.Editor
|
|||||||
AddAssert("sliders have hitsounds", hasHitsounds);
|
AddAssert("sliders have hitsounds", hasHitsounds);
|
||||||
|
|
||||||
bool hasHitsounds() => sample is not null &&
|
bool hasHitsounds() => sample is not null &&
|
||||||
EditorBeatmap.HitObjects.All(o => o.SampleControlPoint.SampleBank == "soft" &&
|
EditorBeatmap.HitObjects.All(o => o.Samples.Contains(sample));
|
||||||
o.SampleControlPoint.SampleVolume == 70 &&
|
|
||||||
o.Samples.Contains(sample));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool sliderCreatedFor(Slider s, double startTime, double endTime, params (Vector2 pos, PathType? pathType)[] expectedControlPoints)
|
private bool sliderCreatedFor(Slider s, double startTime, double endTime, params (Vector2 pos, PathType? pathType)[] expectedControlPoints)
|
||||||
|
@ -199,8 +199,7 @@ namespace osu.Game.Rulesets.Osu.Tests.Editor
|
|||||||
Precision.AlmostEquals(circle.StartTime, time, 1)
|
Precision.AlmostEquals(circle.StartTime, time, 1)
|
||||||
&& Precision.AlmostEquals(circle.Position, position, 0.01f)
|
&& Precision.AlmostEquals(circle.Position, position, 0.01f)
|
||||||
&& circle.NewCombo == startsNewCombo
|
&& circle.NewCombo == startsNewCombo
|
||||||
&& circle.Samples.SequenceEqual(slider.HeadCircle.Samples)
|
&& circle.Samples.SequenceEqual(slider.HeadCircle.Samples);
|
||||||
&& circle.SampleControlPoint.IsRedundant(slider.SampleControlPoint);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool sliderRestored(Slider slider)
|
private bool sliderRestored(Slider slider)
|
||||||
|
@ -480,7 +480,7 @@ namespace osu.Game.Tests.Beatmaps.Formats
|
|||||||
Assert.AreEqual("Gameplay/soft-hitnormal8", getTestableSampleInfo(hitObjects[4]).LookupNames.First());
|
Assert.AreEqual("Gameplay/soft-hitnormal8", getTestableSampleInfo(hitObjects[4]).LookupNames.First());
|
||||||
}
|
}
|
||||||
|
|
||||||
static HitSampleInfo getTestableSampleInfo(HitObject hitObject) => hitObject.SampleControlPoint.ApplyTo(hitObject.Samples[0]);
|
static HitSampleInfo getTestableSampleInfo(HitObject hitObject) => hitObject.Samples[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
@ -498,7 +498,7 @@ namespace osu.Game.Tests.Beatmaps.Formats
|
|||||||
Assert.AreEqual("Gameplay/normal-hitnormal3", getTestableSampleInfo(hitObjects[2]).LookupNames.First());
|
Assert.AreEqual("Gameplay/normal-hitnormal3", getTestableSampleInfo(hitObjects[2]).LookupNames.First());
|
||||||
}
|
}
|
||||||
|
|
||||||
static HitSampleInfo getTestableSampleInfo(HitObject hitObject) => hitObject.SampleControlPoint.ApplyTo(hitObject.Samples[0]);
|
static HitSampleInfo getTestableSampleInfo(HitObject hitObject) => hitObject.Samples[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
@ -518,7 +518,7 @@ namespace osu.Game.Tests.Beatmaps.Formats
|
|||||||
Assert.AreEqual(70, getTestableSampleInfo(hitObjects[3]).Volume);
|
Assert.AreEqual(70, getTestableSampleInfo(hitObjects[3]).Volume);
|
||||||
}
|
}
|
||||||
|
|
||||||
static HitSampleInfo getTestableSampleInfo(HitObject hitObject) => hitObject.SampleControlPoint.ApplyTo(hitObject.Samples[0]);
|
static HitSampleInfo getTestableSampleInfo(HitObject hitObject) => hitObject.Samples[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
|
@ -95,10 +95,6 @@ namespace osu.Game.Tests.Visual.Editing
|
|||||||
var path = slider.Path;
|
var path = slider.Path;
|
||||||
return path.ControlPoints.Count == 2 && path.ControlPoints.SequenceEqual(addedObject.Path.ControlPoints);
|
return path.ControlPoints.Count == 2 && path.ControlPoints.SequenceEqual(addedObject.Path.ControlPoints);
|
||||||
});
|
});
|
||||||
|
|
||||||
// see `HitObject.control_point_leniency`.
|
|
||||||
AddAssert("sample control point has correct time", () => Precision.AlmostEquals(slider.SampleControlPoint.Time, slider.GetEndTime(), 1));
|
|
||||||
AddAssert("difficulty control point has correct time", () => slider.DifficultyControlPoint.Time == slider.StartTime);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
|
@ -122,19 +122,9 @@ namespace osu.Game.Tests.Visual.Editing
|
|||||||
|
|
||||||
AddAssert("Beatmap has correct timing point", () => EditorBeatmap.ControlPointInfo.TimingPoints.Single().Time == 500);
|
AddAssert("Beatmap has correct timing point", () => EditorBeatmap.ControlPointInfo.TimingPoints.Single().Time == 500);
|
||||||
|
|
||||||
// After placement these must be non-default as defaults are read-only.
|
|
||||||
AddAssert("Placed object has non-default control points", () =>
|
|
||||||
!ReferenceEquals(EditorBeatmap.HitObjects[0].SampleControlPoint, SampleControlPoint.DEFAULT) &&
|
|
||||||
!ReferenceEquals(EditorBeatmap.HitObjects[0].DifficultyControlPoint, DifficultyControlPoint.DEFAULT));
|
|
||||||
|
|
||||||
ReloadEditorToSameBeatmap();
|
ReloadEditorToSameBeatmap();
|
||||||
|
|
||||||
AddAssert("Beatmap still has correct timing point", () => EditorBeatmap.ControlPointInfo.TimingPoints.Single().Time == 500);
|
AddAssert("Beatmap still has correct timing point", () => EditorBeatmap.ControlPointInfo.TimingPoints.Single().Time == 500);
|
||||||
|
|
||||||
// After placement these must be non-default as defaults are read-only.
|
|
||||||
AddAssert("Placed object still has non-default control points", () =>
|
|
||||||
!ReferenceEquals(EditorBeatmap.HitObjects[0].SampleControlPoint, SampleControlPoint.DEFAULT) &&
|
|
||||||
!ReferenceEquals(EditorBeatmap.HitObjects[0].DifficultyControlPoint, DifficultyControlPoint.DEFAULT));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
|
@ -7,6 +7,7 @@ using System.Linq;
|
|||||||
using Humanizer;
|
using Humanizer;
|
||||||
using NUnit.Framework;
|
using NUnit.Framework;
|
||||||
using osu.Framework.Testing;
|
using osu.Framework.Testing;
|
||||||
|
using osu.Game.Audio;
|
||||||
using osu.Game.Beatmaps;
|
using osu.Game.Beatmaps;
|
||||||
using osu.Game.Beatmaps.ControlPoints;
|
using osu.Game.Beatmaps.ControlPoints;
|
||||||
using osu.Game.Graphics.UserInterface;
|
using osu.Game.Graphics.UserInterface;
|
||||||
@ -39,10 +40,9 @@ namespace osu.Game.Tests.Visual.Editing
|
|||||||
{
|
{
|
||||||
StartTime = 0,
|
StartTime = 0,
|
||||||
Position = (OsuPlayfield.BASE_SIZE - new Vector2(100, 0)) / 2,
|
Position = (OsuPlayfield.BASE_SIZE - new Vector2(100, 0)) / 2,
|
||||||
SampleControlPoint = new SampleControlPoint
|
Samples = new List<HitSampleInfo>
|
||||||
{
|
{
|
||||||
SampleBank = "normal",
|
new HitSampleInfo(HitSampleInfo.HIT_NORMAL, "normal", volume: 80)
|
||||||
SampleVolume = 80
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -50,10 +50,9 @@ namespace osu.Game.Tests.Visual.Editing
|
|||||||
{
|
{
|
||||||
StartTime = 500,
|
StartTime = 500,
|
||||||
Position = (OsuPlayfield.BASE_SIZE + new Vector2(100, 0)) / 2,
|
Position = (OsuPlayfield.BASE_SIZE + new Vector2(100, 0)) / 2,
|
||||||
SampleControlPoint = new SampleControlPoint
|
Samples = new List<HitSampleInfo>
|
||||||
{
|
{
|
||||||
SampleBank = "soft",
|
new HitSampleInfo(HitSampleInfo.HIT_NORMAL, "soft", volume: 60)
|
||||||
SampleVolume = 60
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@ -96,7 +95,12 @@ namespace osu.Game.Tests.Visual.Editing
|
|||||||
AddStep("unify sample volume", () =>
|
AddStep("unify sample volume", () =>
|
||||||
{
|
{
|
||||||
foreach (var h in EditorBeatmap.HitObjects)
|
foreach (var h in EditorBeatmap.HitObjects)
|
||||||
h.SampleControlPoint.SampleVolume = 50;
|
{
|
||||||
|
for (int i = 0; i < h.Samples.Count; i++)
|
||||||
|
{
|
||||||
|
h.Samples[i] = h.Samples[i].With(newVolume: 50);
|
||||||
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
AddStep("select both objects", () => EditorBeatmap.SelectedHitObjects.AddRange(EditorBeatmap.HitObjects));
|
AddStep("select both objects", () => EditorBeatmap.SelectedHitObjects.AddRange(EditorBeatmap.HitObjects));
|
||||||
@ -136,7 +140,12 @@ namespace osu.Game.Tests.Visual.Editing
|
|||||||
AddStep("unify sample bank", () =>
|
AddStep("unify sample bank", () =>
|
||||||
{
|
{
|
||||||
foreach (var h in EditorBeatmap.HitObjects)
|
foreach (var h in EditorBeatmap.HitObjects)
|
||||||
h.SampleControlPoint.SampleBank = "soft";
|
{
|
||||||
|
for (int i = 0; i < h.Samples.Count; i++)
|
||||||
|
{
|
||||||
|
h.Samples[i] = h.Samples[i].With(newBank: "soft");
|
||||||
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
AddStep("select both objects", () => EditorBeatmap.SelectedHitObjects.AddRange(EditorBeatmap.HitObjects));
|
AddStep("select both objects", () => EditorBeatmap.SelectedHitObjects.AddRange(EditorBeatmap.HitObjects));
|
||||||
@ -248,7 +257,7 @@ namespace osu.Game.Tests.Visual.Editing
|
|||||||
private void hitObjectHasSampleVolume(int objectIndex, int volume) => AddAssert($"{objectIndex.ToOrdinalWords()} has volume {volume}", () =>
|
private void hitObjectHasSampleVolume(int objectIndex, int volume) => AddAssert($"{objectIndex.ToOrdinalWords()} has volume {volume}", () =>
|
||||||
{
|
{
|
||||||
var h = EditorBeatmap.HitObjects.ElementAt(objectIndex);
|
var h = EditorBeatmap.HitObjects.ElementAt(objectIndex);
|
||||||
return h.SampleControlPoint.SampleVolume == volume;
|
return h.Samples.All(o => o.Volume == volume);
|
||||||
});
|
});
|
||||||
|
|
||||||
private void setBankViaPopover(string bank) => AddStep($"set bank {bank} via popover", () =>
|
private void setBankViaPopover(string bank) => AddStep($"set bank {bank} via popover", () =>
|
||||||
@ -265,7 +274,7 @@ namespace osu.Game.Tests.Visual.Editing
|
|||||||
private void hitObjectHasSampleBank(int objectIndex, string bank) => AddAssert($"{objectIndex.ToOrdinalWords()} has bank {bank}", () =>
|
private void hitObjectHasSampleBank(int objectIndex, string bank) => AddAssert($"{objectIndex.ToOrdinalWords()} has bank {bank}", () =>
|
||||||
{
|
{
|
||||||
var h = EditorBeatmap.HitObjects.ElementAt(objectIndex);
|
var h = EditorBeatmap.HitObjects.ElementAt(objectIndex);
|
||||||
return h.SampleControlPoint.SampleBank == bank;
|
return h.Samples.All(o => o.Bank == bank);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -73,8 +73,7 @@ namespace osu.Game.Tests.Visual.Gameplay
|
|||||||
new HitCircle
|
new HitCircle
|
||||||
{
|
{
|
||||||
StartTime = t += spacing,
|
StartTime = t += spacing,
|
||||||
Samples = new[] { new HitSampleInfo(HitSampleInfo.HIT_NORMAL) },
|
Samples = new[] { new HitSampleInfo(HitSampleInfo.HIT_NORMAL, "soft") },
|
||||||
SampleControlPoint = new SampleControlPoint { SampleBank = "soft" },
|
|
||||||
},
|
},
|
||||||
new HitCircle
|
new HitCircle
|
||||||
{
|
{
|
||||||
@ -84,8 +83,7 @@ namespace osu.Game.Tests.Visual.Gameplay
|
|||||||
{
|
{
|
||||||
StartTime = t += spacing,
|
StartTime = t += spacing,
|
||||||
Path = new SliderPath(PathType.Linear, new[] { Vector2.Zero, Vector2.UnitY * 200 }),
|
Path = new SliderPath(PathType.Linear, new[] { Vector2.Zero, Vector2.UnitY * 200 }),
|
||||||
Samples = new[] { new HitSampleInfo(HitSampleInfo.HIT_WHISTLE) },
|
Samples = new[] { new HitSampleInfo(HitSampleInfo.HIT_WHISTLE, "soft") },
|
||||||
SampleControlPoint = new SampleControlPoint { SampleBank = "soft" },
|
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
|
using osu.Game.Beatmaps.ControlPoints;
|
||||||
using osu.Game.Utils;
|
using osu.Game.Utils;
|
||||||
|
|
||||||
namespace osu.Game.Audio
|
namespace osu.Game.Audio
|
||||||
@ -32,7 +33,7 @@ namespace osu.Game.Audio
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// The bank to load the sample from.
|
/// The bank to load the sample from.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public readonly string? Bank;
|
public readonly string Bank;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// An optional suffix to provide priority lookup. Falls back to non-suffixed <see cref="Name"/>.
|
/// An optional suffix to provide priority lookup. Falls back to non-suffixed <see cref="Name"/>.
|
||||||
@ -47,7 +48,7 @@ namespace osu.Game.Audio
|
|||||||
public HitSampleInfo(string name, string? bank = null, string? suffix = null, int volume = 0)
|
public HitSampleInfo(string name, string? bank = null, string? suffix = null, int volume = 0)
|
||||||
{
|
{
|
||||||
Name = name;
|
Name = name;
|
||||||
Bank = bank;
|
Bank = bank ?? SampleControlPoint.DEFAULT_BANK;
|
||||||
Suffix = suffix;
|
Suffix = suffix;
|
||||||
Volume = volume;
|
Volume = volume;
|
||||||
}
|
}
|
||||||
|
@ -76,7 +76,6 @@ namespace osu.Game.Rulesets.Objects
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public virtual IList<HitSampleInfo> AuxiliarySamples => ImmutableList<HitSampleInfo>.Empty;
|
public virtual IList<HitSampleInfo> AuxiliarySamples => ImmutableList<HitSampleInfo>.Empty;
|
||||||
|
|
||||||
public SampleControlPoint SampleControlPoint = SampleControlPoint.DEFAULT;
|
|
||||||
public DifficultyControlPoint DifficultyControlPoint = DifficultyControlPoint.DEFAULT;
|
public DifficultyControlPoint DifficultyControlPoint = DifficultyControlPoint.DEFAULT;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
Loading…
Reference in New Issue
Block a user