1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-14 08:43:01 +08:00

Merge branch 'master' into fix-gameplay-seek-sample-pausing

This commit is contained in:
Dean Herbert 2020-10-05 16:21:28 +09:00 committed by GitHub
commit d43ea68709
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 66 additions and 8 deletions

View File

@ -5,6 +5,8 @@ using System;
using System.IO;
using System.Linq;
using NUnit.Framework;
using osu.Framework.Allocation;
using osu.Framework.Screens;
using osu.Framework.Testing;
using osu.Game.Beatmaps;
using osu.Game.Rulesets;
@ -22,6 +24,9 @@ namespace osu.Game.Tests.Visual.Editing
protected override bool EditorComponentsReady => Editor.ChildrenOfType<SetupScreen>().SingleOrDefault()?.IsLoaded == true;
[Resolved]
private BeatmapManager beatmapManager { get; set; }
public override void SetUpSteps()
{
AddStep("set dummy", () => Beatmap.Value = new DummyWorkingBeatmap(Audio, null));
@ -38,6 +43,15 @@ namespace osu.Game.Tests.Visual.Editing
{
AddStep("save beatmap", () => Editor.Save());
AddAssert("new beatmap persisted", () => EditorBeatmap.BeatmapInfo.ID > 0);
AddAssert("new beatmap in database", () => beatmapManager.QueryBeatmapSet(s => s.ID == EditorBeatmap.BeatmapInfo.BeatmapSet.ID)?.DeletePending == false);
}
[Test]
public void TestExitWithoutSave()
{
AddStep("exit without save", () => Editor.Exit());
AddUntilStep("wait for exit", () => !Editor.IsCurrentScreen());
AddAssert("new beatmap not persisted", () => beatmapManager.QueryBeatmapSet(s => s.ID == EditorBeatmap.BeatmapInfo.BeatmapSet.ID)?.DeletePending == true);
}
[Test]

View File

@ -84,6 +84,8 @@ namespace osu.Game.Screens.Edit
private DependencyContainer dependencies;
private bool isNewBeatmap;
protected override UserActivity InitialActivity => new UserActivity.Editing(Beatmap.Value.BeatmapInfo);
protected override IReadOnlyDependencyContainer CreateChildDependencies(IReadOnlyDependencyContainer parent)
@ -113,8 +115,6 @@ namespace osu.Game.Screens.Edit
// todo: remove caching of this and consume via editorBeatmap?
dependencies.Cache(beatDivisor);
bool isNewBeatmap = false;
if (Beatmap.Value is DummyWorkingBeatmap)
{
isNewBeatmap = true;
@ -287,6 +287,9 @@ namespace osu.Game.Screens.Edit
protected void Save()
{
// no longer new after first user-triggered save.
isNewBeatmap = false;
// apply any set-level metadata changes.
beatmapManager.Update(playableBeatmap.BeatmapInfo.BeatmapSet);
@ -435,10 +438,20 @@ namespace osu.Game.Screens.Edit
public override bool OnExiting(IScreen next)
{
if (!exitConfirmed && dialogOverlay != null && HasUnsavedChanges && !(dialogOverlay.CurrentDialog is PromptForSaveDialog))
if (!exitConfirmed)
{
dialogOverlay?.Push(new PromptForSaveDialog(confirmExit, confirmExitWithSave));
return true;
// if the confirm dialog is already showing (or we can't show it, ie. in tests) exit without save.
if (dialogOverlay == null || dialogOverlay.CurrentDialog is PromptForSaveDialog)
{
confirmExit();
return true;
}
if (isNewBeatmap || HasUnsavedChanges)
{
dialogOverlay?.Push(new PromptForSaveDialog(confirmExit, confirmExitWithSave));
return true;
}
}
Background.FadeColour(Color4.White, 500);
@ -456,6 +469,12 @@ namespace osu.Game.Screens.Edit
private void confirmExit()
{
if (isNewBeatmap)
{
// confirming exit without save means we should delete the new beatmap completely.
beatmapManager.Delete(playableBeatmap.BeatmapInfo.BeatmapSet);
}
exitConfirmed = true;
this.Exit();
}

View File

@ -81,9 +81,6 @@ namespace osu.Game.Screens.Edit
SaveState();
}
/// <summary>
/// Saves the current <see cref="Editor"/> state.
/// </summary>
public void SaveState()
{
if (bulkChangesStarted > 0)

View File

@ -35,5 +35,11 @@ namespace osu.Game.Screens.Edit
/// This should be invoked as soon as possible after <see cref="BeginChange"/> to cause a state change.
/// </remarks>
void EndChange();
/// <summary>
/// Immediately saves the current <see cref="Editor"/> state.
/// Note that this will be a no-op if there is a change in progress via <see cref="BeginChange"/>.
/// </summary>
void SaveState();
}
}

View File

@ -28,6 +28,7 @@ namespace osu.Game.Screens.Edit.Timing
if (point.NewValue != null)
{
multiplierSlider.Current = point.NewValue.SpeedMultiplierBindable;
multiplierSlider.Current.BindValueChanged(_ => ChangeHandler?.SaveState());
}
}

View File

@ -28,7 +28,10 @@ namespace osu.Game.Screens.Edit.Timing
if (point.NewValue != null)
{
kiai.Current = point.NewValue.KiaiModeBindable;
kiai.Current.BindValueChanged(_ => ChangeHandler?.SaveState());
omitBarLine.Current = point.NewValue.OmitFirstBarLineBindable;
omitBarLine.Current.BindValueChanged(_ => ChangeHandler?.SaveState());
}
}

View File

@ -35,7 +35,10 @@ namespace osu.Game.Screens.Edit.Timing
if (point.NewValue != null)
{
bank.Current = point.NewValue.SampleBankBindable;
bank.Current.BindValueChanged(_ => ChangeHandler?.SaveState());
volume.Current = point.NewValue.SampleVolumeBindable;
volume.Current.BindValueChanged(_ => ChangeHandler?.SaveState());
}
}

View File

@ -32,6 +32,9 @@ namespace osu.Game.Screens.Edit.Timing
[Resolved]
protected Bindable<ControlPointGroup> SelectedGroup { get; private set; }
[Resolved(canBeNull: true)]
protected IEditorChangeHandler ChangeHandler { get; private set; }
[BackgroundDependencyLoader]
private void load(OsuColour colours)
{

View File

@ -38,6 +38,7 @@ namespace osu.Game.Screens.Edit.Timing
},
slider = new SettingsSlider<T>
{
TransferValueOnCommit = true,
RelativeSizeAxes = Axes.X,
}
}

View File

@ -87,6 +87,9 @@ namespace osu.Game.Screens.Edit.Timing
[Resolved]
private Bindable<ControlPointGroup> selectedGroup { get; set; }
[Resolved(canBeNull: true)]
private IEditorChangeHandler changeHandler { get; set; }
[BackgroundDependencyLoader]
private void load(OsuColour colours)
{
@ -146,6 +149,7 @@ namespace osu.Game.Screens.Edit.Timing
controlGroups.BindCollectionChanged((sender, args) =>
{
table.ControlGroups = controlGroups;
changeHandler.SaveState();
}, true);
}

View File

@ -37,8 +37,13 @@ namespace osu.Game.Screens.Edit.Timing
if (point.NewValue != null)
{
bpmSlider.Bindable = point.NewValue.BeatLengthBindable;
bpmSlider.Bindable.BindValueChanged(_ => ChangeHandler?.SaveState());
bpmTextEntry.Bindable = point.NewValue.BeatLengthBindable;
// no need to hook change handler here as it's the same bindable as above
timeSignature.Bindable = point.NewValue.TimeSignatureBindable;
timeSignature.Bindable.BindValueChanged(_ => ChangeHandler?.SaveState());
}
}
@ -117,6 +122,8 @@ namespace osu.Game.Screens.Edit.Timing
bpmBindable.BindValueChanged(bpm => beatLengthBindable.Value = beatLengthToBpm(bpm.NewValue));
base.Bindable = bpmBindable;
TransferValueOnCommit = true;
}
public override Bindable<double> Bindable