diff --git a/osu.Game/Overlays/Toolbar/ToolbarButton.cs b/osu.Game/Overlays/Toolbar/ToolbarButton.cs index 5b75b8419c..b0a6841a2f 100644 --- a/osu.Game/Overlays/Toolbar/ToolbarButton.cs +++ b/osu.Game/Overlays/Toolbar/ToolbarButton.cs @@ -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, - }, }, }, }, diff --git a/osu.Game/Overlays/Toolbar/ToolbarMusicButton.cs b/osu.Game/Overlays/Toolbar/ToolbarMusicButton.cs index 51b95b7d32..e6ffc1ad5e 100644 --- a/osu.Game/Overlays/Toolbar/ToolbarMusicButton.cs +++ b/osu.Game/Overlays/Toolbar/ToolbarMusicButton.cs @@ -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[] { diff --git a/osu.Game/Overlays/Toolbar/ToolbarUserButton.cs b/osu.Game/Overlays/Toolbar/ToolbarUserButton.cs index 2ade335ef7..d8350ce451 100644 --- a/osu.Game/Overlays/Toolbar/ToolbarUserButton.cs +++ b/osu.Game/Overlays/Toolbar/ToolbarUserButton.cs @@ -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 = 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 user) => Schedule(() => { - Text = user.NewValue.Username; + usernameText.Text = user.NewValue.Username; avatar.User = user.NewValue; }); diff --git a/osu.Game/Overlays/Toolbar/TransientUserStatisticsUpdateDisplay.cs b/osu.Game/Overlays/Toolbar/TransientUserStatisticsUpdateDisplay.cs index 85b7358d2d..e5df7a65dc 100644 --- a/osu.Game/Overlays/Toolbar/TransientUserStatisticsUpdateDisplay.cs +++ b/osu.Game/Overlays/Toolbar/TransientUserStatisticsUpdateDisplay.cs @@ -26,12 +26,12 @@ namespace osu.Game.Overlays.Toolbar private Statistic globalRank = null!; private Statistic 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(UsersStrings.ShowRankGlobalSimple, @"#", Comparer.Create((before, after) => before - after)), pp = new Statistic(RankingsStrings.StatPerformance, string.Empty, Comparer.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); + }); + } }); }