2019-01-24 16:43:03 +08: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 17:19:50 +08:00
|
|
|
|
|
|
|
|
|
using NUnit.Framework;
|
|
|
|
|
using osu.Framework.Allocation;
|
2019-02-21 18:04:31 +08:00
|
|
|
|
using osu.Framework.Bindables;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
|
using osu.Framework.Graphics.Containers;
|
|
|
|
|
using osu.Framework.Graphics.Shapes;
|
|
|
|
|
using osu.Framework.Timing;
|
|
|
|
|
using osu.Game.Beatmaps;
|
|
|
|
|
using osu.Game.Overlays;
|
|
|
|
|
using osu.Game.Storyboards.Drawables;
|
2018-11-20 15:51:59 +08:00
|
|
|
|
using osuTK.Graphics;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2019-03-25 00:02:36 +08:00
|
|
|
|
namespace osu.Game.Tests.Visual.Gameplay
|
2018-04-13 17:19:50 +08:00
|
|
|
|
{
|
|
|
|
|
[TestFixture]
|
2019-05-15 03:37:25 +08:00
|
|
|
|
public class TestSceneStoryboard : OsuTestScene
|
2018-04-13 17:19:50 +08:00
|
|
|
|
{
|
|
|
|
|
private readonly Container<DrawableStoryboard> storyboardContainer;
|
|
|
|
|
private DrawableStoryboard storyboard;
|
|
|
|
|
|
2019-05-15 03:37:25 +08:00
|
|
|
|
public TestSceneStoryboard()
|
2018-04-13 17:19:50 +08:00
|
|
|
|
{
|
|
|
|
|
Clock = new FramedClock();
|
|
|
|
|
|
|
|
|
|
Add(new Container
|
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
|
Children = new Drawable[]
|
|
|
|
|
{
|
|
|
|
|
new Box
|
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
|
Colour = Color4.Black,
|
|
|
|
|
},
|
|
|
|
|
storyboardContainer = new Container<DrawableStoryboard>
|
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
});
|
2018-05-23 16:37:39 +08:00
|
|
|
|
|
2018-04-13 17:19:50 +08:00
|
|
|
|
Add(new MusicController
|
|
|
|
|
{
|
|
|
|
|
Origin = Anchor.TopRight,
|
|
|
|
|
Anchor = Anchor.TopRight,
|
2019-06-11 13:28:52 +08:00
|
|
|
|
State = { Value = Visibility.Visible },
|
2018-04-13 17:19:50 +08:00
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
AddStep("Restart", restart);
|
2019-02-28 12:31:40 +08:00
|
|
|
|
AddToggleStep("Passing", passing =>
|
|
|
|
|
{
|
|
|
|
|
if (storyboard != null) storyboard.Passing = passing;
|
|
|
|
|
});
|
2018-04-13 17:19:50 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[BackgroundDependencyLoader]
|
2018-05-23 16:37:39 +08:00
|
|
|
|
private void load()
|
2018-04-13 17:19:50 +08:00
|
|
|
|
{
|
2018-05-23 16:37:39 +08:00
|
|
|
|
Beatmap.ValueChanged += beatmapChanged;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
}
|
|
|
|
|
|
2019-02-21 17:56:34 +08:00
|
|
|
|
private void beatmapChanged(ValueChangedEvent<WorkingBeatmap> e)
|
|
|
|
|
=> loadStoryboard(e.NewValue);
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
|
|
|
|
private void restart()
|
|
|
|
|
{
|
2018-05-23 16:37:39 +08:00
|
|
|
|
var track = Beatmap.Value.Track;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
|
|
|
|
track.Reset();
|
2019-02-21 17:56:34 +08:00
|
|
|
|
loadStoryboard(Beatmap.Value);
|
2018-04-13 17:19:50 +08:00
|
|
|
|
track.Start();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void loadStoryboard(WorkingBeatmap working)
|
|
|
|
|
{
|
|
|
|
|
if (storyboard != null)
|
|
|
|
|
storyboardContainer.Remove(storyboard);
|
|
|
|
|
|
|
|
|
|
var decoupledClock = new DecoupleableInterpolatingFramedClock { IsCoupled = true };
|
|
|
|
|
storyboardContainer.Clock = decoupledClock;
|
|
|
|
|
|
2019-02-21 17:56:34 +08:00
|
|
|
|
storyboard = working.Storyboard.CreateDrawable(Beatmap.Value);
|
2018-04-13 17:19:50 +08:00
|
|
|
|
storyboard.Passing = false;
|
|
|
|
|
|
|
|
|
|
storyboardContainer.Add(storyboard);
|
|
|
|
|
decoupledClock.ChangeSource(working.Track);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|