Bind ruleset to toolbar later for safety

This commit is contained in:
Dean Herbert
2022-01-10 16:31:28 +09:00
parent 605898ec53
commit c33e163178

View File

@ -58,8 +58,11 @@ namespace osu.Game.Overlays.Toolbar
AlwaysPresent = false; AlwaysPresent = false;
} }
[Resolved]
private Bindable<RulesetInfo> ruleset { get; set; }
[BackgroundDependencyLoader(true)] [BackgroundDependencyLoader(true)]
private void load(OsuGame osuGame, Bindable<RulesetInfo> parentRuleset) private void load(OsuGame osuGame)
{ {
Children = new Drawable[] Children = new Drawable[]
{ {
@ -106,13 +109,17 @@ namespace osu.Game.Overlays.Toolbar
} }
}; };
// Bound after the selector is added to the hierarchy to give it a chance to load the available rulesets
rulesetSelector.Current.BindTo(parentRuleset);
if (osuGame != null) if (osuGame != null)
OverlayActivationMode.BindTo(osuGame.OverlayActivationMode); OverlayActivationMode.BindTo(osuGame.OverlayActivationMode);
} }
protected override void LoadComplete()
{
base.LoadComplete();
rulesetSelector.Current.BindTo(ruleset);
}
public class ToolbarBackground : Container public class ToolbarBackground : Container
{ {
private readonly Box gradientBackground; private readonly Box gradientBackground;