mirror of
https://github.com/ppy/osu.git
synced 2024-12-14 09: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:
commit
f6a5f773c4
@ -1 +1 @@
|
||||
Subproject commit 08f85f9bf9a7376aec8dfcde8c7c96d267d8c295
|
||||
Subproject commit 64e04b9ff2d5ba53e5c3a46cfa42a79baeffc014
|
@ -26,6 +26,7 @@ namespace osu.Game.Tests.Visual
|
||||
private RulesetStore rulesets;
|
||||
|
||||
private DependencyContainer dependencies;
|
||||
private WorkingBeatmap defaultBeatmap;
|
||||
|
||||
public override IReadOnlyList<Type> RequiredTypes => new[]
|
||||
{
|
||||
@ -47,31 +48,61 @@ namespace osu.Game.Tests.Visual
|
||||
|
||||
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]
|
||||
private void load(BeatmapManager baseManager)
|
||||
{
|
||||
PlaySongSelect songSelect;
|
||||
TestSongSelect songSelect = null;
|
||||
|
||||
if (manager == null)
|
||||
var storage = new TestStorage(@"TestCasePlaySongSelect");
|
||||
|
||||
// this is by no means clean. should be replacing inside of OsuGameBase somehow.
|
||||
var context = new OsuDbContext();
|
||||
|
||||
Func<OsuDbContext> contextFactory = () => context;
|
||||
|
||||
dependencies.Cache(rulesets = new RulesetStore(contextFactory));
|
||||
dependencies.Cache(manager = new BeatmapManager(storage, contextFactory, rulesets, null)
|
||||
{
|
||||
var storage = new TestStorage(@"TestCasePlaySongSelect");
|
||||
DefaultBeatmap = defaultBeatmap = baseManager.GetWorkingBeatmap(null)
|
||||
});
|
||||
|
||||
// this is by no means clean. should be replacing inside of OsuGameBase somehow.
|
||||
var context = new OsuDbContext();
|
||||
void loadNewSongSelect(bool deleteMaps = false) => AddStep("reload song select", () =>
|
||||
{
|
||||
if (deleteMaps) manager.DeleteAll();
|
||||
|
||||
Func<OsuDbContext> contextFactory = () => context;
|
||||
|
||||
dependencies.Cache(rulesets = new RulesetStore(contextFactory));
|
||||
dependencies.Cache(manager = new BeatmapManager(storage, contextFactory, rulesets, null)
|
||||
if (songSelect != null)
|
||||
{
|
||||
DefaultBeatmap = baseManager.GetWorkingBeatmap(null)
|
||||
});
|
||||
Remove(songSelect);
|
||||
songSelect.Dispose();
|
||||
}
|
||||
|
||||
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));
|
||||
}
|
||||
});
|
||||
|
||||
Add(songSelect = new PlaySongSelect());
|
||||
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 Title", delegate { songSelect.FilterControl.Sort = SortMode.Title; });
|
||||
|
@ -75,7 +75,8 @@ namespace osu.Game.Screens.Select
|
||||
scrollableContent.Clear(false);
|
||||
itemsCache.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);
|
||||
|
||||
itemsCache.Invalidate();
|
||||
Schedule(() => BeatmapSetsChanged?.Invoke());
|
||||
});
|
||||
}
|
||||
|
||||
@ -511,7 +513,7 @@ namespace osu.Game.Screens.Select
|
||||
currentY += DrawHeight / 2;
|
||||
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;
|
||||
SelectionChanged?.Invoke(null);
|
||||
|
@ -66,6 +66,8 @@ namespace osu.Game.Screens.Select
|
||||
Depth = info?.Depth + 1 ?? 0,
|
||||
}, newInfo =>
|
||||
{
|
||||
State = beatmap == null ? Visibility.Hidden : Visibility.Visible;
|
||||
|
||||
// ensure we ourselves are visible if not already.
|
||||
if (!IsPresent)
|
||||
this.FadeIn(250);
|
||||
|
@ -55,7 +55,7 @@ namespace osu.Game.Screens.Select
|
||||
|
||||
protected Container LeftContent;
|
||||
|
||||
private readonly BeatmapCarousel carousel;
|
||||
protected readonly BeatmapCarousel Carousel;
|
||||
private readonly BeatmapInfoWedge beatmapInfoWedge;
|
||||
private DialogOverlay dialogOverlay;
|
||||
private BeatmapManager beatmaps;
|
||||
@ -118,7 +118,7 @@ namespace osu.Game.Screens.Select
|
||||
Width = 0.5f,
|
||||
Children = new Drawable[]
|
||||
{
|
||||
carousel = new BeatmapCarousel
|
||||
Carousel = new BeatmapCarousel
|
||||
{
|
||||
Masking = false,
|
||||
RelativeSizeAxes = Axes.Y,
|
||||
@ -132,7 +132,7 @@ namespace osu.Game.Screens.Select
|
||||
{
|
||||
RelativeSizeAxes = Axes.X,
|
||||
Height = filter_height,
|
||||
FilterChanged = c => carousel.Filter(c),
|
||||
FilterChanged = c => Carousel.Filter(c),
|
||||
Background = { Width = 2 },
|
||||
Exit = Exit,
|
||||
},
|
||||
@ -150,7 +150,7 @@ namespace osu.Game.Screens.Select
|
||||
Right = left_area_padding,
|
||||
},
|
||||
},
|
||||
new ResetScrollContainer(() => carousel.ScrollToSelected())
|
||||
new ResetScrollContainer(() => Carousel.ScrollToSelected())
|
||||
{
|
||||
RelativeSizeAxes = Axes.Y,
|
||||
Width = 250,
|
||||
@ -210,15 +210,15 @@ namespace osu.Game.Screens.Select
|
||||
|
||||
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.ValueChanged += b =>
|
||||
{
|
||||
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.
|
||||
// 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)
|
||||
{
|
||||
@ -302,9 +302,9 @@ namespace osu.Game.Screens.Select
|
||||
private void triggerRandom()
|
||||
{
|
||||
if (GetContainingInputManager().CurrentState.Keyboard.ShiftPressed)
|
||||
carousel.SelectPreviousRandom();
|
||||
Carousel.SelectPreviousRandom();
|
||||
else
|
||||
carousel.SelectNextRandom();
|
||||
Carousel.SelectNextRandom();
|
||||
}
|
||||
|
||||
protected override void OnEntering(Screen last)
|
||||
@ -419,7 +419,6 @@ namespace osu.Game.Screens.Select
|
||||
backgroundModeBeatmap.FadeTo(1, 250);
|
||||
}
|
||||
|
||||
beatmapInfoWedge.State = Visibility.Visible;
|
||||
beatmapInfoWedge.UpdateBeatmap(beatmap);
|
||||
}
|
||||
|
||||
@ -437,17 +436,17 @@ namespace osu.Game.Screens.Select
|
||||
}
|
||||
}
|
||||
|
||||
private void onBeatmapSetAdded(BeatmapSetInfo s) => carousel.UpdateBeatmapSet(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 onBeatmapHidden(BeatmapInfo b) => carousel.UpdateBeatmapSet(beatmaps.QueryBeatmapSet(s => s.ID == b.BeatmapSetInfoID));
|
||||
private void onBeatmapSetAdded(BeatmapSetInfo s) => Carousel.UpdateBeatmapSet(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 onBeatmapHidden(BeatmapInfo b) => Carousel.UpdateBeatmapSet(beatmaps.QueryBeatmapSet(s => s.ID == b.BeatmapSetInfoID));
|
||||
|
||||
private void carouselBeatmapsLoaded()
|
||||
{
|
||||
if (Beatmap.Value.BeatmapSetInfo?.DeletePending == false)
|
||||
carousel.SelectBeatmap(Beatmap.Value.BeatmapInfo);
|
||||
if (!Beatmap.IsDefault && Beatmap.Value.BeatmapSetInfo?.DeletePending == false)
|
||||
Carousel.SelectBeatmap(Beatmap.Value.BeatmapInfo);
|
||||
else
|
||||
carousel.SelectNextRandom();
|
||||
Carousel.SelectNextRandom();
|
||||
}
|
||||
|
||||
private void delete(BeatmapSetInfo beatmap)
|
||||
|
Loading…
Reference in New Issue
Block a user