2019-10-08 05:23:13 +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.
|
|
|
|
|
|
2019-10-27 07:30:05 +00:00
|
|
|
|
using System.Linq;
|
2019-10-09 07:06:16 +00:00
|
|
|
|
using osu.Framework.Allocation;
|
|
|
|
|
using osu.Framework.Bindables;
|
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
|
using osu.Framework.Graphics.Containers;
|
|
|
|
|
using osu.Framework.Graphics.Shapes;
|
|
|
|
|
using osu.Game.Beatmaps;
|
2019-10-11 09:46:05 +00:00
|
|
|
|
using osu.Game.Beatmaps.ControlPoints;
|
2019-10-09 07:06:16 +00:00
|
|
|
|
using osu.Game.Graphics;
|
|
|
|
|
using osu.Game.Graphics.Containers;
|
2019-10-22 12:50:21 +00:00
|
|
|
|
using osu.Game.Graphics.UserInterface;
|
|
|
|
|
using osuTK;
|
2019-10-09 07:06:16 +00:00
|
|
|
|
|
2019-10-08 05:23:13 +00:00
|
|
|
|
namespace osu.Game.Screens.Edit.Timing
|
|
|
|
|
{
|
2019-10-09 07:06:16 +00:00
|
|
|
|
public class TimingScreen : EditorScreenWithTimeline
|
2019-10-08 05:23:13 +00:00
|
|
|
|
{
|
2019-10-11 09:46:05 +00:00
|
|
|
|
[Cached]
|
2019-11-06 03:32:12 +00:00
|
|
|
|
private Bindable<ControlPointGroup> selectedGroup = new Bindable<ControlPointGroup>();
|
2019-10-11 09:46:05 +00:00
|
|
|
|
|
2019-10-22 11:17:19 +00:00
|
|
|
|
[Resolved]
|
2020-05-22 07:37:28 +00:00
|
|
|
|
private EditorClock clock { get; set; }
|
2019-10-22 11:17:19 +00:00
|
|
|
|
|
2019-10-09 07:06:16 +00:00
|
|
|
|
protected override Drawable CreateMainContent() => new GridContainer
|
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
|
ColumnDimensions = new[]
|
|
|
|
|
{
|
|
|
|
|
new Dimension(),
|
|
|
|
|
new Dimension(GridSizeMode.Absolute, 200),
|
|
|
|
|
},
|
|
|
|
|
Content = new[]
|
|
|
|
|
{
|
|
|
|
|
new Drawable[]
|
|
|
|
|
{
|
|
|
|
|
new ControlPointList(),
|
|
|
|
|
new ControlPointSettings(),
|
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
2019-10-22 11:17:19 +00:00
|
|
|
|
protected override void LoadComplete()
|
|
|
|
|
{
|
|
|
|
|
base.LoadComplete();
|
|
|
|
|
|
2019-11-06 03:45:35 +00:00
|
|
|
|
selectedGroup.BindValueChanged(selected =>
|
|
|
|
|
{
|
|
|
|
|
if (selected.NewValue != null)
|
2020-05-22 07:40:52 +00:00
|
|
|
|
clock.SeekTo(selected.NewValue.Time);
|
2019-11-06 03:45:35 +00:00
|
|
|
|
});
|
2019-10-22 11:17:19 +00:00
|
|
|
|
}
|
|
|
|
|
|
2019-10-09 07:06:16 +00:00
|
|
|
|
public class ControlPointList : CompositeDrawable
|
2019-10-08 05:23:13 +00:00
|
|
|
|
{
|
2019-10-22 12:50:21 +00:00
|
|
|
|
private OsuButton deleteButton;
|
2019-10-27 07:13:24 +00:00
|
|
|
|
private ControlPointTable table;
|
|
|
|
|
|
|
|
|
|
private IBindableList<ControlPointGroup> controlGroups;
|
|
|
|
|
|
|
|
|
|
[Resolved]
|
2020-05-22 10:49:49 +00:00
|
|
|
|
private EditorClock clock { get; set; }
|
2019-10-22 12:50:21 +00:00
|
|
|
|
|
2019-10-09 07:06:16 +00:00
|
|
|
|
[Resolved]
|
|
|
|
|
protected IBindable<WorkingBeatmap> Beatmap { get; private set; }
|
|
|
|
|
|
2019-10-22 12:50:21 +00:00
|
|
|
|
[Resolved]
|
2019-10-27 07:13:24 +00:00
|
|
|
|
private Bindable<ControlPointGroup> selectedGroup { get; set; }
|
2019-10-22 12:50:21 +00:00
|
|
|
|
|
2019-10-09 07:06:16 +00:00
|
|
|
|
[BackgroundDependencyLoader]
|
|
|
|
|
private void load(OsuColour colours)
|
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.Both;
|
|
|
|
|
|
|
|
|
|
InternalChildren = new Drawable[]
|
|
|
|
|
{
|
|
|
|
|
new Box
|
|
|
|
|
{
|
|
|
|
|
Colour = colours.Gray0,
|
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
|
},
|
|
|
|
|
new OsuScrollContainer
|
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
2019-10-27 07:13:24 +00:00
|
|
|
|
Child = table = new ControlPointTable(),
|
2019-10-22 12:50:21 +00:00
|
|
|
|
},
|
|
|
|
|
new FillFlowContainer
|
|
|
|
|
{
|
|
|
|
|
AutoSizeAxes = Axes.Both,
|
|
|
|
|
Anchor = Anchor.BottomRight,
|
|
|
|
|
Origin = Anchor.BottomRight,
|
|
|
|
|
Direction = FillDirection.Horizontal,
|
|
|
|
|
Margin = new MarginPadding(10),
|
|
|
|
|
Spacing = new Vector2(5),
|
|
|
|
|
Children = new Drawable[]
|
|
|
|
|
{
|
|
|
|
|
deleteButton = new OsuButton
|
|
|
|
|
{
|
|
|
|
|
Text = "-",
|
|
|
|
|
Size = new Vector2(30, 30),
|
|
|
|
|
Action = delete,
|
|
|
|
|
Anchor = Anchor.BottomRight,
|
|
|
|
|
Origin = Anchor.BottomRight,
|
|
|
|
|
},
|
|
|
|
|
new OsuButton
|
|
|
|
|
{
|
|
|
|
|
Text = "+",
|
|
|
|
|
Action = addNew,
|
|
|
|
|
Size = new Vector2(30, 30),
|
|
|
|
|
Anchor = Anchor.BottomRight,
|
|
|
|
|
Origin = Anchor.BottomRight,
|
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
},
|
2019-10-09 07:06:16 +00:00
|
|
|
|
};
|
|
|
|
|
}
|
2019-10-22 12:50:21 +00:00
|
|
|
|
|
|
|
|
|
protected override void LoadComplete()
|
|
|
|
|
{
|
|
|
|
|
base.LoadComplete();
|
|
|
|
|
|
2019-10-27 07:13:24 +00:00
|
|
|
|
selectedGroup.BindValueChanged(selected => { deleteButton.Enabled.Value = selected.NewValue != null; }, true);
|
|
|
|
|
|
|
|
|
|
controlGroups = Beatmap.Value.Beatmap.ControlPointInfo.Groups.GetBoundCopy();
|
|
|
|
|
controlGroups.ItemsAdded += _ => createContent();
|
|
|
|
|
controlGroups.ItemsRemoved += _ => createContent();
|
|
|
|
|
createContent();
|
2019-10-22 12:50:21 +00:00
|
|
|
|
}
|
|
|
|
|
|
2019-10-27 07:13:24 +00:00
|
|
|
|
private void createContent() => table.ControlGroups = controlGroups;
|
|
|
|
|
|
2019-10-22 12:50:21 +00:00
|
|
|
|
private void delete()
|
|
|
|
|
{
|
2019-10-27 07:13:24 +00:00
|
|
|
|
if (selectedGroup.Value == null)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
Beatmap.Value.Beatmap.ControlPointInfo.RemoveGroup(selectedGroup.Value);
|
2019-10-27 07:30:05 +00:00
|
|
|
|
|
|
|
|
|
selectedGroup.Value = Beatmap.Value.Beatmap.ControlPointInfo.Groups.FirstOrDefault(g => g.Time >= clock.CurrentTime);
|
2019-10-22 12:50:21 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void addNew()
|
|
|
|
|
{
|
2019-10-28 01:45:11 +00:00
|
|
|
|
selectedGroup.Value = Beatmap.Value.Beatmap.ControlPointInfo.GroupAt(clock.CurrentTime, true);
|
2019-10-22 12:50:21 +00:00
|
|
|
|
}
|
2019-10-09 07:06:16 +00:00
|
|
|
|
}
|
2019-10-08 05:23:13 +00:00
|
|
|
|
}
|
|
|
|
|
}
|