diff --git a/osu.Game/Overlays/Settings/Sections/General/LoginSettings.cs b/osu.Game/Overlays/Settings/Sections/General/LoginSettings.cs index da07f55be0..b740aa282a 100644 --- a/osu.Game/Overlays/Settings/Sections/General/LoginSettings.cs +++ b/osu.Game/Overlays/Settings/Sections/General/LoginSettings.cs @@ -26,6 +26,7 @@ public class LoginSettings : FillFlowContainer, IOnlineComponent { private bool bounding = true; private LoginForm form; + private OsuColour colours; public override RectangleF BoundingBox => bounding ? base.BoundingBox : RectangleF.Empty; @@ -48,8 +49,9 @@ public LoginSettings() } [BackgroundDependencyLoader(permitNulls: true)] - private void load(APIAccess api) + private void load(OsuColour colours, APIAccess api) { + this.colours = colours; api?.Register(this); } @@ -93,6 +95,8 @@ public void APIStateChanged(APIAccess api, APIState state) }; break; case APIState.Online: + UserDropdown dropdown; + UserPanel panel; Children = new Drawable[] { new FillFlowContainer @@ -121,17 +125,40 @@ public void APIStateChanged(APIAccess api, APIState state) }, }, }, - new UserPanel(api.LocalUser.Value) + panel = new UserPanel(api.LocalUser.Value) { RelativeSizeAxes = Axes.X, }, - new UserDropdown + dropdown = new UserDropdown { RelativeSizeAxes = Axes.X, }, }, }, }; + panel.Status.BindTo(api.LocalUser.Value.Status); + dropdown.Current.ValueChanged += newValue => + { + switch (newValue) + { + case UserAction.Online: + api.LocalUser.Value.Status.Value = new UserStatusOnline(); + dropdown.StatusColour = colours.Green; + break; + case UserAction.DoNotDisturb: + api.LocalUser.Value.Status.Value = new UserStatusDoNotDisturb(); + dropdown.StatusColour = colours.Red; + break; + case UserAction.AppearOffline: + api.LocalUser.Value.Status.Value = new UserStatusOffline(); + dropdown.StatusColour = colours.Gray7; + break; + case UserAction.SignOut: + api.Logout(); + break; + } + }; + dropdown.Current.TriggerChange(); break; } @@ -225,6 +252,14 @@ private class UserDropdown : OsuEnumDropdown protected override Menu CreateMenu() => new UserDropdownMenu(); protected override DropdownMenuItem CreateMenuItem(string text, UserAction value) => new UserDropdownMenuItem(text, value) { AccentColour = AccentColour }; + public Color4 StatusColour + { + set + { + (Header as UserDropdownHeader).StatusColour = value; + } + } + [BackgroundDependencyLoader] private void load(OsuColour colours) { @@ -235,6 +270,14 @@ private class UserDropdownHeader : OsuDropdownHeader { protected readonly TextAwesome statusIcon; + public Color4 StatusColour + { + set + { + statusIcon.FadeColour(value, 500, EasingTypes.OutQuint); + } + } + public UserDropdownHeader() { Foreground.Padding = new MarginPadding { Left = 10, Right = 10 }; @@ -268,8 +311,6 @@ private void load(OsuColour colours) { BackgroundColour = colours.Gray3; } - - public void SetStatusColour(Color4 colour) => statusIcon.FadeColour(colour, 500, EasingTypes.OutQuint); } private class UserDropdownMenu : OsuMenu @@ -298,7 +339,8 @@ private class UserDropdownMenuItem : OsuDropdownMenuItem { public UserDropdownMenuItem(string text, UserAction current) : base(text, current) { - Foreground.Padding = new MarginPadding(5); + //todo: Another magic number + Foreground.Padding = new MarginPadding { Top = 5, Bottom = 5, Left = 19, Right = 5 }; CornerRadius = 5; } } diff --git a/osu.Game/Users/User.cs b/osu.Game/Users/User.cs index 1361eefcff..93933c8fe9 100644 --- a/osu.Game/Users/User.cs +++ b/osu.Game/Users/User.cs @@ -2,6 +2,7 @@ // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE using Newtonsoft.Json; +using osu.Framework.Configuration; namespace osu.Game.Users { @@ -19,6 +20,8 @@ public class User [JsonProperty(@"country")] public Country Country; + public Bindable Status = new Bindable(); + //public Team Team; [JsonProperty(@"profile_colour")] diff --git a/osu.Game/Users/UserStatus.cs b/osu.Game/Users/UserStatus.cs index dcb5ccbd8f..15e6c4fb60 100644 --- a/osu.Game/Users/UserStatus.cs +++ b/osu.Game/Users/UserStatus.cs @@ -58,4 +58,10 @@ public class UserStatusModding : UserStatus public override string Message => @"Modding a map"; public override Color4 GetAppropriateColour(OsuColour colours) => colours.PurpleDark; } + + public class UserStatusDoNotDisturb : UserStatus + { + public override string Message => @"Do not disturb"; + public override Color4 GetAppropriateColour(OsuColour colours) => colours.RedDark; + } }