mirror of
https://github.com/osukey/osukey.git
synced 2025-08-06 16:13:57 +09:00
Merge pull request #21417 from peppy/dont-change-ruleset-convert
Avoid changing ruleset when presenting a beatmap if it can be converted
This commit is contained in:
@ -9,8 +9,10 @@ using NUnit.Framework;
|
|||||||
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.Extensions;
|
using osu.Game.Extensions;
|
||||||
using osu.Game.Rulesets;
|
using osu.Game.Rulesets;
|
||||||
|
using osu.Game.Rulesets.Catch;
|
||||||
using osu.Game.Rulesets.Mania;
|
using osu.Game.Rulesets.Mania;
|
||||||
using osu.Game.Rulesets.Osu;
|
using osu.Game.Rulesets.Osu;
|
||||||
using osu.Game.Screens.Menu;
|
using osu.Game.Screens.Menu;
|
||||||
@ -71,17 +73,51 @@ namespace osu.Game.Tests.Visual.Navigation
|
|||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void TestFromSongSelectDifferentRuleset()
|
public void TestFromSongSelectDifferentRulesetWithConvertDisallowed()
|
||||||
{
|
{
|
||||||
var firstImport = importBeatmap(1);
|
AddStep("Set converts disallowed", () => Game.LocalConfig.SetValue(OsuSetting.ShowConvertedBeatmaps, false));
|
||||||
presentAndConfirm(firstImport);
|
|
||||||
|
|
||||||
var secondImport = importBeatmap(3, new ManiaRuleset().RulesetInfo);
|
var osuImport = importBeatmap(1);
|
||||||
confirmBeatmapInSongSelect(secondImport);
|
presentAndConfirm(osuImport);
|
||||||
presentAndConfirm(secondImport);
|
|
||||||
|
|
||||||
presentSecondDifficultyAndConfirm(firstImport, 1);
|
var maniaImport = importBeatmap(2, new ManiaRuleset().RulesetInfo);
|
||||||
presentSecondDifficultyAndConfirm(secondImport, 3);
|
confirmBeatmapInSongSelect(maniaImport);
|
||||||
|
presentAndConfirm(maniaImport);
|
||||||
|
|
||||||
|
var catchImport = importBeatmap(3, new CatchRuleset().RulesetInfo);
|
||||||
|
confirmBeatmapInSongSelect(catchImport);
|
||||||
|
presentAndConfirm(catchImport);
|
||||||
|
|
||||||
|
// Ruleset is always changed.
|
||||||
|
presentSecondDifficultyAndConfirm(maniaImport, 2);
|
||||||
|
presentSecondDifficultyAndConfirm(osuImport, 1);
|
||||||
|
presentSecondDifficultyAndConfirm(catchImport, 3);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestFromSongSelectDifferentRulesetWithConvertAllowed()
|
||||||
|
{
|
||||||
|
AddStep("Set converts allowed", () => Game.LocalConfig.SetValue(OsuSetting.ShowConvertedBeatmaps, true));
|
||||||
|
|
||||||
|
var osuImport = importBeatmap(1);
|
||||||
|
presentAndConfirm(osuImport);
|
||||||
|
|
||||||
|
var maniaImport = importBeatmap(2, new ManiaRuleset().RulesetInfo);
|
||||||
|
confirmBeatmapInSongSelect(maniaImport);
|
||||||
|
presentAndConfirm(maniaImport);
|
||||||
|
|
||||||
|
var catchImport = importBeatmap(3, new CatchRuleset().RulesetInfo);
|
||||||
|
confirmBeatmapInSongSelect(catchImport);
|
||||||
|
presentAndConfirm(catchImport);
|
||||||
|
|
||||||
|
// force ruleset to osu!mania
|
||||||
|
presentSecondDifficultyAndConfirm(maniaImport, 2);
|
||||||
|
|
||||||
|
// ruleset is not changed as we can convert osu! beatmap.
|
||||||
|
presentSecondDifficultyAndConfirm(osuImport, 1, expectedRulesetOnlineID: 3);
|
||||||
|
|
||||||
|
// ruleset is changed as we cannot convert.
|
||||||
|
presentSecondDifficultyAndConfirm(catchImport, 3);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void returnToMenu()
|
private void returnToMenu()
|
||||||
@ -112,19 +148,19 @@ namespace osu.Game.Tests.Visual.Navigation
|
|||||||
imported = Game.BeatmapManager.Import(new BeatmapSetInfo
|
imported = Game.BeatmapManager.Import(new BeatmapSetInfo
|
||||||
{
|
{
|
||||||
Hash = Guid.NewGuid().ToString(),
|
Hash = Guid.NewGuid().ToString(),
|
||||||
OnlineID = i,
|
OnlineID = i * 1024,
|
||||||
Beatmaps =
|
Beatmaps =
|
||||||
{
|
{
|
||||||
new BeatmapInfo
|
new BeatmapInfo
|
||||||
{
|
{
|
||||||
OnlineID = i * 1024,
|
OnlineID = i * 1024 + 1,
|
||||||
Metadata = metadata,
|
Metadata = metadata,
|
||||||
Difficulty = new BeatmapDifficulty(),
|
Difficulty = new BeatmapDifficulty(),
|
||||||
Ruleset = ruleset ?? new OsuRuleset().RulesetInfo
|
Ruleset = ruleset ?? new OsuRuleset().RulesetInfo
|
||||||
},
|
},
|
||||||
new BeatmapInfo
|
new BeatmapInfo
|
||||||
{
|
{
|
||||||
OnlineID = i * 2048,
|
OnlineID = i * 1024 + 2,
|
||||||
Metadata = metadata,
|
Metadata = metadata,
|
||||||
Difficulty = new BeatmapDifficulty(),
|
Difficulty = new BeatmapDifficulty(),
|
||||||
Ruleset = ruleset ?? new OsuRuleset().RulesetInfo
|
Ruleset = ruleset ?? new OsuRuleset().RulesetInfo
|
||||||
@ -156,14 +192,14 @@ namespace osu.Game.Tests.Visual.Navigation
|
|||||||
AddAssert("correct ruleset selected", () => Game.Ruleset.Value, () => Is.EqualTo(getImport().Beatmaps.First().Ruleset));
|
AddAssert("correct ruleset selected", () => Game.Ruleset.Value, () => Is.EqualTo(getImport().Beatmaps.First().Ruleset));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void presentSecondDifficultyAndConfirm(Func<BeatmapSetInfo> getImport, int importedID)
|
private void presentSecondDifficultyAndConfirm(Func<BeatmapSetInfo> getImport, int importedID, int? expectedRulesetOnlineID = null)
|
||||||
{
|
{
|
||||||
Predicate<BeatmapInfo> pred = b => b.OnlineID == importedID * 2048;
|
Predicate<BeatmapInfo> pred = b => b.OnlineID == importedID * 1024 + 2;
|
||||||
AddStep("present difficulty", () => Game.PresentBeatmap(getImport(), pred));
|
AddStep("present difficulty", () => Game.PresentBeatmap(getImport(), pred));
|
||||||
|
|
||||||
AddUntilStep("wait for song select", () => Game.ScreenStack.CurrentScreen is Screens.Select.SongSelect songSelect && songSelect.IsLoaded);
|
AddUntilStep("wait for song select", () => Game.ScreenStack.CurrentScreen is Screens.Select.SongSelect songSelect && songSelect.IsLoaded);
|
||||||
AddUntilStep("correct beatmap displayed", () => Game.Beatmap.Value.BeatmapInfo.OnlineID, () => Is.EqualTo(importedID * 2048));
|
AddUntilStep("correct beatmap displayed", () => Game.Beatmap.Value.BeatmapInfo.OnlineID, () => Is.EqualTo(importedID * 1024 + 2));
|
||||||
AddAssert("correct ruleset selected", () => Game.Ruleset.Value, () => Is.EqualTo(getImport().Beatmaps.First().Ruleset));
|
AddAssert("correct ruleset selected", () => Game.Ruleset.Value.OnlineID, () => Is.EqualTo(expectedRulesetOnlineID ?? getImport().Beatmaps.First().Ruleset.OnlineID));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -520,11 +520,29 @@ namespace osu.Game
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Logger.Log($"Completing {nameof(PresentBeatmap)} with beatmap {beatmap} ruleset {selection.Ruleset}");
|
// Don't change the local ruleset if the user is on another ruleset and is showing converted beatmaps at song select.
|
||||||
|
// Eventually we probably want to check whether conversion is actually possible for the current ruleset.
|
||||||
|
bool requiresRulesetSwitch = !selection.Ruleset.Equals(Ruleset.Value)
|
||||||
|
&& (selection.Ruleset.OnlineID > 0 || !LocalConfig.Get<bool>(OsuSetting.ShowConvertedBeatmaps));
|
||||||
|
|
||||||
|
if (requiresRulesetSwitch)
|
||||||
|
{
|
||||||
Ruleset.Value = selection.Ruleset;
|
Ruleset.Value = selection.Ruleset;
|
||||||
Beatmap.Value = BeatmapManager.GetWorkingBeatmap(selection);
|
Beatmap.Value = BeatmapManager.GetWorkingBeatmap(selection);
|
||||||
|
|
||||||
|
Logger.Log($"Completing {nameof(PresentBeatmap)} with beatmap {beatmap} ruleset {selection.Ruleset}");
|
||||||
}
|
}
|
||||||
}, validScreens: new[] { typeof(SongSelect), typeof(IHandlePresentBeatmap) });
|
else
|
||||||
|
{
|
||||||
|
Beatmap.Value = BeatmapManager.GetWorkingBeatmap(selection);
|
||||||
|
|
||||||
|
Logger.Log($"Completing {nameof(PresentBeatmap)} with beatmap {beatmap} (maintaining ruleset)");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}, validScreens: new[]
|
||||||
|
{
|
||||||
|
typeof(SongSelect), typeof(IHandlePresentBeatmap)
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
Reference in New Issue
Block a user