Replace Reset with overridden TransformImmediately/TransformDuration

This commit is contained in:
HoLLy 2019-06-24 10:51:45 +02:00
parent fafec00667
commit aed83471f4
3 changed files with 21 additions and 18 deletions

View File

@ -53,7 +53,7 @@ public TopScoreUserSection()
Size = new Vector2(40),
FillMode = FillMode.Fit,
},
avatar = new UpdateableAvatar
avatar = new UpdateableAvatar(transformImmediately: true)
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
@ -90,7 +90,7 @@ public TopScoreUserSection()
Origin = Anchor.CentreLeft,
Font = OsuFont.GetFont(size: 15, weight: FontWeight.Bold)
},
flag = new UpdateableFlag
flag = new UpdateableFlag(transformImmediately: true)
{
Anchor = Anchor.CentreLeft,
Origin = Anchor.CentreLeft,
@ -116,7 +116,6 @@ public ScoreInfo Score
{
set
{
avatar.Reset();
avatar.User = value.User;
flag.Country = value.User.Country;
date.Text = $@"achieved {value.Date.Humanize()}";

View File

@ -37,6 +37,10 @@ public User User
set => base.EdgeEffect = value;
}
protected override bool TransformImmediately { get; }
protected override double TransformDuration { get; } = 1000;
/// <summary>
/// Whether to show a default guest representation on null user (as opposed to nothing).
/// </summary>
@ -47,23 +51,14 @@ public User User
/// </summary>
public readonly BindableBool OpenOnClick = new BindableBool(true);
public UpdateableAvatar(User user = null)
public UpdateableAvatar(User user = null, bool transformImmediately = false)
{
User = user;
}
/// <summary>
/// Fades and expires the <see cref="ModelBackedDrawable{T}.DisplayedDrawable"/>, and sets the
/// <see cref="ModelBackedDrawable{T}.Model"/> to null.
/// </summary>
/// <remarks>
/// Can be used when the <see cref="ModelBackedDrawable{T}.DisplayedDrawable"/> needs to be removed instantly.
/// </remarks>
public void Reset()
{
DisplayedDrawable?.FadeOut().Expire();
User = null;
if (transformImmediately) {
TransformDuration = 0;
TransformImmediately = true;
}
}
protected override Drawable CreateDrawable(User user)

View File

@ -14,14 +14,23 @@ public Country Country
set => Model = value;
}
protected override bool TransformImmediately { get; }
protected override double TransformDuration { get; } = 1000;
/// <summary>
/// Whether to show a place holder on null country.
/// </summary>
public bool ShowPlaceholderOnNull = true;
public UpdateableFlag(Country country = null)
public UpdateableFlag(Country country = null, bool transformImmediately = false)
{
Country = country;
if (transformImmediately) {
TransformDuration = 0;
TransformImmediately = true;
}
}
protected override Drawable CreateDrawable(Country country)