1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-14 14:32:55 +08:00

Merge pull request #1726 from peppy/fix-info-wedge

Fix beatmap info wedge not showing up when zero beatmaps are loaded
This commit is contained in:
Dan Balasescu 2017-12-26 20:16:40 +09:00 committed by GitHub
commit f6a5f773c4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 69 additions and 35 deletions

@ -1 +1 @@
Subproject commit 08f85f9bf9a7376aec8dfcde8c7c96d267d8c295 Subproject commit 64e04b9ff2d5ba53e5c3a46cfa42a79baeffc014

View File

@ -26,6 +26,7 @@ namespace osu.Game.Tests.Visual
private RulesetStore rulesets; private RulesetStore rulesets;
private DependencyContainer dependencies; private DependencyContainer dependencies;
private WorkingBeatmap defaultBeatmap;
public override IReadOnlyList<Type> RequiredTypes => new[] public override IReadOnlyList<Type> RequiredTypes => new[]
{ {
@ -47,13 +48,17 @@ namespace osu.Game.Tests.Visual
protected override IReadOnlyDependencyContainer CreateLocalDependencies(IReadOnlyDependencyContainer parent) => dependencies = new DependencyContainer(parent); protected override IReadOnlyDependencyContainer CreateLocalDependencies(IReadOnlyDependencyContainer parent) => dependencies = new DependencyContainer(parent);
private class TestSongSelect : PlaySongSelect
{
public WorkingBeatmap CurrentBeatmap => Beatmap.Value;
public new BeatmapCarousel Carousel => base.Carousel;
}
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load(BeatmapManager baseManager) private void load(BeatmapManager baseManager)
{ {
PlaySongSelect songSelect; TestSongSelect songSelect = null;
if (manager == null)
{
var storage = new TestStorage(@"TestCasePlaySongSelect"); var storage = new TestStorage(@"TestCasePlaySongSelect");
// this is by no means clean. should be replacing inside of OsuGameBase somehow. // this is by no means clean. should be replacing inside of OsuGameBase somehow.
@ -64,14 +69,40 @@ namespace osu.Game.Tests.Visual
dependencies.Cache(rulesets = new RulesetStore(contextFactory)); dependencies.Cache(rulesets = new RulesetStore(contextFactory));
dependencies.Cache(manager = new BeatmapManager(storage, contextFactory, rulesets, null) dependencies.Cache(manager = new BeatmapManager(storage, contextFactory, rulesets, null)
{ {
DefaultBeatmap = baseManager.GetWorkingBeatmap(null) DefaultBeatmap = defaultBeatmap = baseManager.GetWorkingBeatmap(null)
}); });
for (int i = 0; i < 100; i += 10) void loadNewSongSelect(bool deleteMaps = false) => AddStep("reload song select", () =>
manager.Import(createTestBeatmapSet(i)); {
if (deleteMaps) manager.DeleteAll();
if (songSelect != null)
{
Remove(songSelect);
songSelect.Dispose();
} }
Add(songSelect = new PlaySongSelect()); Add(songSelect = new TestSongSelect());
});
loadNewSongSelect(true);
AddWaitStep(3);
AddAssert("dummy selected", () => songSelect.CurrentBeatmap == defaultBeatmap);
AddStep("import test maps", () =>
{
for (int i = 0; i < 100; i += 10)
manager.Import(createTestBeatmapSet(i));
});
AddWaitStep(3);
AddAssert("random map selected", () => songSelect.CurrentBeatmap != defaultBeatmap);
loadNewSongSelect();
AddWaitStep(3);
AddAssert("random map selected", () => songSelect.CurrentBeatmap != defaultBeatmap);
AddStep(@"Sort by Artist", delegate { songSelect.FilterControl.Sort = SortMode.Artist; }); AddStep(@"Sort by Artist", delegate { songSelect.FilterControl.Sort = SortMode.Artist; });
AddStep(@"Sort by Title", delegate { songSelect.FilterControl.Sort = SortMode.Title; }); AddStep(@"Sort by Title", delegate { songSelect.FilterControl.Sort = SortMode.Title; });

View File

@ -75,7 +75,8 @@ namespace osu.Game.Screens.Select
scrollableContent.Clear(false); scrollableContent.Clear(false);
itemsCache.Invalidate(); itemsCache.Invalidate();
scrollPositionCache.Invalidate(); scrollPositionCache.Invalidate();
BeatmapSetsChanged?.Invoke();
Schedule(() => BeatmapSetsChanged?.Invoke());
})); }));
} }
} }
@ -154,6 +155,7 @@ namespace osu.Game.Screens.Select
select((CarouselItem)newSet.Beatmaps.FirstOrDefault(b => b.Beatmap.ID == selectedBeatmap?.Beatmap.ID) ?? newSet); select((CarouselItem)newSet.Beatmaps.FirstOrDefault(b => b.Beatmap.ID == selectedBeatmap?.Beatmap.ID) ?? newSet);
itemsCache.Invalidate(); itemsCache.Invalidate();
Schedule(() => BeatmapSetsChanged?.Invoke());
}); });
} }
@ -511,7 +513,7 @@ namespace osu.Game.Screens.Select
currentY += DrawHeight / 2; currentY += DrawHeight / 2;
scrollableContent.Height = currentY; scrollableContent.Height = currentY;
if (selectedBeatmapSet != null && (selectedBeatmap == null || selectedBeatmapSet.State.Value != CarouselItemState.Selected)) if (selectedBeatmapSet == null || selectedBeatmap == null || selectedBeatmapSet.State.Value != CarouselItemState.Selected)
{ {
selectedBeatmapSet = null; selectedBeatmapSet = null;
SelectionChanged?.Invoke(null); SelectionChanged?.Invoke(null);

View File

@ -66,6 +66,8 @@ namespace osu.Game.Screens.Select
Depth = info?.Depth + 1 ?? 0, Depth = info?.Depth + 1 ?? 0,
}, newInfo => }, newInfo =>
{ {
State = beatmap == null ? Visibility.Hidden : Visibility.Visible;
// ensure we ourselves are visible if not already. // ensure we ourselves are visible if not already.
if (!IsPresent) if (!IsPresent)
this.FadeIn(250); this.FadeIn(250);

View File

@ -55,7 +55,7 @@ namespace osu.Game.Screens.Select
protected Container LeftContent; protected Container LeftContent;
private readonly BeatmapCarousel carousel; protected readonly BeatmapCarousel Carousel;
private readonly BeatmapInfoWedge beatmapInfoWedge; private readonly BeatmapInfoWedge beatmapInfoWedge;
private DialogOverlay dialogOverlay; private DialogOverlay dialogOverlay;
private BeatmapManager beatmaps; private BeatmapManager beatmaps;
@ -118,7 +118,7 @@ namespace osu.Game.Screens.Select
Width = 0.5f, Width = 0.5f,
Children = new Drawable[] Children = new Drawable[]
{ {
carousel = new BeatmapCarousel Carousel = new BeatmapCarousel
{ {
Masking = false, Masking = false,
RelativeSizeAxes = Axes.Y, RelativeSizeAxes = Axes.Y,
@ -132,7 +132,7 @@ namespace osu.Game.Screens.Select
{ {
RelativeSizeAxes = Axes.X, RelativeSizeAxes = Axes.X,
Height = filter_height, Height = filter_height,
FilterChanged = c => carousel.Filter(c), FilterChanged = c => Carousel.Filter(c),
Background = { Width = 2 }, Background = { Width = 2 },
Exit = Exit, Exit = Exit,
}, },
@ -150,7 +150,7 @@ namespace osu.Game.Screens.Select
Right = left_area_padding, Right = left_area_padding,
}, },
}, },
new ResetScrollContainer(() => carousel.ScrollToSelected()) new ResetScrollContainer(() => Carousel.ScrollToSelected())
{ {
RelativeSizeAxes = Axes.Y, RelativeSizeAxes = Axes.Y,
Width = 250, Width = 250,
@ -210,15 +210,15 @@ namespace osu.Game.Screens.Select
initialAddSetsTask = new CancellationTokenSource(); initialAddSetsTask = new CancellationTokenSource();
carousel.BeatmapSets = this.beatmaps.GetAllUsableBeatmapSets(); Carousel.BeatmapSets = this.beatmaps.GetAllUsableBeatmapSets();
Beatmap.DisabledChanged += disabled => carousel.AllowSelection = !disabled; Beatmap.DisabledChanged += disabled => Carousel.AllowSelection = !disabled;
Beatmap.TriggerChange(); Beatmap.TriggerChange();
Beatmap.ValueChanged += b => Beatmap.ValueChanged += b =>
{ {
if (IsCurrentScreen) if (IsCurrentScreen)
carousel.SelectBeatmap(b?.BeatmapInfo); Carousel.SelectBeatmap(b?.BeatmapInfo);
}; };
} }
@ -232,9 +232,9 @@ namespace osu.Game.Screens.Select
{ {
// if we have a pending filter operation, we want to run it now. // if we have a pending filter operation, we want to run it now.
// it could change selection (ie. if the ruleset has been changed). // it could change selection (ie. if the ruleset has been changed).
carousel.FlushPendingFilterOperations(); Carousel.FlushPendingFilterOperations();
carousel.SelectBeatmap(beatmap); Carousel.SelectBeatmap(beatmap);
if (selectionChangedDebounce?.Completed == false) if (selectionChangedDebounce?.Completed == false)
{ {
@ -302,9 +302,9 @@ namespace osu.Game.Screens.Select
private void triggerRandom() private void triggerRandom()
{ {
if (GetContainingInputManager().CurrentState.Keyboard.ShiftPressed) if (GetContainingInputManager().CurrentState.Keyboard.ShiftPressed)
carousel.SelectPreviousRandom(); Carousel.SelectPreviousRandom();
else else
carousel.SelectNextRandom(); Carousel.SelectNextRandom();
} }
protected override void OnEntering(Screen last) protected override void OnEntering(Screen last)
@ -419,7 +419,6 @@ namespace osu.Game.Screens.Select
backgroundModeBeatmap.FadeTo(1, 250); backgroundModeBeatmap.FadeTo(1, 250);
} }
beatmapInfoWedge.State = Visibility.Visible;
beatmapInfoWedge.UpdateBeatmap(beatmap); beatmapInfoWedge.UpdateBeatmap(beatmap);
} }
@ -437,17 +436,17 @@ namespace osu.Game.Screens.Select
} }
} }
private void onBeatmapSetAdded(BeatmapSetInfo s) => carousel.UpdateBeatmapSet(s); private void onBeatmapSetAdded(BeatmapSetInfo s) => Carousel.UpdateBeatmapSet(s);
private void onBeatmapSetRemoved(BeatmapSetInfo s) => carousel.RemoveBeatmapSet(s); private void onBeatmapSetRemoved(BeatmapSetInfo s) => Carousel.RemoveBeatmapSet(s);
private void onBeatmapRestored(BeatmapInfo b) => carousel.UpdateBeatmapSet(beatmaps.QueryBeatmapSet(s => s.ID == b.BeatmapSetInfoID)); private void onBeatmapRestored(BeatmapInfo b) => Carousel.UpdateBeatmapSet(beatmaps.QueryBeatmapSet(s => s.ID == b.BeatmapSetInfoID));
private void onBeatmapHidden(BeatmapInfo b) => carousel.UpdateBeatmapSet(beatmaps.QueryBeatmapSet(s => s.ID == b.BeatmapSetInfoID)); private void onBeatmapHidden(BeatmapInfo b) => Carousel.UpdateBeatmapSet(beatmaps.QueryBeatmapSet(s => s.ID == b.BeatmapSetInfoID));
private void carouselBeatmapsLoaded() private void carouselBeatmapsLoaded()
{ {
if (Beatmap.Value.BeatmapSetInfo?.DeletePending == false) if (!Beatmap.IsDefault && Beatmap.Value.BeatmapSetInfo?.DeletePending == false)
carousel.SelectBeatmap(Beatmap.Value.BeatmapInfo); Carousel.SelectBeatmap(Beatmap.Value.BeatmapInfo);
else else
carousel.SelectNextRandom(); Carousel.SelectNextRandom();
} }
private void delete(BeatmapSetInfo beatmap) private void delete(BeatmapSetInfo beatmap)