2019-10-08 13:23:13 +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.
|
|
|
|
|
|
2019-10-27 15:30:05 +08:00
|
|
|
|
using System.Linq;
|
2019-10-09 15:06:16 +08:00
|
|
|
|
using osu.Framework.Allocation;
|
|
|
|
|
using osu.Framework.Bindables;
|
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
|
using osu.Framework.Graphics.Containers;
|
|
|
|
|
using osu.Framework.Graphics.Shapes;
|
2019-10-11 17:46:05 +08:00
|
|
|
|
using osu.Game.Beatmaps.ControlPoints;
|
2019-10-09 15:06:16 +08:00
|
|
|
|
using osu.Game.Graphics.Containers;
|
2019-10-22 20:50:21 +08:00
|
|
|
|
using osu.Game.Graphics.UserInterface;
|
2021-04-19 13:11:26 +08:00
|
|
|
|
using osu.Game.Overlays;
|
2019-10-22 20:50:21 +08:00
|
|
|
|
using osuTK;
|
2019-10-09 15:06:16 +08:00
|
|
|
|
|
2019-10-08 13:23:13 +08:00
|
|
|
|
namespace osu.Game.Screens.Edit.Timing
|
|
|
|
|
{
|
2021-04-19 13:11:26 +08:00
|
|
|
|
public class TimingScreen : RoundedContentEditorScreen
|
2019-10-08 13:23:13 +08:00
|
|
|
|
{
|
2019-10-11 17:46:05 +08:00
|
|
|
|
[Cached]
|
2019-11-06 11:32:12 +08:00
|
|
|
|
private Bindable<ControlPointGroup> selectedGroup = new Bindable<ControlPointGroup>();
|
2019-10-11 17:46:05 +08:00
|
|
|
|
|
2020-09-24 16:03:54 +08:00
|
|
|
|
public TimingScreen()
|
|
|
|
|
: base(EditorScreenMode.Timing)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2021-04-19 13:11:26 +08:00
|
|
|
|
[BackgroundDependencyLoader]
|
|
|
|
|
private void load()
|
2019-10-09 15:06:16 +08:00
|
|
|
|
{
|
2021-04-19 13:11:26 +08:00
|
|
|
|
Add(new GridContainer
|
2019-10-09 15:06:16 +08:00
|
|
|
|
{
|
2021-04-19 13:11:26 +08:00
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
|
ColumnDimensions = new[]
|
2019-10-09 15:06:16 +08:00
|
|
|
|
{
|
2021-04-19 13:11:26 +08:00
|
|
|
|
new Dimension(),
|
|
|
|
|
new Dimension(GridSizeMode.Absolute, 350),
|
2019-10-09 15:06:16 +08:00
|
|
|
|
},
|
2021-04-19 13:11:26 +08:00
|
|
|
|
Content = new[]
|
|
|
|
|
{
|
|
|
|
|
new Drawable[]
|
|
|
|
|
{
|
|
|
|
|
new ControlPointList(),
|
|
|
|
|
new ControlPointSettings(),
|
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
});
|
2020-09-30 15:39:27 +08:00
|
|
|
|
}
|
|
|
|
|
|
2019-10-09 15:06:16 +08:00
|
|
|
|
public class ControlPointList : CompositeDrawable
|
2019-10-08 13:23:13 +08:00
|
|
|
|
{
|
2019-10-22 20:50:21 +08:00
|
|
|
|
private OsuButton deleteButton;
|
2019-10-27 15:13:24 +08:00
|
|
|
|
private ControlPointTable table;
|
|
|
|
|
|
2020-11-04 14:29:14 +08:00
|
|
|
|
private readonly IBindableList<ControlPointGroup> controlPointGroups = new BindableList<ControlPointGroup>();
|
2019-10-27 15:13:24 +08:00
|
|
|
|
|
|
|
|
|
[Resolved]
|
2020-05-22 18:49:49 +08:00
|
|
|
|
private EditorClock clock { get; set; }
|
2019-10-22 20:50:21 +08:00
|
|
|
|
|
2019-10-09 15:06:16 +08:00
|
|
|
|
[Resolved]
|
2021-01-04 15:38:15 +08:00
|
|
|
|
protected EditorBeatmap Beatmap { get; private set; }
|
2019-10-09 15:06:16 +08:00
|
|
|
|
|
2019-10-22 20:50:21 +08:00
|
|
|
|
[Resolved]
|
2019-10-27 15:13:24 +08:00
|
|
|
|
private Bindable<ControlPointGroup> selectedGroup { get; set; }
|
2019-10-22 20:50:21 +08:00
|
|
|
|
|
2020-10-02 16:15:58 +08:00
|
|
|
|
[Resolved(canBeNull: true)]
|
|
|
|
|
private IEditorChangeHandler changeHandler { get; set; }
|
|
|
|
|
|
2019-10-09 15:06:16 +08:00
|
|
|
|
[BackgroundDependencyLoader]
|
2021-04-19 13:11:26 +08:00
|
|
|
|
private void load(OverlayColourProvider colours)
|
2019-10-09 15:06:16 +08:00
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.Both;
|
|
|
|
|
|
2021-04-19 17:25:30 +08:00
|
|
|
|
const float margins = 10;
|
2019-10-09 15:06:16 +08:00
|
|
|
|
InternalChildren = new Drawable[]
|
|
|
|
|
{
|
|
|
|
|
new Box
|
|
|
|
|
{
|
2021-04-19 17:25:30 +08:00
|
|
|
|
Colour = colours.Background3,
|
2019-10-09 15:06:16 +08:00
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
|
},
|
2021-04-19 17:25:30 +08:00
|
|
|
|
new Box
|
|
|
|
|
{
|
|
|
|
|
Colour = colours.Background2,
|
|
|
|
|
RelativeSizeAxes = Axes.Y,
|
|
|
|
|
Width = ControlPointTable.TIMING_COLUMN_WIDTH + margins,
|
|
|
|
|
},
|
2019-10-09 15:06:16 +08:00
|
|
|
|
new OsuScrollContainer
|
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
2019-10-27 15:13:24 +08:00
|
|
|
|
Child = table = new ControlPointTable(),
|
2019-10-22 20:50:21 +08:00
|
|
|
|
},
|
|
|
|
|
new FillFlowContainer
|
|
|
|
|
{
|
|
|
|
|
AutoSizeAxes = Axes.Both,
|
|
|
|
|
Anchor = Anchor.BottomRight,
|
|
|
|
|
Origin = Anchor.BottomRight,
|
|
|
|
|
Direction = FillDirection.Horizontal,
|
2021-04-19 17:25:30 +08:00
|
|
|
|
Margin = new MarginPadding(margins),
|
2019-10-22 20:50:21 +08:00
|
|
|
|
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
|
|
|
|
|
{
|
2021-04-19 12:15:24 +08:00
|
|
|
|
Text = "+ Add at current time",
|
2019-10-22 20:50:21 +08:00
|
|
|
|
Action = addNew,
|
2021-04-19 12:15:24 +08:00
|
|
|
|
Size = new Vector2(160, 30),
|
2019-10-22 20:50:21 +08:00
|
|
|
|
Anchor = Anchor.BottomRight,
|
|
|
|
|
Origin = Anchor.BottomRight,
|
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
},
|
2019-10-09 15:06:16 +08:00
|
|
|
|
};
|
|
|
|
|
}
|
2019-10-22 20:50:21 +08:00
|
|
|
|
|
|
|
|
|
protected override void LoadComplete()
|
|
|
|
|
{
|
|
|
|
|
base.LoadComplete();
|
|
|
|
|
|
2019-10-27 15:13:24 +08:00
|
|
|
|
selectedGroup.BindValueChanged(selected => { deleteButton.Enabled.Value = selected.NewValue != null; }, true);
|
|
|
|
|
|
2021-01-04 15:38:15 +08:00
|
|
|
|
controlPointGroups.BindTo(Beatmap.ControlPointInfo.Groups);
|
2020-11-04 14:29:14 +08:00
|
|
|
|
controlPointGroups.BindCollectionChanged((sender, args) =>
|
2020-09-30 15:02:22 +08:00
|
|
|
|
{
|
2020-11-04 14:29:14 +08:00
|
|
|
|
table.ControlGroups = controlPointGroups;
|
2020-11-14 21:48:48 +08:00
|
|
|
|
changeHandler?.SaveState();
|
2020-09-30 15:02:22 +08:00
|
|
|
|
}, true);
|
|
|
|
|
}
|
2019-10-27 15:13:24 +08:00
|
|
|
|
|
2019-10-22 20:50:21 +08:00
|
|
|
|
private void delete()
|
|
|
|
|
{
|
2019-10-27 15:13:24 +08:00
|
|
|
|
if (selectedGroup.Value == null)
|
|
|
|
|
return;
|
|
|
|
|
|
2021-01-04 15:38:15 +08:00
|
|
|
|
Beatmap.ControlPointInfo.RemoveGroup(selectedGroup.Value);
|
2019-10-27 15:30:05 +08:00
|
|
|
|
|
2021-01-04 15:38:15 +08:00
|
|
|
|
selectedGroup.Value = Beatmap.ControlPointInfo.Groups.FirstOrDefault(g => g.Time >= clock.CurrentTime);
|
2019-10-22 20:50:21 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void addNew()
|
|
|
|
|
{
|
2021-01-04 15:38:15 +08:00
|
|
|
|
selectedGroup.Value = Beatmap.ControlPointInfo.GroupAt(clock.CurrentTime, true);
|
2019-10-22 20:50:21 +08:00
|
|
|
|
}
|
2019-10-09 15:06:16 +08:00
|
|
|
|
}
|
2019-10-08 13:23:13 +08:00
|
|
|
|
}
|
|
|
|
|
}
|