1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-11 09:27:29 +08:00

Merge pull request #26585 from frenzibyte/fix-editor-ux

Fix timing point changes not applying after selecting another one
This commit is contained in:
Dean Herbert 2024-01-17 19:53:35 +09:00 committed by GitHub
commit 6a8a45bb13
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 42 additions and 2 deletions

View File

@ -4,11 +4,13 @@
#nullable disable
using System;
using System.Diagnostics;
using System.Linq;
using NUnit.Framework;
using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.UserInterface;
using osu.Framework.Testing;
using osu.Game.Beatmaps.ControlPoints;
using osu.Game.Graphics.Containers;
@ -177,6 +179,43 @@ namespace osu.Game.Tests.Visual.Editing
AddUntilStep("Scrolled to end", () => timingScreen.ChildrenOfType<OsuScrollContainer>().First().IsScrolledToEnd());
}
[Test]
public void TestEditThenClickAwayAppliesChanges()
{
AddStep("Add two control points", () =>
{
editorBeatmap.ControlPointInfo.Clear();
editorBeatmap.ControlPointInfo.Add(1000, new TimingControlPoint());
editorBeatmap.ControlPointInfo.Add(2000, new TimingControlPoint());
});
AddStep("Select second timing point", () =>
{
InputManager.MoveMouseTo(Child.ChildrenOfType<TimingRowAttribute>().Last());
InputManager.Click(MouseButton.Left);
});
AddStep("Scroll to end", () => timingScreen.ChildrenOfType<ControlPointSettings>().Single().ChildrenOfType<OsuScrollContainer>().Single().ScrollToEnd(false));
AddStep("Modify time signature", () =>
{
var timeSignatureTextBox = Child.ChildrenOfType<LabelledTimeSignature.TimeSignatureBox>().Single().ChildrenOfType<TextBox>().Single();
InputManager.MoveMouseTo(timeSignatureTextBox);
InputManager.Click(MouseButton.Left);
Debug.Assert(!timeSignatureTextBox.Current.Value.Equals("1", StringComparison.Ordinal));
timeSignatureTextBox.Current.Value = "1";
});
AddStep("Select first timing point", () =>
{
InputManager.MoveMouseTo(Child.ChildrenOfType<TimingRowAttribute>().First());
InputManager.Click(MouseButton.Left);
});
AddAssert("Second timing point changed time signature", () => editorBeatmap.ControlPointInfo.TimingPoints.Last().TimeSignature.Numerator == 1);
AddAssert("First timing point preserved time signature", () => editorBeatmap.ControlPointInfo.TimingPoints.First().TimeSignature.Numerator == 4);
}
protected override void Dispose(bool isDisposing)
{
Beatmap.Disabled = false;

View File

@ -44,11 +44,12 @@ namespace osu.Game.Screens.Edit.Timing
{
BackgroundFlow.Add(new RowBackground(group)
{
Action = () =>
// schedule to give time for any modified focused text box to lose focus and commit changes (e.g. BPM / time signature textboxes) before switching to new point.
Action = () => Schedule(() =>
{
SetSelectedRow(group);
clock.SeekSmoothlyTo(group.Time);
}
})
});
}