1
0
mirror of https://github.com/ppy/osu.git synced 2025-03-14 13:27:19 +08:00

Merge pull request #31454 from bdach/select-closest-timing-point-on-every-enter

Select closest timing point every time the timing screen is changed to
This commit is contained in:
Dan Balasescu 2025-01-09 09:04:18 +09:00 committed by GitHub
commit 520a5e4bfb
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -15,6 +15,8 @@ namespace osu.Game.Screens.Edit.Timing
[Cached]
public readonly Bindable<ControlPointGroup> SelectedGroup = new Bindable<ControlPointGroup>();
private readonly Bindable<EditorScreenMode> currentEditorMode = new Bindable<EditorScreenMode>();
[Resolved]
private EditorClock? editorClock { get; set; }
@ -41,18 +43,35 @@ namespace osu.Game.Screens.Edit.Timing
}
};
[BackgroundDependencyLoader]
private void load(Editor? editor)
{
if (editor != null)
currentEditorMode.BindTo(editor.Mode);
}
protected override void LoadComplete()
{
base.LoadComplete();
if (editorClock != null)
// 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 =>
{
// 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.
var nearestTimingPoint = EditorBeatmap.ControlPointInfo.TimingPointAt(editorClock.CurrentTime);
SelectedGroup.Value = EditorBeatmap.ControlPointInfo.GroupAt(nearestTimingPoint.Time);
}
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)