Merge pull request #19479 from frenzibyte/carousel-update-on-resume

Fix song select not updating selected beatmap card on editor resume
This commit is contained in:
Dean Herbert 2022-08-02 00:48:18 +09:00 committed by GitHub
commit 01cc9bd7ef
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 35 additions and 9 deletions

View File

@ -10,6 +10,7 @@ using NUnit.Framework;
using osu.Framework.Allocation;
using osu.Framework.Audio;
using osu.Framework.Bindables;
using osu.Framework.Extensions.IEnumerableExtensions;
using osu.Framework.Graphics.Containers;
using osu.Framework.Platform;
using osu.Framework.Screens;
@ -282,6 +283,28 @@ namespace osu.Game.Tests.Visual.SongSelect
AddAssert("filter count is 2", () => songSelect.FilterCount == 2);
}
[Test]
public void TestCarouselSelectionUpdatesOnResume()
{
addRulesetImportStep(0);
createSongSelect();
AddStep("push child screen", () => Stack.Push(new TestSceneOsuScreenStack.TestScreen("test child")));
AddUntilStep("wait for not current", () => !songSelect.IsCurrentScreen());
AddStep("update beatmap", () =>
{
var selectedBeatmap = Beatmap.Value.BeatmapInfo;
var anotherBeatmap = Beatmap.Value.BeatmapSetInfo.Beatmaps.Except(selectedBeatmap.Yield()).First();
Beatmap.Value = manager.GetWorkingBeatmap(anotherBeatmap);
});
AddStep("return", () => songSelect.MakeCurrent());
AddUntilStep("wait for current", () => songSelect.IsCurrentScreen());
AddAssert("carousel updated", () => songSelect.Carousel.SelectedBeatmapInfo.Equals(Beatmap.Value.BeatmapInfo));
}
[Test]
public void TestAudioResuming()
{

View File

@ -405,20 +405,21 @@ namespace osu.Game.Screens.Select
private ScheduledDelegate selectionChangedDebounce;
private void workingBeatmapChanged(ValueChangedEvent<WorkingBeatmap> e)
private void updateCarouselSelection(ValueChangedEvent<WorkingBeatmap> e = null)
{
if (e.NewValue is DummyWorkingBeatmap || !this.IsCurrentScreen()) return;
var beatmap = e?.NewValue ?? Beatmap.Value;
if (beatmap is DummyWorkingBeatmap || !this.IsCurrentScreen()) return;
Logger.Log($"Song select working beatmap updated to {e.NewValue}");
Logger.Log($"Song select working beatmap updated to {beatmap}");
if (!Carousel.SelectBeatmap(e.NewValue.BeatmapInfo, false))
if (!Carousel.SelectBeatmap(beatmap.BeatmapInfo, false))
{
// A selection may not have been possible with filters applied.
// There was possibly a ruleset mismatch. This is a case we can help things along by updating the game-wide ruleset to match.
if (!e.NewValue.BeatmapInfo.Ruleset.Equals(decoupledRuleset.Value))
if (!beatmap.BeatmapInfo.Ruleset.Equals(decoupledRuleset.Value))
{
Ruleset.Value = e.NewValue.BeatmapInfo.Ruleset;
Ruleset.Value = beatmap.BeatmapInfo.Ruleset;
transferRulesetValue();
}
@ -426,10 +427,10 @@ namespace osu.Game.Screens.Select
// we still want to temporarily show the new beatmap, bypassing filters.
// This will be undone the next time the user changes the filter.
var criteria = FilterControl.CreateCriteria();
criteria.SelectedBeatmapSet = e.NewValue.BeatmapInfo.BeatmapSet;
criteria.SelectedBeatmapSet = beatmap.BeatmapInfo.BeatmapSet;
Carousel.Filter(criteria);
Carousel.SelectBeatmap(e.NewValue.BeatmapInfo);
Carousel.SelectBeatmap(beatmap.BeatmapInfo);
}
}
@ -597,6 +598,8 @@ namespace osu.Game.Screens.Select
if (Beatmap != null && !Beatmap.Value.BeatmapSetInfo.DeletePending)
{
updateCarouselSelection();
updateComponentFromBeatmap(Beatmap.Value);
if (ControlGlobalMusic)
@ -805,7 +808,7 @@ namespace osu.Game.Screens.Select
};
decoupledRuleset.DisabledChanged += r => Ruleset.Disabled = r;
Beatmap.BindValueChanged(workingBeatmapChanged);
Beatmap.BindValueChanged(updateCarouselSelection);
boundLocalBindables = true;
}