mirror of
https://github.com/ppy/osu.git
synced 2024-11-18 02:06:08 +08:00
89 lines
2.6 KiB
C#
89 lines
2.6 KiB
C#
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
|
|
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
|
|
|
using NUnit.Framework;
|
|
using osu.Framework.Allocation;
|
|
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;
|
|
using OpenTK.Graphics;
|
|
|
|
namespace osu.Game.Tests.Visual
|
|
{
|
|
[TestFixture]
|
|
public class TestCaseStoryboard : OsuTestCase
|
|
{
|
|
private readonly Container<DrawableStoryboard> storyboardContainer;
|
|
private DrawableStoryboard storyboard;
|
|
|
|
public TestCaseStoryboard()
|
|
{
|
|
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,
|
|
},
|
|
},
|
|
});
|
|
|
|
Add(new MusicController
|
|
{
|
|
Origin = Anchor.TopRight,
|
|
Anchor = Anchor.TopRight,
|
|
State = Visibility.Visible,
|
|
});
|
|
|
|
AddStep("Restart", restart);
|
|
AddToggleStep("Passing", passing => { if (storyboard != null) storyboard.Passing = passing; });
|
|
}
|
|
|
|
[BackgroundDependencyLoader]
|
|
private void load()
|
|
{
|
|
Beatmap.ValueChanged += beatmapChanged;
|
|
}
|
|
|
|
private void beatmapChanged(WorkingBeatmap working)
|
|
=> loadStoryboard(working);
|
|
|
|
private void restart()
|
|
{
|
|
var track = Beatmap.Value.Track;
|
|
|
|
track.Reset();
|
|
loadStoryboard(Beatmap);
|
|
track.Start();
|
|
}
|
|
|
|
private void loadStoryboard(WorkingBeatmap working)
|
|
{
|
|
if (storyboard != null)
|
|
storyboardContainer.Remove(storyboard);
|
|
|
|
var decoupledClock = new DecoupleableInterpolatingFramedClock { IsCoupled = true };
|
|
storyboardContainer.Clock = decoupledClock;
|
|
|
|
storyboard = working.Storyboard.CreateDrawable(Beatmap);
|
|
storyboard.Passing = false;
|
|
|
|
storyboardContainer.Add(storyboard);
|
|
decoupledClock.ChangeSource(working.Track);
|
|
}
|
|
}
|
|
}
|