1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-13 20:07:25 +08:00

Merge branch 'master' into fix-random-select-crash

This commit is contained in:
Dan Balasescu 2019-03-22 14:11:06 +09:00 committed by GitHub
commit 5de99f3f5b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 38 additions and 27 deletions

View File

@ -1,6 +1,7 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence. // Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text. // See the LICENCE file in the repository root for full licence text.
using osu.Framework.Graphics.Cursor;
using osu.Game.Beatmaps; using osu.Game.Beatmaps;
using osu.Game.Rulesets.Osu.UI; using osu.Game.Rulesets.Osu.UI;
using osu.Game.Rulesets.UI; using osu.Game.Rulesets.UI;
@ -19,10 +20,7 @@ namespace osu.Game.Rulesets.Osu.Edit
private class OsuPlayfieldNoCursor : OsuPlayfield private class OsuPlayfieldNoCursor : OsuPlayfield
{ {
public OsuPlayfieldNoCursor() protected override CursorContainer CreateCursor() => null;
{
Cursor?.Expire();
}
} }
} }
} }

View File

@ -55,9 +55,9 @@ namespace osu.Game.Screens.Select
public override bool HandlePositionalInput => AllowSelection; public override bool HandlePositionalInput => AllowSelection;
/// <summary> /// <summary>
/// Used to avoid firing null selections before the initial beatmaps have been loaded via <see cref="BeatmapSets"/>. /// Whether carousel items have completed asynchronously loaded.
/// </summary> /// </summary>
private bool initialLoadComplete; public bool BeatmapSetsLoaded { get; private set; }
private IEnumerable<CarouselBeatmapSet> beatmapSets => root.Children.OfType<CarouselBeatmapSet>(); private IEnumerable<CarouselBeatmapSet> beatmapSets => root.Children.OfType<CarouselBeatmapSet>();
@ -90,7 +90,7 @@ namespace osu.Game.Screens.Select
Schedule(() => Schedule(() =>
{ {
BeatmapSetsChanged?.Invoke(); BeatmapSetsChanged?.Invoke();
initialLoadComplete = true; BeatmapSetsLoaded = true;
}); });
})); }));
} }
@ -596,7 +596,7 @@ namespace osu.Game.Screens.Select
currentY += DrawHeight / 2; currentY += DrawHeight / 2;
scrollableContent.Height = currentY; scrollableContent.Height = currentY;
if (initialLoadComplete && (selectedBeatmapSet == null || selectedBeatmap == null || selectedBeatmapSet.State.Value != CarouselItemState.Selected)) if (BeatmapSetsLoaded && (selectedBeatmapSet == null || selectedBeatmap == null || selectedBeatmapSet.State.Value != CarouselItemState.Selected))
{ {
selectedBeatmapSet = null; selectedBeatmapSet = null;
SelectionChanged?.Invoke(null); SelectionChanged?.Invoke(null);

View File

@ -300,6 +300,10 @@ namespace osu.Game.Screens.Select
/// <param name="performStartAction">Whether to trigger <see cref="OnStart"/>.</param> /// <param name="performStartAction">Whether to trigger <see cref="OnStart"/>.</param>
public void FinaliseSelection(BeatmapInfo beatmap = null, bool performStartAction = true) public void FinaliseSelection(BeatmapInfo beatmap = null, bool performStartAction = true)
{ {
// This is very important as we have not yet bound to screen-level bindables before the carousel load is completed.
if (!Carousel.BeatmapSetsLoaded)
return;
// 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();
@ -373,6 +377,13 @@ namespace osu.Game.Screens.Select
var beatmap = beatmapNoDebounce; var beatmap = beatmapNoDebounce;
var ruleset = rulesetNoDebounce; var ruleset = rulesetNoDebounce;
selectionChangedDebounce?.Cancel();
if (beatmap == null)
run();
else
selectionChangedDebounce = Scheduler.AddDelayed(run, 200);
void run() void run()
{ {
Logger.Log($"updating selection with beatmap:{beatmap?.ID.ToString() ?? "null"} ruleset:{ruleset?.ID.ToString() ?? "null"}"); Logger.Log($"updating selection with beatmap:{beatmap?.ID.ToString() ?? "null"} ruleset:{ruleset?.ID.ToString() ?? "null"}");
@ -417,13 +428,6 @@ namespace osu.Game.Screens.Select
if (this.IsCurrentScreen()) ensurePlayingSelected(preview); if (this.IsCurrentScreen()) ensurePlayingSelected(preview);
UpdateBeatmap(Beatmap.Value); UpdateBeatmap(Beatmap.Value);
} }
selectionChangedDebounce?.Cancel();
if (beatmap == null)
run();
else
selectionChangedDebounce = Scheduler.AddDelayed(run, 200);
} }
private void triggerRandom() private void triggerRandom()
@ -593,18 +597,7 @@ namespace osu.Game.Screens.Select
private void carouselBeatmapsLoaded() private void carouselBeatmapsLoaded()
{ {
if (rulesetNoDebounce == null) bindBindables();
{
// manual binding to parent ruleset to allow for delayed load in the incoming direction.
rulesetNoDebounce = decoupledRuleset.Value = Ruleset.Value;
Ruleset.ValueChanged += r => updateSelectedRuleset(r.NewValue);
decoupledRuleset.ValueChanged += r => Ruleset.Value = r.NewValue;
decoupledRuleset.DisabledChanged += r => Ruleset.Disabled = r;
Beatmap.BindDisabledChanged(disabled => Carousel.AllowSelection = !disabled, true);
Beatmap.BindValueChanged(workingBeatmapChanged);
}
if (!Beatmap.IsDefault && Beatmap.Value.BeatmapSetInfo?.DeletePending == false && Beatmap.Value.BeatmapSetInfo?.Protected == false if (!Beatmap.IsDefault && Beatmap.Value.BeatmapSetInfo?.DeletePending == false && Beatmap.Value.BeatmapSetInfo?.Protected == false
&& Carousel.SelectBeatmap(Beatmap.Value.BeatmapInfo, false)) && Carousel.SelectBeatmap(Beatmap.Value.BeatmapInfo, false))
@ -618,6 +611,26 @@ namespace osu.Game.Screens.Select
} }
} }
private bool boundLocalBindables;
private void bindBindables()
{
if (boundLocalBindables)
return;
// manual binding to parent ruleset to allow for delayed load in the incoming direction.
rulesetNoDebounce = decoupledRuleset.Value = Ruleset.Value;
Ruleset.ValueChanged += r => updateSelectedRuleset(r.NewValue);
decoupledRuleset.ValueChanged += r => Ruleset.Value = r.NewValue;
decoupledRuleset.DisabledChanged += r => Ruleset.Disabled = r;
Beatmap.BindDisabledChanged(disabled => Carousel.AllowSelection = !disabled, true);
Beatmap.BindValueChanged(workingBeatmapChanged);
boundLocalBindables = true;
}
private void delete(BeatmapSetInfo beatmap) private void delete(BeatmapSetInfo beatmap)
{ {
if (beatmap == null || beatmap.ID <= 0) return; if (beatmap == null || beatmap.ID <= 0) return;