Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix editor not updating ruleset when switching difficulty #28738

Merged
merged 2 commits into from
Jul 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions osu.Game.Tests/Visual/Editing/TestSceneDifficultySwitching.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@
using osu.Game.Beatmaps;
using osu.Game.Overlays.Dialog;
using osu.Game.Rulesets;
using osu.Game.Rulesets.Catch;
using osu.Game.Rulesets.Osu;
using osu.Game.Rulesets.Taiko;
using osu.Game.Rulesets.UI;
using osu.Game.Screens.Edit;
using osu.Game.Storyboards;
Expand Down Expand Up @@ -169,6 +171,24 @@ public void TestAllowSwitchAfterDiscardingUnsavedChanges()
AddAssert("stack empty", () => Stack.CurrentScreen == null);
}

[Test]
public void TestSwitchToDifficultyOfAnotherRuleset()
{
BeatmapInfo targetDifficulty = null;

AddAssert("ruleset is catch", () => Ruleset.Value.CreateInstance() is CatchRuleset);

AddStep("set taiko difficulty", () => targetDifficulty = importedBeatmapSet.Beatmaps.First(b => b.Ruleset.OnlineID == 1));
switchToDifficulty(() => targetDifficulty);
confirmEditingBeatmap(() => targetDifficulty);

AddAssert("ruleset switched to taiko", () => Ruleset.Value.CreateInstance() is TaikoRuleset);

AddStep("exit editor forcefully", () => Stack.Exit());
// ensure editor loader didn't resume.
AddAssert("stack empty", () => Stack.CurrentScreen == null);
}

private void switchToDifficulty(Func<BeatmapInfo> difficulty) => AddStep("switch to difficulty", () => Editor.SwitchToDifficulty(difficulty.Invoke()));

private void confirmEditingBeatmap(Func<BeatmapInfo> targetDifficulty)
Expand Down
6 changes: 5 additions & 1 deletion osu.Game/Screens/Edit/EditorLoader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,11 @@ private void scheduleDifficultySwitch(Func<WorkingBeatmap> nextBeatmap, EditorSt

scheduledDifficultySwitch = Schedule(() =>
{
Beatmap.Value = nextBeatmap.Invoke();
var workingBeatmap = nextBeatmap.Invoke();

Ruleset.Value = workingBeatmap.BeatmapInfo.Ruleset;
Beatmap.Value = workingBeatmap;

state = editorState;

// This screen is a weird exception to the rule that nothing after song select changes the global beatmap.
Expand Down
Loading