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 System;
|
|
|
|
using System.Collections.Generic;
|
|
|
|
using NUnit.Framework;
|
2018-06-13 14:10:08 +08:00
|
|
|
using osu.Framework.Allocation;
|
2019-05-31 13:40:53 +08:00
|
|
|
using osu.Framework.Audio;
|
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;
|
2018-06-13 14:10:08 +08:00
|
|
|
using osu.Framework.Graphics.Shapes;
|
|
|
|
using osu.Framework.Timing;
|
|
|
|
using osu.Game.Beatmaps;
|
2019-11-06 13:08:52 +08:00
|
|
|
using osu.Game.Graphics.UserInterface;
|
2019-12-06 10:26:50 +08:00
|
|
|
using osu.Game.Rulesets.Objects;
|
2019-12-05 18:31:40 +08:00
|
|
|
using osu.Game.Screens.Edit;
|
2018-11-06 17:28:22 +08:00
|
|
|
using osu.Game.Screens.Edit.Compose.Components.Timeline;
|
2019-03-25 00:02:36 +08:00
|
|
|
using osuTK;
|
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.Editor
|
2018-04-13 17:19:50 +08:00
|
|
|
{
|
|
|
|
[TestFixture]
|
2019-05-15 03:37:25 +08:00
|
|
|
public class TestSceneEditorComposeTimeline : EditorClockTestScene
|
2018-04-13 17:19:50 +08:00
|
|
|
{
|
2018-05-24 14:23:59 +08:00
|
|
|
public override IReadOnlyList<Type> RequiredTypes => new[]
|
|
|
|
{
|
|
|
|
typeof(TimelineArea),
|
2019-12-05 18:31:40 +08:00
|
|
|
typeof(TimelineHitObjectDisplay),
|
2018-05-24 14:23:59 +08:00
|
|
|
typeof(Timeline),
|
|
|
|
typeof(TimelineButton),
|
|
|
|
typeof(CentreMarker)
|
|
|
|
};
|
2018-04-13 17:19:50 +08:00
|
|
|
|
2019-12-05 22:31:21 +08:00
|
|
|
[BackgroundDependencyLoader]
|
|
|
|
private void load(AudioManager audio)
|
2019-12-05 18:31:40 +08:00
|
|
|
{
|
2019-05-31 13:40:53 +08:00
|
|
|
Beatmap.Value = new WaveformTestBeatmap(audio);
|
2018-06-13 14:10:08 +08:00
|
|
|
|
2019-12-27 18:39:30 +08:00
|
|
|
var editorBeatmap = new EditorBeatmap((Beatmap<HitObject>)Beatmap.Value.Beatmap);
|
2019-12-06 10:26:50 +08:00
|
|
|
|
2020-01-21 16:35:36 +08:00
|
|
|
Dependencies.Cache(editorBeatmap);
|
|
|
|
|
2018-04-13 17:19:50 +08:00
|
|
|
Children = new Drawable[]
|
|
|
|
{
|
2018-06-13 14:10:08 +08:00
|
|
|
new FillFlowContainer
|
2018-04-13 17:19:50 +08:00
|
|
|
{
|
2018-06-13 14:10:08 +08:00
|
|
|
AutoSizeAxes = Axes.Both,
|
|
|
|
Direction = FillDirection.Vertical,
|
|
|
|
Spacing = new Vector2(0, 5),
|
|
|
|
Children = new Drawable[]
|
|
|
|
{
|
|
|
|
new StartStopButton(),
|
|
|
|
new AudioVisualiser(),
|
|
|
|
}
|
2018-04-13 17:19:50 +08:00
|
|
|
},
|
2018-06-11 19:08:17 +08:00
|
|
|
new TimelineArea
|
2018-04-13 17:19:50 +08:00
|
|
|
{
|
2019-12-06 10:26:50 +08:00
|
|
|
Child = new TimelineHitObjectDisplay(editorBeatmap),
|
2018-04-13 17:19:50 +08:00
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
Origin = Anchor.Centre,
|
2018-05-16 16:54:44 +08:00
|
|
|
RelativeSizeAxes = Axes.X,
|
|
|
|
Size = new Vector2(0.8f, 100)
|
2018-04-13 17:19:50 +08:00
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
2018-06-13 14:10:08 +08:00
|
|
|
|
|
|
|
private class AudioVisualiser : CompositeDrawable
|
|
|
|
{
|
|
|
|
private readonly Drawable marker;
|
|
|
|
|
2019-12-19 18:48:48 +08:00
|
|
|
[Resolved]
|
|
|
|
private IBindable<WorkingBeatmap> beatmap { get; set; }
|
|
|
|
|
|
|
|
[Resolved]
|
|
|
|
private IAdjustableClock adjustableClock { get; set; }
|
2018-06-13 14:10:08 +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();
|
2018-06-15 14:38:19 +08:00
|
|
|
|
|
|
|
if (beatmap.Value.Track.IsLoaded)
|
|
|
|
marker.X = (float)(adjustableClock.CurrentTime / beatmap.Value.Track.Length);
|
2018-06-13 14:10:08 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-11-06 13:08:52 +08:00
|
|
|
private class StartStopButton : OsuButton
|
2018-06-13 14:10:08 +08:00
|
|
|
{
|
|
|
|
private IAdjustableClock adjustableClock;
|
|
|
|
private bool started;
|
|
|
|
|
|
|
|
public StartStopButton()
|
|
|
|
{
|
|
|
|
BackgroundColour = Color4.SlateGray;
|
|
|
|
Size = new Vector2(100, 50);
|
|
|
|
Text = "Start";
|
|
|
|
|
|
|
|
Action = onClick;
|
|
|
|
}
|
|
|
|
|
|
|
|
[BackgroundDependencyLoader]
|
|
|
|
private void load(IAdjustableClock adjustableClock)
|
|
|
|
{
|
|
|
|
this.adjustableClock = adjustableClock;
|
|
|
|
}
|
|
|
|
|
|
|
|
private void onClick()
|
|
|
|
{
|
|
|
|
if (started)
|
|
|
|
{
|
|
|
|
adjustableClock.Stop();
|
|
|
|
Text = "Start";
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
adjustableClock.Start();
|
|
|
|
Text = "Stop";
|
|
|
|
}
|
|
|
|
|
|
|
|
started = !started;
|
|
|
|
}
|
|
|
|
}
|
2018-04-13 17:19:50 +08:00
|
|
|
}
|
|
|
|
}
|