mirror of
https://github.com/ppy/osu.git
synced 2026-05-17 16:53:15 +08:00
Merge pull request #36738 from peppy/user-button-animation-fix
Fix transient user stats animation changing speed after first display
This commit is contained in:
@@ -45,12 +45,6 @@ namespace osu.Game.Overlays.Toolbar
|
||||
Icon = icon,
|
||||
});
|
||||
|
||||
public LocalisableString Text
|
||||
{
|
||||
get => DrawableText.Text;
|
||||
set => DrawableText.Text = value;
|
||||
}
|
||||
|
||||
public LocalisableString TooltipMain
|
||||
{
|
||||
get => tooltip1.Text;
|
||||
@@ -67,7 +61,6 @@ namespace osu.Game.Overlays.Toolbar
|
||||
|
||||
protected readonly Container ButtonContent;
|
||||
protected ConstrainedIconContainer IconContainer;
|
||||
protected SpriteText DrawableText;
|
||||
protected Box HoverBackground;
|
||||
private readonly Box flashBackground;
|
||||
private readonly FillFlowContainer tooltipContainer;
|
||||
@@ -124,7 +117,6 @@ namespace osu.Game.Overlays.Toolbar
|
||||
Flow = new FillFlowContainer
|
||||
{
|
||||
Direction = FillDirection.Horizontal,
|
||||
Spacing = new Vector2(5),
|
||||
Anchor = Anchor.TopCentre,
|
||||
Origin = Anchor.TopCentre,
|
||||
Padding = new MarginPadding { Left = Toolbar.HEIGHT / 2, Right = Toolbar.HEIGHT / 2 },
|
||||
@@ -139,11 +131,6 @@ namespace osu.Game.Overlays.Toolbar
|
||||
Size = new Vector2(20),
|
||||
Alpha = 0,
|
||||
},
|
||||
DrawableText = new OsuSpriteText
|
||||
{
|
||||
Anchor = Anchor.CentreLeft,
|
||||
Origin = Anchor.CentreLeft,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
@@ -43,7 +43,7 @@ namespace osu.Game.Overlays.Toolbar
|
||||
Origin = Anchor.CentreLeft,
|
||||
Width = 3f,
|
||||
Height = IconContainer.Height,
|
||||
Margin = new MarginPadding { Horizontal = 2.5f },
|
||||
Margin = new MarginPadding { Left = 7.5f, Right = 2.5f },
|
||||
Masking = true,
|
||||
Children = new[]
|
||||
{
|
||||
|
||||
@@ -10,6 +10,7 @@ using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Effects;
|
||||
using osu.Framework.Graphics.Sprites;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Graphics.Sprites;
|
||||
using osu.Game.Graphics.UserInterface;
|
||||
using osu.Game.Localisation;
|
||||
using osu.Game.Online.API;
|
||||
@@ -32,6 +33,8 @@ namespace osu.Game.Overlays.Toolbar
|
||||
|
||||
private IBindable<APIState> apiState = null!;
|
||||
|
||||
private OsuSpriteText usernameText = null!;
|
||||
|
||||
public ToolbarUserButton()
|
||||
{
|
||||
ButtonContent.AutoSizeAxes = Axes.X;
|
||||
@@ -40,52 +43,58 @@ namespace osu.Game.Overlays.Toolbar
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(OsuColour colours, IAPIProvider api, LoginOverlay? login)
|
||||
{
|
||||
Flow.Add(new Container
|
||||
Flow.AddRange(new Drawable[]
|
||||
{
|
||||
Masking = true,
|
||||
CornerRadius = 4,
|
||||
Size = new Vector2(32),
|
||||
Anchor = Anchor.CentreLeft,
|
||||
Origin = Anchor.CentreLeft,
|
||||
EdgeEffect = new EdgeEffectParameters
|
||||
usernameText = new OsuSpriteText
|
||||
{
|
||||
Type = EdgeEffectType.Shadow,
|
||||
Radius = 4,
|
||||
Colour = Color4.Black.Opacity(0.1f),
|
||||
Anchor = Anchor.CentreLeft,
|
||||
Origin = Anchor.CentreLeft,
|
||||
Margin = new MarginPadding { Right = 5 },
|
||||
},
|
||||
Children = new Drawable[]
|
||||
new Container
|
||||
{
|
||||
avatar = new UpdateableAvatar(isInteractive: false)
|
||||
Masking = true,
|
||||
CornerRadius = 4,
|
||||
Size = new Vector2(32),
|
||||
Anchor = Anchor.CentreLeft,
|
||||
Origin = Anchor.CentreLeft,
|
||||
EdgeEffect = new EdgeEffectParameters
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Type = EdgeEffectType.Shadow,
|
||||
Radius = 4,
|
||||
Colour = Color4.Black.Opacity(0.1f),
|
||||
},
|
||||
spinner = new LoadingLayer(dimBackground: true, withBox: false)
|
||||
Children = new Drawable[]
|
||||
{
|
||||
BlockPositionalInput = false,
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
},
|
||||
failingIcon = new SpriteIcon
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
Alpha = 0,
|
||||
Size = new Vector2(0.3f),
|
||||
Icon = FontAwesome.Solid.ExclamationTriangle,
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Colour = colours.YellowLight,
|
||||
},
|
||||
avatar = new UpdateableAvatar(isInteractive: false)
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
},
|
||||
spinner = new LoadingLayer(dimBackground: true, withBox: false)
|
||||
{
|
||||
BlockPositionalInput = false,
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
},
|
||||
failingIcon = new SpriteIcon
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
Alpha = 0,
|
||||
Size = new Vector2(0.3f),
|
||||
Icon = FontAwesome.Solid.ExclamationTriangle,
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Colour = colours.YellowLight,
|
||||
},
|
||||
}
|
||||
},
|
||||
new TransientUserStatisticsUpdateDisplay
|
||||
{
|
||||
Alpha = 0,
|
||||
}
|
||||
});
|
||||
|
||||
Flow.Add(new TransientUserStatisticsUpdateDisplay
|
||||
{
|
||||
Alpha = 0
|
||||
});
|
||||
Flow.AutoSizeEasing = Easing.OutQuint;
|
||||
Flow.AutoSizeDuration = 250;
|
||||
|
||||
apiState = api.State.GetBoundCopy();
|
||||
apiState.BindValueChanged(onlineStateChanged, true);
|
||||
|
||||
@@ -97,7 +106,7 @@ namespace osu.Game.Overlays.Toolbar
|
||||
|
||||
private void userChanged(ValueChangedEvent<APIUser> user) => Schedule(() =>
|
||||
{
|
||||
Text = user.NewValue.Username;
|
||||
usernameText.Text = user.NewValue.Username;
|
||||
avatar.User = user.NewValue;
|
||||
});
|
||||
|
||||
|
||||
@@ -26,12 +26,12 @@ namespace osu.Game.Overlays.Toolbar
|
||||
private Statistic<int> globalRank = null!;
|
||||
private Statistic<int> pp = null!;
|
||||
|
||||
private ScheduledDelegate? shrinkDelegate;
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(UserStatisticsWatcher? userStatisticsWatcher)
|
||||
{
|
||||
RelativeSizeAxes = Axes.Y;
|
||||
AutoSizeAxes = Axes.X;
|
||||
Alpha = 0;
|
||||
|
||||
InternalChild = new FillFlowContainer
|
||||
{
|
||||
@@ -40,7 +40,7 @@ namespace osu.Game.Overlays.Toolbar
|
||||
Padding = new MarginPadding { Horizontal = 10 },
|
||||
Spacing = new Vector2(10),
|
||||
Direction = FillDirection.Horizontal,
|
||||
Children = new Drawable[]
|
||||
Children = new[]
|
||||
{
|
||||
globalRank = new Statistic<int>(UsersStrings.ShowRankGlobalSimple, @"#", Comparer<int>.Create((before, after) => before - after)),
|
||||
pp = new Statistic<int>(RankingsStrings.StatPerformance, string.Empty, Comparer<int>.Create((before, after) => Math.Sign(after - before))),
|
||||
@@ -71,8 +71,7 @@ namespace osu.Game.Overlays.Toolbar
|
||||
return;
|
||||
|
||||
FinishTransforms(true);
|
||||
|
||||
this.FadeIn(500, Easing.OutQuint);
|
||||
shrinkDelegate?.Cancel();
|
||||
|
||||
if (update.After.GlobalRank != null)
|
||||
{
|
||||
@@ -90,7 +89,21 @@ namespace osu.Game.Overlays.Toolbar
|
||||
pp.Display(before, delta, after);
|
||||
}
|
||||
|
||||
this.Delay(5000).FadeOut(500, Easing.OutQuint);
|
||||
this.FadeIn(500, Easing.OutQuint);
|
||||
|
||||
AutoSizeAxes = Axes.X;
|
||||
AutoSizeDuration = 500;
|
||||
AutoSizeEasing = Easing.OutQuint;
|
||||
|
||||
using (BeginDelayedSequence(5000))
|
||||
{
|
||||
this.FadeOut(500, Easing.OutQuint);
|
||||
shrinkDelegate = Schedule(() =>
|
||||
{
|
||||
AutoSizeAxes = Axes.None;
|
||||
this.ResizeWidthTo(0, 500, Easing.OutQuint);
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user