mirror of
https://github.com/ppy/osu.git
synced 2025-02-12 08:33:04 +08:00
Merge pull request #25691 from bdach/fix-skin-editor-crash-again
Fix skin editor crashing in some circumstances when opened in main menu
This commit is contained in:
commit
c6b1a5f1ee
@ -283,15 +283,17 @@ namespace osu.Game.Tests.Visual.Navigation
|
||||
openSkinEditor();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestOpenSkinEditorGameplaySceneWhenDifferentRulesetActive()
|
||||
[TestCase(1)]
|
||||
[TestCase(2)]
|
||||
[TestCase(3)]
|
||||
public void TestOpenSkinEditorGameplaySceneWhenDifferentRulesetActive(int rulesetId)
|
||||
{
|
||||
BeatmapSetInfo beatmapSet = null!;
|
||||
|
||||
AddStep("import beatmap", () => beatmapSet = BeatmapImportHelper.LoadQuickOszIntoOsu(Game).GetResultSafely());
|
||||
AddStep("select mania difficulty", () =>
|
||||
AddStep($"select difficulty for ruleset w/ ID {rulesetId}", () =>
|
||||
{
|
||||
var beatmap = beatmapSet.Beatmaps.First(b => b.Ruleset.OnlineID == 3);
|
||||
var beatmap = beatmapSet.Beatmaps.First(b => b.Ruleset.OnlineID == rulesetId);
|
||||
Game.Beatmap.Value = Game.BeatmapManager.GetWorkingBeatmap(beatmap);
|
||||
});
|
||||
|
||||
|
@ -17,6 +17,7 @@ using osu.Game.Beatmaps;
|
||||
using osu.Game.Configuration;
|
||||
using osu.Game.Graphics.Containers;
|
||||
using osu.Game.Input.Bindings;
|
||||
using osu.Game.Rulesets;
|
||||
using osu.Game.Rulesets.Mods;
|
||||
using osu.Game.Scoring;
|
||||
using osu.Game.Screens;
|
||||
@ -58,6 +59,9 @@ namespace osu.Game.Overlays.SkinEditor
|
||||
[Resolved]
|
||||
private Bindable<IReadOnlyList<Mod>> mods { get; set; } = null!;
|
||||
|
||||
[Resolved]
|
||||
private Bindable<RulesetInfo> ruleset { get; set; } = null!;
|
||||
|
||||
[Resolved]
|
||||
private IBindable<WorkingBeatmap> beatmap { get; set; } = null!;
|
||||
|
||||
@ -153,7 +157,11 @@ namespace osu.Game.Overlays.SkinEditor
|
||||
if (screen is Player)
|
||||
return;
|
||||
|
||||
var replayGeneratingMod = beatmap.Value.BeatmapInfo.Ruleset.CreateInstance().GetAutoplayMod();
|
||||
// the validity of the current game-wide beatmap + ruleset combination is enforced by song select.
|
||||
// if we're anywhere else, the state is unknown and may not make sense, so forcibly set something that does.
|
||||
if (screen is not PlaySongSelect)
|
||||
ruleset.Value = beatmap.Value.BeatmapInfo.Ruleset;
|
||||
var replayGeneratingMod = ruleset.Value.CreateInstance().GetAutoplayMod();
|
||||
|
||||
IReadOnlyList<Mod> usableMods = mods.Value;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user