From e8d568470dd21ecc2b8b72ad2dd1f378444953ee Mon Sep 17 00:00:00 2001 From: jorolf Date: Sat, 2 Mar 2019 19:13:38 +0100 Subject: [PATCH] use a bindable instead --- osu.Game/Screens/Menu/Disclaimer.cs | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/osu.Game/Screens/Menu/Disclaimer.cs b/osu.Game/Screens/Menu/Disclaimer.cs index a4736e8c60..b8b372fa24 100644 --- a/osu.Game/Screens/Menu/Disclaimer.cs +++ b/osu.Game/Screens/Menu/Disclaimer.cs @@ -36,8 +36,7 @@ namespace osu.Game.Screens.Menu private const float icon_y = -85; - [Resolved] - private APIAccess api { get; set; } + private readonly Bindable currentUser = new Bindable(); public Disclaimer() { @@ -45,7 +44,7 @@ namespace osu.Game.Screens.Menu } [BackgroundDependencyLoader] - private void load(OsuColour colours) + private void load(OsuColour colours, APIAccess api) { InternalChildren = new Drawable[] { @@ -102,14 +101,19 @@ namespace osu.Game.Screens.Menu }).First()); iconColour = colours.Yellow; + + currentUser.BindTo(api.LocalUser); + currentUser.BindValueChanged(e => + { + if (e.NewValue.IsSupporter) + supporterDrawables.ForEach(d => d.FadeOut(200, Easing.OutQuint).Expire()); + }, true); } protected override void LoadComplete() { base.LoadComplete(); LoadComponentAsync(intro = new Intro()); - - api.LocalUser.BindValueChanged(userChanged, true); } public override void OnEntering(IScreen last) @@ -140,12 +144,7 @@ namespace osu.Game.Screens.Menu { base.OnSuspending(next); - api.LocalUser.ValueChanged -= userChanged; - } - - private void userChanged(ValueChangedEvent user) - { - if (user.NewValue.IsSupporter) supporterDrawables.ForEach(d => d.FadeOut(200, Easing.OutQuint).Expire()); + currentUser.UnbindAll(); } } }