mirror of
https://github.com/ppy/osu.git
synced 2024-11-11 14:17:26 +08:00
Merge pull request #20173 from peppy/test-scene-storyboard-tidy
Tidy up `TestSceneStoryboard`
This commit is contained in:
commit
264c9bfaf6
@ -1,8 +1,6 @@
|
||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
#nullable disable
|
||||
|
||||
using NUnit.Framework;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Bindables;
|
||||
@ -24,8 +22,9 @@ namespace osu.Game.Tests.Visual.Gameplay
|
||||
[TestFixture]
|
||||
public class TestSceneStoryboard : OsuTestScene
|
||||
{
|
||||
private Container<DrawableStoryboard> storyboardContainer;
|
||||
private DrawableStoryboard storyboard;
|
||||
private Container<DrawableStoryboard> storyboardContainer = null!;
|
||||
|
||||
private DrawableStoryboard? storyboard;
|
||||
|
||||
[Test]
|
||||
public void TestStoryboard()
|
||||
@ -40,7 +39,7 @@ namespace osu.Game.Tests.Visual.Gameplay
|
||||
[Test]
|
||||
public void TestStoryboardMissingVideo()
|
||||
{
|
||||
AddStep("Load storyboard with missing video", loadStoryboardNoVideo);
|
||||
AddStep("Load storyboard with missing video", () => loadStoryboard("storyboard_no_video.osu"));
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
@ -77,18 +76,18 @@ namespace osu.Game.Tests.Visual.Gameplay
|
||||
Beatmap.BindValueChanged(beatmapChanged, true);
|
||||
}
|
||||
|
||||
private void beatmapChanged(ValueChangedEvent<WorkingBeatmap> e) => loadStoryboard(e.NewValue);
|
||||
private void beatmapChanged(ValueChangedEvent<WorkingBeatmap> e) => loadStoryboard(e.NewValue.Storyboard);
|
||||
|
||||
private void restart()
|
||||
{
|
||||
var track = Beatmap.Value.Track;
|
||||
|
||||
track.Reset();
|
||||
loadStoryboard(Beatmap.Value);
|
||||
loadStoryboard(Beatmap.Value.Storyboard);
|
||||
track.Start();
|
||||
}
|
||||
|
||||
private void loadStoryboard(IWorkingBeatmap working)
|
||||
private void loadStoryboard(Storyboard toLoad)
|
||||
{
|
||||
if (storyboard != null)
|
||||
storyboardContainer.Remove(storyboard, true);
|
||||
@ -96,34 +95,25 @@ namespace osu.Game.Tests.Visual.Gameplay
|
||||
var decoupledClock = new DecoupleableInterpolatingFramedClock { IsCoupled = true };
|
||||
storyboardContainer.Clock = decoupledClock;
|
||||
|
||||
storyboard = working.Storyboard.CreateDrawable(SelectedMods.Value);
|
||||
storyboard = toLoad.CreateDrawable(SelectedMods.Value);
|
||||
storyboard.Passing = false;
|
||||
|
||||
storyboardContainer.Add(storyboard);
|
||||
decoupledClock.ChangeSource(working.Track);
|
||||
}
|
||||
|
||||
private void loadStoryboardNoVideo()
|
||||
{
|
||||
if (storyboard != null)
|
||||
storyboardContainer.Remove(storyboard, true);
|
||||
|
||||
var decoupledClock = new DecoupleableInterpolatingFramedClock { IsCoupled = true };
|
||||
storyboardContainer.Clock = decoupledClock;
|
||||
|
||||
Storyboard sb;
|
||||
|
||||
using (var str = TestResources.OpenResource("storyboard_no_video.osu"))
|
||||
using (var bfr = new LineBufferedReader(str))
|
||||
{
|
||||
var decoder = new LegacyStoryboardDecoder();
|
||||
sb = decoder.Decode(bfr);
|
||||
}
|
||||
|
||||
storyboard = sb.CreateDrawable(SelectedMods.Value);
|
||||
|
||||
storyboardContainer.Add(storyboard);
|
||||
decoupledClock.ChangeSource(Beatmap.Value.Track);
|
||||
}
|
||||
|
||||
private void loadStoryboard(string filename)
|
||||
{
|
||||
Storyboard loaded;
|
||||
|
||||
using (var str = TestResources.OpenResource(filename))
|
||||
using (var bfr = new LineBufferedReader(str))
|
||||
{
|
||||
var decoder = new LegacyStoryboardDecoder();
|
||||
loaded = decoder.Decode(bfr);
|
||||
}
|
||||
|
||||
loadStoryboard(loaded);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user