2019-01-24 08:43:03 +00: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 09:19:50 +00:00
|
|
|
|
|
|
|
using System;
|
|
|
|
using System.Collections.Generic;
|
|
|
|
using NUnit.Framework;
|
2018-06-13 06:10:08 +00:00
|
|
|
using osu.Framework.Allocation;
|
2019-05-31 05:40:53 +00:00
|
|
|
using osu.Framework.Audio;
|
2019-02-21 10:04:31 +00:00
|
|
|
using osu.Framework.Bindables;
|
2018-04-13 09:19:50 +00:00
|
|
|
using osu.Framework.Graphics;
|
|
|
|
using osu.Framework.Graphics.Containers;
|
2018-06-13 06:10:08 +00:00
|
|
|
using osu.Framework.Graphics.Shapes;
|
|
|
|
using osu.Framework.Graphics.UserInterface;
|
|
|
|
using osu.Framework.Timing;
|
|
|
|
using osu.Game.Beatmaps;
|
2018-11-06 09:28:22 +00:00
|
|
|
using osu.Game.Screens.Edit.Compose.Components.Timeline;
|
2019-03-24 16:02:36 +00:00
|
|
|
using osuTK;
|
2018-11-20 07:51:59 +00:00
|
|
|
using osuTK.Graphics;
|
2018-04-13 09:19:50 +00:00
|
|
|
|
2019-03-24 16:02:36 +00:00
|
|
|
namespace osu.Game.Tests.Visual.Editor
|
2018-04-13 09:19:50 +00:00
|
|
|
{
|
|
|
|
[TestFixture]
|
2019-05-14 19:37:25 +00:00
|
|
|
public class TestSceneEditorComposeTimeline : EditorClockTestScene
|
2018-04-13 09:19:50 +00:00
|
|
|
{
|
2018-05-24 06:23:59 +00:00
|
|
|
public override IReadOnlyList<Type> RequiredTypes => new[]
|
|
|
|
{
|
|
|
|
typeof(TimelineArea),
|
|
|
|
typeof(Timeline),
|
|
|
|
typeof(TimelineButton),
|
|
|
|
typeof(CentreMarker)
|
|
|
|
};
|
2018-04-13 09:19:50 +00:00
|
|
|
|
2018-06-13 06:10:08 +00:00
|
|
|
[BackgroundDependencyLoader]
|
2019-05-31 05:40:53 +00:00
|
|
|
private void load(AudioManager audio)
|
2018-04-13 09:19:50 +00:00
|
|
|
{
|
2019-05-31 05:40:53 +00:00
|
|
|
Beatmap.Value = new WaveformTestBeatmap(audio);
|
2018-06-13 06:10:08 +00:00
|
|
|
|
2018-04-13 09:19:50 +00:00
|
|
|
Children = new Drawable[]
|
|
|
|
{
|
2018-06-13 06:10:08 +00:00
|
|
|
new FillFlowContainer
|
2018-04-13 09:19:50 +00:00
|
|
|
{
|
2018-06-13 06:10:08 +00:00
|
|
|
AutoSizeAxes = Axes.Both,
|
|
|
|
Direction = FillDirection.Vertical,
|
|
|
|
Spacing = new Vector2(0, 5),
|
|
|
|
Children = new Drawable[]
|
|
|
|
{
|
|
|
|
new StartStopButton(),
|
|
|
|
new AudioVisualiser(),
|
|
|
|
}
|
2018-04-13 09:19:50 +00:00
|
|
|
},
|
2018-06-11 11:08:17 +00:00
|
|
|
new TimelineArea
|
2018-04-13 09:19:50 +00:00
|
|
|
{
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
Origin = Anchor.Centre,
|
2018-05-16 08:54:44 +00:00
|
|
|
RelativeSizeAxes = Axes.X,
|
|
|
|
Size = new Vector2(0.8f, 100)
|
2018-04-13 09:19:50 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
2018-06-13 06:10:08 +00:00
|
|
|
|
|
|
|
private class AudioVisualiser : CompositeDrawable
|
|
|
|
{
|
|
|
|
private readonly Drawable marker;
|
|
|
|
|
|
|
|
private readonly IBindable<WorkingBeatmap> beatmap = new Bindable<WorkingBeatmap>();
|
|
|
|
private IAdjustableClock adjustableClock;
|
|
|
|
|
|
|
|
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,
|
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
[BackgroundDependencyLoader]
|
2019-02-01 06:42:15 +00:00
|
|
|
private void load(IAdjustableClock adjustableClock, IBindable<WorkingBeatmap> beatmap)
|
2018-06-13 06:10:08 +00:00
|
|
|
{
|
|
|
|
this.adjustableClock = adjustableClock;
|
|
|
|
this.beatmap.BindTo(beatmap);
|
|
|
|
}
|
|
|
|
|
|
|
|
protected override void Update()
|
|
|
|
{
|
|
|
|
base.Update();
|
2018-06-15 06:38:19 +00:00
|
|
|
|
|
|
|
if (beatmap.Value.Track.IsLoaded)
|
|
|
|
marker.X = (float)(adjustableClock.CurrentTime / beatmap.Value.Track.Length);
|
2018-06-13 06:10:08 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private class StartStopButton : Button
|
|
|
|
{
|
|
|
|
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 09:19:50 +00:00
|
|
|
}
|
|
|
|
}
|