2019-01-24 08:43:03 +00:00
|
|
|
|
// 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.
|
2018-04-13 09:19:50 +00:00
|
|
|
|
|
|
|
|
|
using NUnit.Framework;
|
|
|
|
|
using osu.Framework.Allocation;
|
2019-02-21 10:04:31 +00:00
|
|
|
|
using osu.Framework.Bindables;
|
2018-04-13 09:19:50 +00:00
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
|
using osu.Framework.Graphics.Containers;
|
|
|
|
|
using osu.Framework.Graphics.Shapes;
|
|
|
|
|
using osu.Framework.Timing;
|
|
|
|
|
using osu.Game.Beatmaps;
|
2020-03-27 08:43:51 +00:00
|
|
|
|
using osu.Game.Beatmaps.Formats;
|
|
|
|
|
using osu.Game.IO;
|
2018-04-13 09:19:50 +00:00
|
|
|
|
using osu.Game.Overlays;
|
2020-03-27 08:43:51 +00:00
|
|
|
|
using osu.Game.Storyboards;
|
2018-04-13 09:19:50 +00:00
|
|
|
|
using osu.Game.Storyboards.Drawables;
|
2020-03-27 08:43:51 +00:00
|
|
|
|
using osu.Game.Tests.Resources;
|
2018-11-20 07:51:59 +00:00
|
|
|
|
using osuTK.Graphics;
|
2018-04-13 09:19:50 +00:00
|
|
|
|
|
2019-03-24 16:02:36 +00:00
|
|
|
|
namespace osu.Game.Tests.Visual.Gameplay
|
2018-04-13 09:19:50 +00:00
|
|
|
|
{
|
|
|
|
|
[TestFixture]
|
2019-05-14 19:37:25 +00:00
|
|
|
|
public class TestSceneStoryboard : OsuTestScene
|
2018-04-13 09:19:50 +00:00
|
|
|
|
{
|
2020-08-21 09:44:14 +00:00
|
|
|
|
private Container<DrawableStoryboard> storyboardContainer;
|
2018-04-13 09:19:50 +00:00
|
|
|
|
private DrawableStoryboard storyboard;
|
|
|
|
|
|
2020-08-21 09:44:14 +00:00
|
|
|
|
[Test]
|
|
|
|
|
public void TestStoryboard()
|
|
|
|
|
{
|
|
|
|
|
AddStep("Restart", restart);
|
|
|
|
|
AddToggleStep("Passing", passing =>
|
|
|
|
|
{
|
|
|
|
|
if (storyboard != null) storyboard.Passing = passing;
|
|
|
|
|
});
|
|
|
|
|
}
|
2020-08-21 08:21:08 +00:00
|
|
|
|
|
2020-08-21 09:44:14 +00:00
|
|
|
|
[Test]
|
|
|
|
|
public void TestStoryboardMissingVideo()
|
|
|
|
|
{
|
|
|
|
|
AddStep("Load storyboard with missing video", loadStoryboardNoVideo);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[BackgroundDependencyLoader]
|
|
|
|
|
private void load()
|
2018-04-13 09:19:50 +00:00
|
|
|
|
{
|
|
|
|
|
Clock = new FramedClock();
|
|
|
|
|
|
2019-08-13 05:29:58 +00:00
|
|
|
|
AddRange(new Drawable[]
|
2018-04-13 09:19:50 +00:00
|
|
|
|
{
|
2019-08-13 05:29:58 +00:00
|
|
|
|
new Container
|
2018-04-13 09:19:50 +00:00
|
|
|
|
{
|
2019-08-13 05:29:58 +00:00
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
|
Children = new Drawable[]
|
2018-04-13 09:19:50 +00:00
|
|
|
|
{
|
2019-08-13 05:29:58 +00:00
|
|
|
|
new Box
|
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
|
Colour = Color4.Black,
|
|
|
|
|
},
|
|
|
|
|
storyboardContainer = new Container<DrawableStoryboard>
|
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
|
},
|
2018-04-13 09:19:50 +00:00
|
|
|
|
},
|
|
|
|
|
},
|
2019-08-13 05:29:58 +00:00
|
|
|
|
new NowPlayingOverlay
|
|
|
|
|
{
|
|
|
|
|
Origin = Anchor.TopRight,
|
|
|
|
|
Anchor = Anchor.TopRight,
|
|
|
|
|
State = { Value = Visibility.Visible },
|
|
|
|
|
}
|
2018-04-13 09:19:50 +00:00
|
|
|
|
});
|
|
|
|
|
|
2020-08-21 09:44:14 +00:00
|
|
|
|
Beatmap.BindValueChanged(beatmapChanged, true);
|
2018-04-13 09:19:50 +00:00
|
|
|
|
}
|
|
|
|
|
|
2020-08-21 09:44:14 +00:00
|
|
|
|
private void beatmapChanged(ValueChangedEvent<WorkingBeatmap> e) => loadStoryboard(e.NewValue);
|
2018-04-13 09:19:50 +00:00
|
|
|
|
|
|
|
|
|
private void restart()
|
|
|
|
|
{
|
2020-08-21 08:21:08 +00:00
|
|
|
|
var track = Beatmap.Value.Track;
|
|
|
|
|
|
|
|
|
|
track.Reset();
|
2019-02-21 09:56:34 +00:00
|
|
|
|
loadStoryboard(Beatmap.Value);
|
2020-08-21 08:21:08 +00:00
|
|
|
|
track.Start();
|
2018-04-13 09:19:50 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void loadStoryboard(WorkingBeatmap working)
|
|
|
|
|
{
|
|
|
|
|
if (storyboard != null)
|
|
|
|
|
storyboardContainer.Remove(storyboard);
|
|
|
|
|
|
|
|
|
|
var decoupledClock = new DecoupleableInterpolatingFramedClock { IsCoupled = true };
|
|
|
|
|
storyboardContainer.Clock = decoupledClock;
|
|
|
|
|
|
2019-02-21 09:56:34 +00:00
|
|
|
|
storyboard = working.Storyboard.CreateDrawable(Beatmap.Value);
|
2018-04-13 09:19:50 +00:00
|
|
|
|
storyboard.Passing = false;
|
|
|
|
|
|
|
|
|
|
storyboardContainer.Add(storyboard);
|
2020-08-21 08:21:08 +00:00
|
|
|
|
decoupledClock.ChangeSource(working.Track);
|
2018-04-13 09:19:50 +00:00
|
|
|
|
}
|
2020-03-27 08:43:51 +00:00
|
|
|
|
|
|
|
|
|
private void loadStoryboardNoVideo()
|
|
|
|
|
{
|
|
|
|
|
if (storyboard != null)
|
|
|
|
|
storyboardContainer.Remove(storyboard);
|
|
|
|
|
|
|
|
|
|
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(Beatmap.Value);
|
|
|
|
|
|
|
|
|
|
storyboardContainer.Add(storyboard);
|
2020-08-21 08:21:08 +00:00
|
|
|
|
decoupledClock.ChangeSource(Beatmap.Value.Track);
|
2020-03-27 08:43:51 +00:00
|
|
|
|
}
|
2018-04-13 09:19:50 +00:00
|
|
|
|
}
|
|
|
|
|
}
|