From aed83471f4a253fb3807af4cc970b8ef002f1383 Mon Sep 17 00:00:00 2001 From: HoLLy Date: Mon, 24 Jun 2019 10:51:45 +0200 Subject: [PATCH] Replace Reset with overridden TransformImmediately/TransformDuration --- .../BeatmapSet/Scores/TopScoreUserSection.cs | 5 ++-- osu.Game/Users/Drawables/UpdateableAvatar.cs | 23 ++++++++----------- osu.Game/Users/Drawables/UpdateableFlag.cs | 11 ++++++++- 3 files changed, 21 insertions(+), 18 deletions(-) diff --git a/osu.Game/Overlays/BeatmapSet/Scores/TopScoreUserSection.cs b/osu.Game/Overlays/BeatmapSet/Scores/TopScoreUserSection.cs index a441d544d1..bf27935824 100644 --- a/osu.Game/Overlays/BeatmapSet/Scores/TopScoreUserSection.cs +++ b/osu.Game/Overlays/BeatmapSet/Scores/TopScoreUserSection.cs @@ -53,7 +53,7 @@ namespace osu.Game.Overlays.BeatmapSet.Scores 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 @@ namespace osu.Game.Overlays.BeatmapSet.Scores 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 @@ namespace osu.Game.Overlays.BeatmapSet.Scores { set { - avatar.Reset(); avatar.User = value.User; flag.Country = value.User.Country; date.Text = $@"achieved {value.Date.Humanize()}"; diff --git a/osu.Game/Users/Drawables/UpdateableAvatar.cs b/osu.Game/Users/Drawables/UpdateableAvatar.cs index 87a6943e80..ba4f5aef82 100644 --- a/osu.Game/Users/Drawables/UpdateableAvatar.cs +++ b/osu.Game/Users/Drawables/UpdateableAvatar.cs @@ -37,6 +37,10 @@ namespace osu.Game.Users.Drawables set => base.EdgeEffect = value; } + protected override bool TransformImmediately { get; } + + protected override double TransformDuration { get; } = 1000; + /// /// Whether to show a default guest representation on null user (as opposed to nothing). /// @@ -47,23 +51,14 @@ namespace osu.Game.Users.Drawables /// public readonly BindableBool OpenOnClick = new BindableBool(true); - public UpdateableAvatar(User user = null) + public UpdateableAvatar(User user = null, bool transformImmediately = false) { User = user; - } - /// - /// Fades and expires the , and sets the - /// to null. - /// - /// - /// Can be used when the needs to be removed instantly. - /// - public void Reset() - { - DisplayedDrawable?.FadeOut().Expire(); - - User = null; + if (transformImmediately) { + TransformDuration = 0; + TransformImmediately = true; + } } protected override Drawable CreateDrawable(User user) diff --git a/osu.Game/Users/Drawables/UpdateableFlag.cs b/osu.Game/Users/Drawables/UpdateableFlag.cs index abc16b2390..4d4d512ee7 100644 --- a/osu.Game/Users/Drawables/UpdateableFlag.cs +++ b/osu.Game/Users/Drawables/UpdateableFlag.cs @@ -14,14 +14,23 @@ namespace osu.Game.Users.Drawables set => Model = value; } + protected override bool TransformImmediately { get; } + + protected override double TransformDuration { get; } = 1000; + /// /// Whether to show a place holder on null country. /// 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)