1
0
mirror of https://github.com/ppy/osu.git synced 2026-05-17 19:44:22 +08:00

Merge pull request #32718 from minetoblend/feature/tag-vote-count-transition

Add transition when vote-count changes in user tag control
This commit is contained in:
Bartłomiej Dach
2025-04-08 07:46:12 +02:00
committed by GitHub
Unverified
+54 -5
View File
@@ -302,7 +302,7 @@ namespace osu.Game.Screens.Ranking
protected OsuSpriteText TagCategoryText { get; private set; } = null!;
protected OsuSpriteText TagNameText { get; private set; } = null!;
protected OsuSpriteText VoteCountText { get; private set; } = null!;
protected VoteCountText VoteCountText { get; private set; } = null!;
private readonly bool showVoteCount;
@@ -382,7 +382,8 @@ namespace osu.Game.Screens.Ranking
showVoteCount
? new Container
{
AutoSizeAxes = Axes.Both,
RelativeSizeAxes = Axes.Y,
AutoSizeAxes = Axes.X,
Anchor = Anchor.CentreLeft,
Origin = Anchor.CentreLeft,
Children = new Drawable[]
@@ -391,9 +392,9 @@ namespace osu.Game.Screens.Ranking
{
RelativeSizeAxes = Axes.Both,
},
VoteCountText = new OsuSpriteText
VoteCountText = new VoteCountText(voteCount)
{
Margin = new MarginPadding { Horizontal = 6, Vertical = 3, },
Margin = new MarginPadding { Horizontal = 6 },
},
}
}
@@ -418,7 +419,6 @@ namespace osu.Game.Screens.Ranking
{
voteCount.BindValueChanged(_ =>
{
VoteCountText.Text = voteCount.Value.ToLocalisableString();
confirmed.Value = voteCount.Value >= 10;
}, true);
voted.BindValueChanged(v =>
@@ -731,5 +731,54 @@ namespace osu.Game.Screens.Ranking
}
}
}
private partial class VoteCountText : CompositeDrawable
{
private OsuSpriteText? text;
private readonly Bindable<int> voteCount;
public VoteCountText(Bindable<int> voteCount)
{
RelativeSizeAxes = Axes.Y;
AutoSizeAxes = Axes.X;
this.voteCount = voteCount.GetBoundCopy();
}
protected override void LoadComplete()
{
base.LoadComplete();
voteCount.BindValueChanged(count =>
{
OsuSpriteText? previousText = text;
AddInternal(text = new OsuSpriteText
{
Anchor = Anchor.CentreLeft,
Origin = Anchor.CentreLeft,
Font = OsuFont.GetFont(weight: FontWeight.SemiBold),
Text = voteCount.Value.ToLocalisableString(),
});
if (previousText != null)
{
const double transition_duration = 500;
bool isIncrease = count.NewValue > count.OldValue;
text.MoveToY(isIncrease ? 20 : -20)
.MoveToY(0, transition_duration, Easing.OutExpo);
previousText.BypassAutoSizeAxes = Axes.Both;
previousText.MoveToY(isIncrease ? -20 : 20, transition_duration, Easing.OutExpo).Expire();
AutoSizeDuration = 300;
AutoSizeEasing = Easing.OutQuint;
}
}, true);
}
}
}
}