mirror of
https://github.com/ppy/osu.git
synced 2024-11-11 09:27:29 +08:00
Merge pull request #21386 from peppy/fix-editor-tap-timing-crash
Fix crash when hitting 'T' to tap timing while no timing point is selected
This commit is contained in:
commit
224bf85e4a
@ -18,6 +18,7 @@ using osu.Game.Overlays;
|
||||
using osu.Game.Screens.Edit;
|
||||
using osu.Game.Screens.Edit.Timing;
|
||||
using osuTK;
|
||||
using osuTK.Input;
|
||||
|
||||
namespace osu.Game.Tests.Visual.Editing
|
||||
{
|
||||
@ -125,6 +126,41 @@ namespace osu.Game.Tests.Visual.Editing
|
||||
AddUntilStep("wait for track stopped", () => !EditorClock.IsRunning);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestNoCrashesWhenNoGroupSelected()
|
||||
{
|
||||
AddStep("unset selected group", () => selectedGroup.Value = null);
|
||||
AddStep("press T to tap", () => InputManager.Key(Key.T));
|
||||
|
||||
AddStep("click tap button", () =>
|
||||
{
|
||||
control.ChildrenOfType<OsuButton>()
|
||||
.Last()
|
||||
.TriggerClick();
|
||||
});
|
||||
|
||||
AddStep("click reset button", () =>
|
||||
{
|
||||
control.ChildrenOfType<OsuButton>()
|
||||
.First()
|
||||
.TriggerClick();
|
||||
});
|
||||
|
||||
AddStep("adjust offset", () =>
|
||||
{
|
||||
var adjustOffsetButton = control.ChildrenOfType<TimingAdjustButton>().First();
|
||||
InputManager.MoveMouseTo(adjustOffsetButton);
|
||||
InputManager.Click(MouseButton.Left);
|
||||
});
|
||||
|
||||
AddStep("adjust BPM", () =>
|
||||
{
|
||||
var adjustBPMButton = control.ChildrenOfType<TimingAdjustButton>().Last();
|
||||
InputManager.MoveMouseTo(adjustBPMButton);
|
||||
InputManager.Click(MouseButton.Left);
|
||||
});
|
||||
}
|
||||
|
||||
protected override void Dispose(bool isDisposing)
|
||||
{
|
||||
Beatmap.Disabled = false;
|
||||
|
@ -295,6 +295,9 @@ namespace osu.Game.Screens.Edit.Timing
|
||||
|
||||
private void handleTap()
|
||||
{
|
||||
if (selectedGroup?.Value == null)
|
||||
return;
|
||||
|
||||
tapTimings.Add(Clock.CurrentTime);
|
||||
|
||||
if (tapTimings.Count > initial_taps_to_ignore + max_taps_to_consider)
|
||||
|
@ -183,18 +183,27 @@ namespace osu.Game.Screens.Edit.Timing
|
||||
|
||||
private void start()
|
||||
{
|
||||
if (selectedGroup.Value == null)
|
||||
return;
|
||||
|
||||
editorClock.Seek(selectedGroup.Value.Time);
|
||||
editorClock.Start();
|
||||
}
|
||||
|
||||
private void reset()
|
||||
{
|
||||
if (selectedGroup.Value == null)
|
||||
return;
|
||||
|
||||
editorClock.Stop();
|
||||
editorClock.Seek(selectedGroup.Value.Time);
|
||||
}
|
||||
|
||||
private void adjustOffset(double adjust)
|
||||
{
|
||||
if (selectedGroup.Value == null)
|
||||
return;
|
||||
|
||||
bool wasAtStart = editorClock.CurrentTimeAccurate == selectedGroup.Value.Time;
|
||||
|
||||
// VERY TEMPORARY
|
||||
@ -216,7 +225,7 @@ namespace osu.Game.Screens.Edit.Timing
|
||||
|
||||
private void adjustBpm(double adjust)
|
||||
{
|
||||
var timing = selectedGroup.Value.ControlPoints.OfType<TimingControlPoint>().FirstOrDefault();
|
||||
var timing = selectedGroup.Value?.ControlPoints.OfType<TimingControlPoint>().FirstOrDefault();
|
||||
|
||||
if (timing == null)
|
||||
return;
|
||||
|
Loading…
Reference in New Issue
Block a user