1
0
mirror of https://github.com/ppy/osu.git synced 2026-05-17 01:03:15 +08:00
Files
osu-lazer/osu.Game/Online/Leaderboards/UpdateableRank.cs
T
Salman Alshamrani 522f94277b Fix incorrect rank animation when beatmap panels retrieved from pool
Rank animation is played for new panels when scrolling down, showing the
previous rank belonging to the previous beatmap assigned to that
specific panel instance.
2025-08-11 19:21:22 +03:00

69 lines
2.0 KiB
C#

// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
using System;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Transforms;
using osu.Game.Scoring;
namespace osu.Game.Online.Leaderboards
{
public partial class UpdateableRank : ModelBackedDrawable<ScoreRank?>
{
private readonly bool animate;
protected override double TransformDuration => animate ? 600 : 0;
protected override bool TransformImmediately => true;
public ScoreRank? Rank
{
get => Model;
set => Model = value;
}
public UpdateableRank(ScoreRank? rank = null, bool animate = true)
{
this.animate = animate;
Rank = rank;
}
protected override DelayedLoadWrapper CreateDelayedLoadWrapper(Func<Drawable> createContentFunc, double timeBeforeLoad)
{
return base.CreateDelayedLoadWrapper(createContentFunc, timeBeforeLoad)
.With(w =>
{
w.Anchor = Anchor.Centre;
w.Origin = Anchor.Centre;
});
}
protected override Drawable? CreateDrawable(ScoreRank? rank)
{
if (rank.HasValue)
{
return new DrawableRank(rank.Value)
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
};
}
return null;
}
protected override TransformSequence<Drawable> ApplyShowTransforms(Drawable drawable)
{
drawable.ScaleTo(1);
return base.ApplyShowTransforms(drawable);
}
protected override TransformSequence<Drawable> ApplyHideTransforms(Drawable drawable)
{
drawable.ScaleTo(1.8f, TransformDuration, Easing.Out);
return base.ApplyHideTransforms(drawable);
}
}
}