mirror of
https://github.com/ppy/osu
synced 2025-02-15 09:37:07 +00:00
use a bindable instead
This commit is contained in:
parent
176cbc7f2e
commit
e8d568470d
@ -36,8 +36,7 @@ namespace osu.Game.Screens.Menu
|
|||||||
|
|
||||||
private const float icon_y = -85;
|
private const float icon_y = -85;
|
||||||
|
|
||||||
[Resolved]
|
private readonly Bindable<User> currentUser = new Bindable<User>();
|
||||||
private APIAccess api { get; set; }
|
|
||||||
|
|
||||||
public Disclaimer()
|
public Disclaimer()
|
||||||
{
|
{
|
||||||
@ -45,7 +44,7 @@ namespace osu.Game.Screens.Menu
|
|||||||
}
|
}
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
private void load(OsuColour colours)
|
private void load(OsuColour colours, APIAccess api)
|
||||||
{
|
{
|
||||||
InternalChildren = new Drawable[]
|
InternalChildren = new Drawable[]
|
||||||
{
|
{
|
||||||
@ -102,14 +101,19 @@ namespace osu.Game.Screens.Menu
|
|||||||
}).First());
|
}).First());
|
||||||
|
|
||||||
iconColour = colours.Yellow;
|
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()
|
protected override void LoadComplete()
|
||||||
{
|
{
|
||||||
base.LoadComplete();
|
base.LoadComplete();
|
||||||
LoadComponentAsync(intro = new Intro());
|
LoadComponentAsync(intro = new Intro());
|
||||||
|
|
||||||
api.LocalUser.BindValueChanged(userChanged, true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void OnEntering(IScreen last)
|
public override void OnEntering(IScreen last)
|
||||||
@ -140,12 +144,7 @@ namespace osu.Game.Screens.Menu
|
|||||||
{
|
{
|
||||||
base.OnSuspending(next);
|
base.OnSuspending(next);
|
||||||
|
|
||||||
api.LocalUser.ValueChanged -= userChanged;
|
currentUser.UnbindAll();
|
||||||
}
|
|
||||||
|
|
||||||
private void userChanged(ValueChangedEvent<User> user)
|
|
||||||
{
|
|
||||||
if (user.NewValue.IsSupporter) supporterDrawables.ForEach(d => d.FadeOut(200, Easing.OutQuint).Expire());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user