Skip to content

Commit 520a5e4

Browse files
authored
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
2 parents 2e10f83 + 5a20247 commit 520a5e4

File tree

1 file changed

+26
-7
lines changed

1 file changed

+26
-7
lines changed

osu.Game/Screens/Edit/Timing/TimingScreen.cs

+26-7
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ public partial class TimingScreen : EditorScreenWithTimeline
1515
[Cached]
1616
public readonly Bindable<ControlPointGroup> SelectedGroup = new Bindable<ControlPointGroup>();
1717

18+
private readonly Bindable<EditorScreenMode> currentEditorMode = new Bindable<EditorScreenMode>();
19+
1820
[Resolved]
1921
private EditorClock? editorClock { get; set; }
2022

@@ -41,18 +43,35 @@ public TimingScreen()
4143
}
4244
};
4345

46+
[BackgroundDependencyLoader]
47+
private void load(Editor? editor)
48+
{
49+
if (editor != null)
50+
currentEditorMode.BindTo(editor.Mode);
51+
}
52+
4453
protected override void LoadComplete()
4554
{
4655
base.LoadComplete();
4756

48-
if (editorClock != null)
57+
// When entering the timing screen, let's choose the closest valid timing point.
58+
// This will emulate the osu-stable behaviour where a metronome and timing information
59+
// are presented on entering the screen.
60+
currentEditorMode.BindValueChanged(mode =>
4961
{
50-
// When entering the timing screen, let's choose the closest valid timing point.
51-
// This will emulate the osu-stable behaviour where a metronome and timing information
52-
// are presented on entering the screen.
53-
var nearestTimingPoint = EditorBeatmap.ControlPointInfo.TimingPointAt(editorClock.CurrentTime);
54-
SelectedGroup.Value = EditorBeatmap.ControlPointInfo.GroupAt(nearestTimingPoint.Time);
55-
}
62+
if (mode.NewValue == EditorScreenMode.Timing)
63+
selectClosestTimingPoint();
64+
});
65+
selectClosestTimingPoint();
66+
}
67+
68+
private void selectClosestTimingPoint()
69+
{
70+
if (editorClock == null)
71+
return;
72+
73+
var nearestTimingPoint = EditorBeatmap.ControlPointInfo.TimingPointAt(editorClock.CurrentTime);
74+
SelectedGroup.Value = EditorBeatmap.ControlPointInfo.GroupAt(nearestTimingPoint.Time);
5675
}
5776

5877
protected override void ConfigureTimeline(TimelineArea timelineArea)

0 commit comments

Comments
 (0)