mirror of
https://github.com/ppy/osu.git
synced 2026-05-21 21:40:56 +08:00
Hide object-typed CurrentSelection and expose strongly-typed alternatives instead
This commit is contained in:
@@ -325,7 +325,7 @@ namespace osu.Game.Tests.Visual.Background
|
||||
private void setupUserSettings()
|
||||
{
|
||||
AddUntilStep("Song select is current", () => songSelect.IsCurrentScreen());
|
||||
AddUntilStep("Song select has selection", () => songSelect.Carousel?.CurrentSelection != null);
|
||||
AddUntilStep("Song select has selection", () => songSelect.Carousel?.CurrentGroupedBeatmap != null);
|
||||
AddStep("Set default user settings", () =>
|
||||
{
|
||||
SelectedMods.Value = new[] { new OsuModNoFail() };
|
||||
|
||||
@@ -118,14 +118,14 @@ namespace osu.Game.Tests.Visual.SongSelectV2
|
||||
RequestSelection = b =>
|
||||
{
|
||||
BeatmapRequestedSelections.Push(b.Beatmap);
|
||||
Carousel.CurrentSelection = b;
|
||||
Carousel.CurrentGroupedBeatmap = b;
|
||||
},
|
||||
RequestRecommendedSelection = groupedBeatmaps =>
|
||||
{
|
||||
var recommendedBeatmap = BeatmapRecommendationFunction?.Invoke(groupedBeatmaps.Select(gb => gb.Beatmap)) ?? groupedBeatmaps.First().Beatmap;
|
||||
var recommendedGroupedBeatmap = groupedBeatmaps.First(gb => gb.Beatmap.Equals(recommendedBeatmap));
|
||||
BeatmapSetRequestedSelections.Push(recommendedBeatmap.BeatmapSet!);
|
||||
Carousel.CurrentSelection = recommendedGroupedBeatmap;
|
||||
Carousel.CurrentGroupedBeatmap = recommendedGroupedBeatmap;
|
||||
},
|
||||
BleedTop = 50,
|
||||
BleedBottom = 50,
|
||||
@@ -219,8 +219,8 @@ namespace osu.Game.Tests.Visual.SongSelectV2
|
||||
|
||||
protected void Select() => AddStep("select", () => InputManager.Key(Key.Enter));
|
||||
|
||||
protected void CheckNoSelection() => AddAssert("has no selection", () => Carousel.CurrentSelection, () => Is.Null);
|
||||
protected void CheckHasSelection() => AddAssert("has selection", () => Carousel.CurrentSelection, () => Is.Not.Null);
|
||||
protected void CheckNoSelection() => AddAssert("has no selection", () => Carousel.CurrentGroupedBeatmap, () => Is.Null);
|
||||
protected void CheckHasSelection() => AddAssert("has selection", () => Carousel.CurrentGroupedBeatmap, () => Is.Not.Null);
|
||||
|
||||
protected void CheckRequestPresentCount(int expected) =>
|
||||
AddAssert($"check present count is {expected}", () => Carousel.RequestPresentBeatmapCount, () => Is.EqualTo(expected));
|
||||
@@ -285,8 +285,7 @@ namespace osu.Game.Tests.Visual.SongSelectV2
|
||||
// offset by one because the group itself is included in the items list.
|
||||
CarouselItem item = groupingFilter.GroupItems[groupDefinition].ElementAt(panel + 1);
|
||||
|
||||
return (Carousel.CurrentSelection as GroupedBeatmap)?
|
||||
.Equals(item.Model as GroupedBeatmap) == true;
|
||||
return Carousel.CurrentGroupedBeatmap?.Equals(item.Model as GroupedBeatmap) == true;
|
||||
});
|
||||
}
|
||||
|
||||
@@ -295,12 +294,12 @@ namespace osu.Game.Tests.Visual.SongSelectV2
|
||||
if (diff != null)
|
||||
{
|
||||
AddUntilStep($"selected is set{set} diff{diff.Value}",
|
||||
() => (Carousel.CurrentSelection as GroupedBeatmap)?.Beatmap,
|
||||
() => Carousel.CurrentBeatmap,
|
||||
() => Is.EqualTo(BeatmapSets[set].Beatmaps[diff.Value]));
|
||||
}
|
||||
else
|
||||
{
|
||||
AddUntilStep($"selected is set{set}", () => BeatmapSets[set].Beatmaps.Contains(((GroupedBeatmap)Carousel.CurrentSelection!).Beatmap));
|
||||
AddUntilStep($"selected is set{set}", () => BeatmapSets[set].Beatmaps.Contains(Carousel.CurrentBeatmap!));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -419,7 +418,7 @@ namespace osu.Game.Tests.Visual.SongSelectV2
|
||||
tracked: {Carousel.ItemsTracked}
|
||||
displayable: {Carousel.DisplayableItems}
|
||||
displayed: {Carousel.VisibleItems}
|
||||
selected: {Carousel.CurrentSelection}
|
||||
selected: {Carousel.CurrentGroupedBeatmap}
|
||||
""");
|
||||
|
||||
void createHeader(string text)
|
||||
|
||||
@@ -80,7 +80,7 @@ namespace osu.Game.Tests.Visual.SongSelectV2
|
||||
|
||||
CheckHasSelection();
|
||||
AddAssert("drawable selection non-null", () => selection, () => Is.Not.Null);
|
||||
AddAssert("drawable selection matches carousel selection", () => selection, () => Is.EqualTo(Carousel.CurrentSelection));
|
||||
AddAssert("drawable selection matches carousel selection", () => selection, () => Is.EqualTo(Carousel.CurrentGroupedBeatmap));
|
||||
|
||||
RemoveAllBeatmaps();
|
||||
AddUntilStep("no drawable selection", GetSelectedPanel, () => Is.Null);
|
||||
@@ -93,7 +93,7 @@ namespace osu.Game.Tests.Visual.SongSelectV2
|
||||
|
||||
AddStep("add previous selection", () => BeatmapSets.Add(((GroupedBeatmap)selection!).Beatmap.BeatmapSet!));
|
||||
|
||||
AddAssert("selection matches original carousel selection", () => selection, () => Is.EqualTo(Carousel.CurrentSelection));
|
||||
AddAssert("selection matches original carousel selection", () => selection, () => Is.EqualTo(Carousel.CurrentGroupedBeatmap));
|
||||
AddUntilStep("drawable selection restored", () => GetSelectedPanel()?.Item?.Model, () => Is.EqualTo(selection));
|
||||
AddAssert("carousel item is visible", () => GetSelectedPanel()?.Item?.IsVisible, () => Is.True);
|
||||
|
||||
|
||||
@@ -70,7 +70,7 @@ namespace osu.Game.Tests.Visual.SongSelectV2
|
||||
|
||||
CheckHasSelection();
|
||||
AddAssert("drawable selection non-null", () => selection, () => Is.Not.Null);
|
||||
AddAssert("drawable selection matches carousel selection", () => selection, () => Is.EqualTo(Carousel.CurrentSelection));
|
||||
AddAssert("drawable selection matches carousel selection", () => selection, () => Is.EqualTo(Carousel.CurrentGroupedBeatmap));
|
||||
|
||||
RemoveAllBeatmaps();
|
||||
AddUntilStep("no drawable selection", GetSelectedPanel, () => Is.Null);
|
||||
@@ -83,7 +83,7 @@ namespace osu.Game.Tests.Visual.SongSelectV2
|
||||
|
||||
AddStep("add previous selection", () => BeatmapSets.Add(((GroupedBeatmap)selection!).Beatmap.BeatmapSet!));
|
||||
|
||||
AddAssert("selection matches original carousel selection", () => selection, () => Is.EqualTo(Carousel.CurrentSelection));
|
||||
AddAssert("selection matches original carousel selection", () => selection, () => Is.EqualTo(Carousel.CurrentGroupedBeatmap));
|
||||
AddUntilStep("drawable selection restored", () => GetSelectedPanel()?.Item?.Model, () => Is.EqualTo(selection));
|
||||
AddAssert("carousel item is visible", () => GetSelectedPanel()?.Item?.IsVisible, () => Is.True);
|
||||
|
||||
@@ -198,7 +198,7 @@ namespace osu.Game.Tests.Visual.SongSelectV2
|
||||
}
|
||||
|
||||
private void checkBeatmapIsKeyboardSelected() =>
|
||||
AddUntilStep("check keyboard selected group is beatmap", () => GetKeyboardSelectedPanel()?.Item?.Model, () => Is.EqualTo(Carousel.CurrentSelection));
|
||||
AddUntilStep("check keyboard selected group is beatmap", () => GetKeyboardSelectedPanel()?.Item?.Model, () => Is.EqualTo(Carousel.CurrentGroupedBeatmap));
|
||||
|
||||
private void checkGroupKeyboardSelected(int index) => AddUntilStep($"check keyboard selected group is {index}", () => GetKeyboardSelectedPanel()?.Item?.Model, () =>
|
||||
{
|
||||
|
||||
@@ -130,14 +130,14 @@ namespace osu.Game.Tests.Visual.SongSelectV2
|
||||
SelectNextPanel();
|
||||
Select();
|
||||
|
||||
AddStep("record selection", () => selectedID = ((GroupedBeatmap)Carousel.CurrentSelection!).Beatmap.ID);
|
||||
AddStep("record selection", () => selectedID = Carousel.CurrentBeatmap!.ID);
|
||||
|
||||
for (int i = 0; i < 5; i++)
|
||||
{
|
||||
ApplyToFilterAndWaitForFilter("filter all", c => c.SearchText = Guid.NewGuid().ToString());
|
||||
AddAssert("selection not changed", () => ((GroupedBeatmap)Carousel.CurrentSelection!).Beatmap.ID == selectedID);
|
||||
AddAssert("selection not changed", () => Carousel.CurrentBeatmap!.ID == selectedID);
|
||||
ApplyToFilterAndWaitForFilter("remove filter", c => c.SearchText = string.Empty);
|
||||
AddAssert("selection not changed", () => ((GroupedBeatmap)Carousel.CurrentSelection!).Beatmap.ID == selectedID);
|
||||
AddAssert("selection not changed", () => Carousel.CurrentBeatmap!.ID == selectedID);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -177,14 +177,14 @@ namespace osu.Game.Tests.Visual.SongSelectV2
|
||||
|
||||
SelectNextSet();
|
||||
|
||||
AddStep("record selection", () => selectedID = ((GroupedBeatmap)Carousel.CurrentSelection!).Beatmap.ID);
|
||||
AddStep("record selection", () => selectedID = Carousel.CurrentBeatmap!.ID);
|
||||
|
||||
for (int i = 0; i < 5; i++)
|
||||
{
|
||||
ApplyToFilterAndWaitForFilter("filter all", c => c.SearchText = Guid.NewGuid().ToString());
|
||||
AddAssert("selection not changed", () => ((GroupedBeatmap)Carousel.CurrentSelection!).Beatmap.ID == selectedID);
|
||||
AddAssert("selection not changed", () => Carousel.CurrentBeatmap!.ID == selectedID);
|
||||
ApplyToFilterAndWaitForFilter("remove filter", c => c.SearchText = string.Empty);
|
||||
AddAssert("selection not changed", () => ((GroupedBeatmap)Carousel.CurrentSelection!).Beatmap.ID == selectedID);
|
||||
AddAssert("selection not changed", () => Carousel.CurrentBeatmap!.ID == selectedID);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -200,14 +200,14 @@ namespace osu.Game.Tests.Visual.SongSelectV2
|
||||
{
|
||||
int diff = i;
|
||||
|
||||
AddStep($"select diff {diff}", () => Carousel.CurrentSelection = chosenBeatmap = BeatmapSets[20].Beatmaps[diff]);
|
||||
AddUntilStep("selection changed", () => ((GroupedBeatmap)Carousel.CurrentSelection!).Beatmap, () => Is.EqualTo(chosenBeatmap));
|
||||
AddStep($"select diff {diff}", () => Carousel.CurrentBeatmap = chosenBeatmap = BeatmapSets[20].Beatmaps[diff]);
|
||||
AddUntilStep("selection changed", () => Carousel.CurrentBeatmap, () => Is.EqualTo(chosenBeatmap));
|
||||
|
||||
SortBy(SortMode.Difficulty);
|
||||
AddAssert("selection retained", () => ((GroupedBeatmap)Carousel.CurrentSelection!).Beatmap, () => Is.EqualTo(chosenBeatmap));
|
||||
AddAssert("selection retained", () => Carousel.CurrentBeatmap, () => Is.EqualTo(chosenBeatmap));
|
||||
|
||||
SortBy(SortMode.Title);
|
||||
AddAssert("selection retained", () => ((GroupedBeatmap)Carousel.CurrentSelection!).Beatmap, () => Is.EqualTo(chosenBeatmap));
|
||||
AddAssert("selection retained", () => Carousel.CurrentBeatmap, () => Is.EqualTo(chosenBeatmap));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -89,7 +89,7 @@ namespace osu.Game.Tests.Visual.SongSelectV2
|
||||
|
||||
CheckHasSelection();
|
||||
AddAssert("drawable selection non-null", () => selection, () => Is.Not.Null);
|
||||
AddAssert("drawable selection matches carousel selection", () => selection, () => Is.EqualTo(Carousel.CurrentSelection));
|
||||
AddAssert("drawable selection matches carousel selection", () => selection, () => Is.EqualTo(Carousel.CurrentGroupedBeatmap));
|
||||
|
||||
RemoveAllBeatmaps();
|
||||
AddUntilStep("no drawable selection", GetSelectedPanel, () => Is.Null);
|
||||
@@ -102,7 +102,7 @@ namespace osu.Game.Tests.Visual.SongSelectV2
|
||||
|
||||
AddStep("add previous selection", () => BeatmapSets.Add(((GroupedBeatmap)selection!).Beatmap.BeatmapSet!));
|
||||
|
||||
AddAssert("selection matches original carousel selection", () => selection, () => Is.EqualTo(Carousel.CurrentSelection));
|
||||
AddAssert("selection matches original carousel selection", () => selection, () => Is.EqualTo(Carousel.CurrentGroupedBeatmap));
|
||||
AddUntilStep("drawable selection restored", () => GetSelectedPanel()?.Item?.Model, () => Is.EqualTo(selection));
|
||||
AddAssert("carousel item is visible", () => GetSelectedPanel()?.Item?.IsVisible, () => Is.True);
|
||||
}
|
||||
@@ -389,15 +389,15 @@ namespace osu.Game.Tests.Visual.SongSelectV2
|
||||
|
||||
private void checkSelectionIterating(bool isIterating)
|
||||
{
|
||||
object? selection = null;
|
||||
GroupedBeatmap? selection = null;
|
||||
|
||||
for (int i = 0; i < 3; i++)
|
||||
{
|
||||
AddStep("store selection", () => selection = Carousel.CurrentSelection);
|
||||
AddStep("store selection", () => selection = Carousel.CurrentGroupedBeatmap);
|
||||
if (isIterating)
|
||||
AddUntilStep("selection changed", () => Carousel.CurrentSelection != selection);
|
||||
AddUntilStep("selection changed", () => Carousel.CurrentGroupedBeatmap != selection);
|
||||
else
|
||||
AddUntilStep("selection not changed", () => Carousel.CurrentSelection == selection);
|
||||
AddUntilStep("selection not changed", () => Carousel.CurrentGroupedBeatmap == selection);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -50,12 +50,12 @@ namespace osu.Game.Tests.Visual.SongSelectV2
|
||||
nextRandom();
|
||||
ensureRandomDidNotRepeat();
|
||||
|
||||
AddStep("store selection", () => originalSelected = ((GroupedBeatmap)Carousel.CurrentSelection!).Beatmap);
|
||||
AddStep("store selection", () => originalSelected = Carousel.CurrentBeatmap!);
|
||||
|
||||
SortAndGroupBy(SortMode.Artist, GroupMode.Difficulty);
|
||||
WaitForFiltering();
|
||||
|
||||
AddAssert("selection not changed", () => ((GroupedBeatmap)Carousel.CurrentSelection!).Beatmap, () => Is.EqualTo(originalSelected));
|
||||
AddAssert("selection not changed", () => Carousel.CurrentBeatmap, () => Is.EqualTo(originalSelected));
|
||||
|
||||
storeExpandedGroup();
|
||||
|
||||
@@ -282,7 +282,7 @@ namespace osu.Game.Tests.Visual.SongSelectV2
|
||||
nextRandom();
|
||||
|
||||
CheckHasSelection();
|
||||
AddStep("store selection", () => originalSelected = ((GroupedBeatmap)Carousel.CurrentSelection!));
|
||||
AddStep("store selection", () => originalSelected = Carousel.CurrentGroupedBeatmap!);
|
||||
|
||||
AddStep("random then rewind", () =>
|
||||
{
|
||||
@@ -290,7 +290,7 @@ namespace osu.Game.Tests.Visual.SongSelectV2
|
||||
Carousel.PreviousRandom();
|
||||
});
|
||||
|
||||
AddAssert("selection not changed", () => Carousel.CurrentSelection, () => Is.EqualTo(originalSelected));
|
||||
AddAssert("selection not changed", () => Carousel.CurrentGroupedBeatmap, () => Is.EqualTo(originalSelected));
|
||||
}
|
||||
|
||||
[Test]
|
||||
@@ -305,20 +305,20 @@ namespace osu.Game.Tests.Visual.SongSelectV2
|
||||
nextRandom();
|
||||
|
||||
CheckHasSelection();
|
||||
AddStep("store selection", () => originalSelected = (GroupedBeatmap)Carousel.CurrentSelection!);
|
||||
AddStep("store selection", () => originalSelected = Carousel.CurrentGroupedBeatmap!);
|
||||
|
||||
nextRandom();
|
||||
AddStep("store selection", () => postRandomSelection = (GroupedBeatmap)Carousel.CurrentSelection!);
|
||||
AddStep("store selection", () => postRandomSelection = Carousel.CurrentGroupedBeatmap!);
|
||||
|
||||
AddAssert("selection changed", () => originalSelected, () => Is.Not.SameAs(postRandomSelection));
|
||||
|
||||
AddStep("delete previous selection beatmaps", () => BeatmapSets.Remove(originalSelected!.Beatmap.BeatmapSet!));
|
||||
WaitForFiltering();
|
||||
|
||||
AddAssert("selection not changed", () => Carousel.CurrentSelection, () => Is.EqualTo(postRandomSelection));
|
||||
AddAssert("selection not changed", () => Carousel.CurrentGroupedBeatmap, () => Is.EqualTo(postRandomSelection));
|
||||
|
||||
prevRandomSet();
|
||||
AddAssert("selection not changed", () => Carousel.CurrentSelection, () => Is.EqualTo(postRandomSelection));
|
||||
AddAssert("selection not changed", () => Carousel.CurrentGroupedBeatmap, () => Is.EqualTo(postRandomSelection));
|
||||
}
|
||||
|
||||
private void nextRandom() =>
|
||||
|
||||
@@ -27,7 +27,7 @@ namespace osu.Game.Tests.Visual.SongSelectV2
|
||||
{
|
||||
Quad positionBefore = default;
|
||||
|
||||
AddStep("select middle beatmap", () => Carousel.CurrentSelection = new GroupedBeatmap(null, BeatmapSets.ElementAt(BeatmapSets.Count - 2).Beatmaps.First()));
|
||||
AddStep("select middle beatmap", () => Carousel.CurrentGroupedBeatmap = new GroupedBeatmap(null, BeatmapSets.ElementAt(BeatmapSets.Count - 2).Beatmaps.First()));
|
||||
|
||||
WaitForScrolling();
|
||||
|
||||
@@ -45,7 +45,7 @@ namespace osu.Game.Tests.Visual.SongSelectV2
|
||||
{
|
||||
Quad positionBefore = default;
|
||||
|
||||
AddStep("select middle beatmap", () => Carousel.CurrentSelection = new GroupedBeatmap(null, BeatmapSets.ElementAt(BeatmapSets.Count - 2).Beatmaps.First()));
|
||||
AddStep("select middle beatmap", () => Carousel.CurrentGroupedBeatmap = new GroupedBeatmap(null, BeatmapSets.ElementAt(BeatmapSets.Count - 2).Beatmaps.First()));
|
||||
WaitForScrolling();
|
||||
|
||||
AddStep("override scroll with user scroll", () =>
|
||||
@@ -71,7 +71,7 @@ namespace osu.Game.Tests.Visual.SongSelectV2
|
||||
|
||||
AddStep("scroll to end", () => Scroll.ScrollToEnd(false));
|
||||
|
||||
AddStep("select last beatmap", () => Carousel.CurrentSelection = new GroupedBeatmap(null, BeatmapSets.Last().Beatmaps.Last()));
|
||||
AddStep("select last beatmap", () => Carousel.CurrentGroupedBeatmap = new GroupedBeatmap(null, BeatmapSets.Last().Beatmaps.Last()));
|
||||
|
||||
WaitForScrolling();
|
||||
|
||||
@@ -88,7 +88,7 @@ namespace osu.Game.Tests.Visual.SongSelectV2
|
||||
{
|
||||
Quad positionBefore = default;
|
||||
|
||||
AddStep("select first beatmap", () => Carousel.CurrentSelection = new GroupedBeatmap(null, BeatmapSets.First().Beatmaps.First()));
|
||||
AddStep("select first beatmap", () => Carousel.CurrentGroupedBeatmap = new GroupedBeatmap(null, BeatmapSets.First().Beatmaps.First()));
|
||||
|
||||
WaitForScrolling();
|
||||
|
||||
@@ -108,7 +108,7 @@ namespace osu.Game.Tests.Visual.SongSelectV2
|
||||
{
|
||||
Quad positionBefore = default;
|
||||
|
||||
AddStep("select first beatmap", () => Carousel.CurrentSelection = new GroupedBeatmap(null, BeatmapSets.First().Beatmaps.First()));
|
||||
AddStep("select first beatmap", () => Carousel.CurrentGroupedBeatmap = new GroupedBeatmap(null, BeatmapSets.First().Beatmaps.First()));
|
||||
WaitForScrolling();
|
||||
|
||||
AddStep("override scroll with user scroll", () =>
|
||||
|
||||
@@ -179,7 +179,7 @@ namespace osu.Game.Tests.Visual.SongSelectV2
|
||||
SelectNextSet();
|
||||
|
||||
WaitForSetSelection(1, 0);
|
||||
AddAssert("selection is updateable beatmap", () => ((GroupedBeatmap)Carousel.CurrentSelection!).Beatmap, () => Is.EqualTo(baseTestBeatmap.Beatmaps[0]));
|
||||
AddAssert("selection is updateable beatmap", () => Carousel.CurrentBeatmap, () => Is.EqualTo(baseTestBeatmap.Beatmaps[0]));
|
||||
AddAssert("visible panel is updateable beatmap", () => (GetSelectedPanel()?.Item?.Model as GroupedBeatmap)?.Beatmap, () => Is.EqualTo(baseTestBeatmap.Beatmaps[0]));
|
||||
|
||||
updateBeatmap(b =>
|
||||
@@ -195,7 +195,7 @@ namespace osu.Game.Tests.Visual.SongSelectV2
|
||||
|
||||
WaitForFiltering();
|
||||
|
||||
AddAssert("selection is updateable beatmap", () => ((GroupedBeatmap)Carousel.CurrentSelection!).Beatmap, () => Is.EqualTo(baseTestBeatmap.Beatmaps[0]));
|
||||
AddAssert("selection is updateable beatmap", () => Carousel.CurrentBeatmap, () => Is.EqualTo(baseTestBeatmap.Beatmaps[0]));
|
||||
AddAssert("visible panel is updateable beatmap", () => (GetSelectedPanel()?.Item?.Model as GroupedBeatmap)?.Beatmap, () => Is.EqualTo(baseTestBeatmap.Beatmaps[0]));
|
||||
}
|
||||
|
||||
@@ -205,14 +205,14 @@ namespace osu.Game.Tests.Visual.SongSelectV2
|
||||
SelectNextSet();
|
||||
|
||||
WaitForSetSelection(1, 0);
|
||||
AddAssert("selection is updateable beatmap", () => ((GroupedBeatmap)Carousel.CurrentSelection!).Beatmap, () => Is.EqualTo(baseTestBeatmap.Beatmaps[0]));
|
||||
AddAssert("selection is updateable beatmap", () => Carousel.CurrentBeatmap, () => Is.EqualTo(baseTestBeatmap.Beatmaps[0]));
|
||||
AddAssert("visible panel is updateable beatmap", () => (GetSelectedPanel()?.Item?.Model as GroupedBeatmap)?.Beatmap, () => Is.EqualTo(baseTestBeatmap.Beatmaps[0]));
|
||||
|
||||
updateBeatmap(b => b.DifficultyName = "new name");
|
||||
assertDidFilter();
|
||||
WaitForFiltering();
|
||||
|
||||
AddAssert("selection is updateable beatmap", () => ((GroupedBeatmap)Carousel.CurrentSelection!).Beatmap, () => Is.EqualTo(baseTestBeatmap.Beatmaps[0]));
|
||||
AddAssert("selection is updateable beatmap", () => Carousel.CurrentBeatmap, () => Is.EqualTo(baseTestBeatmap.Beatmaps[0]));
|
||||
AddAssert("visible panel is updateable beatmap", () => (GetSelectedPanel()?.Item?.Model as GroupedBeatmap)?.Beatmap, () => Is.EqualTo(baseTestBeatmap.Beatmaps[0]));
|
||||
}
|
||||
|
||||
@@ -222,14 +222,14 @@ namespace osu.Game.Tests.Visual.SongSelectV2
|
||||
SelectNextSet();
|
||||
|
||||
WaitForSetSelection(1, 0);
|
||||
AddAssert("selection is updateable beatmap", () => ((GroupedBeatmap)Carousel.CurrentSelection!).Beatmap, () => Is.EqualTo(baseTestBeatmap.Beatmaps[0]));
|
||||
AddAssert("selection is updateable beatmap", () => Carousel.CurrentBeatmap, () => Is.EqualTo(baseTestBeatmap.Beatmaps[0]));
|
||||
AddAssert("visible panel is updateable beatmap", () => (GetSelectedPanel()?.Item?.Model as GroupedBeatmap)?.Beatmap, () => Is.EqualTo(baseTestBeatmap.Beatmaps[0]));
|
||||
|
||||
updateBeatmap(b => b.OnlineID = b.OnlineID + 1);
|
||||
assertDidFilter();
|
||||
WaitForFiltering();
|
||||
|
||||
AddAssert("selection is updateable beatmap", () => ((GroupedBeatmap)Carousel.CurrentSelection!).Beatmap, () => Is.EqualTo(baseTestBeatmap.Beatmaps[0]));
|
||||
AddAssert("selection is updateable beatmap", () => Carousel.CurrentBeatmap, () => Is.EqualTo(baseTestBeatmap.Beatmaps[0]));
|
||||
AddAssert("visible panel is updateable beatmap", () => (GetSelectedPanel()?.Item?.Model as GroupedBeatmap)?.Beatmap, () => Is.EqualTo(baseTestBeatmap.Beatmaps[0]));
|
||||
}
|
||||
|
||||
@@ -239,7 +239,7 @@ namespace osu.Game.Tests.Visual.SongSelectV2
|
||||
SelectNextSet();
|
||||
|
||||
WaitForSetSelection(1, 0);
|
||||
AddAssert("selection is updateable beatmap", () => ((GroupedBeatmap)Carousel.CurrentSelection!).Beatmap, () => Is.EqualTo(baseTestBeatmap.Beatmaps[0]));
|
||||
AddAssert("selection is updateable beatmap", () => Carousel.CurrentBeatmap, () => Is.EqualTo(baseTestBeatmap.Beatmaps[0]));
|
||||
AddAssert("visible panel is updateable beatmap", () => (GetSelectedPanel()?.Item?.Model as GroupedBeatmap)?.Beatmap, () => Is.EqualTo(baseTestBeatmap.Beatmaps[0]));
|
||||
|
||||
// Add another difficulty with same online ID.
|
||||
@@ -252,7 +252,7 @@ namespace osu.Game.Tests.Visual.SongSelectV2
|
||||
|
||||
WaitForFiltering();
|
||||
|
||||
AddAssert("selection is updateable beatmap", () => ((GroupedBeatmap)Carousel.CurrentSelection!).Beatmap, () => Is.EqualTo(baseTestBeatmap.Beatmaps[0]));
|
||||
AddAssert("selection is updateable beatmap", () => Carousel.CurrentBeatmap, () => Is.EqualTo(baseTestBeatmap.Beatmaps[0]));
|
||||
AddAssert("visible panel is updateable beatmap", () => (GetSelectedPanel()?.Item?.Model as GroupedBeatmap)?.Beatmap, () => Is.EqualTo(baseTestBeatmap.Beatmaps[0]));
|
||||
}
|
||||
|
||||
@@ -262,7 +262,7 @@ namespace osu.Game.Tests.Visual.SongSelectV2
|
||||
SelectNextSet();
|
||||
|
||||
WaitForSetSelection(1, 0);
|
||||
AddAssert("selection is updateable beatmap", () => ((GroupedBeatmap)Carousel.CurrentSelection!).Beatmap, () => Is.EqualTo(baseTestBeatmap.Beatmaps[0]));
|
||||
AddAssert("selection is updateable beatmap", () => Carousel.CurrentBeatmap, () => Is.EqualTo(baseTestBeatmap.Beatmaps[0]));
|
||||
AddAssert("visible panel is updateable beatmap", () => (GetSelectedPanel()?.Item?.Model as GroupedBeatmap)?.Beatmap, () => Is.EqualTo(baseTestBeatmap.Beatmaps[0]));
|
||||
|
||||
// Remove original selected difficulty, and add two difficulties with same name as selection.
|
||||
@@ -284,7 +284,7 @@ namespace osu.Game.Tests.Visual.SongSelectV2
|
||||
|
||||
WaitForFiltering();
|
||||
|
||||
AddAssert("selection is updateable beatmap", () => ((GroupedBeatmap)Carousel.CurrentSelection!).Beatmap, () => Is.EqualTo(baseTestBeatmap.Beatmaps[0]));
|
||||
AddAssert("selection is updateable beatmap", () => Carousel.CurrentBeatmap, () => Is.EqualTo(baseTestBeatmap.Beatmaps[0]));
|
||||
AddAssert("visible panel is updateable beatmap", () => (GetSelectedPanel()?.Item?.Model as GroupedBeatmap)?.Beatmap, () => Is.EqualTo(baseTestBeatmap.Beatmaps[0]));
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -27,7 +27,7 @@ namespace osu.Game.Tests.Visual.SongSelectV2
|
||||
/// </summary>
|
||||
public partial class TestSceneSongSelectCurrentSelectionInvalidated : SongSelectTestScene
|
||||
{
|
||||
private BeatmapInfo? selectedBeatmap => (Carousel.CurrentSelection as GroupedBeatmap)?.Beatmap;
|
||||
private BeatmapInfo? selectedBeatmap => Carousel.CurrentBeatmap;
|
||||
private BeatmapSetInfo? selectedBeatmapSet => selectedBeatmap?.BeatmapSet;
|
||||
|
||||
[SetUpSteps]
|
||||
|
||||
@@ -107,7 +107,7 @@ namespace osu.Game.Graphics.Carousel
|
||||
/// The selection is never reset due to not existing. It can be set to anything.
|
||||
/// If no matching carousel item exists, there will be no visually selected item while waiting for potential new item which matches.
|
||||
/// </remarks>
|
||||
public virtual object? CurrentSelection
|
||||
protected object? CurrentSelection
|
||||
{
|
||||
get => currentSelection.Model;
|
||||
set
|
||||
|
||||
@@ -295,28 +295,47 @@ namespace osu.Game.Screens.SelectV2
|
||||
protected override bool ShouldActivateOnKeyboardSelection(CarouselItem item) =>
|
||||
grouping.BeatmapSetsGroupedTogether && item.Model is GroupedBeatmap;
|
||||
|
||||
public override object? CurrentSelection
|
||||
/// <summary>
|
||||
/// The currently selected <see cref="GroupedBeatmap"/>.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// The selection is never reset due to not existing. It can be set to anything.
|
||||
/// If no matching carousel item exists, there will be no visually selected item while waiting for potential new item which matches.
|
||||
/// </remarks>
|
||||
public GroupedBeatmap? CurrentGroupedBeatmap
|
||||
{
|
||||
get => base.CurrentSelection;
|
||||
get => CurrentSelection as GroupedBeatmap;
|
||||
set => CurrentSelection = value;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The currently selected <see cref="BeatmapInfo"/>.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// This is a property mostly dedicated to external consumers who only care about showing some particular copy of a beatmap
|
||||
/// (there could be multiple panels for one beatmap due to grouping).
|
||||
/// Through this property, the carousel basically figures out what group to use internally.
|
||||
/// </remarks>
|
||||
public BeatmapInfo? CurrentBeatmap
|
||||
{
|
||||
get => CurrentGroupedBeatmap?.Beatmap;
|
||||
set
|
||||
{
|
||||
// this is a special pathway for external consumers who only care about showing some particular copy of a beatmap
|
||||
// (there could be multiple panels for one beatmap due to grouping).
|
||||
// in this pathway we basically figure out what group to use internally, and continue working with `GroupedBeatmap` all the way after that.
|
||||
if (value is BeatmapInfo beatmapInfo)
|
||||
if (value == null)
|
||||
{
|
||||
if (CurrentSelection is GroupedBeatmap groupedBeatmap && beatmapInfo.Equals(groupedBeatmap.Beatmap))
|
||||
return;
|
||||
|
||||
// it is not universally guaranteed that the carousel items will be materialised at the time this is set.
|
||||
// therefore, in cases where it is known that they will not be, default to a null group.
|
||||
// even if grouping is active, this will be rectified to a correct group on the next invocation of `HandleFilterCompleted()`.
|
||||
value = IsLoaded && !IsFiltering
|
||||
? GetCarouselItems()?.Select(item => item.Model).OfType<GroupedBeatmap>().FirstOrDefault(gb => gb.Beatmap.Equals(beatmapInfo))
|
||||
: new GroupedBeatmap(null, beatmapInfo);
|
||||
CurrentGroupedBeatmap = null;
|
||||
return;
|
||||
}
|
||||
|
||||
base.CurrentSelection = value;
|
||||
if (CurrentGroupedBeatmap != null && value.Equals(CurrentGroupedBeatmap.Beatmap))
|
||||
return;
|
||||
|
||||
// it is not universally guaranteed that the carousel items will be materialised at the time this is set.
|
||||
// therefore, in cases where it is known that they will not be, default to a null group.
|
||||
// even if grouping is active, this will be rectified to a correct group on the next invocation of `HandleFilterCompleted()`.
|
||||
CurrentGroupedBeatmap = IsLoaded && !IsFiltering
|
||||
? GetCarouselItems()?.Select(item => item.Model).OfType<GroupedBeatmap>().FirstOrDefault(gb => gb.Beatmap.Equals(value))
|
||||
: new GroupedBeatmap(null, value);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -479,7 +479,7 @@ namespace osu.Game.Screens.SelectV2
|
||||
if (!this.IsCurrentScreen())
|
||||
return;
|
||||
|
||||
carousel.CurrentSelection = groupedBeatmap;
|
||||
carousel.CurrentGroupedBeatmap = groupedBeatmap;
|
||||
|
||||
// Debounce consideration is to avoid beatmap churn on key repeat selection.
|
||||
selectionDebounce?.Cancel();
|
||||
@@ -512,7 +512,7 @@ namespace osu.Game.Screens.SelectV2
|
||||
|
||||
if (validSelection)
|
||||
{
|
||||
carousel.CurrentSelection = currentBeatmap.BeatmapInfo;
|
||||
carousel.CurrentBeatmap = currentBeatmap.BeatmapInfo;
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -535,7 +535,7 @@ namespace osu.Game.Screens.SelectV2
|
||||
|
||||
if (validBeatmaps.Any())
|
||||
{
|
||||
carousel.CurrentSelection = difficultyRecommender?.GetRecommendedBeatmap(validBeatmaps) ?? validBeatmaps.First();
|
||||
carousel.CurrentBeatmap = difficultyRecommender?.GetRecommendedBeatmap(validBeatmaps) ?? validBeatmaps.First();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user