Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Storyboards implementation. #1224

Merged
merged 21 commits into from
Sep 14, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
90 changes: 90 additions & 0 deletions osu.Desktop.Tests/Visual/TestCaseStoryboard.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE

using OpenTK.Graphics;
using osu.Framework.Allocation;
using osu.Framework.Configuration;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes;
using osu.Framework.Timing;
using osu.Game;
using osu.Game.Beatmaps;
using osu.Game.Overlays;
using osu.Game.Storyboards.Drawables;

namespace osu.Desktop.Tests.Visual
{
internal class TestCaseStoryboard : OsuTestCase
{
public override string Description => @"Tests storyboards.";

private readonly Bindable<WorkingBeatmap> beatmapBacking = new Bindable<WorkingBeatmap>();

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(OsuGameBase game)
{
beatmapBacking.BindTo(game.Beatmap);
beatmapBacking.ValueChanged += beatmapChanged;
}

private void beatmapChanged(WorkingBeatmap working)
=> loadStoryboard(working);

private void restart()
{
var track = beatmapBacking.Value.Track;

track.Reset();
loadStoryboard(beatmapBacking.Value);
track.Start();
}

private void loadStoryboard(WorkingBeatmap working)
{
if (storyboard != null)
storyboardContainer.Remove(storyboard);

var decoupledClock = new DecoupleableInterpolatingFramedClock { IsCoupled = true };
decoupledClock.ChangeSource(working.Track);
storyboardContainer.Clock = decoupledClock;

storyboardContainer.Add(storyboard = working.Beatmap.Storyboard.CreateDrawable());
storyboard.Passing = false;
}
}
}
1 change: 1 addition & 0 deletions osu.Desktop.Tests/osu.Desktop.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@
<Compile Include="Visual\TestCaseMenuButtonSystem.cs" />
<Compile Include="Visual\TestCaseMenuOverlays.cs" />
<Compile Include="Visual\TestCaseMods.cs" />
<Compile Include="Visual\TestCaseStoryboard.cs" />
<Compile Include="Visual\TestCaseMusicController.cs" />
<Compile Include="Visual\TestCaseNotificationOverlay.cs" />
<Compile Include="Visual\TestCaseOnScreenDisplay.cs" />
Expand Down
7 changes: 7 additions & 0 deletions osu.Game/Beatmaps/Beatmap.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
using System.Linq;
using osu.Game.Beatmaps.ControlPoints;
using osu.Game.IO.Serialization;
using osu.Game.Storyboards;

namespace osu.Game.Beatmaps
{
Expand Down Expand Up @@ -40,6 +41,11 @@ public class Beatmap<T>
/// </summary>
public double TotalBreakTime => Breaks.Sum(b => b.Duration);

/// <summary>
/// The Beatmap's Storyboard.
/// </summary>
public Storyboard Storyboard = new Storyboard();

/// <summary>
/// Constructs a new beatmap.
/// </summary>
Expand All @@ -51,6 +57,7 @@ public Beatmap(Beatmap<T> original = null)
Breaks = original?.Breaks ?? Breaks;
ComboColors = original?.ComboColors ?? ComboColors;
HitObjects = original?.HitObjects ?? HitObjects;
Storyboard = original?.Storyboard ?? Storyboard;
}
}

Expand Down
Loading