mirror of
https://github.com/osukey/osukey.git
synced 2025-06-05 12:57:39 +09:00
Rework update methods to separate out ruleset and beatmap changes
Combining them was causing complexity and logic errors.
This commit is contained in:
parent
693ba8e994
commit
c31676f8f1
@ -138,7 +138,7 @@ namespace osu.Game.Screens.Select
|
|||||||
Size = new Vector2(carousel_width, 1),
|
Size = new Vector2(carousel_width, 1),
|
||||||
Anchor = Anchor.CentreRight,
|
Anchor = Anchor.CentreRight,
|
||||||
Origin = Anchor.CentreRight,
|
Origin = Anchor.CentreRight,
|
||||||
SelectionChanged = b => updateSelectedBeatmap(b, null),
|
SelectionChanged = updateSelectedBeatmap,
|
||||||
BeatmapSetsChanged = carouselBeatmapsLoaded,
|
BeatmapSetsChanged = carouselBeatmapsLoaded,
|
||||||
},
|
},
|
||||||
FilterControl = new FilterControl
|
FilterControl = new FilterControl
|
||||||
@ -282,13 +282,31 @@ namespace osu.Game.Screens.Select
|
|||||||
private BeatmapInfo beatmapNoDebounce;
|
private BeatmapInfo beatmapNoDebounce;
|
||||||
private RulesetInfo rulesetNoDebounce;
|
private RulesetInfo rulesetNoDebounce;
|
||||||
|
|
||||||
|
private void updateSelectedBeatmap(BeatmapInfo beatmap)
|
||||||
|
{
|
||||||
|
if (beatmap?.Equals(beatmapNoDebounce) == true)
|
||||||
|
return;
|
||||||
|
|
||||||
|
beatmapNoDebounce = beatmap;
|
||||||
|
performUpdateSelected();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void updateSelectedRuleset(RulesetInfo ruleset)
|
||||||
|
{
|
||||||
|
if (ruleset?.Equals(rulesetNoDebounce) == true)
|
||||||
|
return;
|
||||||
|
|
||||||
|
rulesetNoDebounce = ruleset;
|
||||||
|
performUpdateSelected();
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// selection has been changed as the result of a user interaction.
|
/// selection has been changed as the result of a user interaction.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private void updateSelectedBeatmap(BeatmapInfo beatmap, RulesetInfo ruleset)
|
private void performUpdateSelected()
|
||||||
{
|
{
|
||||||
if (ruleset == null) ruleset = rulesetNoDebounce;
|
var beatmap = beatmapNoDebounce;
|
||||||
if (beatmap == null) beatmap = beatmapNoDebounce;
|
var ruleset = rulesetNoDebounce;
|
||||||
|
|
||||||
void performLoad()
|
void performLoad()
|
||||||
{
|
{
|
||||||
@ -296,7 +314,7 @@ namespace osu.Game.Screens.Select
|
|||||||
|
|
||||||
bool preview = false;
|
bool preview = false;
|
||||||
|
|
||||||
if (ruleset?.Equals(Ruleset.Value) != true)
|
if (ruleset?.Equals(Ruleset.Value) == false)
|
||||||
{
|
{
|
||||||
Ruleset.Value = ruleset;
|
Ruleset.Value = ruleset;
|
||||||
|
|
||||||
@ -307,40 +325,33 @@ namespace osu.Game.Screens.Select
|
|||||||
|
|
||||||
// We may be arriving here due to another component changing the bindable Beatmap.
|
// We may be arriving here due to another component changing the bindable Beatmap.
|
||||||
// In these cases, the other component has already loaded the beatmap, so we don't need to do so again.
|
// In these cases, the other component has already loaded the beatmap, so we don't need to do so again.
|
||||||
if (beatmap?.Equals(Beatmap.Value.BeatmapInfo) != true)
|
if (!Equals(beatmap, Beatmap.Value.BeatmapInfo))
|
||||||
{
|
{
|
||||||
preview = beatmap?.BeatmapSetInfoID != Beatmap.Value?.BeatmapInfo.BeatmapSetInfoID;
|
preview = beatmap?.BeatmapSetInfoID != Beatmap.Value?.BeatmapInfo.BeatmapSetInfoID;
|
||||||
working = beatmaps.GetWorkingBeatmap(beatmap, Beatmap.Value);
|
working = beatmaps.GetWorkingBeatmap(beatmap, Beatmap.Value);
|
||||||
|
|
||||||
|
if (beatmap != null)
|
||||||
|
{
|
||||||
|
if (beatmap.BeatmapSetInfoID == beatmapNoDebounce?.BeatmapSetInfoID)
|
||||||
|
sampleChangeDifficulty.Play();
|
||||||
|
else
|
||||||
|
sampleChangeBeatmap.Play();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
working.Mods.Value = Enumerable.Empty<Mod>();
|
working.Mods.Value = Enumerable.Empty<Mod>();
|
||||||
|
|
||||||
Beatmap.Value = working;
|
Beatmap.Value = working;
|
||||||
|
|
||||||
ensurePlayingSelected(preview);
|
ensurePlayingSelected(preview);
|
||||||
|
|
||||||
UpdateBeatmap(Beatmap.Value);
|
UpdateBeatmap(Beatmap.Value);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (beatmap?.Equals(beatmapNoDebounce) == true && ruleset?.Equals(rulesetNoDebounce) == true)
|
|
||||||
return;
|
|
||||||
|
|
||||||
selectionChangedDebounce?.Cancel();
|
selectionChangedDebounce?.Cancel();
|
||||||
|
|
||||||
beatmapNoDebounce = beatmap;
|
|
||||||
rulesetNoDebounce = ruleset;
|
|
||||||
|
|
||||||
if (beatmap == null)
|
if (beatmap == null)
|
||||||
performLoad();
|
performLoad();
|
||||||
else
|
else
|
||||||
{
|
|
||||||
if (beatmap.BeatmapSetInfoID == beatmapNoDebounce?.BeatmapSetInfoID)
|
|
||||||
sampleChangeDifficulty.Play();
|
|
||||||
else
|
|
||||||
sampleChangeBeatmap.Play();
|
|
||||||
|
|
||||||
selectionChangedDebounce = Scheduler.AddDelayed(performLoad, 200);
|
selectionChangedDebounce = Scheduler.AddDelayed(performLoad, 200);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void triggerRandom()
|
private void triggerRandom()
|
||||||
@ -487,13 +498,16 @@ namespace osu.Game.Screens.Select
|
|||||||
|
|
||||||
private void carouselBeatmapsLoaded()
|
private void carouselBeatmapsLoaded()
|
||||||
{
|
{
|
||||||
// manual binding to parent ruleset to allow for delayed load in the incoming direction.
|
if (rulesetNoDebounce == null)
|
||||||
rulesetNoDebounce = Ruleset.Value = base.Ruleset.Value;
|
{
|
||||||
base.Ruleset.ValueChanged += r => updateSelectedBeatmap(null, r);
|
// manual binding to parent ruleset to allow for delayed load in the incoming direction.
|
||||||
Ruleset.ValueChanged += r => base.Ruleset.Value = r;
|
rulesetNoDebounce = Ruleset.Value = base.Ruleset.Value;
|
||||||
|
base.Ruleset.ValueChanged += updateSelectedRuleset;
|
||||||
|
Ruleset.ValueChanged += r => base.Ruleset.Value = r;
|
||||||
|
|
||||||
Beatmap.BindDisabledChanged(disabled => Carousel.AllowSelection = !disabled, true);
|
Beatmap.BindDisabledChanged(disabled => Carousel.AllowSelection = !disabled, true);
|
||||||
Beatmap.BindValueChanged(workingBeatmapChanged);
|
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))
|
||||||
@ -503,7 +517,7 @@ namespace osu.Game.Screens.Select
|
|||||||
{
|
{
|
||||||
// in the case random selection failed, we want to trigger selectionChanged
|
// in the case random selection failed, we want to trigger selectionChanged
|
||||||
// to show the dummy beatmap (we have nothing else to display).
|
// to show the dummy beatmap (we have nothing else to display).
|
||||||
updateSelectedBeatmap(null, null);
|
performUpdateSelected();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user