mirror of
https://github.com/ppy/osu.git
synced 2025-01-12 18:23:04 +08:00
Merge pull request #25380 from frenzibyte/fix-create-difficulty-crash
Fix editor crash when creating a new difficulty in a non-existent beatmap
This commit is contained in:
commit
5ac285ed2f
@ -6,11 +6,13 @@ using NUnit.Framework;
|
|||||||
using osu.Framework.Extensions;
|
using osu.Framework.Extensions;
|
||||||
using osu.Framework.Extensions.IEnumerableExtensions;
|
using osu.Framework.Extensions.IEnumerableExtensions;
|
||||||
using osu.Framework.Extensions.ObjectExtensions;
|
using osu.Framework.Extensions.ObjectExtensions;
|
||||||
|
using osu.Framework.Graphics.UserInterface;
|
||||||
using osu.Framework.Screens;
|
using osu.Framework.Screens;
|
||||||
using osu.Framework.Testing;
|
using osu.Framework.Testing;
|
||||||
using osu.Game.Beatmaps;
|
using osu.Game.Beatmaps;
|
||||||
using osu.Game.Configuration;
|
using osu.Game.Configuration;
|
||||||
using osu.Game.Database;
|
using osu.Game.Database;
|
||||||
|
using osu.Game.Overlays;
|
||||||
using osu.Game.Rulesets.Mania;
|
using osu.Game.Rulesets.Mania;
|
||||||
using osu.Game.Rulesets.Osu;
|
using osu.Game.Rulesets.Osu;
|
||||||
using osu.Game.Screens.Edit;
|
using osu.Game.Screens.Edit;
|
||||||
@ -232,6 +234,35 @@ namespace osu.Game.Tests.Visual.Navigation
|
|||||||
() => Is.EqualTo(beatmapSet.Beatmaps.First(b => b.Ruleset.OnlineID == 0).ID));
|
() => Is.EqualTo(beatmapSet.Beatmaps.First(b => b.Ruleset.OnlineID == 0).ID));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestCreateNewDifficultyOnNonExistentBeatmap()
|
||||||
|
{
|
||||||
|
AddUntilStep("wait for dialog overlay", () => Game.ChildrenOfType<DialogOverlay>().SingleOrDefault() != null);
|
||||||
|
|
||||||
|
AddStep("open editor", () => Game.ChildrenOfType<ButtonSystem>().Single().OnEdit.Invoke());
|
||||||
|
AddUntilStep("wait for editor", () => Game.ScreenStack.CurrentScreen is Editor editor && editor.IsLoaded);
|
||||||
|
AddStep("click on file", () =>
|
||||||
|
{
|
||||||
|
var item = getEditor().ChildrenOfType<Menu.DrawableMenuItem>().Single(i => i.Item.Text.Value.ToString() == "File");
|
||||||
|
item.TriggerClick();
|
||||||
|
});
|
||||||
|
AddStep("click on create new difficulty", () =>
|
||||||
|
{
|
||||||
|
var item = getEditor().ChildrenOfType<Menu.DrawableMenuItem>().Single(i => i.Item.Text.Value.ToString() == "Create new difficulty");
|
||||||
|
item.TriggerClick();
|
||||||
|
});
|
||||||
|
AddStep("click on catch", () =>
|
||||||
|
{
|
||||||
|
var item = getEditor().ChildrenOfType<Menu.DrawableMenuItem>().Single(i => i.Item.Text.Value.ToString() == "osu!catch");
|
||||||
|
item.TriggerClick();
|
||||||
|
});
|
||||||
|
AddAssert("save dialog displayed", () => Game.ChildrenOfType<DialogOverlay>().Single().CurrentDialog is SaveRequiredPopupDialog);
|
||||||
|
|
||||||
|
AddStep("press save", () => Game.ChildrenOfType<DialogOverlay>().Single().CurrentDialog!.PerformOkAction());
|
||||||
|
AddUntilStep("wait for editor", () => Game.ScreenStack.CurrentScreen is Editor editor && editor.IsLoaded);
|
||||||
|
AddAssert("editor beatmap uses catch ruleset", () => getEditorBeatmap().BeatmapInfo.Ruleset.ShortName == "fruits");
|
||||||
|
}
|
||||||
|
|
||||||
private EditorBeatmap getEditorBeatmap() => getEditor().ChildrenOfType<EditorBeatmap>().Single();
|
private EditorBeatmap getEditorBeatmap() => getEditor().ChildrenOfType<EditorBeatmap>().Single();
|
||||||
|
|
||||||
private Editor getEditor() => (Editor)Game.ScreenStack.CurrentScreen;
|
private Editor getEditor() => (Editor)Game.ScreenStack.CurrentScreen;
|
||||||
|
@ -1095,6 +1095,19 @@ namespace osu.Game.Screens.Edit
|
|||||||
|
|
||||||
protected void CreateNewDifficulty(RulesetInfo rulesetInfo)
|
protected void CreateNewDifficulty(RulesetInfo rulesetInfo)
|
||||||
{
|
{
|
||||||
|
if (isNewBeatmap)
|
||||||
|
{
|
||||||
|
dialogOverlay.Push(new SaveRequiredPopupDialog("This beatmap will be saved in order to create another difficulty.", () =>
|
||||||
|
{
|
||||||
|
if (!Save())
|
||||||
|
return;
|
||||||
|
|
||||||
|
CreateNewDifficulty(rulesetInfo);
|
||||||
|
}));
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (!rulesetInfo.Equals(editorBeatmap.BeatmapInfo.Ruleset))
|
if (!rulesetInfo.Equals(editorBeatmap.BeatmapInfo.Ruleset))
|
||||||
{
|
{
|
||||||
switchToNewDifficulty(rulesetInfo, false);
|
switchToNewDifficulty(rulesetInfo, false);
|
||||||
|
Loading…
Reference in New Issue
Block a user