From 2be1b00a766d063305575522f345183eb64dd81f Mon Sep 17 00:00:00 2001 From: DrabWeb Date: Wed, 24 May 2017 00:45:56 -0300 Subject: [PATCH] Hide status bar when Status is null --- .../Tests/TestCaseUserPanel.cs | 1 + .../Settings/Sections/General/LoginSettings.cs | 4 +--- osu.Game/Users/UserPanel.cs | 17 ++++++++++++----- 3 files changed, 14 insertions(+), 8 deletions(-) diff --git a/osu.Desktop.VisualTests/Tests/TestCaseUserPanel.cs b/osu.Desktop.VisualTests/Tests/TestCaseUserPanel.cs index 254c5bc243..513bf24e0d 100644 --- a/osu.Desktop.VisualTests/Tests/TestCaseUserPanel.cs +++ b/osu.Desktop.VisualTests/Tests/TestCaseUserPanel.cs @@ -51,6 +51,7 @@ namespace osu.Desktop.VisualTests.Tests AddStep(@"multiplaying", () => { flyte.Status.Value = new UserStatusMultiplayerGame(); }); AddStep(@"modding", () => { flyte.Status.Value = new UserStatusModding(); }); AddStep(@"offline", () => { flyte.Status.Value = new UserStatusOffline(); }); + AddStep(@"null status", () => { flyte.Status.Value = null; }); } } } diff --git a/osu.Game/Overlays/Settings/Sections/General/LoginSettings.cs b/osu.Game/Overlays/Settings/Sections/General/LoginSettings.cs index 73521a31c3..d94388ed87 100644 --- a/osu.Game/Overlays/Settings/Sections/General/LoginSettings.cs +++ b/osu.Game/Overlays/Settings/Sections/General/LoginSettings.cs @@ -72,10 +72,9 @@ namespace osu.Game.Overlays.Settings.Sections.General }; break; case APIState.Online: - UserPanel p; Children = new Drawable[] { - p = new UserPanel(api.LocalUser.Value) + new UserPanel(api.LocalUser.Value) { RelativeSizeAxes = Axes.X, }, @@ -86,7 +85,6 @@ namespace osu.Game.Overlays.Settings.Sections.General Action = api.Logout } }; - p.Status.Value = new UserStatusOnline(); break; } diff --git a/osu.Game/Users/UserPanel.cs b/osu.Game/Users/UserPanel.cs index f32158e00b..df37b339c3 100644 --- a/osu.Game/Users/UserPanel.cs +++ b/osu.Game/Users/UserPanel.cs @@ -23,6 +23,7 @@ namespace osu.Game.Users private OsuColour colours; + private readonly Container statusBar; private readonly Box statusBg; private readonly OsuSpriteText statusMessage; @@ -30,7 +31,7 @@ namespace osu.Game.Users public UserPanel(User user) { - Height = height; + Height = height - status_height; Masking = true; CornerRadius = 5; EdgeEffect = new EdgeEffect @@ -54,8 +55,9 @@ namespace osu.Game.Users }, new Container { - RelativeSizeAxes = Axes.Both, - Padding = new MarginPadding { Top = content_padding, Bottom = status_height + content_padding, Left = content_padding, Right = content_padding }, + RelativeSizeAxes = Axes.X, + AutoSizeAxes = Axes.Y, + Padding = new MarginPadding { Top = content_padding, Left = content_padding, Right = content_padding }, Children = new Drawable[] { new UpdateableAvatar @@ -114,12 +116,12 @@ namespace osu.Game.Users }, }, }, - new Container + statusBar = new Container { Anchor = Anchor.BottomLeft, Origin = Anchor.BottomLeft, RelativeSizeAxes = Axes.X, - Height = status_height, + Alpha = 0f, Children = new Drawable[] { statusBg = new Box @@ -174,6 +176,11 @@ namespace osu.Game.Users private void displayStatus(UserStatus status) { + statusBar.ResizeHeightTo(status == null ? 0f : status_height, 500, EasingTypes.OutQuint); + statusBar.FadeTo(status == null ? 0f : 1f, 500, EasingTypes.OutQuint); + ResizeHeightTo(status == null ? height - status_height : height, 500, EasingTypes.OutQuint); + if (status == null) return; + statusBg.FadeColour(status.GetAppropriateColour(colours), 500, EasingTypes.OutQuint); statusMessage.Text = status.Message; }