From 88b8afbb6aa0c8468b3b9e22e760ca9735e4fda2 Mon Sep 17 00:00:00 2001 From: Lucas A Date: Sun, 5 May 2019 20:51:55 +0200 Subject: [PATCH] Make UserPanel show current user activity when user status is online. --- .../Sections/General/LoginSettings.cs | 1 + osu.Game/Overlays/SocialOverlay.cs | 1 + osu.Game/Screens/OsuScreen.cs | 4 ++-- osu.Game/Users/UserPanel.cs | 21 +++++++++++++++---- 4 files changed, 21 insertions(+), 6 deletions(-) diff --git a/osu.Game/Overlays/Settings/Sections/General/LoginSettings.cs b/osu.Game/Overlays/Settings/Sections/General/LoginSettings.cs index 98eb4b662f..bf5a3c12f5 100644 --- a/osu.Game/Overlays/Settings/Sections/General/LoginSettings.cs +++ b/osu.Game/Overlays/Settings/Sections/General/LoginSettings.cs @@ -152,6 +152,7 @@ namespace osu.Game.Overlays.Settings.Sections.General }; panel.Status.BindTo(api.LocalUser.Value.Status); + panel.Activity.BindTo(api.LocalUser.Value.Activity); dropdown.Current.ValueChanged += action => { diff --git a/osu.Game/Overlays/SocialOverlay.cs b/osu.Game/Overlays/SocialOverlay.cs index daf3d1c576..0ad3541071 100644 --- a/osu.Game/Overlays/SocialOverlay.cs +++ b/osu.Game/Overlays/SocialOverlay.cs @@ -126,6 +126,7 @@ namespace osu.Game.Overlays } panel.Status.BindTo(u.Status); + panel.Activity.BindTo(u.Activity); return panel; }) }; diff --git a/osu.Game/Screens/OsuScreen.cs b/osu.Game/Screens/OsuScreen.cs index d8b38ff20a..170f548676 100644 --- a/osu.Game/Screens/OsuScreen.cs +++ b/osu.Game/Screens/OsuScreen.cs @@ -150,7 +150,7 @@ namespace osu.Game.Screens sampleExit?.Play(); applyArrivingDefaults(true); - ScreenStatus = ScreenStatus; + ScreenActivity = ScreenActivity; base.OnResuming(last); } @@ -168,7 +168,7 @@ namespace osu.Game.Screens backgroundStack?.Push(localBackground = CreateBackground()); - ScreenStatus = InitialScreenActivity; + ScreenActivity = InitialScreenActivity; base.OnEntering(last); } diff --git a/osu.Game/Users/UserPanel.cs b/osu.Game/Users/UserPanel.cs index 47571b673d..d5061ad423 100644 --- a/osu.Game/Users/UserPanel.cs +++ b/osu.Game/Users/UserPanel.cs @@ -30,6 +30,9 @@ namespace osu.Game.Users private const float content_padding = 10; private const float status_height = 30; + [Resolved(canBeNull: true)] + private OsuColour colours { get; set; } + private Container statusBar; private Box statusBg; private OsuSpriteText statusMessage; @@ -39,6 +42,8 @@ namespace osu.Game.Users public readonly Bindable Status = new Bindable(); + public readonly Bindable Activity = new Bindable(); + public new Action Action; protected Action ViewProfile; @@ -54,7 +59,7 @@ namespace osu.Game.Users } [BackgroundDependencyLoader(permitNulls: true)] - private void load(OsuColour colours, UserProfileOverlay profile) + private void load(UserProfileOverlay profile) { if (colours == null) throw new ArgumentNullException(nameof(colours)); @@ -195,8 +200,8 @@ namespace osu.Game.Users }); } - Status.ValueChanged += status => displayStatus(status.NewValue); - Status.ValueChanged += status => statusBg.FadeColour(status.NewValue?.GetAppropriateColour(colours) ?? colours.Gray5, 500, Easing.OutQuint); + Status.ValueChanged += status => displayStatus(status.NewValue, Activity.Value); + Activity.ValueChanged += activity => displayStatus(Status.Value, activity.NewValue); base.Action = ViewProfile = () => { @@ -211,7 +216,7 @@ namespace osu.Game.Users Status.TriggerChange(); } - private void displayStatus(UserStatus status) + private void displayStatus(UserStatus status, UserActivity activity = null) { const float transition_duration = 500; @@ -227,7 +232,15 @@ namespace osu.Game.Users statusBar.FadeIn(transition_duration, Easing.OutQuint); this.ResizeHeightTo(height, transition_duration, Easing.OutQuint); + if (status is UserStatusOnline && activity != null) + { + statusMessage.Text = activity.Status; + statusBg.FadeColour(status.GetAppropriateColour(colours), 500, Easing.OutQuint); + return; + } + statusMessage.Text = status.Message; + statusBg.FadeColour(status?.GetAppropriateColour(colours) ?? colours.Gray5, 500, Easing.OutQuint); } }