2020-01-27 15:54:36 +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.
|
|
|
|
|
|
|
|
using osu.Framework.Allocation;
|
|
|
|
using osu.Framework.Audio;
|
|
|
|
using osu.Framework.Bindables;
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
using osu.Framework.Graphics.Containers;
|
|
|
|
using osu.Framework.Graphics.Shapes;
|
|
|
|
using osu.Game.Beatmaps;
|
|
|
|
using osu.Game.Graphics.UserInterface;
|
|
|
|
using osu.Game.Rulesets.Edit;
|
|
|
|
using osu.Game.Screens.Edit;
|
|
|
|
using osu.Game.Screens.Edit.Compose.Components.Timeline;
|
|
|
|
using osuTK;
|
|
|
|
using osuTK.Graphics;
|
|
|
|
|
2020-04-23 16:07:55 +08:00
|
|
|
namespace osu.Game.Tests.Visual.Editing
|
2020-01-27 15:54:36 +08:00
|
|
|
{
|
|
|
|
public abstract class TimelineTestScene : EditorClockTestScene
|
|
|
|
{
|
|
|
|
protected TimelineArea TimelineArea { get; private set; }
|
|
|
|
|
2020-11-13 16:51:01 +08:00
|
|
|
protected HitObjectComposer Composer { get; private set; }
|
|
|
|
|
2020-01-27 15:54:36 +08:00
|
|
|
[BackgroundDependencyLoader]
|
|
|
|
private void load(AudioManager audio)
|
|
|
|
{
|
|
|
|
Beatmap.Value = new WaveformTestBeatmap(audio);
|
|
|
|
|
2020-02-05 17:14:44 +08:00
|
|
|
var playable = Beatmap.Value.GetPlayableBeatmap(Beatmap.Value.BeatmapInfo.Ruleset);
|
|
|
|
var editorBeatmap = new EditorBeatmap(playable);
|
2020-01-27 15:54:36 +08:00
|
|
|
|
|
|
|
Dependencies.Cache(editorBeatmap);
|
|
|
|
Dependencies.CacheAs<IBeatSnapProvider>(editorBeatmap);
|
|
|
|
|
2020-11-13 16:51:01 +08:00
|
|
|
Composer = playable.BeatmapInfo.Ruleset.CreateInstance().CreateHitObjectComposer().With(d => d.Alpha = 0);
|
|
|
|
|
2020-01-27 15:54:36 +08:00
|
|
|
AddRange(new Drawable[]
|
|
|
|
{
|
2020-02-05 16:32:33 +08:00
|
|
|
editorBeatmap,
|
2020-11-13 16:51:01 +08:00
|
|
|
Composer,
|
2020-01-27 15:54:36 +08:00
|
|
|
new FillFlowContainer
|
|
|
|
{
|
|
|
|
AutoSizeAxes = Axes.Both,
|
|
|
|
Direction = FillDirection.Vertical,
|
|
|
|
Spacing = new Vector2(0, 5),
|
|
|
|
Children = new Drawable[]
|
|
|
|
{
|
|
|
|
new StartStopButton(),
|
|
|
|
new AudioVisualiser(),
|
|
|
|
}
|
|
|
|
},
|
|
|
|
TimelineArea = new TimelineArea
|
|
|
|
{
|
|
|
|
Child = CreateTestComponent(),
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
Origin = Anchor.Centre,
|
|
|
|
RelativeSizeAxes = Axes.X,
|
|
|
|
Size = new Vector2(0.8f, 100),
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
public abstract Drawable CreateTestComponent();
|
|
|
|
|
|
|
|
private class AudioVisualiser : CompositeDrawable
|
|
|
|
{
|
|
|
|
private readonly Drawable marker;
|
|
|
|
|
|
|
|
[Resolved]
|
|
|
|
private IBindable<WorkingBeatmap> beatmap { get; set; }
|
|
|
|
|
|
|
|
[Resolved]
|
2020-05-22 18:49:49 +08:00
|
|
|
private EditorClock editorClock { get; set; }
|
2020-01-27 15:54:36 +08:00
|
|
|
|
|
|
|
public AudioVisualiser()
|
|
|
|
{
|
|
|
|
Size = new Vector2(250, 25);
|
|
|
|
|
|
|
|
InternalChildren = new[]
|
|
|
|
{
|
|
|
|
new Box
|
|
|
|
{
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
Alpha = 0.25f,
|
|
|
|
},
|
|
|
|
marker = new Box
|
|
|
|
{
|
|
|
|
RelativePositionAxes = Axes.X,
|
|
|
|
RelativeSizeAxes = Axes.Y,
|
|
|
|
Width = 2,
|
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
protected override void Update()
|
|
|
|
{
|
|
|
|
base.Update();
|
|
|
|
|
|
|
|
if (beatmap.Value.Track.IsLoaded)
|
2020-05-22 18:49:49 +08:00
|
|
|
marker.X = (float)(editorClock.CurrentTime / beatmap.Value.Track.Length);
|
2020-01-27 15:54:36 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private class StartStopButton : OsuButton
|
|
|
|
{
|
2020-05-22 17:23:24 +08:00
|
|
|
[Resolved]
|
|
|
|
private EditorClock editorClock { get; set; }
|
|
|
|
|
2020-01-27 15:54:36 +08:00
|
|
|
private bool started;
|
|
|
|
|
|
|
|
public StartStopButton()
|
|
|
|
{
|
|
|
|
BackgroundColour = Color4.SlateGray;
|
|
|
|
Size = new Vector2(100, 50);
|
|
|
|
Text = "Start";
|
|
|
|
|
|
|
|
Action = onClick;
|
|
|
|
}
|
|
|
|
|
|
|
|
private void onClick()
|
|
|
|
{
|
|
|
|
if (started)
|
|
|
|
{
|
2020-05-22 17:23:24 +08:00
|
|
|
editorClock.Stop();
|
2020-01-27 15:54:36 +08:00
|
|
|
Text = "Start";
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2020-05-22 17:23:24 +08:00
|
|
|
editorClock.Start();
|
2020-01-27 15:54:36 +08:00
|
|
|
Text = "Stop";
|
|
|
|
}
|
|
|
|
|
|
|
|
started = !started;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|