1
0
mirror of https://github.com/ppy/osu.git synced 2025-02-01 22:42:54 +08:00
osu-lazer/osu.Game/Screens/Edit/Timing/TimingScreen.cs

85 lines
2.7 KiB
C#
Raw Normal View History

// 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-09 15:06:16 +08:00
using osu.Framework.Allocation;
using osu.Framework.Bindables;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
2019-10-11 17:46:05 +08:00
using osu.Game.Beatmaps.ControlPoints;
using osu.Game.Screens.Edit.Compose.Components.Timeline;
2019-10-09 15:06:16 +08:00
namespace osu.Game.Screens.Edit.Timing
{
2022-11-24 13:32:20 +08:00
public partial class TimingScreen : EditorScreenWithTimeline
{
2019-10-11 17:46:05 +08:00
[Cached]
public readonly Bindable<ControlPointGroup> SelectedGroup = new Bindable<ControlPointGroup>();
2019-10-11 17:46:05 +08:00
private readonly Bindable<EditorScreenMode> currentEditorMode = new Bindable<EditorScreenMode>();
[Resolved]
private EditorClock? editorClock { get; set; }
public TimingScreen()
: base(EditorScreenMode.Timing)
{
}
protected override Drawable CreateMainContent() => new GridContainer
2019-10-09 15:06:16 +08:00
{
RelativeSizeAxes = Axes.Both,
ColumnDimensions = new[]
2019-10-09 15:06:16 +08:00
{
new Dimension(),
new Dimension(GridSizeMode.Absolute, 350),
},
Content = new[]
{
new Drawable[]
2019-10-09 15:06:16 +08:00
{
new ControlPointList(),
new ControlPointSettings(),
2019-10-09 15:06:16 +08:00
},
}
};
[BackgroundDependencyLoader]
private void load(Editor? editor)
{
if (editor != null)
currentEditorMode.BindTo(editor.Mode);
}
protected override void LoadComplete()
{
base.LoadComplete();
// When entering the timing screen, let's choose the closest valid timing point.
// This will emulate the osu-stable behaviour where a metronome and timing information
// are presented on entering the screen.
currentEditorMode.BindValueChanged(mode =>
{
if (mode.NewValue == EditorScreenMode.Timing)
selectClosestTimingPoint();
});
selectClosestTimingPoint();
}
private void selectClosestTimingPoint()
{
if (editorClock == null)
return;
var nearestTimingPoint = EditorBeatmap.ControlPointInfo.TimingPointAt(editorClock.CurrentTime);
SelectedGroup.Value = EditorBeatmap.ControlPointInfo.GroupAt(nearestTimingPoint.Time);
}
protected override void ConfigureTimeline(TimelineArea timelineArea)
{
base.ConfigureTimeline(timelineArea);
timelineArea.Timeline.AlwaysShowControlPoints = true;
}
}
}