2022-05-20 13:34:33 +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.
|
|
|
|
|
2022-05-31 20:10:02 +08:00
|
|
|
using System.Linq;
|
2022-05-20 13:34:33 +08:00
|
|
|
using osu.Framework.Allocation;
|
2022-05-20 15:45:01 +08:00
|
|
|
using osu.Framework.Bindables;
|
2022-05-20 13:34:33 +08:00
|
|
|
using osu.Framework.Graphics;
|
|
|
|
using osu.Framework.Graphics.Containers;
|
|
|
|
using osu.Framework.Graphics.Shapes;
|
2022-05-20 14:56:39 +08:00
|
|
|
using osu.Game.Beatmaps.ControlPoints;
|
2022-05-20 13:34:33 +08:00
|
|
|
using osu.Game.Graphics;
|
|
|
|
using osu.Game.Graphics.UserInterfaceV2;
|
|
|
|
using osu.Game.Overlays;
|
|
|
|
|
|
|
|
namespace osu.Game.Screens.Edit.Timing
|
|
|
|
{
|
|
|
|
public class TapTimingControl : CompositeDrawable
|
|
|
|
{
|
|
|
|
[Resolved]
|
|
|
|
private EditorClock editorClock { get; set; }
|
|
|
|
|
2022-05-31 20:10:02 +08:00
|
|
|
[Resolved]
|
|
|
|
private EditorBeatmap beatmap { get; set; }
|
|
|
|
|
2022-05-20 16:12:35 +08:00
|
|
|
[Resolved]
|
|
|
|
private Bindable<ControlPointGroup> selectedGroup { get; set; }
|
|
|
|
|
2022-05-20 13:34:33 +08:00
|
|
|
[BackgroundDependencyLoader]
|
|
|
|
private void load(OverlayColourProvider colourProvider, OsuColour colours)
|
|
|
|
{
|
|
|
|
RelativeSizeAxes = Axes.X;
|
2022-05-23 18:52:01 +08:00
|
|
|
AutoSizeAxes = Axes.Y;
|
2022-05-20 13:34:33 +08:00
|
|
|
|
|
|
|
CornerRadius = LabelledDrawable<Drawable>.CORNER_RADIUS;
|
|
|
|
Masking = true;
|
|
|
|
|
|
|
|
InternalChildren = new Drawable[]
|
|
|
|
{
|
|
|
|
new Box
|
|
|
|
{
|
|
|
|
Colour = colourProvider.Background4,
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
},
|
|
|
|
new GridContainer
|
|
|
|
{
|
2022-05-23 18:52:01 +08:00
|
|
|
RelativeSizeAxes = Axes.X,
|
|
|
|
AutoSizeAxes = Axes.Y,
|
2022-05-20 13:34:33 +08:00
|
|
|
RowDimensions = new[]
|
|
|
|
{
|
2022-05-23 18:52:01 +08:00
|
|
|
new Dimension(GridSizeMode.Absolute, 200),
|
2022-05-20 13:34:33 +08:00
|
|
|
new Dimension(GridSizeMode.Absolute, 60),
|
2022-05-31 20:10:02 +08:00
|
|
|
new Dimension(GridSizeMode.Absolute, 60),
|
2022-05-20 13:34:33 +08:00
|
|
|
},
|
|
|
|
Content = new[]
|
|
|
|
{
|
|
|
|
new Drawable[]
|
|
|
|
{
|
2022-05-23 18:52:01 +08:00
|
|
|
new Container
|
2022-05-20 16:12:35 +08:00
|
|
|
{
|
2022-05-23 18:52:01 +08:00
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
Children = new Drawable[]
|
|
|
|
{
|
|
|
|
new GridContainer
|
|
|
|
{
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
ColumnDimensions = new[]
|
|
|
|
{
|
|
|
|
new Dimension(GridSizeMode.AutoSize),
|
|
|
|
new Dimension()
|
|
|
|
},
|
|
|
|
Content = new[]
|
|
|
|
{
|
|
|
|
new Drawable[]
|
|
|
|
{
|
|
|
|
new MetronomeDisplay
|
|
|
|
{
|
|
|
|
Anchor = Anchor.CentreLeft,
|
|
|
|
Origin = Anchor.CentreLeft,
|
|
|
|
},
|
|
|
|
new WaveformComparisonDisplay(),
|
|
|
|
}
|
|
|
|
},
|
|
|
|
}
|
|
|
|
}
|
2022-05-31 20:10:02 +08:00
|
|
|
},
|
|
|
|
},
|
|
|
|
new Drawable[]
|
|
|
|
{
|
|
|
|
new Container
|
|
|
|
{
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
Padding = new MarginPadding(10),
|
|
|
|
Children = new Drawable[]
|
|
|
|
{
|
2022-06-01 16:46:05 +08:00
|
|
|
new TimingAdjustButton(1)
|
2022-05-31 20:10:02 +08:00
|
|
|
{
|
|
|
|
Text = "Offset",
|
|
|
|
RelativeSizeAxes = Axes.X,
|
|
|
|
Width = 0.48f,
|
|
|
|
Height = 50,
|
|
|
|
Action = adjustOffset,
|
|
|
|
},
|
2022-06-01 16:46:05 +08:00
|
|
|
new TimingAdjustButton(0.1)
|
2022-05-31 20:10:02 +08:00
|
|
|
{
|
|
|
|
Anchor = Anchor.TopRight,
|
|
|
|
Origin = Anchor.TopRight,
|
|
|
|
Text = "BPM",
|
|
|
|
RelativeSizeAxes = Axes.X,
|
|
|
|
Width = 0.48f,
|
|
|
|
Height = 50,
|
|
|
|
Action = adjustBpm,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
2022-05-20 13:34:33 +08:00
|
|
|
},
|
|
|
|
new Drawable[]
|
|
|
|
{
|
|
|
|
new Container
|
|
|
|
{
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
Padding = new MarginPadding(10),
|
|
|
|
Children = new Drawable[]
|
|
|
|
{
|
|
|
|
new RoundedButton
|
|
|
|
{
|
|
|
|
Text = "Reset",
|
|
|
|
BackgroundColour = colours.Pink,
|
|
|
|
RelativeSizeAxes = Axes.X,
|
|
|
|
Width = 0.3f,
|
|
|
|
Action = reset,
|
|
|
|
},
|
|
|
|
new RoundedButton
|
|
|
|
{
|
|
|
|
Anchor = Anchor.TopRight,
|
|
|
|
Origin = Anchor.TopRight,
|
2022-05-20 16:12:35 +08:00
|
|
|
Text = "Play from start",
|
2022-05-20 13:34:33 +08:00
|
|
|
RelativeSizeAxes = Axes.X,
|
|
|
|
BackgroundColour = colourProvider.Background1,
|
|
|
|
Width = 0.68f,
|
|
|
|
Action = tap,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2022-05-31 20:10:02 +08:00
|
|
|
private void adjustOffset(double adjust)
|
|
|
|
{
|
|
|
|
// VERY TEMPORARY
|
|
|
|
var currentGroupItems = selectedGroup.Value.ControlPoints.ToArray();
|
|
|
|
|
|
|
|
beatmap.ControlPointInfo.RemoveGroup(selectedGroup.Value);
|
|
|
|
|
|
|
|
double newOffset = selectedGroup.Value.Time + adjust;
|
|
|
|
|
|
|
|
foreach (var cp in currentGroupItems)
|
|
|
|
beatmap.ControlPointInfo.Add(newOffset, cp);
|
|
|
|
|
|
|
|
// the control point might not necessarily exist yet, if currentGroupItems was empty.
|
|
|
|
selectedGroup.Value = beatmap.ControlPointInfo.GroupAt(newOffset, true);
|
|
|
|
|
|
|
|
if (!editorClock.IsRunning)
|
|
|
|
editorClock.Seek(newOffset);
|
|
|
|
}
|
|
|
|
|
|
|
|
private void adjustBpm(double adjust)
|
|
|
|
{
|
|
|
|
var timing = selectedGroup.Value.ControlPoints.OfType<TimingControlPoint>().FirstOrDefault();
|
|
|
|
|
|
|
|
if (timing == null)
|
|
|
|
return;
|
|
|
|
|
|
|
|
timing.BeatLength = 60000 / (timing.BPM + adjust);
|
|
|
|
}
|
|
|
|
|
2022-05-20 13:34:33 +08:00
|
|
|
private void tap()
|
|
|
|
{
|
2022-05-20 16:12:35 +08:00
|
|
|
editorClock.Seek(selectedGroup.Value.Time);
|
|
|
|
editorClock.Start();
|
2022-05-20 13:34:33 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
private void reset()
|
|
|
|
{
|
|
|
|
editorClock.Stop();
|
2022-05-20 16:12:35 +08:00
|
|
|
editorClock.Seek(selectedGroup.Value.Time);
|
2022-05-20 13:34:33 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|