Fix beatmap ruleset selector selecting initial ruleset

This commit is contained in:
Salman Ahmed
2021-08-23 09:56:00 +03:00
parent 2ba88923b6
commit 1d89d757af
3 changed files with 24 additions and 8 deletions

View File

@ -6,11 +6,14 @@ using osu.Framework.Graphics.UserInterface;
using osu.Game.Beatmaps;
using osu.Game.Rulesets;
using System.Linq;
using osu.Framework.Allocation;
namespace osu.Game.Overlays.BeatmapSet
{
public class BeatmapRulesetSelector : OverlayRulesetSelector
{
protected override bool SelectInitialRuleset => false;
private readonly Bindable<BeatmapSetInfo> beatmapSet = new Bindable<BeatmapSetInfo>();
public BeatmapSetInfo BeatmapSet

View File

@ -20,12 +20,15 @@ namespace osu.Game.Overlays
[BackgroundDependencyLoader]
private void load(RulesetStore store, IAPIProvider api)
{
if (SelectInitialRuleset)
{
var preferredRuleset = store.GetRuleset(api.LocalUser.Value.PlayMode);
if (preferredRuleset != null)
Current.Value = preferredRuleset;
}
}
protected override TabItem<RulesetInfo> CreateTabItem(RulesetInfo value) => new OverlayRulesetTabItem(value);

View File

@ -14,12 +14,21 @@ namespace osu.Game.Rulesets
protected override Dropdown<RulesetInfo> CreateDropdown() => null;
protected virtual bool SelectInitialRuleset => true;
protected RulesetSelector()
{
SelectFirstTabByDefault = false;
}
[BackgroundDependencyLoader]
private void load()
{
foreach (var r in Rulesets.AvailableRulesets)
AddItem(r);
if (SelectInitialRuleset)
{
// This is supposed to be an implicit process in the base class, but the problem is that it happens in LoadComplete.
// That can become an issue with overlays that require access to the initial ruleset value
// before the ruleset selectors reached a LoadComplete state.
@ -27,4 +36,5 @@ namespace osu.Game.Rulesets
Current.Value = Items.First();
}
}
}
}