mirror of
https://github.com/osukey/osukey.git
synced 2025-05-09 15:47:38 +09:00
Merge pull request #10325 from peppy/editor-timing-move-control-group
Add the ability to move a control point around in time
This commit is contained in:
commit
7f67b9bc46
@ -41,6 +41,7 @@ namespace osu.Game.Screens.Edit.Timing
|
|||||||
|
|
||||||
private IReadOnlyList<Drawable> createSections() => new Drawable[]
|
private IReadOnlyList<Drawable> createSections() => new Drawable[]
|
||||||
{
|
{
|
||||||
|
new GroupSection(),
|
||||||
new TimingSection(),
|
new TimingSection(),
|
||||||
new DifficultySection(),
|
new DifficultySection(),
|
||||||
new SampleSection(),
|
new SampleSection(),
|
||||||
|
113
osu.Game/Screens/Edit/Timing/GroupSection.cs
Normal file
113
osu.Game/Screens/Edit/Timing/GroupSection.cs
Normal file
@ -0,0 +1,113 @@
|
|||||||
|
// 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 System.Linq;
|
||||||
|
using osu.Framework.Allocation;
|
||||||
|
using osu.Framework.Bindables;
|
||||||
|
using osu.Framework.Graphics;
|
||||||
|
using osu.Framework.Graphics.Containers;
|
||||||
|
using osu.Game.Beatmaps;
|
||||||
|
using osu.Game.Beatmaps.ControlPoints;
|
||||||
|
using osu.Game.Graphics.UserInterface;
|
||||||
|
using osu.Game.Graphics.UserInterfaceV2;
|
||||||
|
using osuTK;
|
||||||
|
|
||||||
|
namespace osu.Game.Screens.Edit.Timing
|
||||||
|
{
|
||||||
|
internal class GroupSection : CompositeDrawable
|
||||||
|
{
|
||||||
|
private LabelledTextBox textBox;
|
||||||
|
|
||||||
|
[Resolved]
|
||||||
|
protected Bindable<ControlPointGroup> SelectedGroup { get; private set; }
|
||||||
|
|
||||||
|
[Resolved]
|
||||||
|
protected IBindable<WorkingBeatmap> Beatmap { get; private set; }
|
||||||
|
|
||||||
|
[Resolved]
|
||||||
|
private EditorClock clock { get; set; }
|
||||||
|
|
||||||
|
[Resolved(canBeNull: true)]
|
||||||
|
private IEditorChangeHandler changeHandler { get; set; }
|
||||||
|
|
||||||
|
[BackgroundDependencyLoader]
|
||||||
|
private void load()
|
||||||
|
{
|
||||||
|
RelativeSizeAxes = Axes.X;
|
||||||
|
AutoSizeAxes = Axes.Y;
|
||||||
|
|
||||||
|
Padding = new MarginPadding(10);
|
||||||
|
|
||||||
|
InternalChildren = new Drawable[]
|
||||||
|
{
|
||||||
|
new FillFlowContainer
|
||||||
|
{
|
||||||
|
RelativeSizeAxes = Axes.X,
|
||||||
|
AutoSizeAxes = Axes.Y,
|
||||||
|
Spacing = new Vector2(10),
|
||||||
|
Direction = FillDirection.Vertical,
|
||||||
|
Children = new Drawable[]
|
||||||
|
{
|
||||||
|
textBox = new LabelledTextBox
|
||||||
|
{
|
||||||
|
Label = "Time"
|
||||||
|
},
|
||||||
|
new TriangleButton
|
||||||
|
{
|
||||||
|
Text = "Use current time",
|
||||||
|
RelativeSizeAxes = Axes.X,
|
||||||
|
Action = () => changeSelectedGroupTime(clock.CurrentTime)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
textBox.OnCommit += (sender, isNew) =>
|
||||||
|
{
|
||||||
|
if (!isNew)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (double.TryParse(sender.Text, out var newTime))
|
||||||
|
{
|
||||||
|
changeSelectedGroupTime(newTime);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
SelectedGroup.TriggerChange();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
SelectedGroup.BindValueChanged(group =>
|
||||||
|
{
|
||||||
|
if (group.NewValue == null)
|
||||||
|
{
|
||||||
|
textBox.Text = string.Empty;
|
||||||
|
textBox.Current.Disabled = true;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
textBox.Current.Disabled = false;
|
||||||
|
textBox.Text = $"{group.NewValue.Time:n0}";
|
||||||
|
}, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void changeSelectedGroupTime(in double time)
|
||||||
|
{
|
||||||
|
if (time == SelectedGroup.Value.Time)
|
||||||
|
return;
|
||||||
|
|
||||||
|
changeHandler?.BeginChange();
|
||||||
|
|
||||||
|
var currentGroupItems = SelectedGroup.Value.ControlPoints.ToArray();
|
||||||
|
|
||||||
|
Beatmap.Value.Beatmap.ControlPointInfo.RemoveGroup(SelectedGroup.Value);
|
||||||
|
|
||||||
|
foreach (var cp in currentGroupItems)
|
||||||
|
Beatmap.Value.Beatmap.ControlPointInfo.Add(time, cp);
|
||||||
|
|
||||||
|
SelectedGroup.Value = Beatmap.Value.Beatmap.ControlPointInfo.GroupAt(time);
|
||||||
|
|
||||||
|
changeHandler?.EndChange();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user