From 7ce3b73ecdaf0f1df0d390f51c24a5318a0c4cf0 Mon Sep 17 00:00:00 2001 From: DrabWeb Date: Mon, 22 May 2017 03:11:42 -0300 Subject: [PATCH 01/14] Added UserPanel and UserStatus --- .../Tests/TestCaseUserPanel.cs | 40 ++++ .../osu.Desktop.VisualTests.csproj | 1 + osu.Game/Users/UserPanel.cs | 183 ++++++++++++++++++ osu.Game/Users/UserStatus.cs | 55 ++++++ osu.Game/osu.Game.csproj | 2 + 5 files changed, 281 insertions(+) create mode 100644 osu.Desktop.VisualTests/Tests/TestCaseUserPanel.cs create mode 100644 osu.Game/Users/UserPanel.cs create mode 100644 osu.Game/Users/UserStatus.cs diff --git a/osu.Desktop.VisualTests/Tests/TestCaseUserPanel.cs b/osu.Desktop.VisualTests/Tests/TestCaseUserPanel.cs new file mode 100644 index 0000000000..ab8bb425a7 --- /dev/null +++ b/osu.Desktop.VisualTests/Tests/TestCaseUserPanel.cs @@ -0,0 +1,40 @@ +// Copyright (c) 2007-2017 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using osu.Framework.Testing; +using osu.Framework.Graphics; +using osu.Game.Graphics.UserInterface; +using osu.Game.Users; + +namespace osu.Desktop.VisualTests.Tests +{ + internal class TestCaseUserPanel : TestCase + { + public override string Description => @"Panels for displaying a user's status"; + + public override void Reset() + { + base.Reset(); + + UserPanel p; + Add(p = new UserPanel(new User + { + Username = @"flyte", + Id = 3103765, + Country = new Country { FlagName = @"JP" }, + CoverUrl = @"https://assets.ppy.sh/user-profile-covers/3103765/5b012e13611d5761caa7e24fecb3d3a16e1cf48fc2a3032cfd43dd444af83d82.jpeg" + }) + { + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + Width = 300, + }); + + p.Status.Value = new UserStatusOnline(); + + AddStep(@"spectating", () => { p.Status.Value = new UserStatusSpectating(); }); + AddStep(@"multiplaying", () => { p.Status.Value = new UserStatusMultiplayerGame(); }); + AddStep(@"modding", () => { p.Status.Value = new UserStatusModding(); }); + } + } +} diff --git a/osu.Desktop.VisualTests/osu.Desktop.VisualTests.csproj b/osu.Desktop.VisualTests/osu.Desktop.VisualTests.csproj index dbb1750b72..e68935a561 100644 --- a/osu.Desktop.VisualTests/osu.Desktop.VisualTests.csproj +++ b/osu.Desktop.VisualTests/osu.Desktop.VisualTests.csproj @@ -220,6 +220,7 @@ + diff --git a/osu.Game/Users/UserPanel.cs b/osu.Game/Users/UserPanel.cs new file mode 100644 index 0000000000..80d706d985 --- /dev/null +++ b/osu.Game/Users/UserPanel.cs @@ -0,0 +1,183 @@ +// Copyright (c) 2007-2017 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using OpenTK; +using OpenTK.Graphics; +using osu.Framework.Allocation; +using osu.Framework.Configuration; +using osu.Framework.Extensions.Color4Extensions; +using osu.Framework.Graphics; +using osu.Framework.Graphics.Containers; +using osu.Framework.Graphics.Sprites; +using osu.Framework.Graphics.Textures; +using osu.Game.Graphics; +using osu.Game.Graphics.Sprites; + +namespace osu.Game.Users +{ + public class UserPanel : Container + { + private const float height = 100; + private const float content_padding = 10; + private const float status_height = 30; + + private readonly User user; + private OsuColour colours; + + private readonly Container cover; + private readonly Box statusBg; + private readonly OsuSpriteText statusMessage; + + public readonly Bindable Status = new Bindable(); + + public UserPanel(User user) + { + this.user = user; + + Height = height; + Masking = true; + CornerRadius = 5; + EdgeEffect = new EdgeEffect + { + Type = EdgeEffectType.Shadow, + Colour = Color4.Black.Opacity(0.25f), + Radius = 4, + }; + + Children = new Drawable[] + { + cover = new Container + { + RelativeSizeAxes = Axes.Both, + }, + new Box + { + RelativeSizeAxes = Axes.Both, + Colour = Color4.Black.Opacity(0.7f), + }, + new Container + { + RelativeSizeAxes = Axes.Both, + Padding = new MarginPadding { Top = content_padding, Bottom = status_height + content_padding, Left = content_padding, Right = content_padding }, + Children = new Drawable[] + { + new UpdateableAvatar + { + Size = new Vector2(height - status_height - content_padding * 2), + User = user, + Masking = true, + CornerRadius = 5, + EdgeEffect = new EdgeEffect + { + Type = EdgeEffectType.Shadow, + Colour = Color4.Black.Opacity(0.25f), + Radius = 4, + }, + }, + new Container + { + RelativeSizeAxes = Axes.Both, + Margin = new MarginPadding { Left = height - status_height - content_padding }, + Children = new Drawable[] + { + new OsuSpriteText + { + Text = user.Username, + TextSize = 18, + Font = @"Exo2.0-SemiBoldItalic", + }, + new FillFlowContainer + { + Anchor = Anchor.BottomLeft, + Origin = Anchor.BottomLeft, + AutoSizeAxes = Axes.X, + Height = 20f, + Direction = FillDirection.Horizontal, + Spacing = new Vector2(5f, 0f), + Children = new Drawable[] + { + new DrawableFlag(user.Country?.FlagName ?? @"__") + { + Width = 30f, + RelativeSizeAxes = Axes.Y, + }, + new Container + { + Width = 40f, + RelativeSizeAxes = Axes.Y, + }, + new CircularContainer + { + Width = 20f, + RelativeSizeAxes = Axes.Y, + }, + }, + }, + }, + }, + }, + }, + new Container + { + Anchor = Anchor.BottomLeft, + Origin = Anchor.BottomLeft, + RelativeSizeAxes = Axes.X, + Height = status_height, + Children = new Drawable[] + { + statusBg = new Box + { + RelativeSizeAxes = Axes.Both, + Alpha = 0.5f, + }, + new FillFlowContainer + { + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + AutoSizeAxes = Axes.Both, + Spacing = new Vector2(5f, 0f), + Children = new[] + { + new TextAwesome + { + Anchor = Anchor.CentreLeft, + Origin = Anchor.CentreLeft, + Icon = FontAwesome.fa_circle_o, + Shadow = true, + TextSize = 14, + }, + statusMessage = new OsuSpriteText + { + Anchor = Anchor.CentreLeft, + Origin = Anchor.CentreLeft, + Font = @"Exo2.0-Semibold", + }, + }, + }, + }, + }, + }; + + Status.ValueChanged += displayStatus; + } + + [BackgroundDependencyLoader] + private void load(OsuColour colours, TextureStore textures) + { + this.colours = colours; + + cover.Add(new AsyncLoadWrapper(new Sprite + { + Texture = textures.Get(user.CoverUrl), + FillMode = FillMode.Fill, + OnLoadComplete = d => d.FadeInFromZero(200), + }) { RelativeSizeAxes = Axes.Both }); + } + + private void displayStatus(UserStatus status) + { + statusBg.FadeColour(status.Colour(colours), 200); + statusMessage.Text = status.Message; + } + } +} diff --git a/osu.Game/Users/UserStatus.cs b/osu.Game/Users/UserStatus.cs new file mode 100644 index 0000000000..b6ae53c9cd --- /dev/null +++ b/osu.Game/Users/UserStatus.cs @@ -0,0 +1,55 @@ +// Copyright (c) 2007-2017 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using OpenTK.Graphics; +using osu.Game.Graphics; + +namespace osu.Game.Users +{ + public abstract class UserStatus + { + public abstract string Message { get; } + public abstract Color4 Colour(OsuColour colours); + } + + public abstract class UserStatusAvailable : UserStatus + { + public override Color4 Colour(OsuColour colours) => colours.BlueDarker; + } + + public abstract class UserStatusBusy : UserStatus + { + public override Color4 Colour(OsuColour colours) => colours.YellowDark; + } + + public class UserStatusOnline : UserStatusAvailable + { + public override string Message => @"Online"; + } + + public class UserStatusSpectating : UserStatusAvailable + { + public override string Message => @"Spectating a game"; + } + + public class UserStatusInLobby : UserStatusAvailable + { + public override string Message => @"in Multiplayer Lobby"; + } + + public class UserStatusSoloGame : UserStatusBusy + { + public override string Message => @"Solo Game"; + } + + public class UserStatusMultiplayerGame: UserStatusBusy + { + public override string Message => @"Multiplaying"; + } + + public class UserStatusModding : UserStatus + { + public override string Message => @"Modding a map"; + public override Color4 Colour(OsuColour colours) => colours.PurpleDark; + } +} diff --git a/osu.Game/osu.Game.csproj b/osu.Game/osu.Game.csproj index 1631311ef6..ba72b0422d 100644 --- a/osu.Game/osu.Game.csproj +++ b/osu.Game/osu.Game.csproj @@ -425,6 +425,8 @@ + + From a73cf929946cb30ec7154014b66fe091595c6bdc Mon Sep 17 00:00:00 2001 From: DrabWeb Date: Mon, 22 May 2017 03:27:08 -0300 Subject: [PATCH 02/14] Add second UserPanel to visual test, center cover sprite --- .../Tests/TestCaseUserPanel.cs | 42 +++++++++++++------ osu.Game/Users/UserPanel.cs | 3 ++ 2 files changed, 32 insertions(+), 13 deletions(-) diff --git a/osu.Desktop.VisualTests/Tests/TestCaseUserPanel.cs b/osu.Desktop.VisualTests/Tests/TestCaseUserPanel.cs index ab8bb425a7..efee8e0e24 100644 --- a/osu.Desktop.VisualTests/Tests/TestCaseUserPanel.cs +++ b/osu.Desktop.VisualTests/Tests/TestCaseUserPanel.cs @@ -5,6 +5,8 @@ using osu.Framework.Testing; using osu.Framework.Graphics; using osu.Game.Graphics.UserInterface; using osu.Game.Users; +using osu.Framework.Graphics.Containers; +using OpenTK; namespace osu.Desktop.VisualTests.Tests { @@ -16,25 +18,39 @@ namespace osu.Desktop.VisualTests.Tests { base.Reset(); - UserPanel p; - Add(p = new UserPanel(new User - { - Username = @"flyte", - Id = 3103765, - Country = new Country { FlagName = @"JP" }, - CoverUrl = @"https://assets.ppy.sh/user-profile-covers/3103765/5b012e13611d5761caa7e24fecb3d3a16e1cf48fc2a3032cfd43dd444af83d82.jpeg" - }) + UserPanel flyte; + UserPanel peppy; + Add(new FillFlowContainer { Anchor = Anchor.Centre, Origin = Anchor.Centre, - Width = 300, + AutoSizeAxes = Axes.Both, + Spacing = new Vector2(10f), + Children = new[] + { + flyte = new UserPanel(new User + { + Username = @"flyte", + Id = 3103765, + Country = new Country { FlagName = @"JP" }, + CoverUrl = @"https://assets.ppy.sh/user-profile-covers/3103765/5b012e13611d5761caa7e24fecb3d3a16e1cf48fc2a3032cfd43dd444af83d82.jpeg" + }), + peppy = new UserPanel(new User + { + Username = @"peppy", + Id = 2, + Country = new Country { FlagName = @"AU" }, + CoverUrl = @"https://assets.ppy.sh/user-profile-covers/2/08cad88747c235a64fca5f1b770e100f120827ded1ffe3b66bfcd19c940afa65.jpeg" + }), + }, }); - p.Status.Value = new UserStatusOnline(); + flyte.Status.Value = new UserStatusOnline(); + peppy.Status.Value = new UserStatusSoloGame(); - AddStep(@"spectating", () => { p.Status.Value = new UserStatusSpectating(); }); - AddStep(@"multiplaying", () => { p.Status.Value = new UserStatusMultiplayerGame(); }); - AddStep(@"modding", () => { p.Status.Value = new UserStatusModding(); }); + AddStep(@"spectating", () => { flyte.Status.Value = new UserStatusSpectating(); }); + AddStep(@"multiplaying", () => { flyte.Status.Value = new UserStatusMultiplayerGame(); }); + AddStep(@"modding", () => { flyte.Status.Value = new UserStatusModding(); }); } } } diff --git a/osu.Game/Users/UserPanel.cs b/osu.Game/Users/UserPanel.cs index 80d706d985..4de309fb62 100644 --- a/osu.Game/Users/UserPanel.cs +++ b/osu.Game/Users/UserPanel.cs @@ -34,6 +34,7 @@ namespace osu.Game.Users { this.user = user; + Width = 300; Height = height; Masking = true; CornerRadius = 5; @@ -168,6 +169,8 @@ namespace osu.Game.Users cover.Add(new AsyncLoadWrapper(new Sprite { + Anchor = Anchor.Centre, + Origin = Anchor.Centre, Texture = textures.Get(user.CoverUrl), FillMode = FillMode.Fill, OnLoadComplete = d => d.FadeInFromZero(200), From aa40f882586b9a9137e9b0a1aa0c1cffaa9aad8f Mon Sep 17 00:00:00 2001 From: DrabWeb Date: Mon, 22 May 2017 03:32:02 -0300 Subject: [PATCH 03/14] Add UserStatusOffline --- osu.Desktop.VisualTests/Tests/TestCaseUserPanel.cs | 1 + osu.Game/Users/UserStatus.cs | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/osu.Desktop.VisualTests/Tests/TestCaseUserPanel.cs b/osu.Desktop.VisualTests/Tests/TestCaseUserPanel.cs index efee8e0e24..d783d42f1f 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(@"spectating", () => { flyte.Status.Value = new UserStatusSpectating(); }); AddStep(@"multiplaying", () => { flyte.Status.Value = new UserStatusMultiplayerGame(); }); AddStep(@"modding", () => { flyte.Status.Value = new UserStatusModding(); }); + AddStep(@"offline", () => { flyte.Status.Value = new UserStatusOffline(); }); } } } diff --git a/osu.Game/Users/UserStatus.cs b/osu.Game/Users/UserStatus.cs index b6ae53c9cd..97ee47423e 100644 --- a/osu.Game/Users/UserStatus.cs +++ b/osu.Game/Users/UserStatus.cs @@ -22,6 +22,12 @@ namespace osu.Game.Users public override Color4 Colour(OsuColour colours) => colours.YellowDark; } + public class UserStatusOffline : UserStatus + { + public override string Message => @"Offline"; + public override Color4 Colour(OsuColour colours) => colours.Gray7; + } + public class UserStatusOnline : UserStatusAvailable { public override string Message => @"Online"; From 8a364c606824d7376286f38429dfe5545db3454e Mon Sep 17 00:00:00 2001 From: DrabWeb Date: Mon, 22 May 2017 03:37:36 -0300 Subject: [PATCH 04/14] CI fixes --- osu.Desktop.VisualTests/Tests/TestCaseUserPanel.cs | 8 ++++---- osu.Game/Users/UserStatus.cs | 12 ++++++------ 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/osu.Desktop.VisualTests/Tests/TestCaseUserPanel.cs b/osu.Desktop.VisualTests/Tests/TestCaseUserPanel.cs index d783d42f1f..f7f0f8b24a 100644 --- a/osu.Desktop.VisualTests/Tests/TestCaseUserPanel.cs +++ b/osu.Desktop.VisualTests/Tests/TestCaseUserPanel.cs @@ -10,10 +10,10 @@ using OpenTK; namespace osu.Desktop.VisualTests.Tests { - internal class TestCaseUserPanel : TestCase - { - public override string Description => @"Panels for displaying a user's status"; - + internal class TestCaseUserPanel : TestCase + { + public override string Description => @"Panels for displaying a user's status"; + public override void Reset() { base.Reset(); diff --git a/osu.Game/Users/UserStatus.cs b/osu.Game/Users/UserStatus.cs index 97ee47423e..0ff8333c24 100644 --- a/osu.Game/Users/UserStatus.cs +++ b/osu.Game/Users/UserStatus.cs @@ -24,7 +24,7 @@ namespace osu.Game.Users public class UserStatusOffline : UserStatus { - public override string Message => @"Offline"; + public override string Message => @"Offline"; public override Color4 Colour(OsuColour colours) => colours.Gray7; } @@ -35,27 +35,27 @@ namespace osu.Game.Users public class UserStatusSpectating : UserStatusAvailable { - public override string Message => @"Spectating a game"; + public override string Message => @"Spectating a game"; } public class UserStatusInLobby : UserStatusAvailable { - public override string Message => @"in Multiplayer Lobby"; + public override string Message => @"in Multiplayer Lobby"; } public class UserStatusSoloGame : UserStatusBusy { - public override string Message => @"Solo Game"; + public override string Message => @"Solo Game"; } public class UserStatusMultiplayerGame: UserStatusBusy { - public override string Message => @"Multiplaying"; + public override string Message => @"Multiplaying"; } public class UserStatusModding : UserStatus { - public override string Message => @"Modding a map"; + public override string Message => @"Modding a map"; public override Color4 Colour(OsuColour colours) => colours.PurpleDark; } } From 62ca76bc4188f5241fa222b7e4ac971c449b9c3f Mon Sep 17 00:00:00 2001 From: DrabWeb Date: Mon, 22 May 2017 03:42:32 -0300 Subject: [PATCH 05/14] Unused using --- osu.Desktop.VisualTests/Tests/TestCaseUserPanel.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/osu.Desktop.VisualTests/Tests/TestCaseUserPanel.cs b/osu.Desktop.VisualTests/Tests/TestCaseUserPanel.cs index f7f0f8b24a..7c2745ee0f 100644 --- a/osu.Desktop.VisualTests/Tests/TestCaseUserPanel.cs +++ b/osu.Desktop.VisualTests/Tests/TestCaseUserPanel.cs @@ -3,7 +3,6 @@ using osu.Framework.Testing; using osu.Framework.Graphics; -using osu.Game.Graphics.UserInterface; using osu.Game.Users; using osu.Framework.Graphics.Containers; using OpenTK; From 35814e47e46bdd0df6f98d43b91a72e58a96eb91 Mon Sep 17 00:00:00 2001 From: DrabWeb Date: Mon, 22 May 2017 12:37:19 -0300 Subject: [PATCH 06/14] Colour -> GetAppropriateColour, adjust status change transition --- osu.Game/Users/UserPanel.cs | 4 ++-- osu.Game/Users/UserStatus.cs | 14 +++++++------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/osu.Game/Users/UserPanel.cs b/osu.Game/Users/UserPanel.cs index 4de309fb62..745fd166f8 100644 --- a/osu.Game/Users/UserPanel.cs +++ b/osu.Game/Users/UserPanel.cs @@ -78,7 +78,7 @@ namespace osu.Game.Users new Container { RelativeSizeAxes = Axes.Both, - Margin = new MarginPadding { Left = height - status_height - content_padding }, + Padding = new MarginPadding { Left = height - status_height - content_padding }, Children = new Drawable[] { new OsuSpriteText @@ -179,7 +179,7 @@ namespace osu.Game.Users private void displayStatus(UserStatus status) { - statusBg.FadeColour(status.Colour(colours), 200); + statusBg.FadeColour(status.GetAppropriateColour(colours), 500, EasingTypes.OutQuint); statusMessage.Text = status.Message; } } diff --git a/osu.Game/Users/UserStatus.cs b/osu.Game/Users/UserStatus.cs index 0ff8333c24..dcb5ccbd8f 100644 --- a/osu.Game/Users/UserStatus.cs +++ b/osu.Game/Users/UserStatus.cs @@ -9,23 +9,23 @@ namespace osu.Game.Users public abstract class UserStatus { public abstract string Message { get; } - public abstract Color4 Colour(OsuColour colours); + public abstract Color4 GetAppropriateColour(OsuColour colours); } public abstract class UserStatusAvailable : UserStatus { - public override Color4 Colour(OsuColour colours) => colours.BlueDarker; + public override Color4 GetAppropriateColour(OsuColour colours) => colours.BlueDarker; } public abstract class UserStatusBusy : UserStatus { - public override Color4 Colour(OsuColour colours) => colours.YellowDark; + public override Color4 GetAppropriateColour(OsuColour colours) => colours.YellowDark; } - public class UserStatusOffline : UserStatus - { + public class UserStatusOffline : UserStatus + { public override string Message => @"Offline"; - public override Color4 Colour(OsuColour colours) => colours.Gray7; + public override Color4 GetAppropriateColour(OsuColour colours) => colours.Gray7; } public class UserStatusOnline : UserStatusAvailable @@ -56,6 +56,6 @@ namespace osu.Game.Users public class UserStatusModding : UserStatus { public override string Message => @"Modding a map"; - public override Color4 Colour(OsuColour colours) => colours.PurpleDark; + public override Color4 GetAppropriateColour(OsuColour colours) => colours.PurpleDark; } } From 261ea4c1767c85931e5f7ebef1062fe746fd7f31 Mon Sep 17 00:00:00 2001 From: DrabWeb Date: Mon, 22 May 2017 12:41:59 -0300 Subject: [PATCH 07/14] CoverBackgroundSprite for actually async cover loading --- osu.Game/Users/UserPanel.cs | 36 ++++++++++++++++++++++++++---------- 1 file changed, 26 insertions(+), 10 deletions(-) diff --git a/osu.Game/Users/UserPanel.cs b/osu.Game/Users/UserPanel.cs index 745fd166f8..81e28e2735 100644 --- a/osu.Game/Users/UserPanel.cs +++ b/osu.Game/Users/UserPanel.cs @@ -159,22 +159,21 @@ namespace osu.Game.Users }, }; + cover.Add(new AsyncLoadWrapper(new CoverBackgroundSprite(user) + { + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + FillMode = FillMode.Fill, + OnLoadComplete = d => d.FadeInFromZero(200), + }) { RelativeSizeAxes = Axes.Both }); + Status.ValueChanged += displayStatus; } [BackgroundDependencyLoader] - private void load(OsuColour colours, TextureStore textures) + private void load(OsuColour colours) { this.colours = colours; - - cover.Add(new AsyncLoadWrapper(new Sprite - { - Anchor = Anchor.Centre, - Origin = Anchor.Centre, - Texture = textures.Get(user.CoverUrl), - FillMode = FillMode.Fill, - OnLoadComplete = d => d.FadeInFromZero(200), - }) { RelativeSizeAxes = Axes.Both }); } private void displayStatus(UserStatus status) @@ -182,5 +181,22 @@ namespace osu.Game.Users statusBg.FadeColour(status.GetAppropriateColour(colours), 500, EasingTypes.OutQuint); statusMessage.Text = status.Message; } + + private class CoverBackgroundSprite : Sprite + { + private readonly User user; + + public CoverBackgroundSprite(User user) + { + this.user = user; + } + + [BackgroundDependencyLoader] + private void load(TextureStore textures) + { + if (!string.IsNullOrEmpty(user.CoverUrl)) + Texture = textures.Get(user.CoverUrl); + } + } } } From 8b505a9e8b2458beefbeab5efe017026df6c7e87 Mon Sep 17 00:00:00 2001 From: DrabWeb Date: Mon, 22 May 2017 13:06:52 -0300 Subject: [PATCH 08/14] Remove tab character --- osu.Game/Users/UserPanel.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/osu.Game/Users/UserPanel.cs b/osu.Game/Users/UserPanel.cs index 81e28e2735..6eff471989 100644 --- a/osu.Game/Users/UserPanel.cs +++ b/osu.Game/Users/UserPanel.cs @@ -159,9 +159,9 @@ namespace osu.Game.Users }, }; - cover.Add(new AsyncLoadWrapper(new CoverBackgroundSprite(user) - { - Anchor = Anchor.Centre, + cover.Add(new AsyncLoadWrapper(new CoverBackgroundSprite(user) + { + Anchor = Anchor.Centre, Origin = Anchor.Centre, FillMode = FillMode.Fill, OnLoadComplete = d => d.FadeInFromZero(200), From 4681beab5d2c64ccf1b958378dceb3eb0c4736f0 Mon Sep 17 00:00:00 2001 From: DrabWeb Date: Mon, 22 May 2017 13:22:14 -0300 Subject: [PATCH 09/14] CI fixes --- osu.Game/Users/UserPanel.cs | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/osu.Game/Users/UserPanel.cs b/osu.Game/Users/UserPanel.cs index 6eff471989..3502443d49 100644 --- a/osu.Game/Users/UserPanel.cs +++ b/osu.Game/Users/UserPanel.cs @@ -21,10 +21,8 @@ namespace osu.Game.Users private const float content_padding = 10; private const float status_height = 30; - private readonly User user; private OsuColour colours; - private readonly Container cover; private readonly Box statusBg; private readonly OsuSpriteText statusMessage; @@ -32,8 +30,6 @@ namespace osu.Game.Users public UserPanel(User user) { - this.user = user; - Width = 300; Height = height; Masking = true; @@ -45,6 +41,7 @@ namespace osu.Game.Users Radius = 4, }; + Container cover; Children = new Drawable[] { cover = new Container From 247d8e9b21edb038de7a7869c349d5797d34f92e Mon Sep 17 00:00:00 2001 From: DrabWeb Date: Wed, 24 May 2017 00:23:48 -0300 Subject: [PATCH 10/14] Replace "Connected as _" in login form with a UserPanel --- osu.Desktop.VisualTests/Tests/TestCaseUserPanel.cs | 4 ++-- .../Overlays/Settings/Sections/General/LoginSettings.cs | 7 +++++-- osu.Game/Users/UserPanel.cs | 1 - 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/osu.Desktop.VisualTests/Tests/TestCaseUserPanel.cs b/osu.Desktop.VisualTests/Tests/TestCaseUserPanel.cs index 7c2745ee0f..254c5bc243 100644 --- a/osu.Desktop.VisualTests/Tests/TestCaseUserPanel.cs +++ b/osu.Desktop.VisualTests/Tests/TestCaseUserPanel.cs @@ -33,14 +33,14 @@ namespace osu.Desktop.VisualTests.Tests Id = 3103765, Country = new Country { FlagName = @"JP" }, CoverUrl = @"https://assets.ppy.sh/user-profile-covers/3103765/5b012e13611d5761caa7e24fecb3d3a16e1cf48fc2a3032cfd43dd444af83d82.jpeg" - }), + }) { Width = 300 }, peppy = new UserPanel(new User { Username = @"peppy", Id = 2, Country = new Country { FlagName = @"AU" }, CoverUrl = @"https://assets.ppy.sh/user-profile-covers/2/08cad88747c235a64fca5f1b770e100f120827ded1ffe3b66bfcd19c940afa65.jpeg" - }), + }) { Width = 300 }, }, }); diff --git a/osu.Game/Overlays/Settings/Sections/General/LoginSettings.cs b/osu.Game/Overlays/Settings/Sections/General/LoginSettings.cs index 86a47d8a95..73521a31c3 100644 --- a/osu.Game/Overlays/Settings/Sections/General/LoginSettings.cs +++ b/osu.Game/Overlays/Settings/Sections/General/LoginSettings.cs @@ -12,6 +12,7 @@ using osu.Game.Graphics.UserInterface; using osu.Game.Online.API; using OpenTK; using osu.Framework.Input; +using osu.Game.Users; namespace osu.Game.Overlays.Settings.Sections.General { @@ -71,11 +72,12 @@ namespace osu.Game.Overlays.Settings.Sections.General }; break; case APIState.Online: + UserPanel p; Children = new Drawable[] { - new OsuSpriteText + p = new UserPanel(api.LocalUser.Value) { - Text = $"Connected as {api.Username}!", + RelativeSizeAxes = Axes.X, }, new OsuButton { @@ -84,6 +86,7 @@ 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 3502443d49..f32158e00b 100644 --- a/osu.Game/Users/UserPanel.cs +++ b/osu.Game/Users/UserPanel.cs @@ -30,7 +30,6 @@ namespace osu.Game.Users public UserPanel(User user) { - Width = 300; Height = height; Masking = true; CornerRadius = 5; From 2be1b00a766d063305575522f345183eb64dd81f Mon Sep 17 00:00:00 2001 From: DrabWeb Date: Wed, 24 May 2017 00:45:56 -0300 Subject: [PATCH 11/14] 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; } From 7c6540b008b568b5647cf330194342c20f3ee7c1 Mon Sep 17 00:00:00 2001 From: DrabWeb Date: Wed, 24 May 2017 03:49:06 -0300 Subject: [PATCH 12/14] Cleanup status transition code --- osu.Game/Users/UserPanel.cs | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/osu.Game/Users/UserPanel.cs b/osu.Game/Users/UserPanel.cs index df37b339c3..7a6fdda825 100644 --- a/osu.Game/Users/UserPanel.cs +++ b/osu.Game/Users/UserPanel.cs @@ -176,13 +176,23 @@ 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; + float transition_duration = 500; - statusBg.FadeColour(status.GetAppropriateColour(colours), 500, EasingTypes.OutQuint); - statusMessage.Text = status.Message; + if (status == null) + { + statusBar.ResizeHeightTo(0f, transition_duration, EasingTypes.OutQuint); + statusBar.FadeOut(transition_duration, EasingTypes.OutQuint); + ResizeHeightTo(height - status_height, transition_duration, EasingTypes.OutQuint); + } + else + { + statusBar.ResizeHeightTo(status_height, transition_duration, EasingTypes.OutQuint); + statusBar.FadeIn(transition_duration, EasingTypes.OutQuint); + ResizeHeightTo(height, transition_duration, EasingTypes.OutQuint); + + statusBg.FadeColour(status.GetAppropriateColour(colours), 500, EasingTypes.OutQuint); + statusMessage.Text = status.Message; + } } private class CoverBackgroundSprite : Sprite From a7914dc1e837f4e47c7f07766067e64e24321845 Mon Sep 17 00:00:00 2001 From: DrabWeb Date: Wed, 24 May 2017 04:00:39 -0300 Subject: [PATCH 13/14] Convert transition_duration to const --- osu.Game/Users/UserPanel.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Users/UserPanel.cs b/osu.Game/Users/UserPanel.cs index 7a6fdda825..f7714fd819 100644 --- a/osu.Game/Users/UserPanel.cs +++ b/osu.Game/Users/UserPanel.cs @@ -176,7 +176,7 @@ namespace osu.Game.Users private void displayStatus(UserStatus status) { - float transition_duration = 500; + const float transition_duration = 500; if (status == null) { From ca6a9b1b71432f3ed68f9cdf3185687b69d6fd28 Mon Sep 17 00:00:00 2001 From: DrabWeb Date: Wed, 24 May 2017 04:21:34 -0300 Subject: [PATCH 14/14] Inline cover --- osu.Game/Users/UserPanel.cs | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/osu.Game/Users/UserPanel.cs b/osu.Game/Users/UserPanel.cs index f7714fd819..c78a69dac8 100644 --- a/osu.Game/Users/UserPanel.cs +++ b/osu.Game/Users/UserPanel.cs @@ -41,13 +41,15 @@ namespace osu.Game.Users Radius = 4, }; - Container cover; Children = new Drawable[] { - cover = new Container + new AsyncLoadWrapper(new CoverBackgroundSprite(user) { - RelativeSizeAxes = Axes.Both, - }, + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + FillMode = FillMode.Fill, + OnLoadComplete = d => d.FadeInFromZero(200), + }) { RelativeSizeAxes = Axes.Both }, new Box { RelativeSizeAxes = Axes.Both, @@ -157,14 +159,6 @@ namespace osu.Game.Users }, }; - cover.Add(new AsyncLoadWrapper(new CoverBackgroundSprite(user) - { - Anchor = Anchor.Centre, - Origin = Anchor.Centre, - FillMode = FillMode.Fill, - OnLoadComplete = d => d.FadeInFromZero(200), - }) { RelativeSizeAxes = Axes.Both }); - Status.ValueChanged += displayStatus; }