From 9bc1eece0a65da71a3a7e99dc780f4f8deea7bd1 Mon Sep 17 00:00:00 2001 From: Huo Yaoyuan Date: Thu, 25 May 2017 02:11:07 +0800 Subject: [PATCH 001/106] Basic section management of userpage. --- osu.Game/Overlays/UserPage/UserPageHeader.cs | 16 ++++++ osu.Game/Overlays/UserPage/UserPageSection.cs | 19 +++++++ osu.Game/Overlays/UserPageOverlay.cs | 54 +++++++++++++++++++ osu.Game/osu.Game.csproj | 3 ++ 4 files changed, 92 insertions(+) create mode 100644 osu.Game/Overlays/UserPage/UserPageHeader.cs create mode 100644 osu.Game/Overlays/UserPage/UserPageSection.cs create mode 100644 osu.Game/Overlays/UserPageOverlay.cs diff --git a/osu.Game/Overlays/UserPage/UserPageHeader.cs b/osu.Game/Overlays/UserPage/UserPageHeader.cs new file mode 100644 index 0000000000..9982d18d07 --- /dev/null +++ b/osu.Game/Overlays/UserPage/UserPageHeader.cs @@ -0,0 +1,16 @@ +// Copyright (c) 2007-2017 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using osu.Framework.Graphics.Containers; + +namespace osu.Game.Overlays.UserPage +{ + public class UserPageHeader : Container + { + } +} diff --git a/osu.Game/Overlays/UserPage/UserPageSection.cs b/osu.Game/Overlays/UserPage/UserPageSection.cs new file mode 100644 index 0000000000..77202d6aef --- /dev/null +++ b/osu.Game/Overlays/UserPage/UserPageSection.cs @@ -0,0 +1,19 @@ +// Copyright (c) 2007-2017 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using osu.Framework.Graphics.Containers; +using osu.Game.Users; + +namespace osu.Game.Overlays.UserPage +{ + public abstract class UserPageSection : Container + { + protected readonly User User; + public abstract string Title { get; } + + protected UserPageSection(User user) + { + User = user; + } + } +} diff --git a/osu.Game/Overlays/UserPageOverlay.cs b/osu.Game/Overlays/UserPageOverlay.cs new file mode 100644 index 0000000000..1e0d672c22 --- /dev/null +++ b/osu.Game/Overlays/UserPageOverlay.cs @@ -0,0 +1,54 @@ +// Copyright (c) 2007-2017 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using osu.Framework.Graphics.Containers; +using osu.Game.Graphics.Containers; +using osu.Game.Graphics.UserInterface; +using osu.Game.Overlays.UserPage; +using osu.Game.Users; + +namespace osu.Game.Overlays +{ + public class UserPageOverlay : FocusedOverlayContainer + { + private readonly User user; + private UserPageSection lastSection; + public UserPageOverlay(User user) + { + this.user = user; + var tab = new OsuTabControl(); + var sections = new UserPageSection[] { }; + var sectionsContainer = new SectionsContainer + { + ExpandableHeader = new UserPageHeader(), + FixedHeader = tab, + Sections = sections + }; + + Add(sectionsContainer); + + sectionsContainer.SelectedSection.ValueChanged += s => + { + if (lastSection != s) + { + lastSection = s as UserPageSection; + tab.Current.Value = lastSection; + } + }; + + tab.Current.ValueChanged += s => + { + if (lastSection != s) + { + lastSection = s; + sectionsContainer.ScrollContainer.ScrollIntoView(lastSection); + } + }; + } + } +} diff --git a/osu.Game/osu.Game.csproj b/osu.Game/osu.Game.csproj index 98fb4b9707..3e2d86dfaa 100644 --- a/osu.Game/osu.Game.csproj +++ b/osu.Game/osu.Game.csproj @@ -85,6 +85,9 @@ + + + From 159e8d84c2fed23eeb5377debe90ca8c15c7c91a Mon Sep 17 00:00:00 2001 From: Huo Yaoyuan Date: Sat, 27 May 2017 23:37:15 +0800 Subject: [PATCH 002/106] Move namespace and make cover background public. --- osu.Game/Users/UserCoverBackground.cs | 26 +++++++++++++++++++ .../UserPage/UserPageHeader.cs | 7 ++++- .../UserPage/UserPageSection.cs | 3 +-- .../{Overlays => Users}/UserPageOverlay.cs | 7 +++-- osu.Game/Users/UserPanel.cs | 20 +------------- osu.Game/osu.Game.csproj | 7 ++--- 6 files changed, 41 insertions(+), 29 deletions(-) create mode 100644 osu.Game/Users/UserCoverBackground.cs rename osu.Game/{Overlays => Users}/UserPage/UserPageHeader.cs (67%) rename osu.Game/{Overlays => Users}/UserPage/UserPageSection.cs (84%) rename osu.Game/{Overlays => Users}/UserPageOverlay.cs (88%) diff --git a/osu.Game/Users/UserCoverBackground.cs b/osu.Game/Users/UserCoverBackground.cs new file mode 100644 index 0000000000..c0f0d09d9d --- /dev/null +++ b/osu.Game/Users/UserCoverBackground.cs @@ -0,0 +1,26 @@ +// Copyright (c) 2007-2017 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using osu.Framework.Allocation; +using osu.Framework.Graphics.Sprites; +using osu.Framework.Graphics.Textures; + +namespace osu.Game.Users +{ + public class UserCoverBackground : Sprite + { + private readonly User user; + + public UserCoverBackground(User user) + { + this.user = user; + } + + [BackgroundDependencyLoader] + private void load(TextureStore textures) + { + if (!string.IsNullOrEmpty(user.CoverUrl)) + Texture = textures.Get(user.CoverUrl); + } + } +} diff --git a/osu.Game/Overlays/UserPage/UserPageHeader.cs b/osu.Game/Users/UserPage/UserPageHeader.cs similarity index 67% rename from osu.Game/Overlays/UserPage/UserPageHeader.cs rename to osu.Game/Users/UserPage/UserPageHeader.cs index 9982d18d07..872088fbef 100644 --- a/osu.Game/Overlays/UserPage/UserPageHeader.cs +++ b/osu.Game/Users/UserPage/UserPageHeader.cs @@ -8,9 +8,14 @@ using System.Text; using System.Threading.Tasks; using osu.Framework.Graphics.Containers; -namespace osu.Game.Overlays.UserPage +namespace osu.Game.Users.UserPage { public class UserPageHeader : Container { + private readonly User user; + public UserPageHeader(User user) + { + this.user = user; + } } } diff --git a/osu.Game/Overlays/UserPage/UserPageSection.cs b/osu.Game/Users/UserPage/UserPageSection.cs similarity index 84% rename from osu.Game/Overlays/UserPage/UserPageSection.cs rename to osu.Game/Users/UserPage/UserPageSection.cs index 77202d6aef..cb73218c05 100644 --- a/osu.Game/Overlays/UserPage/UserPageSection.cs +++ b/osu.Game/Users/UserPage/UserPageSection.cs @@ -2,9 +2,8 @@ // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE using osu.Framework.Graphics.Containers; -using osu.Game.Users; -namespace osu.Game.Overlays.UserPage +namespace osu.Game.Users.UserPage { public abstract class UserPageSection : Container { diff --git a/osu.Game/Overlays/UserPageOverlay.cs b/osu.Game/Users/UserPageOverlay.cs similarity index 88% rename from osu.Game/Overlays/UserPageOverlay.cs rename to osu.Game/Users/UserPageOverlay.cs index 1e0d672c22..c7b49433d7 100644 --- a/osu.Game/Overlays/UserPageOverlay.cs +++ b/osu.Game/Users/UserPageOverlay.cs @@ -9,10 +9,9 @@ using System.Threading.Tasks; using osu.Framework.Graphics.Containers; using osu.Game.Graphics.Containers; using osu.Game.Graphics.UserInterface; -using osu.Game.Overlays.UserPage; -using osu.Game.Users; +using osu.Game.Users.UserPage; -namespace osu.Game.Overlays +namespace osu.Game.Users { public class UserPageOverlay : FocusedOverlayContainer { @@ -25,7 +24,7 @@ namespace osu.Game.Overlays var sections = new UserPageSection[] { }; var sectionsContainer = new SectionsContainer { - ExpandableHeader = new UserPageHeader(), + ExpandableHeader = new UserPageHeader(user), FixedHeader = tab, Sections = sections }; diff --git a/osu.Game/Users/UserPanel.cs b/osu.Game/Users/UserPanel.cs index bdfe6d1c8e..0ef56f5060 100644 --- a/osu.Game/Users/UserPanel.cs +++ b/osu.Game/Users/UserPanel.cs @@ -9,7 +9,6 @@ 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; @@ -43,7 +42,7 @@ namespace osu.Game.Users Children = new Drawable[] { - new AsyncLoadWrapper(new CoverBackgroundSprite(user) + new AsyncLoadWrapper(new UserCoverBackground(user) { Anchor = Anchor.Centre, Origin = Anchor.Centre, @@ -193,22 +192,5 @@ namespace osu.Game.Users 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); - } - } } } diff --git a/osu.Game/osu.Game.csproj b/osu.Game/osu.Game.csproj index 5261219422..049f4e14f3 100644 --- a/osu.Game/osu.Game.csproj +++ b/osu.Game/osu.Game.csproj @@ -85,9 +85,10 @@ - - - + + + + From 1b8ef3bbbdd64f6d9ea17fedfb6be918f09a25f2 Mon Sep 17 00:00:00 2001 From: Huo Yaoyuan Date: Mon, 5 Jun 2017 21:04:35 +0800 Subject: [PATCH 003/106] Add test case for UserPage. --- .../Tests/TestCaseUserPage.cs | 38 +++++++++++++++++++ .../osu.Desktop.VisualTests.csproj | 1 + osu.Game/Users/UserPageOverlay.cs | 2 + 3 files changed, 41 insertions(+) create mode 100644 osu.Desktop.VisualTests/Tests/TestCaseUserPage.cs diff --git a/osu.Desktop.VisualTests/Tests/TestCaseUserPage.cs b/osu.Desktop.VisualTests/Tests/TestCaseUserPage.cs new file mode 100644 index 0000000000..24b196f4f3 --- /dev/null +++ b/osu.Desktop.VisualTests/Tests/TestCaseUserPage.cs @@ -0,0 +1,38 @@ +// Copyright (c) 2007-2017 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using osu.Framework.Graphics; +using osu.Framework.Testing; +using osu.Game.Overlays; +using osu.Game.Users; + +namespace osu.Desktop.VisualTests.Tests +{ + internal class TestCaseUserPage : TestCase + { + public override void Reset() + { + base.Reset(); + var userpage = new UserPageOverlay(new User + { + Username = @"peppy", + Id = 2, + Country = new Country { FlagName = @"AU" }, + CoverUrl = @"https://osu.ppy.sh/images/headers/profile-covers/c3.jpg" + }) + { + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + Width = 800, + Height = 500 + }; + Add(userpage); + AddStep("Toggle", userpage.ToggleVisibility); + } + } +} diff --git a/osu.Desktop.VisualTests/osu.Desktop.VisualTests.csproj b/osu.Desktop.VisualTests/osu.Desktop.VisualTests.csproj index 7b7997063b..d5b6b1a91d 100644 --- a/osu.Desktop.VisualTests/osu.Desktop.VisualTests.csproj +++ b/osu.Desktop.VisualTests/osu.Desktop.VisualTests.csproj @@ -210,6 +210,7 @@ + diff --git a/osu.Game/Users/UserPageOverlay.cs b/osu.Game/Users/UserPageOverlay.cs index c7b49433d7..c192e95f35 100644 --- a/osu.Game/Users/UserPageOverlay.cs +++ b/osu.Game/Users/UserPageOverlay.cs @@ -6,6 +6,7 @@ using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; +using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Game.Graphics.Containers; using osu.Game.Graphics.UserInterface; @@ -24,6 +25,7 @@ namespace osu.Game.Users var sections = new UserPageSection[] { }; var sectionsContainer = new SectionsContainer { + RelativeSizeAxes = Axes.Both, ExpandableHeader = new UserPageHeader(user), FixedHeader = tab, Sections = sections From 428b44f7d96ce4cf038fd4a822ab2b1759626b6d Mon Sep 17 00:00:00 2001 From: Huo Yaoyuan Date: Mon, 5 Jun 2017 21:07:57 +0800 Subject: [PATCH 004/106] UserPage -> Profile. --- ...{TestCaseUserPage.cs => TestCaseUserProfile.cs} | 4 ++-- .../osu.Desktop.VisualTests.csproj | 2 +- .../UserPageHeader.cs => Profile/ProfileHeader.cs} | 2 +- .../ProfileSection.cs} | 6 +++--- .../Users/{UserPageOverlay.cs => UserProfile.cs} | 14 +++++++------- osu.Game/osu.Game.csproj | 6 +++--- 6 files changed, 17 insertions(+), 17 deletions(-) rename osu.Desktop.VisualTests/Tests/{TestCaseUserPage.cs => TestCaseUserProfile.cs} (87%) rename osu.Game/Users/{UserPage/UserPageHeader.cs => Profile/ProfileHeader.cs} (90%) rename osu.Game/Users/{UserPage/UserPageSection.cs => Profile/ProfileSection.cs} (69%) rename osu.Game/Users/{UserPageOverlay.cs => UserProfile.cs} (76%) diff --git a/osu.Desktop.VisualTests/Tests/TestCaseUserPage.cs b/osu.Desktop.VisualTests/Tests/TestCaseUserProfile.cs similarity index 87% rename from osu.Desktop.VisualTests/Tests/TestCaseUserPage.cs rename to osu.Desktop.VisualTests/Tests/TestCaseUserProfile.cs index 24b196f4f3..67b89311e6 100644 --- a/osu.Desktop.VisualTests/Tests/TestCaseUserPage.cs +++ b/osu.Desktop.VisualTests/Tests/TestCaseUserProfile.cs @@ -13,12 +13,12 @@ using osu.Game.Users; namespace osu.Desktop.VisualTests.Tests { - internal class TestCaseUserPage : TestCase + internal class TestCaseUserProfile : TestCase { public override void Reset() { base.Reset(); - var userpage = new UserPageOverlay(new User + var userpage = new UserProfile(new User { Username = @"peppy", Id = 2, diff --git a/osu.Desktop.VisualTests/osu.Desktop.VisualTests.csproj b/osu.Desktop.VisualTests/osu.Desktop.VisualTests.csproj index d5b6b1a91d..3886239bf9 100644 --- a/osu.Desktop.VisualTests/osu.Desktop.VisualTests.csproj +++ b/osu.Desktop.VisualTests/osu.Desktop.VisualTests.csproj @@ -210,7 +210,7 @@ - + diff --git a/osu.Game/Users/UserPage/UserPageHeader.cs b/osu.Game/Users/Profile/ProfileHeader.cs similarity index 90% rename from osu.Game/Users/UserPage/UserPageHeader.cs rename to osu.Game/Users/Profile/ProfileHeader.cs index 872088fbef..5a8d982a11 100644 --- a/osu.Game/Users/UserPage/UserPageHeader.cs +++ b/osu.Game/Users/Profile/ProfileHeader.cs @@ -8,7 +8,7 @@ using System.Text; using System.Threading.Tasks; using osu.Framework.Graphics.Containers; -namespace osu.Game.Users.UserPage +namespace osu.Game.Users.Profile { public class UserPageHeader : Container { diff --git a/osu.Game/Users/UserPage/UserPageSection.cs b/osu.Game/Users/Profile/ProfileSection.cs similarity index 69% rename from osu.Game/Users/UserPage/UserPageSection.cs rename to osu.Game/Users/Profile/ProfileSection.cs index cb73218c05..ce362109cc 100644 --- a/osu.Game/Users/UserPage/UserPageSection.cs +++ b/osu.Game/Users/Profile/ProfileSection.cs @@ -3,14 +3,14 @@ using osu.Framework.Graphics.Containers; -namespace osu.Game.Users.UserPage +namespace osu.Game.Users.Profile { - public abstract class UserPageSection : Container + public abstract class ProfileSection : Container { protected readonly User User; public abstract string Title { get; } - protected UserPageSection(User user) + protected ProfileSection(User user) { User = user; } diff --git a/osu.Game/Users/UserPageOverlay.cs b/osu.Game/Users/UserProfile.cs similarity index 76% rename from osu.Game/Users/UserPageOverlay.cs rename to osu.Game/Users/UserProfile.cs index c192e95f35..497d8e0002 100644 --- a/osu.Game/Users/UserPageOverlay.cs +++ b/osu.Game/Users/UserProfile.cs @@ -10,19 +10,19 @@ using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Game.Graphics.Containers; using osu.Game.Graphics.UserInterface; -using osu.Game.Users.UserPage; +using osu.Game.Users.Profile; namespace osu.Game.Users { - public class UserPageOverlay : FocusedOverlayContainer + public class UserProfile : FocusedOverlayContainer { private readonly User user; - private UserPageSection lastSection; - public UserPageOverlay(User user) + private ProfileSection lastSection; + public UserProfile(User user) { this.user = user; - var tab = new OsuTabControl(); - var sections = new UserPageSection[] { }; + var tab = new OsuTabControl(); + var sections = new ProfileSection[] { }; var sectionsContainer = new SectionsContainer { RelativeSizeAxes = Axes.Both, @@ -37,7 +37,7 @@ namespace osu.Game.Users { if (lastSection != s) { - lastSection = s as UserPageSection; + lastSection = s as ProfileSection; tab.Current.Value = lastSection; } }; diff --git a/osu.Game/osu.Game.csproj b/osu.Game/osu.Game.csproj index 049f4e14f3..ce5e1b6667 100644 --- a/osu.Game/osu.Game.csproj +++ b/osu.Game/osu.Game.csproj @@ -86,9 +86,9 @@ - - - + + + From 7d4c5999f663cccc47f84211d7ac58bf838c1bbc Mon Sep 17 00:00:00 2001 From: Huo Yaoyuan Date: Mon, 5 Jun 2017 21:20:04 +0800 Subject: [PATCH 005/106] Add description in test case. --- osu.Desktop.VisualTests/Tests/TestCaseUserProfile.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/osu.Desktop.VisualTests/Tests/TestCaseUserProfile.cs b/osu.Desktop.VisualTests/Tests/TestCaseUserProfile.cs index 67b89311e6..9eea2cbf19 100644 --- a/osu.Desktop.VisualTests/Tests/TestCaseUserProfile.cs +++ b/osu.Desktop.VisualTests/Tests/TestCaseUserProfile.cs @@ -15,6 +15,8 @@ namespace osu.Desktop.VisualTests.Tests { internal class TestCaseUserProfile : TestCase { + public override string Description => "Tests user's profile page."; + public override void Reset() { base.Reset(); From a09d873db9c53803eeb2d7d51fd9d860be5a7668 Mon Sep 17 00:00:00 2001 From: Huo Yaoyuan Date: Tue, 6 Jun 2017 11:25:16 +0800 Subject: [PATCH 006/106] Basic member of profile header. --- osu.Game/Users/Profile/ProfileHeader.cs | 76 +++++++++++++++++++++++-- osu.Game/Users/UserProfile.cs | 8 +-- 2 files changed, 74 insertions(+), 10 deletions(-) diff --git a/osu.Game/Users/Profile/ProfileHeader.cs b/osu.Game/Users/Profile/ProfileHeader.cs index 5a8d982a11..03c0d0f656 100644 --- a/osu.Game/Users/Profile/ProfileHeader.cs +++ b/osu.Game/Users/Profile/ProfileHeader.cs @@ -1,21 +1,87 @@ // Copyright (c) 2007-2017 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; +using OpenTK; +using OpenTK.Graphics; +using osu.Framework.Extensions.Color4Extensions; +using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; +using osu.Game.Graphics.Sprites; namespace osu.Game.Users.Profile { public class UserPageHeader : Container { private readonly User user; + + private const float cover_height = 200, avatar_size = 110, avatar_bottom_position = -20; public UserPageHeader(User user) { this.user = user; + RelativeSizeAxes = Axes.X; + Height = cover_height; + + Children = new Drawable[] + { + new Container + { + RelativeSizeAxes = Axes.X, + Height = cover_height, + Children = new Drawable[] + { + new AsyncLoadWrapper(new UserCoverBackground(user) + { + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + FillMode = FillMode.Fill, + OnLoadComplete = d => d.FadeInFromZero(200) + }) { RelativeSizeAxes = Axes.Both }, + new UpdateableAvatar + { + User = user, + Size = new Vector2(avatar_size), + Anchor = Anchor.BottomLeft, + Origin = Anchor.BottomLeft, + X = UserProfile.CONTENT_X_MARGIN, + Y = avatar_bottom_position, + Masking = true, + CornerRadius = 5, + EdgeEffect = new EdgeEffect + { + Type = EdgeEffectType.Shadow, + Colour = Color4.Black.Opacity(0.25f), + Radius = 4, + }, + }, + new Container + { + Anchor = Anchor.BottomLeft, + Origin = Anchor.BottomLeft, + X = UserProfile.CONTENT_X_MARGIN + avatar_size + 10, + Y = avatar_bottom_position, + Children = new Drawable[] + { + new OsuSpriteText + { + Text = user.Username, + TextSize = 25, + Font = @"Exo2.0-RegularItalic", + Anchor = Anchor.BottomLeft, + Origin = Anchor.BottomLeft, + Y = -55 + }, + new DrawableFlag(user.Country?.FlagName ?? "__") + { + Anchor = Anchor.BottomLeft, + Origin = Anchor.BottomLeft, + Width = 30, + Height = 20 + } + } + } + } + } + }; } } } diff --git a/osu.Game/Users/UserProfile.cs b/osu.Game/Users/UserProfile.cs index 497d8e0002..b4a7f7d546 100644 --- a/osu.Game/Users/UserProfile.cs +++ b/osu.Game/Users/UserProfile.cs @@ -1,11 +1,6 @@ // Copyright (c) 2007-2017 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Game.Graphics.Containers; @@ -18,6 +13,9 @@ namespace osu.Game.Users { private readonly User user; private ProfileSection lastSection; + + public const float CONTENT_X_MARGIN = 50; + public UserProfile(User user) { this.user = user; From 9f9107b84748bc95d0cb04a29760461557d7739c Mon Sep 17 00:00:00 2001 From: Huo Yaoyuan Date: Wed, 7 Jun 2017 21:15:43 +0800 Subject: [PATCH 007/106] Add gray background. --- osu.Game/Users/UserProfile.cs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/osu.Game/Users/UserProfile.cs b/osu.Game/Users/UserProfile.cs index b4a7f7d546..95447bfe26 100644 --- a/osu.Game/Users/UserProfile.cs +++ b/osu.Game/Users/UserProfile.cs @@ -3,6 +3,8 @@ using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; +using osu.Framework.Graphics.Sprites; +using osu.Game.Graphics; using osu.Game.Graphics.Containers; using osu.Game.Graphics.UserInterface; using osu.Game.Users.Profile; @@ -21,6 +23,13 @@ namespace osu.Game.Users this.user = user; var tab = new OsuTabControl(); var sections = new ProfileSection[] { }; + + Add(new Box + { + RelativeSizeAxes = Axes.Both, + Colour = OsuColour.Gray(0.2f) + }); + var sectionsContainer = new SectionsContainer { RelativeSizeAxes = Axes.Both, @@ -28,7 +37,6 @@ namespace osu.Game.Users FixedHeader = tab, Sections = sections }; - Add(sectionsContainer); sectionsContainer.SelectedSection.ValueChanged += s => From e94d98fa841dca86d7b38dd67f02c57e54f304b8 Mon Sep 17 00:00:00 2001 From: Huo Yaoyuan Date: Wed, 7 Jun 2017 22:11:38 +0800 Subject: [PATCH 008/106] Expose header background for SectionsContainer. --- .../Graphics/Containers/SectionsContainer.cs | 24 +++++++++++++++++-- osu.Game/Overlays/SettingsOverlay.cs | 11 ++++----- osu.Game/Users/Profile/ProfileHeader.cs | 6 ++++- osu.Game/Users/UserProfile.cs | 5 ++++ 4 files changed, 36 insertions(+), 10 deletions(-) diff --git a/osu.Game/Graphics/Containers/SectionsContainer.cs b/osu.Game/Graphics/Containers/SectionsContainer.cs index 5fdb5e869e..fb88f842bd 100644 --- a/osu.Game/Graphics/Containers/SectionsContainer.cs +++ b/osu.Game/Graphics/Containers/SectionsContainer.cs @@ -15,9 +15,9 @@ namespace osu.Game.Graphics.Containers /// public class SectionsContainer : Container { - private Drawable expandableHeader, fixedHeader, footer; + private Drawable expandableHeader, fixedHeader, footer, headerBackground; public readonly ScrollContainer ScrollContainer; - private readonly Container sectionsContainer; + private readonly Container sectionsContainer, headerBackgroundContainer; public Drawable ExpandableHeader { @@ -72,6 +72,22 @@ namespace osu.Game.Graphics.Containers } } + public Drawable HeaderBackground + { + get { return headerBackground; } + set + { + if (value == headerBackground) return; + + headerBackgroundContainer.Clear(); + headerBackground = value; + if (value == null) return; + + headerBackgroundContainer.Add(headerBackground); + lastKnownScroll = float.NaN; + } + } + public Bindable SelectedSection { get; } = new Bindable(); protected virtual Container CreateScrollContentContainer() @@ -120,6 +136,7 @@ namespace osu.Game.Graphics.Containers Masking = false, Children = new Drawable[] { sectionsContainer = CreateScrollContentContainer() } }); + Add(headerBackgroundContainer = new Container { RelativeSizeAxes = Axes.X }); originalSectionsMargin = sectionsContainer.Margin; } @@ -150,6 +167,9 @@ namespace osu.Game.Graphics.Containers fixedHeader.Y = -offset + expandableHeader.LayoutSize.Y; } + headerBackgroundContainer.Height = (ExpandableHeader?.LayoutSize.Y ?? 0) + (FixedHeader?.LayoutSize.Y ?? 0); + headerBackgroundContainer.Y = ExpandableHeader?.Y ?? 0; + Drawable bestMatch = null; float minDiff = float.MaxValue; diff --git a/osu.Game/Overlays/SettingsOverlay.cs b/osu.Game/Overlays/SettingsOverlay.cs index 87f6d836af..88a0e26dde 100644 --- a/osu.Game/Overlays/SettingsOverlay.cs +++ b/osu.Game/Overlays/SettingsOverlay.cs @@ -151,7 +151,6 @@ namespace osu.Game.Overlays private class SettingsSectionsContainer : SectionsContainer { public SearchContainer SearchContainer; - private readonly Box headerBackground; protected override Container CreateScrollContentContainer() => SearchContainer = new SearchContainer @@ -164,11 +163,11 @@ namespace osu.Game.Overlays public SettingsSectionsContainer() { ScrollContainer.ScrollbarVisible = false; - Add(headerBackground = new Box + HeaderBackground = new Box { Colour = Color4.Black, - RelativeSizeAxes = Axes.X - }); + RelativeSizeAxes = Axes.Both + }; } protected override void UpdateAfterChildren() @@ -176,9 +175,7 @@ namespace osu.Game.Overlays base.UpdateAfterChildren(); // no null check because the usage of this class is strict - headerBackground.Height = ExpandableHeader.LayoutSize.Y + FixedHeader.LayoutSize.Y; - headerBackground.Y = ExpandableHeader.Y; - headerBackground.Alpha = -ExpandableHeader.Y / ExpandableHeader.LayoutSize.Y * 0.5f; + HeaderBackground.Alpha = -ExpandableHeader.Y / ExpandableHeader.LayoutSize.Y * 0.5f; } } } diff --git a/osu.Game/Users/Profile/ProfileHeader.cs b/osu.Game/Users/Profile/ProfileHeader.cs index 03c0d0f656..e7a8f45689 100644 --- a/osu.Game/Users/Profile/ProfileHeader.cs +++ b/osu.Game/Users/Profile/ProfileHeader.cs @@ -35,7 +35,11 @@ namespace osu.Game.Users.Profile Origin = Anchor.Centre, FillMode = FillMode.Fill, OnLoadComplete = d => d.FadeInFromZero(200) - }) { RelativeSizeAxes = Axes.Both }, + }) + { + Masking = true, + RelativeSizeAxes = Axes.Both + }, new UpdateableAvatar { User = user, diff --git a/osu.Game/Users/UserProfile.cs b/osu.Game/Users/UserProfile.cs index 95447bfe26..55877f248a 100644 --- a/osu.Game/Users/UserProfile.cs +++ b/osu.Game/Users/UserProfile.cs @@ -35,6 +35,11 @@ namespace osu.Game.Users RelativeSizeAxes = Axes.Both, ExpandableHeader = new UserPageHeader(user), FixedHeader = tab, + HeaderBackground = new Box + { + Colour = OsuColour.Gray(34), + RelativeSizeAxes = Axes.Both + }, Sections = sections }; Add(sectionsContainer); From e3cdb9f6fe254f8b57f6df4c5ac7e6423e3a89dd Mon Sep 17 00:00:00 2001 From: Huo Yaoyuan Date: Wed, 7 Jun 2017 22:49:14 +0800 Subject: [PATCH 009/106] Create section classes. --- osu.Game/Users/Profile/AboutSection.cs | 14 ++++++++++++++ osu.Game/Users/Profile/BeatmapsSection.cs | 14 ++++++++++++++ osu.Game/Users/Profile/HistoricalSection.cs | 14 ++++++++++++++ osu.Game/Users/Profile/KudosuSection.cs | 14 ++++++++++++++ osu.Game/Users/Profile/MedalsSection.cs | 14 ++++++++++++++ osu.Game/Users/Profile/ProfileSection.cs | 2 ++ osu.Game/Users/Profile/RanksSection.cs | 14 ++++++++++++++ osu.Game/Users/Profile/RecentSection.cs | 14 ++++++++++++++ osu.Game/Users/UserProfile.cs | 19 +++++++++++++++++-- osu.Game/osu.Game.csproj | 7 +++++++ 10 files changed, 124 insertions(+), 2 deletions(-) create mode 100644 osu.Game/Users/Profile/AboutSection.cs create mode 100644 osu.Game/Users/Profile/BeatmapsSection.cs create mode 100644 osu.Game/Users/Profile/HistoricalSection.cs create mode 100644 osu.Game/Users/Profile/KudosuSection.cs create mode 100644 osu.Game/Users/Profile/MedalsSection.cs create mode 100644 osu.Game/Users/Profile/RanksSection.cs create mode 100644 osu.Game/Users/Profile/RecentSection.cs diff --git a/osu.Game/Users/Profile/AboutSection.cs b/osu.Game/Users/Profile/AboutSection.cs new file mode 100644 index 0000000000..24a4516441 --- /dev/null +++ b/osu.Game/Users/Profile/AboutSection.cs @@ -0,0 +1,14 @@ +// Copyright (c) 2007-2017 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +namespace osu.Game.Users.Profile +{ + public class AboutSection : ProfileSection + { + public override string Title => "me!"; + + public AboutSection(User user) : base(user) + { + } + } +} diff --git a/osu.Game/Users/Profile/BeatmapsSection.cs b/osu.Game/Users/Profile/BeatmapsSection.cs new file mode 100644 index 0000000000..1377702c4b --- /dev/null +++ b/osu.Game/Users/Profile/BeatmapsSection.cs @@ -0,0 +1,14 @@ +// Copyright (c) 2007-2017 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +namespace osu.Game.Users.Profile +{ + public class BeatmapsSection : ProfileSection + { + public override string Title => "Beatmaps"; + + public BeatmapsSection(User user) : base(user) + { + } + } +} diff --git a/osu.Game/Users/Profile/HistoricalSection.cs b/osu.Game/Users/Profile/HistoricalSection.cs new file mode 100644 index 0000000000..751f91e5bc --- /dev/null +++ b/osu.Game/Users/Profile/HistoricalSection.cs @@ -0,0 +1,14 @@ +// Copyright (c) 2007-2017 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +namespace osu.Game.Users.Profile +{ + public class HistoricalSection : ProfileSection + { + public override string Title => "Historical"; + + public HistoricalSection(User user) : base(user) + { + } + } +} diff --git a/osu.Game/Users/Profile/KudosuSection.cs b/osu.Game/Users/Profile/KudosuSection.cs new file mode 100644 index 0000000000..61986ef5d8 --- /dev/null +++ b/osu.Game/Users/Profile/KudosuSection.cs @@ -0,0 +1,14 @@ +// Copyright (c) 2007-2017 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +namespace osu.Game.Users.Profile +{ + public class KudosuSection : ProfileSection + { + public override string Title => "Kudosu!"; + + public KudosuSection(User user) : base(user) + { + } + } +} diff --git a/osu.Game/Users/Profile/MedalsSection.cs b/osu.Game/Users/Profile/MedalsSection.cs new file mode 100644 index 0000000000..581d5e897c --- /dev/null +++ b/osu.Game/Users/Profile/MedalsSection.cs @@ -0,0 +1,14 @@ +// Copyright (c) 2007-2017 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +namespace osu.Game.Users.Profile +{ + public class MedalsSection : ProfileSection + { + public override string Title => "Medals"; + + public MedalsSection(User user) : base(user) + { + } + } +} diff --git a/osu.Game/Users/Profile/ProfileSection.cs b/osu.Game/Users/Profile/ProfileSection.cs index ce362109cc..904b5d77a3 100644 --- a/osu.Game/Users/Profile/ProfileSection.cs +++ b/osu.Game/Users/Profile/ProfileSection.cs @@ -14,5 +14,7 @@ namespace osu.Game.Users.Profile { User = user; } + + public override string ToString() => Title; //for tab control } } diff --git a/osu.Game/Users/Profile/RanksSection.cs b/osu.Game/Users/Profile/RanksSection.cs new file mode 100644 index 0000000000..450c1461e0 --- /dev/null +++ b/osu.Game/Users/Profile/RanksSection.cs @@ -0,0 +1,14 @@ +// Copyright (c) 2007-2017 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +namespace osu.Game.Users.Profile +{ + public class RanksSection : ProfileSection + { + public override string Title => "Ranks"; + + public RanksSection(User user) : base(user) + { + } + } +} diff --git a/osu.Game/Users/Profile/RecentSection.cs b/osu.Game/Users/Profile/RecentSection.cs new file mode 100644 index 0000000000..5a4e2707f8 --- /dev/null +++ b/osu.Game/Users/Profile/RecentSection.cs @@ -0,0 +1,14 @@ +// Copyright (c) 2007-2017 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +namespace osu.Game.Users.Profile +{ + public class RecentSection : ProfileSection + { + public override string Title => "Recent"; + + public RecentSection(User user) : base(user) + { + } + } +} diff --git a/osu.Game/Users/UserProfile.cs b/osu.Game/Users/UserProfile.cs index 55877f248a..eaa89ce42c 100644 --- a/osu.Game/Users/UserProfile.cs +++ b/osu.Game/Users/UserProfile.cs @@ -1,6 +1,7 @@ // Copyright (c) 2007-2017 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE +using osu.Framework.Extensions.IEnumerableExtensions; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Sprites; @@ -21,8 +22,22 @@ namespace osu.Game.Users public UserProfile(User user) { this.user = user; - var tab = new OsuTabControl(); - var sections = new ProfileSection[] { }; + var sections = new ProfileSection[] + { + new AboutSection(user), + new RecentSection(user), + new RanksSection(user), + new MedalsSection(user), + new HistoricalSection(user), + new BeatmapsSection(user), + new KudosuSection(user) + }; + var tab = new OsuTabControl + { + RelativeSizeAxes = Axes.X, + Height = 24 + }; + sections.ForEach(tab.AddItem); Add(new Box { diff --git a/osu.Game/osu.Game.csproj b/osu.Game/osu.Game.csproj index 1e6fd9b6d8..a452192743 100644 --- a/osu.Game/osu.Game.csproj +++ b/osu.Game/osu.Game.csproj @@ -88,6 +88,13 @@ + + + + + + + From 5033526070bc84db3caab43e324f4555a476b68a Mon Sep 17 00:00:00 2001 From: Huo Yaoyuan Date: Fri, 9 Jun 2017 13:37:55 +0800 Subject: [PATCH 010/106] Fix depth in SectiondContainer. --- osu.Game/Graphics/Containers/SectionsContainer.cs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/osu.Game/Graphics/Containers/SectionsContainer.cs b/osu.Game/Graphics/Containers/SectionsContainer.cs index fb88f842bd..99f43abe24 100644 --- a/osu.Game/Graphics/Containers/SectionsContainer.cs +++ b/osu.Game/Graphics/Containers/SectionsContainer.cs @@ -134,9 +134,14 @@ namespace osu.Game.Graphics.Containers { RelativeSizeAxes = Axes.Both, Masking = false, - Children = new Drawable[] { sectionsContainer = CreateScrollContentContainer() } + Children = new Drawable[] { sectionsContainer = CreateScrollContentContainer() }, + Depth = float.MaxValue + }); + Add(headerBackgroundContainer = new Container + { + RelativeSizeAxes = Axes.X, + Depth = float.MaxValue / 2 }); - Add(headerBackgroundContainer = new Container { RelativeSizeAxes = Axes.X }); originalSectionsMargin = sectionsContainer.Margin; } From c31dd7a480b437a6fe21eb073652c2190a3d2fa7 Mon Sep 17 00:00:00 2001 From: Huo Yaoyuan Date: Fri, 9 Jun 2017 14:25:23 +0800 Subject: [PATCH 011/106] Set position and color for tab control. --- osu.Game/Users/Profile/ProfileSection.cs | 2 -- osu.Game/Users/UserProfile.cs | 42 +++++++++++++++++++++--- 2 files changed, 37 insertions(+), 7 deletions(-) diff --git a/osu.Game/Users/Profile/ProfileSection.cs b/osu.Game/Users/Profile/ProfileSection.cs index 904b5d77a3..ce362109cc 100644 --- a/osu.Game/Users/Profile/ProfileSection.cs +++ b/osu.Game/Users/Profile/ProfileSection.cs @@ -14,7 +14,5 @@ namespace osu.Game.Users.Profile { User = user; } - - public override string ToString() => Title; //for tab control } } diff --git a/osu.Game/Users/UserProfile.cs b/osu.Game/Users/UserProfile.cs index eaa89ce42c..cde36cbed8 100644 --- a/osu.Game/Users/UserProfile.cs +++ b/osu.Game/Users/UserProfile.cs @@ -1,10 +1,12 @@ // Copyright (c) 2007-2017 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE +using osu.Framework.Allocation; using osu.Framework.Extensions.IEnumerableExtensions; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Sprites; +using osu.Framework.Graphics.UserInterface; using osu.Game.Graphics; using osu.Game.Graphics.Containers; using osu.Game.Graphics.UserInterface; @@ -16,6 +18,7 @@ namespace osu.Game.Users { private readonly User user; private ProfileSection lastSection; + private readonly ProfileTabControl tabs; public const float CONTENT_X_MARGIN = 50; @@ -32,12 +35,14 @@ namespace osu.Game.Users new BeatmapsSection(user), new KudosuSection(user) }; - var tab = new OsuTabControl + tabs = new ProfileTabControl { RelativeSizeAxes = Axes.X, + Anchor = Anchor.TopCentre, + Origin = Anchor.TopCentre, Height = 24 }; - sections.ForEach(tab.AddItem); + sections.ForEach(tabs.AddItem); Add(new Box { @@ -49,7 +54,7 @@ namespace osu.Game.Users { RelativeSizeAxes = Axes.Both, ExpandableHeader = new UserPageHeader(user), - FixedHeader = tab, + FixedHeader = tabs, HeaderBackground = new Box { Colour = OsuColour.Gray(34), @@ -64,11 +69,11 @@ namespace osu.Game.Users if (lastSection != s) { lastSection = s as ProfileSection; - tab.Current.Value = lastSection; + tabs.Current.Value = lastSection; } }; - tab.Current.ValueChanged += s => + tabs.Current.ValueChanged += s => { if (lastSection != s) { @@ -77,5 +82,32 @@ namespace osu.Game.Users } }; } + + [BackgroundDependencyLoader] + private void load(OsuColour colours) + { + tabs.AccentColour = colours.Yellow; + } + + private class ProfileTabControl : OsuTabControl + { + public ProfileTabControl() + { + TabContainer.RelativeSizeAxes &= ~Axes.X; + TabContainer.AutoSizeAxes |= Axes.X; + TabContainer.Anchor |= Anchor.x1; + TabContainer.Origin |= Anchor.x1; + } + + protected override TabItem CreateTabItem(ProfileSection value) => new ProfileTabItem(value); + + private class ProfileTabItem : OsuTabItem + { + public ProfileTabItem(ProfileSection value) : base(value) + { + Text.Text = value.Title; + } + } + } } } From 5a0bd3b695240a21b23828ebc29d1aa40cc54188 Mon Sep 17 00:00:00 2001 From: Huo Yaoyuan Date: Fri, 9 Jun 2017 14:53:00 +0800 Subject: [PATCH 012/106] Set content in profile sections. --- .../Graphics/Containers/SectionsContainer.cs | 5 +-- osu.Game/Users/Profile/AboutSection.cs | 2 +- osu.Game/Users/Profile/BeatmapsSection.cs | 2 +- osu.Game/Users/Profile/HistoricalSection.cs | 2 +- osu.Game/Users/Profile/KudosuSection.cs | 2 +- osu.Game/Users/Profile/MedalsSection.cs | 2 +- osu.Game/Users/Profile/ProfileSection.cs | 31 ++++++++++++++++--- osu.Game/Users/Profile/RanksSection.cs | 2 +- osu.Game/Users/Profile/RecentSection.cs | 2 +- 9 files changed, 37 insertions(+), 13 deletions(-) diff --git a/osu.Game/Graphics/Containers/SectionsContainer.cs b/osu.Game/Graphics/Containers/SectionsContainer.cs index 99f43abe24..055e655f6e 100644 --- a/osu.Game/Graphics/Containers/SectionsContainer.cs +++ b/osu.Game/Graphics/Containers/SectionsContainer.cs @@ -94,7 +94,8 @@ namespace osu.Game.Graphics.Containers => new FillFlowContainer { Direction = FillDirection.Vertical, - AutoSizeAxes = Axes.Both + AutoSizeAxes = Axes.Y, + RelativeSizeAxes = Axes.X, }; private List sections = new List(); @@ -133,7 +134,7 @@ namespace osu.Game.Graphics.Containers Add(ScrollContainer = new ScrollContainer() { RelativeSizeAxes = Axes.Both, - Masking = false, + Masking = true, Children = new Drawable[] { sectionsContainer = CreateScrollContentContainer() }, Depth = float.MaxValue }); diff --git a/osu.Game/Users/Profile/AboutSection.cs b/osu.Game/Users/Profile/AboutSection.cs index 24a4516441..b2e5ae1b35 100644 --- a/osu.Game/Users/Profile/AboutSection.cs +++ b/osu.Game/Users/Profile/AboutSection.cs @@ -7,7 +7,7 @@ namespace osu.Game.Users.Profile { public override string Title => "me!"; - public AboutSection(User user) : base(user) + public AboutSection(User user) { } } diff --git a/osu.Game/Users/Profile/BeatmapsSection.cs b/osu.Game/Users/Profile/BeatmapsSection.cs index 1377702c4b..4068283c73 100644 --- a/osu.Game/Users/Profile/BeatmapsSection.cs +++ b/osu.Game/Users/Profile/BeatmapsSection.cs @@ -7,7 +7,7 @@ namespace osu.Game.Users.Profile { public override string Title => "Beatmaps"; - public BeatmapsSection(User user) : base(user) + public BeatmapsSection(User user) { } } diff --git a/osu.Game/Users/Profile/HistoricalSection.cs b/osu.Game/Users/Profile/HistoricalSection.cs index 751f91e5bc..12d6d2a409 100644 --- a/osu.Game/Users/Profile/HistoricalSection.cs +++ b/osu.Game/Users/Profile/HistoricalSection.cs @@ -7,7 +7,7 @@ namespace osu.Game.Users.Profile { public override string Title => "Historical"; - public HistoricalSection(User user) : base(user) + public HistoricalSection(User user) { } } diff --git a/osu.Game/Users/Profile/KudosuSection.cs b/osu.Game/Users/Profile/KudosuSection.cs index 61986ef5d8..312661f676 100644 --- a/osu.Game/Users/Profile/KudosuSection.cs +++ b/osu.Game/Users/Profile/KudosuSection.cs @@ -7,7 +7,7 @@ namespace osu.Game.Users.Profile { public override string Title => "Kudosu!"; - public KudosuSection(User user) : base(user) + public KudosuSection(User user) { } } diff --git a/osu.Game/Users/Profile/MedalsSection.cs b/osu.Game/Users/Profile/MedalsSection.cs index 581d5e897c..7db8c69222 100644 --- a/osu.Game/Users/Profile/MedalsSection.cs +++ b/osu.Game/Users/Profile/MedalsSection.cs @@ -7,7 +7,7 @@ namespace osu.Game.Users.Profile { public override string Title => "Medals"; - public MedalsSection(User user) : base(user) + public MedalsSection(User user) { } } diff --git a/osu.Game/Users/Profile/ProfileSection.cs b/osu.Game/Users/Profile/ProfileSection.cs index ce362109cc..035053463f 100644 --- a/osu.Game/Users/Profile/ProfileSection.cs +++ b/osu.Game/Users/Profile/ProfileSection.cs @@ -1,18 +1,41 @@ // Copyright (c) 2007-2017 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE +using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; +using osu.Framework.Graphics.Sprites; +using osu.Game.Graphics; +using osu.Game.Graphics.Sprites; namespace osu.Game.Users.Profile { - public abstract class ProfileSection : Container + public abstract class ProfileSection : FillFlowContainer { - protected readonly User User; public abstract string Title { get; } - protected ProfileSection(User user) + protected ProfileSection() { - User = user; + Margin = new MarginPadding { Horizontal = UserProfile.CONTENT_X_MARGIN }; + Direction = FillDirection.Vertical; + AutoSizeAxes = Axes.Y; + RelativeSizeAxes = Axes.X; + Children = new Drawable[] + { + new OsuSpriteText + { + Text = Title, + TextSize = 16, + Font = @"Exo2.0-RegularItalic", + Margin = new MarginPadding { Vertical = 20 } + }, + new Box + { + RelativeSizeAxes = Axes.X, + Height = 1, + Colour = OsuColour.Gray(34), + Depth = float.MinValue + } + }; } } } diff --git a/osu.Game/Users/Profile/RanksSection.cs b/osu.Game/Users/Profile/RanksSection.cs index 450c1461e0..1c51866218 100644 --- a/osu.Game/Users/Profile/RanksSection.cs +++ b/osu.Game/Users/Profile/RanksSection.cs @@ -7,7 +7,7 @@ namespace osu.Game.Users.Profile { public override string Title => "Ranks"; - public RanksSection(User user) : base(user) + public RanksSection(User user) { } } diff --git a/osu.Game/Users/Profile/RecentSection.cs b/osu.Game/Users/Profile/RecentSection.cs index 5a4e2707f8..96cf9d7a24 100644 --- a/osu.Game/Users/Profile/RecentSection.cs +++ b/osu.Game/Users/Profile/RecentSection.cs @@ -7,7 +7,7 @@ namespace osu.Game.Users.Profile { public override string Title => "Recent"; - public RecentSection(User user) : base(user) + public RecentSection(User user) { } } From 8dce52e6a8437a399b29ad9da11a7a5668ebefac Mon Sep 17 00:00:00 2001 From: Huo Yaoyuan Date: Fri, 9 Jun 2017 14:53:30 +0800 Subject: [PATCH 013/106] Fix incorrect class name. --- osu.Game/Users/Profile/ProfileHeader.cs | 4 ++-- osu.Game/Users/UserProfile.cs | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/osu.Game/Users/Profile/ProfileHeader.cs b/osu.Game/Users/Profile/ProfileHeader.cs index e7a8f45689..fcfeb3479e 100644 --- a/osu.Game/Users/Profile/ProfileHeader.cs +++ b/osu.Game/Users/Profile/ProfileHeader.cs @@ -10,12 +10,12 @@ using osu.Game.Graphics.Sprites; namespace osu.Game.Users.Profile { - public class UserPageHeader : Container + public class ProfileHeader : Container { private readonly User user; private const float cover_height = 200, avatar_size = 110, avatar_bottom_position = -20; - public UserPageHeader(User user) + public ProfileHeader(User user) { this.user = user; RelativeSizeAxes = Axes.X; diff --git a/osu.Game/Users/UserProfile.cs b/osu.Game/Users/UserProfile.cs index cde36cbed8..3c567e9089 100644 --- a/osu.Game/Users/UserProfile.cs +++ b/osu.Game/Users/UserProfile.cs @@ -53,7 +53,7 @@ namespace osu.Game.Users var sectionsContainer = new SectionsContainer { RelativeSizeAxes = Axes.Both, - ExpandableHeader = new UserPageHeader(user), + ExpandableHeader = new ProfileHeader(user), FixedHeader = tabs, HeaderBackground = new Box { From 51107acdffd3978fe73840fdaa137f651de7e561 Mon Sep 17 00:00:00 2001 From: Huo Yaoyuan Date: Fri, 9 Jun 2017 15:22:07 +0800 Subject: [PATCH 014/106] Improve section behaviour. --- osu.Game/Users/Profile/ProfileSection.cs | 26 ++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/osu.Game/Users/Profile/ProfileSection.cs b/osu.Game/Users/Profile/ProfileSection.cs index 035053463f..d8cc2f4e8c 100644 --- a/osu.Game/Users/Profile/ProfileSection.cs +++ b/osu.Game/Users/Profile/ProfileSection.cs @@ -1,6 +1,7 @@ // Copyright (c) 2007-2017 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE +using OpenTK; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Sprites; @@ -13,27 +14,44 @@ namespace osu.Game.Users.Profile { public abstract string Title { get; } + private readonly FillFlowContainer content; + protected override Container Content => content; + protected ProfileSection() { - Margin = new MarginPadding { Horizontal = UserProfile.CONTENT_X_MARGIN }; Direction = FillDirection.Vertical; AutoSizeAxes = Axes.Y; RelativeSizeAxes = Axes.X; - Children = new Drawable[] + InternalChildren = new Drawable[] { new OsuSpriteText { Text = Title, TextSize = 16, Font = @"Exo2.0-RegularItalic", - Margin = new MarginPadding { Vertical = 20 } + Margin = new MarginPadding + { + Horizontal = UserProfile.CONTENT_X_MARGIN, + Vertical = 20 + } + }, + content = new FillFlowContainer + { + Direction = FillDirection.Vertical, + AutoSizeAxes = Axes.Y, + RelativeSizeAxes = Axes.X, + Margin = new MarginPadding + { + Horizontal = UserProfile.CONTENT_X_MARGIN, + Bottom = 20 + } }, new Box { RelativeSizeAxes = Axes.X, Height = 1, Colour = OsuColour.Gray(34), - Depth = float.MinValue + EdgeSmoothness = new Vector2(1) } }; } From 140c74cd2afdcba4ddeb8505cb74817231155706 Mon Sep 17 00:00:00 2001 From: Huo Yaoyuan Date: Fri, 9 Jun 2017 16:01:16 +0800 Subject: [PATCH 015/106] Use PageTabControl. --- .../Graphics/UserInterface/PageTabControl.cs | 8 +++--- osu.Game/Users/UserProfile.cs | 25 +++++++++++++------ 2 files changed, 23 insertions(+), 10 deletions(-) diff --git a/osu.Game/Graphics/UserInterface/PageTabControl.cs b/osu.Game/Graphics/UserInterface/PageTabControl.cs index 8bf455b099..e17281cdc4 100644 --- a/osu.Game/Graphics/UserInterface/PageTabControl.cs +++ b/osu.Game/Graphics/UserInterface/PageTabControl.cs @@ -23,12 +23,14 @@ namespace osu.Game.Graphics.UserInterface Height = 30; } - private class PageTabItem : TabItem + public class PageTabItem : TabItem { private const float transition_duration = 100; private readonly Box box; + protected readonly SpriteText Text; + public override bool Active { get { return base.Active; } @@ -51,12 +53,12 @@ namespace osu.Game.Graphics.UserInterface Children = new Drawable[] { - new OsuSpriteText + Text = new OsuSpriteText { Margin = new MarginPadding { Top = 8, Bottom = 8 }, Origin = Anchor.BottomLeft, Anchor = Anchor.BottomLeft, - Text = (value as Enum).GetDescription() ?? value.ToString(), + Text = (value as Enum)?.GetDescription() ?? value.ToString(), TextSize = 14, Font = @"Exo2.0-Bold", }, diff --git a/osu.Game/Users/UserProfile.cs b/osu.Game/Users/UserProfile.cs index 3c567e9089..6bf46e5725 100644 --- a/osu.Game/Users/UserProfile.cs +++ b/osu.Game/Users/UserProfile.cs @@ -1,6 +1,7 @@ // Copyright (c) 2007-2017 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE +using OpenTK; using osu.Framework.Allocation; using osu.Framework.Extensions.IEnumerableExtensions; using osu.Framework.Graphics; @@ -83,31 +84,41 @@ namespace osu.Game.Users }; } - [BackgroundDependencyLoader] - private void load(OsuColour colours) + private class ProfileTabControl : PageTabControl { - tabs.AccentColour = colours.Yellow; - } + private readonly Box bottom; - private class ProfileTabControl : OsuTabControl - { public ProfileTabControl() { TabContainer.RelativeSizeAxes &= ~Axes.X; TabContainer.AutoSizeAxes |= Axes.X; TabContainer.Anchor |= Anchor.x1; TabContainer.Origin |= Anchor.x1; + Add(bottom = new Box + { + RelativeSizeAxes = Axes.X, + Height = 1, + Anchor = Anchor.BottomCentre, + Origin = Anchor.BottomCentre, + EdgeSmoothness = new Vector2(1) + }); } protected override TabItem CreateTabItem(ProfileSection value) => new ProfileTabItem(value); - private class ProfileTabItem : OsuTabItem + private class ProfileTabItem : PageTabItem { public ProfileTabItem(ProfileSection value) : base(value) { Text.Text = value.Title; } } + + [BackgroundDependencyLoader] + private void load(OsuColour colours) + { + bottom.Colour = colours.Yellow; + } } } } From c60ef2449f26ad633f37e2af5d9468315739ef52 Mon Sep 17 00:00:00 2001 From: Huo Yaoyuan Date: Fri, 9 Jun 2017 16:05:05 +0800 Subject: [PATCH 016/106] Fix initial scroll. --- osu.Game/Users/UserProfile.cs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/osu.Game/Users/UserProfile.cs b/osu.Game/Users/UserProfile.cs index 6bf46e5725..5d592a613d 100644 --- a/osu.Game/Users/UserProfile.cs +++ b/osu.Game/Users/UserProfile.cs @@ -76,6 +76,11 @@ namespace osu.Game.Users tabs.Current.ValueChanged += s => { + if (lastSection == null) + { + lastSection = tabs.Current.Value = sections[0]; + return; + } if (lastSection != s) { lastSection = s; From 798d8711b832dbabf4641cdda7cbc06c728d52ce Mon Sep 17 00:00:00 2001 From: Huo Yaoyuan Date: Fri, 9 Jun 2017 16:24:19 +0800 Subject: [PATCH 017/106] Refactor SectionsContainer to generic. --- .../Graphics/Containers/SectionsContainer.cs | 53 ++++++++----------- osu.Game/Overlays/SettingsOverlay.cs | 10 ++-- osu.Game/Users/UserProfile.cs | 11 ++-- 3 files changed, 33 insertions(+), 41 deletions(-) diff --git a/osu.Game/Graphics/Containers/SectionsContainer.cs b/osu.Game/Graphics/Containers/SectionsContainer.cs index 055e655f6e..1b8e9e1f34 100644 --- a/osu.Game/Graphics/Containers/SectionsContainer.cs +++ b/osu.Game/Graphics/Containers/SectionsContainer.cs @@ -2,7 +2,6 @@ // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE using System; -using System.Collections.Generic; using System.Linq; using osu.Framework.Configuration; using osu.Framework.Graphics; @@ -13,11 +12,15 @@ namespace osu.Game.Graphics.Containers /// /// A container that can scroll to each section inside it. /// - public class SectionsContainer : Container + public class SectionsContainer : Container + where T : Drawable { private Drawable expandableHeader, fixedHeader, footer, headerBackground; public readonly ScrollContainer ScrollContainer; - private readonly Container sectionsContainer, headerBackgroundContainer; + private readonly Container headerBackgroundContainer; + private readonly FlowContainer sectionsContainer; + + protected override Container Content => sectionsContainer; public Drawable ExpandableHeader { @@ -26,12 +29,11 @@ namespace osu.Game.Graphics.Containers { if (value == expandableHeader) return; - if (expandableHeader != null) - Remove(expandableHeader); + expandableHeader?.Expire(); expandableHeader = value; if (value == null) return; - Add(expandableHeader); + AddInternal(expandableHeader); lastKnownScroll = float.NaN; } } @@ -43,12 +45,11 @@ namespace osu.Game.Graphics.Containers { if (value == fixedHeader) return; - if (fixedHeader != null) - Remove(fixedHeader); + fixedHeader?.Expire(); fixedHeader = value; if (value == null) return; - Add(fixedHeader); + AddInternal(fixedHeader); lastKnownScroll = float.NaN; } } @@ -88,39 +89,27 @@ namespace osu.Game.Graphics.Containers } } - public Bindable SelectedSection { get; } = new Bindable(); + public Bindable SelectedSection { get; } = new Bindable(); - protected virtual Container CreateScrollContentContainer() - => new FillFlowContainer + protected virtual FlowContainer CreateScrollContentContainer() + => new FillFlowContainer { Direction = FillDirection.Vertical, AutoSizeAxes = Axes.Y, RelativeSizeAxes = Axes.X, }; - private List sections = new List(); - public IEnumerable Sections + public override void Add(T drawable) { - get { return sections; } - set - { - foreach (var section in sections) - sectionsContainer.Remove(section); - - sections = value.ToList(); - if (sections.Count == 0) return; - - sectionsContainer.Add(sections); - SelectedSection.Value = sections[0]; - lastKnownScroll = float.NaN; - } + base.Add(drawable); + lastKnownScroll = float.NaN; } private float headerHeight, footerHeight; private readonly MarginPadding originalSectionsMargin; private void updateSectionsMargin() { - if (sections.Count == 0) return; + if (!Children.Any()) return; var newMargin = originalSectionsMargin; newMargin.Top += headerHeight; @@ -131,14 +120,14 @@ namespace osu.Game.Graphics.Containers public SectionsContainer() { - Add(ScrollContainer = new ScrollContainer() + AddInternal(ScrollContainer = new ScrollContainer() { RelativeSizeAxes = Axes.Both, Masking = true, Children = new Drawable[] { sectionsContainer = CreateScrollContentContainer() }, Depth = float.MaxValue }); - Add(headerBackgroundContainer = new Container + AddInternal(headerBackgroundContainer = new Container { RelativeSizeAxes = Axes.X, Depth = float.MaxValue / 2 @@ -176,10 +165,10 @@ namespace osu.Game.Graphics.Containers headerBackgroundContainer.Height = (ExpandableHeader?.LayoutSize.Y ?? 0) + (FixedHeader?.LayoutSize.Y ?? 0); headerBackgroundContainer.Y = ExpandableHeader?.Y ?? 0; - Drawable bestMatch = null; + T bestMatch = null; float minDiff = float.MaxValue; - foreach (var section in sections) + foreach (var section in Children) { float diff = Math.Abs(ScrollContainer.GetChildPosInContent(section) - currentScroll); if (diff < minDiff) diff --git a/osu.Game/Overlays/SettingsOverlay.cs b/osu.Game/Overlays/SettingsOverlay.cs index 88a0e26dde..b229a9dfec 100644 --- a/osu.Game/Overlays/SettingsOverlay.cs +++ b/osu.Game/Overlays/SettingsOverlay.cs @@ -83,7 +83,7 @@ namespace osu.Game.Overlays }, Exit = Hide, }, - Sections = sections, + Children = sections, Footer = new SettingsFooter() }, sidebar = new Sidebar @@ -148,12 +148,12 @@ namespace osu.Game.Overlays base.OnFocus(state); } - private class SettingsSectionsContainer : SectionsContainer + private class SettingsSectionsContainer : SectionsContainer { - public SearchContainer SearchContainer; + public SearchContainer SearchContainer; - protected override Container CreateScrollContentContainer() - => SearchContainer = new SearchContainer + protected override FlowContainer CreateScrollContentContainer() + => SearchContainer = new SearchContainer { AutoSizeAxes = Axes.Y, RelativeSizeAxes = Axes.X, diff --git a/osu.Game/Users/UserProfile.cs b/osu.Game/Users/UserProfile.cs index 5d592a613d..27f18a0f14 100644 --- a/osu.Game/Users/UserProfile.cs +++ b/osu.Game/Users/UserProfile.cs @@ -1,6 +1,7 @@ // Copyright (c) 2007-2017 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE +using System.Linq; using OpenTK; using osu.Framework.Allocation; using osu.Framework.Extensions.IEnumerableExtensions; @@ -51,7 +52,7 @@ namespace osu.Game.Users Colour = OsuColour.Gray(0.2f) }); - var sectionsContainer = new SectionsContainer + var sectionsContainer = new SectionsContainer { RelativeSizeAxes = Axes.Both, ExpandableHeader = new ProfileHeader(user), @@ -61,7 +62,7 @@ namespace osu.Game.Users Colour = OsuColour.Gray(34), RelativeSizeAxes = Axes.Both }, - Sections = sections + Children = sections }; Add(sectionsContainer); @@ -69,7 +70,7 @@ namespace osu.Game.Users { if (lastSection != s) { - lastSection = s as ProfileSection; + lastSection = s; tabs.Current.Value = lastSection; } }; @@ -78,7 +79,9 @@ namespace osu.Game.Users { if (lastSection == null) { - lastSection = tabs.Current.Value = sections[0]; + lastSection = sectionsContainer.Children.FirstOrDefault(); + if (lastSection != null) + tabs.Current.Value = lastSection; return; } if (lastSection != s) From 3945d33adcbd38418abf9d981a64e0ce445bd52a Mon Sep 17 00:00:00 2001 From: Huo Yaoyuan Date: Fri, 9 Jun 2017 19:04:29 +0800 Subject: [PATCH 018/106] Make OsuTabControl.isEnumType static. --- osu.Game/Graphics/UserInterface/OsuTabControl.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Graphics/UserInterface/OsuTabControl.cs b/osu.Game/Graphics/UserInterface/OsuTabControl.cs index 4bbae4efd1..6a00e1f55e 100644 --- a/osu.Game/Graphics/UserInterface/OsuTabControl.cs +++ b/osu.Game/Graphics/UserInterface/OsuTabControl.cs @@ -24,7 +24,7 @@ namespace osu.Game.Graphics.UserInterface protected override bool InternalContains(Vector2 screenSpacePos) => base.InternalContains(screenSpacePos) || Dropdown.Contains(screenSpacePos); - private bool isEnumType => typeof(T).IsEnum; + private static bool isEnumType => typeof(T).IsEnum; public OsuTabControl() { From 915f61a8f723fed578e08ac725c75069fc8666ff Mon Sep 17 00:00:00 2001 From: Huo Yaoyuan Date: Mon, 12 Jun 2017 14:39:49 +0800 Subject: [PATCH 019/106] Rename to scrollContentContainer. --- osu.Game/Graphics/Containers/SectionsContainer.cs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/osu.Game/Graphics/Containers/SectionsContainer.cs b/osu.Game/Graphics/Containers/SectionsContainer.cs index 1b8e9e1f34..e11a12d2a1 100644 --- a/osu.Game/Graphics/Containers/SectionsContainer.cs +++ b/osu.Game/Graphics/Containers/SectionsContainer.cs @@ -18,9 +18,9 @@ namespace osu.Game.Graphics.Containers private Drawable expandableHeader, fixedHeader, footer, headerBackground; public readonly ScrollContainer ScrollContainer; private readonly Container headerBackgroundContainer; - private readonly FlowContainer sectionsContainer; + private readonly FlowContainer scrollContentContainer; - protected override Container Content => sectionsContainer; + protected override Container Content => scrollContentContainer; public Drawable ExpandableHeader { @@ -115,7 +115,7 @@ namespace osu.Game.Graphics.Containers newMargin.Top += headerHeight; newMargin.Bottom += footerHeight; - sectionsContainer.Margin = newMargin; + scrollContentContainer.Margin = newMargin; } public SectionsContainer() @@ -124,7 +124,7 @@ namespace osu.Game.Graphics.Containers { RelativeSizeAxes = Axes.Both, Masking = true, - Children = new Drawable[] { sectionsContainer = CreateScrollContentContainer() }, + Children = new Drawable[] { scrollContentContainer = CreateScrollContentContainer() }, Depth = float.MaxValue }); AddInternal(headerBackgroundContainer = new Container @@ -132,7 +132,7 @@ namespace osu.Game.Graphics.Containers RelativeSizeAxes = Axes.X, Depth = float.MaxValue / 2 }); - originalSectionsMargin = sectionsContainer.Margin; + originalSectionsMargin = scrollContentContainer.Margin; } private float lastKnownScroll; From 53da671b60c9443ddc0903143d5a3b4f021272ac Mon Sep 17 00:00:00 2001 From: Huo Yaoyuan Date: Mon, 12 Jun 2017 14:42:14 +0800 Subject: [PATCH 020/106] Update framework type. --- osu.Game/Users/Profile/ProfileHeader.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Users/Profile/ProfileHeader.cs b/osu.Game/Users/Profile/ProfileHeader.cs index fcfeb3479e..d7b874da07 100644 --- a/osu.Game/Users/Profile/ProfileHeader.cs +++ b/osu.Game/Users/Profile/ProfileHeader.cs @@ -50,7 +50,7 @@ namespace osu.Game.Users.Profile Y = avatar_bottom_position, Masking = true, CornerRadius = 5, - EdgeEffect = new EdgeEffect + EdgeEffect = new EdgeEffectParameters { Type = EdgeEffectType.Shadow, Colour = Color4.Black.Opacity(0.25f), From fcd137ced2f1e3305fc03ea2bb8f6a3038a539f9 Mon Sep 17 00:00:00 2001 From: Huo Yaoyuan Date: Tue, 13 Jun 2017 00:51:06 +0800 Subject: [PATCH 021/106] Add OsuTextFlowContainer. --- .../Graphics/Containers/OsuTextFlowContainer.cs | 14 ++++++++++++++ osu.Game/Overlays/Music/PlaylistItem.cs | 11 ++++++----- osu.Game/osu.Game.csproj | 7 ++++--- 3 files changed, 24 insertions(+), 8 deletions(-) create mode 100644 osu.Game/Graphics/Containers/OsuTextFlowContainer.cs diff --git a/osu.Game/Graphics/Containers/OsuTextFlowContainer.cs b/osu.Game/Graphics/Containers/OsuTextFlowContainer.cs new file mode 100644 index 0000000000..06972967be --- /dev/null +++ b/osu.Game/Graphics/Containers/OsuTextFlowContainer.cs @@ -0,0 +1,14 @@ +// Copyright (c) 2007-2017 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu-framework/master/LICENCE + +using osu.Framework.Graphics.Containers; +using osu.Framework.Graphics.Sprites; +using osu.Game.Graphics.Sprites; + +namespace osu.Game.Graphics.Containers +{ + public class OsuTextFlowContainer: TextFlowContainer + { + protected override SpriteText CreateSpriteText() => new OsuSpriteText(); + } +} diff --git a/osu.Game/Overlays/Music/PlaylistItem.cs b/osu.Game/Overlays/Music/PlaylistItem.cs index 69cb9c3464..0a095327b0 100644 --- a/osu.Game/Overlays/Music/PlaylistItem.cs +++ b/osu.Game/Overlays/Music/PlaylistItem.cs @@ -2,15 +2,16 @@ // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE using System; +using System.Collections.Generic; +using OpenTK.Graphics; using osu.Framework.Allocation; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; +using osu.Framework.Graphics.Sprites; +using osu.Framework.Localisation; using osu.Game.Database; using osu.Game.Graphics; -using OpenTK.Graphics; -using osu.Framework.Localisation; -using osu.Framework.Graphics.Sprites; -using System.Collections.Generic; +using osu.Game.Graphics.Containers; namespace osu.Game.Overlays.Music { @@ -77,7 +78,7 @@ namespace osu.Game.Overlays.Music Margin = new MarginPadding { Left = 5 }, Padding = new MarginPadding { Top = 2 }, }, - text = new TextFlowContainer + text = new OsuTextFlowContainer { RelativeSizeAxes = Axes.X, AutoSizeAxes = Axes.Y, diff --git a/osu.Game/osu.Game.csproj b/osu.Game/osu.Game.csproj index 8aa83a65c6..bfb6f4ec77 100644 --- a/osu.Game/osu.Game.csproj +++ b/osu.Game/osu.Game.csproj @@ -43,8 +43,8 @@ $(SolutionDir)\packages\ppy.OpenTK.2.0.50727.1341\lib\net45\OpenTK.dll - $(SolutionDir)\packages\sharpcompress.0.15.2\lib\net45\SharpCompress.dll - $(SolutionDir)\packages\SharpCompress.0.15.2\lib\net45\SharpCompress.dll + $(SolutionDir)\packages\sharpcompress.0.15.2\lib\net45\SharpCompress.dll + $(SolutionDir)\packages\SharpCompress.0.15.2\lib\net45\SharpCompress.dll $(SolutionDir)\packages\SQLite.Net.Core-PCL.3.1.1\lib\portable-win8+net45+wp8+wpa81+MonoAndroid1+MonoTouch1\SQLite.Net.dll @@ -75,6 +75,7 @@ + @@ -511,4 +512,4 @@ --> - + \ No newline at end of file From c75e2909ee53679b3990bcffaa0f103ac689f620 Mon Sep 17 00:00:00 2001 From: Huo Yaoyuan Date: Tue, 13 Jun 2017 00:58:32 +0800 Subject: [PATCH 022/106] Expose AddTextAwesome for OsuTextFlowContainer. --- osu.Game/Graphics/Containers/OsuTextFlowContainer.cs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/osu.Game/Graphics/Containers/OsuTextFlowContainer.cs b/osu.Game/Graphics/Containers/OsuTextFlowContainer.cs index 06972967be..7b5da8587f 100644 --- a/osu.Game/Graphics/Containers/OsuTextFlowContainer.cs +++ b/osu.Game/Graphics/Containers/OsuTextFlowContainer.cs @@ -1,6 +1,8 @@ // Copyright (c) 2007-2017 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu-framework/master/LICENCE +using System; +using System.Collections.Generic; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Sprites; using osu.Game.Graphics.Sprites; @@ -10,5 +12,7 @@ namespace osu.Game.Graphics.Containers public class OsuTextFlowContainer: TextFlowContainer { protected override SpriteText CreateSpriteText() => new OsuSpriteText(); + + public IEnumerable AddTextAwesome(FontAwesome icon, Action creationParameters = null) => AddText(((char)icon).ToString(), creationParameters); } } From 755d2737d0bc1836f3c4acae35bb88962a4edc11 Mon Sep 17 00:00:00 2001 From: Huo Yaoyuan Date: Tue, 13 Jun 2017 02:58:10 +0800 Subject: [PATCH 023/106] Improve OsuTextFlowContainer with framework. --- osu.Game/Graphics/Containers/OsuTextFlowContainer.cs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/osu.Game/Graphics/Containers/OsuTextFlowContainer.cs b/osu.Game/Graphics/Containers/OsuTextFlowContainer.cs index 7b5da8587f..38c1edbc4e 100644 --- a/osu.Game/Graphics/Containers/OsuTextFlowContainer.cs +++ b/osu.Game/Graphics/Containers/OsuTextFlowContainer.cs @@ -9,8 +9,12 @@ using osu.Game.Graphics.Sprites; namespace osu.Game.Graphics.Containers { - public class OsuTextFlowContainer: TextFlowContainer + public class OsuTextFlowContainer : TextFlowContainer { + public OsuTextFlowContainer(Action defaultCreationParameters = null) : base(defaultCreationParameters) + { + } + protected override SpriteText CreateSpriteText() => new OsuSpriteText(); public IEnumerable AddTextAwesome(FontAwesome icon, Action creationParameters = null) => AddText(((char)icon).ToString(), creationParameters); From a1c3a456fbd5512bd9748ffab6dd03924860c32f Mon Sep 17 00:00:00 2001 From: Huo Yaoyuan Date: Tue, 13 Jun 2017 03:31:17 +0800 Subject: [PATCH 024/106] Add placeholder text in profile header. --- osu.Game/Users/Profile/ProfileHeader.cs | 48 ++++++++++++++++++++++++- osu.Game/Users/UserProfile.cs | 4 +-- 2 files changed, 49 insertions(+), 3 deletions(-) diff --git a/osu.Game/Users/Profile/ProfileHeader.cs b/osu.Game/Users/Profile/ProfileHeader.cs index d7b874da07..7d3d3a4c28 100644 --- a/osu.Game/Users/Profile/ProfileHeader.cs +++ b/osu.Game/Users/Profile/ProfileHeader.cs @@ -1,11 +1,15 @@ // Copyright (c) 2007-2017 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE +using System; using OpenTK; using OpenTK.Graphics; using osu.Framework.Extensions.Color4Extensions; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; +using osu.Framework.Graphics.Sprites; +using osu.Game.Graphics; +using osu.Game.Graphics.Containers; using osu.Game.Graphics.Sprites; namespace osu.Game.Users.Profile @@ -14,12 +18,14 @@ namespace osu.Game.Users.Profile { private readonly User user; + private readonly OsuTextFlowContainer infoText; + private const float cover_height = 200, avatar_size = 110, avatar_bottom_position = -20; public ProfileHeader(User user) { this.user = user; RelativeSizeAxes = Axes.X; - Height = cover_height; + Height = cover_height + cover_height - UserProfile.TAB_HEIGHT; Children = new Drawable[] { @@ -84,8 +90,48 @@ namespace osu.Game.Users.Profile } } } + }, + infoText = new OsuTextFlowContainer(t => + { + t.TextSize = 12; + t.Alpha = 0.8f; + }) + { + Y = cover_height + 20, + Margin = new MarginPadding { Horizontal = UserProfile.CONTENT_X_MARGIN }, + RelativeSizeAxes = Axes.X, + AutoSizeAxes = Axes.Y, + ParagraphSpacing = 1, + //LineSpacing = 0.5f } }; + + Action bold = t => + { + t.Font = @"Exo2.0-Bold"; + t.Alpha = 1; + }; + // placeholder text + infoText.AddTextAwesome(FontAwesome.fa_map_marker); + infoText.AddText(" position "); + infoText.AddTextAwesome(FontAwesome.fa_twitter); + infoText.AddText(" tweet "); + infoText.AddTextAwesome(FontAwesome.fa_heart_o); + infoText.AddText(" favorite "); + infoText.NewParagraph(); + infoText.AddText("0 years old"); + infoText.NewLine(); + infoText.AddText("Commander of "); + infoText.AddText("The Color Scribbles", bold); + infoText.NewParagraph(); + infoText.AddText("Joined since "); + infoText.AddText("June 2017", bold); + infoText.NewLine(); + infoText.AddText("Last seen "); + infoText.AddText("0 minutes ago", bold); + infoText.NewParagraph(); + infoText.AddText("Play with "); + infoText.AddText("Mouse, Keyboard, Tablet", bold); } } } diff --git a/osu.Game/Users/UserProfile.cs b/osu.Game/Users/UserProfile.cs index 27f18a0f14..bbe73b8124 100644 --- a/osu.Game/Users/UserProfile.cs +++ b/osu.Game/Users/UserProfile.cs @@ -22,7 +22,7 @@ namespace osu.Game.Users private ProfileSection lastSection; private readonly ProfileTabControl tabs; - public const float CONTENT_X_MARGIN = 50; + public const float CONTENT_X_MARGIN = 50, TAB_HEIGHT = 24; public UserProfile(User user) { @@ -42,7 +42,7 @@ namespace osu.Game.Users RelativeSizeAxes = Axes.X, Anchor = Anchor.TopCentre, Origin = Anchor.TopCentre, - Height = 24 + Height = TAB_HEIGHT }; sections.ForEach(tabs.AddItem); From 3821360942cd33c6dac7e3448610338577df4b0c Mon Sep 17 00:00:00 2001 From: Huo Yaoyuan Date: Tue, 13 Jun 2017 19:43:56 +0800 Subject: [PATCH 025/106] Follow web design more. --- osu.Game/Users/Profile/ProfileHeader.cs | 69 +++++++++++++++++++++++-- 1 file changed, 65 insertions(+), 4 deletions(-) diff --git a/osu.Game/Users/Profile/ProfileHeader.cs b/osu.Game/Users/Profile/ProfileHeader.cs index 7d3d3a4c28..9d20ce637c 100644 --- a/osu.Game/Users/Profile/ProfileHeader.cs +++ b/osu.Game/Users/Profile/ProfileHeader.cs @@ -6,6 +6,7 @@ using OpenTK; using OpenTK.Graphics; using osu.Framework.Extensions.Color4Extensions; using osu.Framework.Graphics; +using osu.Framework.Graphics.Colour; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Sprites; using osu.Game.Graphics; @@ -20,12 +21,12 @@ namespace osu.Game.Users.Profile private readonly OsuTextFlowContainer infoText; - private const float cover_height = 200, avatar_size = 110, avatar_bottom_position = -20; + private const float cover_height = 350, info_height = 150, avatar_size = 110, avatar_bottom_position = -20, level_position = 30, level_height = 60; public ProfileHeader(User user) { this.user = user; RelativeSizeAxes = Axes.X; - Height = cover_height + cover_height - UserProfile.TAB_HEIGHT; + Height = cover_height + info_height - UserProfile.TAB_HEIGHT; Children = new Drawable[] { @@ -46,6 +47,11 @@ namespace osu.Game.Users.Profile Masking = true, RelativeSizeAxes = Axes.Both }, + new Box + { + RelativeSizeAxes = Axes.Both, + ColourInfo = ColourInfo.GradientVertical(Color4.Black.Opacity(0.1f), Color4.Black.Opacity(0.75f)) + }, new UpdateableAvatar { User = user, @@ -101,8 +107,63 @@ namespace osu.Game.Users.Profile Margin = new MarginPadding { Horizontal = UserProfile.CONTENT_X_MARGIN }, RelativeSizeAxes = Axes.X, AutoSizeAxes = Axes.Y, - ParagraphSpacing = 1, - //LineSpacing = 0.5f + ParagraphSpacing = 1 + }, + new Container + { + X = -UserProfile.CONTENT_X_MARGIN, + RelativeSizeAxes = Axes.Y, + Width = 280, + Anchor = Anchor.TopRight, + Origin = Anchor.TopRight, + Children = new Drawable[] + { + new Container + { + RelativeSizeAxes = Axes.X, + Y = level_position, + Height = level_height, + Children = new Drawable[] + { + new Box + { + Colour = Color4.Black.Opacity(0.5f), + RelativeSizeAxes = Axes.Both + } + } + }, + new Container + { + RelativeSizeAxes = Axes.X, + Y = cover_height, + Anchor = Anchor.TopCentre, + Origin = Anchor.BottomCentre, + Height = cover_height - level_height - level_position - 5, + Children = new Drawable[] + { + new Box + { + Colour = Color4.Black.Opacity(0.5f), + RelativeSizeAxes = Axes.Both + } + } + }, + new Container + { + RelativeSizeAxes = Axes.X, + Anchor = Anchor.BottomCentre, + Origin = Anchor.BottomCentre, + Height = info_height - UserProfile.TAB_HEIGHT - 15, + Children = new Drawable[] + { + new Box + { + Colour = Color4.Black.Opacity(0.25f), + RelativeSizeAxes = Axes.Both + } + } + } + } } }; From 29578b0fa393fa4a1d25722850ebf2fc3a57528e Mon Sep 17 00:00:00 2001 From: Huo Yaoyuan Date: Tue, 13 Jun 2017 23:33:39 +0800 Subject: [PATCH 026/106] Update resources. --- osu-resources | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu-resources b/osu-resources index b348c1e540..10fda22522 160000 --- a/osu-resources +++ b/osu-resources @@ -1 +1 @@ -Subproject commit b348c1e540edbb3325a8da9bca452c9dce2938d6 +Subproject commit 10fda22522ffadbdbc43fa0f3683a065e536f7d1 From c35a3e6999812158c1da2c52af594ba691e3d71d Mon Sep 17 00:00:00 2001 From: Huo Yaoyuan Date: Wed, 14 Jun 2017 12:55:01 +0800 Subject: [PATCH 027/106] Level badge and score region. --- osu.Game/Users/Profile/ProfileHeader.cs | 74 +++++++++++++++++++++++++ 1 file changed, 74 insertions(+) diff --git a/osu.Game/Users/Profile/ProfileHeader.cs b/osu.Game/Users/Profile/ProfileHeader.cs index 9d20ce637c..7cab9fcab0 100644 --- a/osu.Game/Users/Profile/ProfileHeader.cs +++ b/osu.Game/Users/Profile/ProfileHeader.cs @@ -4,11 +4,13 @@ using System; using OpenTK; using OpenTK.Graphics; +using osu.Framework.Allocation; using osu.Framework.Extensions.Color4Extensions; using osu.Framework.Graphics; using osu.Framework.Graphics.Colour; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Sprites; +using osu.Framework.Graphics.Textures; using osu.Game.Graphics; using osu.Game.Graphics.Containers; using osu.Game.Graphics.Sprites; @@ -20,6 +22,10 @@ namespace osu.Game.Users.Profile private readonly User user; private readonly OsuTextFlowContainer infoText; + private readonly FillFlowContainer scoreText, scoreNumberText; + + private readonly Sprite levelBadge; + private readonly SpriteText levelText; private const float cover_height = 350, info_height = 150, avatar_size = 110, avatar_bottom_position = -20, level_position = 30, level_height = 60; public ProfileHeader(User user) @@ -129,6 +135,20 @@ namespace osu.Game.Users.Profile { Colour = Color4.Black.Opacity(0.5f), RelativeSizeAxes = Axes.Both + }, + levelBadge = new Sprite + { + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + Height = 50, + Width = 50 + }, + levelText = new OsuSpriteText + { + Anchor = Anchor.TopCentre, + Origin = Anchor.TopCentre, + Y = 11, + TextSize = 18 } } }, @@ -145,6 +165,22 @@ namespace osu.Game.Users.Profile { Colour = Color4.Black.Opacity(0.5f), RelativeSizeAxes = Axes.Both + }, + scoreText = new FillFlowContainer + { + RelativeSizeAxes = Axes.X, + AutoSizeAxes = Axes.Y, + Direction = FillDirection.Vertical, + Padding = new MarginPadding { Horizontal = 20, Vertical = 18 }, + Spacing = new Vector2(0, 2) + }, + scoreNumberText = new FillFlowContainer + { + RelativeSizeAxes = Axes.X, + AutoSizeAxes = Axes.Y, + Direction = FillDirection.Vertical, + Padding = new MarginPadding { Horizontal = 20, Vertical = 18 }, + Spacing = new Vector2(0, 2) } } }, @@ -193,6 +229,44 @@ namespace osu.Game.Users.Profile infoText.NewParagraph(); infoText.AddText("Play with "); infoText.AddText("Mouse, Keyboard, Tablet", bold); + + levelText.Text = "98"; + + scoreText.Add(createScoreText("Ranked Score")); + scoreNumberText.Add(createScoreNumberText("1,870,716,897")); + scoreText.Add(createScoreText("Accuracy")); + scoreNumberText.Add(createScoreNumberText("98.51%")); + scoreText.Add(createScoreText("Play Count")); + scoreNumberText.Add(createScoreNumberText("25,287")); + scoreText.Add(createScoreText("Total Score")); + scoreNumberText.Add(createScoreNumberText("28,444,797,570")); + scoreText.Add(createScoreText("Total Hits")); + scoreNumberText.Add(createScoreNumberText("4,612,765")); + scoreText.Add(createScoreText("Max Combo")); + scoreNumberText.Add(createScoreNumberText("2,056")); + scoreText.Add(createScoreText("Replay Watched")); + scoreNumberText.Add(createScoreNumberText("23")); } + + [BackgroundDependencyLoader] + private void load(TextureStore textures) + { + levelBadge.Texture = textures.Get(@"Profile/levelbadge"); + } + + private OsuSpriteText createScoreText(string text) => new OsuSpriteText + { + TextSize = 14, + Text = text + }; + + private OsuSpriteText createScoreNumberText(string text) => new OsuSpriteText + { + TextSize = 14, + Font = @"Exo2.0-Bold", + Anchor = Anchor.TopRight, + Origin = Anchor.TopRight, + Text = text + }; } } From adb4ee809536d5245ab3079dc752463b5a4c4352 Mon Sep 17 00:00:00 2001 From: Huo Yaoyuan Date: Wed, 14 Jun 2017 14:35:47 +0800 Subject: [PATCH 028/106] Grade badges. --- osu.Game/Users/Profile/ProfileHeader.cs | 71 +++++++++++++++++++++++++ 1 file changed, 71 insertions(+) diff --git a/osu.Game/Users/Profile/ProfileHeader.cs b/osu.Game/Users/Profile/ProfileHeader.cs index 7cab9fcab0..8d15a47fdf 100644 --- a/osu.Game/Users/Profile/ProfileHeader.cs +++ b/osu.Game/Users/Profile/ProfileHeader.cs @@ -26,6 +26,7 @@ namespace osu.Game.Users.Profile private readonly Sprite levelBadge; private readonly SpriteText levelText; + private readonly GradeBadge gradeSSPlus, gradeSS, gradeSPlus, gradeS, gradeA; private const float cover_height = 350, info_height = 150, avatar_size = 110, avatar_bottom_position = -20, level_position = 30, level_height = 60; public ProfileHeader(User user) @@ -181,6 +182,35 @@ namespace osu.Game.Users.Profile Direction = FillDirection.Vertical, Padding = new MarginPadding { Horizontal = 20, Vertical = 18 }, Spacing = new Vector2(0, 2) + }, + new FillFlowContainer + { + AutoSizeAxes = Axes.Both, + Direction = FillDirection.Horizontal, + Anchor = Anchor.BottomCentre, + Origin = Anchor.BottomCentre, + Y = -64, + Spacing = new Vector2(20, 0), + Children = new GradeBadge[] + { + gradeSSPlus = new GradeBadge("SSPlus") { Count = 12 }, + gradeSS = new GradeBadge("SS") { Count = 34 }, + } + }, + new FillFlowContainer + { + AutoSizeAxes = Axes.Both, + Direction = FillDirection.Horizontal, + Anchor = Anchor.BottomCentre, + Origin = Anchor.BottomCentre, + Y = -18, + Spacing = new Vector2(20, 0), + Children = new GradeBadge[] + { + gradeSPlus = new GradeBadge("SPlus") { Count = 567 }, + gradeS = new GradeBadge("S") { Count = 890 }, + gradeA = new GradeBadge("A") { Count = 1234 }, + } } } }, @@ -268,5 +298,46 @@ namespace osu.Game.Users.Profile Origin = Anchor.TopRight, Text = text }; + + private class GradeBadge : Container + { + private const float width = 50; + private readonly string grade; + private readonly Sprite badge; + private readonly SpriteText numberText; + + public int Count + { + set + { + numberText.Text = value.ToString(@"#,#"); + } + } + + public GradeBadge(string grade) + { + this.grade = grade; + Width = width; + Height = 41; + Add(badge = new Sprite + { + Width = width, + Height = 26 + }); + Add(numberText = new SpriteText + { + Anchor = Anchor.BottomCentre, + Origin = Anchor.BottomCentre, + TextSize = 14, + Font = @"Exo2.0-Bold" + }); + } + + [BackgroundDependencyLoader] + private void load(TextureStore textures) + { + badge.Texture = textures.Get($"Grades/{grade}"); + } + } } } From 190de76d9a9709f4d9902d74fb926f2a852c5b4e Mon Sep 17 00:00:00 2001 From: Huo Yaoyuan Date: Wed, 14 Jun 2017 20:37:07 +0800 Subject: [PATCH 029/106] Add LineGraph. --- osu.Game/Graphics/UserInterface/LineGraph.cs | 62 ++++++++++++++++++++ osu.Game/osu.Game.csproj | 1 + 2 files changed, 63 insertions(+) create mode 100644 osu.Game/Graphics/UserInterface/LineGraph.cs diff --git a/osu.Game/Graphics/UserInterface/LineGraph.cs b/osu.Game/Graphics/UserInterface/LineGraph.cs new file mode 100644 index 0000000000..36c63eb13c --- /dev/null +++ b/osu.Game/Graphics/UserInterface/LineGraph.cs @@ -0,0 +1,62 @@ +// Copyright (c) 2007-2017 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using System; +using System.Collections.Generic; +using System.Linq; +using OpenTK; +using osu.Framework.Graphics; +using osu.Framework.Graphics.Containers; +using osu.Framework.Graphics.Lines; + +namespace osu.Game.Graphics.UserInterface +{ + public class LineGraph : Container + { + /// + /// Manually set the max value, otherwise will be used. + /// + public float? MaxValue { get; set; } + + /// + /// Manually set the min value, otherwise will be used. + /// + public float? MinValue { get; set; } + + private const float transform_duration = 250; + + /// + /// Hold an empty area if values are less. + /// + public int DefaultValueCount; + + private Path path; + + /// + /// A list of floats decides position of each line node. + /// + public IEnumerable Values + { + set + { + path?.Expire(); + Path localPath = new Path { RelativeSizeAxes = Axes.Both }; //capture a copy to avoid potential change + Add(path = localPath); + + var values = value.ToArray(); + int count = Math.Max(values.Length, DefaultValueCount); + + float max = values.Max(), min = values.Min(); + if (MaxValue > max) max = MaxValue.Value; + if (MinValue < min) min = MinValue.Value; + + for (int i = 0; i < values.Length; i++) + { + float x = (i + count - values.Length) / (float)(count - 1); + float y = (max - values[i]) / (max - min); + Scheduler.AddDelayed(() => localPath.AddVertex(new Vector2(x, y)), x * transform_duration); + } + } + } + } +} diff --git a/osu.Game/osu.Game.csproj b/osu.Game/osu.Game.csproj index 88ce5e59dc..0fe30c0abc 100644 --- a/osu.Game/osu.Game.csproj +++ b/osu.Game/osu.Game.csproj @@ -80,6 +80,7 @@ + From 43542fa5b417e978810f0e96ddf456ee12d57255 Mon Sep 17 00:00:00 2001 From: Huo Yaoyuan Date: Wed, 14 Jun 2017 20:39:58 +0800 Subject: [PATCH 030/106] Slightly update design to follow web page. --- osu.Game/Users/Profile/ProfileHeader.cs | 6 +++--- osu.Game/Users/UserProfile.cs | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/osu.Game/Users/Profile/ProfileHeader.cs b/osu.Game/Users/Profile/ProfileHeader.cs index 8d15a47fdf..f2b82705dd 100644 --- a/osu.Game/Users/Profile/ProfileHeader.cs +++ b/osu.Game/Users/Profile/ProfileHeader.cs @@ -33,7 +33,7 @@ namespace osu.Game.Users.Profile { this.user = user; RelativeSizeAxes = Axes.X; - Height = cover_height + info_height - UserProfile.TAB_HEIGHT; + Height = cover_height + info_height; Children = new Drawable[] { @@ -106,7 +106,7 @@ namespace osu.Game.Users.Profile }, infoText = new OsuTextFlowContainer(t => { - t.TextSize = 12; + t.TextSize = 14; t.Alpha = 0.8f; }) { @@ -219,7 +219,7 @@ namespace osu.Game.Users.Profile RelativeSizeAxes = Axes.X, Anchor = Anchor.BottomCentre, Origin = Anchor.BottomCentre, - Height = info_height - UserProfile.TAB_HEIGHT - 15, + Height = info_height - 15, Children = new Drawable[] { new Box diff --git a/osu.Game/Users/UserProfile.cs b/osu.Game/Users/UserProfile.cs index bbe73b8124..27f18a0f14 100644 --- a/osu.Game/Users/UserProfile.cs +++ b/osu.Game/Users/UserProfile.cs @@ -22,7 +22,7 @@ namespace osu.Game.Users private ProfileSection lastSection; private readonly ProfileTabControl tabs; - public const float CONTENT_X_MARGIN = 50, TAB_HEIGHT = 24; + public const float CONTENT_X_MARGIN = 50; public UserProfile(User user) { @@ -42,7 +42,7 @@ namespace osu.Game.Users RelativeSizeAxes = Axes.X, Anchor = Anchor.TopCentre, Origin = Anchor.TopCentre, - Height = TAB_HEIGHT + Height = 24 }; sections.ForEach(tabs.AddItem); From 443e24716c4f9212d0bdfc2877006b7d0b2dd028 Mon Sep 17 00:00:00 2001 From: Huo Yaoyuan Date: Wed, 14 Jun 2017 22:00:22 +0800 Subject: [PATCH 031/106] Handle relative size at LineGraph level. --- osu.Game/Graphics/UserInterface/LineGraph.cs | 45 ++++++++++++++------ 1 file changed, 31 insertions(+), 14 deletions(-) diff --git a/osu.Game/Graphics/UserInterface/LineGraph.cs b/osu.Game/Graphics/UserInterface/LineGraph.cs index 36c63eb13c..c03be462dc 100644 --- a/osu.Game/Graphics/UserInterface/LineGraph.cs +++ b/osu.Game/Graphics/UserInterface/LineGraph.cs @@ -32,6 +32,8 @@ namespace osu.Game.Graphics.UserInterface private Path path; + private float[] values; + /// /// A list of floats decides position of each line node. /// @@ -39,23 +41,38 @@ namespace osu.Game.Graphics.UserInterface { set { - path?.Expire(); - Path localPath = new Path { RelativeSizeAxes = Axes.Both }; //capture a copy to avoid potential change - Add(path = localPath); + values = value.ToArray(); + applyPath(); + } + } - var values = value.ToArray(); - int count = Math.Max(values.Length, DefaultValueCount); + public override bool Invalidate(Invalidation invalidation = Invalidation.All, Drawable source = null, bool shallPropagate = true) + { + if ((invalidation & Invalidation.DrawSize) != 0) + applyPath(); + return base.Invalidate(invalidation, source, shallPropagate); + } - float max = values.Max(), min = values.Min(); - if (MaxValue > max) max = MaxValue.Value; - if (MinValue < min) min = MinValue.Value; + private void applyPath() + { + if (values == null) return; - for (int i = 0; i < values.Length; i++) - { - float x = (i + count - values.Length) / (float)(count - 1); - float y = (max - values[i]) / (max - min); - Scheduler.AddDelayed(() => localPath.AddVertex(new Vector2(x, y)), x * transform_duration); - } + path?.Expire(); + Path localPath = new Path { RelativeSizeAxes = Axes.Both, PathWidth = 1 }; //capture a copy to avoid potential change + Add(path = localPath); + + int count = Math.Max(values.Length, DefaultValueCount); + + float max = values.Max(), min = values.Min(); + if (MaxValue > max) max = MaxValue.Value; + if (MinValue < min) min = MinValue.Value; + + for (int i = 0; i < values.Length; i++) + { + float x = (i + count - values.Length) / (float)(count - 1) * DrawWidth - 1; + float y = (max - values[i]) / (max - min) * DrawHeight - 1; + // the -1 is for inner offset in path (actually -PathWidth) + localPath.AddVertex(new Vector2(x, y)); } } } From 3b64dfe0fd3e9bbe40aac9b3d23aafdebfd660e0 Mon Sep 17 00:00:00 2001 From: Huo Yaoyuan Date: Thu, 15 Jun 2017 00:46:39 +0800 Subject: [PATCH 032/106] Update transform using masking. --- osu.Game/Graphics/UserInterface/LineGraph.cs | 24 ++++++++++++++------ 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/osu.Game/Graphics/UserInterface/LineGraph.cs b/osu.Game/Graphics/UserInterface/LineGraph.cs index c03be462dc..3bc4556a27 100644 --- a/osu.Game/Graphics/UserInterface/LineGraph.cs +++ b/osu.Game/Graphics/UserInterface/LineGraph.cs @@ -23,14 +23,15 @@ namespace osu.Game.Graphics.UserInterface /// public float? MinValue { get; set; } - private const float transform_duration = 250; + private const double transform_duration = 500; /// /// Hold an empty area if values are less. /// public int DefaultValueCount; - private Path path; + private readonly Container maskingContainer; + private readonly Path path; private float[] values; @@ -43,9 +44,21 @@ namespace osu.Game.Graphics.UserInterface { values = value.ToArray(); applyPath(); + maskingContainer.Width = 0; + maskingContainer.ResizeWidthTo(1, transform_duration, EasingTypes.OutQuint); } } + public LineGraph() + { + Add(maskingContainer = new Container + { + Masking = true, + RelativeSizeAxes = Axes.Both + }); + maskingContainer.Add(path = new Path { RelativeSizeAxes = Axes.Both, PathWidth = 1 }); + } + public override bool Invalidate(Invalidation invalidation = Invalidation.All, Drawable source = null, bool shallPropagate = true) { if ((invalidation & Invalidation.DrawSize) != 0) @@ -57,10 +70,7 @@ namespace osu.Game.Graphics.UserInterface { if (values == null) return; - path?.Expire(); - Path localPath = new Path { RelativeSizeAxes = Axes.Both, PathWidth = 1 }; //capture a copy to avoid potential change - Add(path = localPath); - + path.ClearVertices(); int count = Math.Max(values.Length, DefaultValueCount); float max = values.Max(), min = values.Min(); @@ -72,7 +82,7 @@ namespace osu.Game.Graphics.UserInterface float x = (i + count - values.Length) / (float)(count - 1) * DrawWidth - 1; float y = (max - values[i]) / (max - min) * DrawHeight - 1; // the -1 is for inner offset in path (actually -PathWidth) - localPath.AddVertex(new Vector2(x, y)); + path.AddVertex(new Vector2(x, y)); } } } From 53ad7bc8ca1bb2e45ca807fb331fc68e81bfbf58 Mon Sep 17 00:00:00 2001 From: Huo Yaoyuan Date: Thu, 15 Jun 2017 00:48:01 +0800 Subject: [PATCH 033/106] Add RankChart. --- osu.Game/Users/Profile/ProfileHeader.cs | 4 ++ osu.Game/Users/Profile/RankChart.cs | 93 +++++++++++++++++++++++++ osu.Game/osu.Game.csproj | 1 + 3 files changed, 98 insertions(+) create mode 100644 osu.Game/Users/Profile/RankChart.cs diff --git a/osu.Game/Users/Profile/ProfileHeader.cs b/osu.Game/Users/Profile/ProfileHeader.cs index f2b82705dd..7772797750 100644 --- a/osu.Game/Users/Profile/ProfileHeader.cs +++ b/osu.Game/Users/Profile/ProfileHeader.cs @@ -226,6 +226,10 @@ namespace osu.Game.Users.Profile { Colour = Color4.Black.Opacity(0.25f), RelativeSizeAxes = Axes.Both + }, + new RankChart(user) + { + RelativeSizeAxes = Axes.Both } } } diff --git a/osu.Game/Users/Profile/RankChart.cs b/osu.Game/Users/Profile/RankChart.cs new file mode 100644 index 0000000000..9cb11623da --- /dev/null +++ b/osu.Game/Users/Profile/RankChart.cs @@ -0,0 +1,93 @@ +// Copyright (c) 2007-2017 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using System; +using System.Linq; +using System.Threading.Tasks; +using osu.Framework.Allocation; +using osu.Framework.Graphics; +using osu.Framework.Graphics.Containers; +using osu.Framework.Graphics.Sprites; +using osu.Game.Graphics; +using osu.Game.Graphics.Sprites; +using osu.Game.Graphics.UserInterface; + +namespace osu.Game.Users.Profile +{ + public class RankChart : Container + { + private readonly SpriteText rank, performance, relative; + private readonly LineGraph graph; + + private readonly int[] ranks, performances; + + public RankChart(User user) + { + Padding = new MarginPadding { Vertical = 10 }; + Children = new Drawable[] + { + rank = new OsuSpriteText + { + Anchor = Anchor.TopCentre, + Origin = Anchor.TopCentre, + Font = @"Exo2.0-RegularItalic", + TextSize = 25 + }, + relative = new OsuSpriteText + { + Anchor = Anchor.TopCentre, + Origin = Anchor.TopCentre, + Font = @"Exo2.0-RegularItalic", + Y = 25, + TextSize = 13 + }, + performance = new OsuSpriteText + { + Anchor = Anchor.BottomCentre, + Origin = Anchor.BottomCentre, + Font = @"Exo2.0-RegularItalic", + TextSize = 13 + }, + graph = new LineGraph + { + Anchor = Anchor.BottomCentre, + Origin = Anchor.BottomCentre, + RelativeSizeAxes = Axes.X, + Y = -13, + DefaultValueCount = 90 + } + }; + + //placeholder text + rank.Text = "#12,345"; + relative.Text = $"{user.Country?.FullName} #678"; + performance.Text = "4,567pp"; + ranks = Enumerable.Range(1234, 80).ToArray(); + performances = ranks.Select(x => 6000 - x).ToArray(); + } + + [BackgroundDependencyLoader] + private void load(OsuColour colours) + { + graph.Colour = colours.Yellow; + Task.Factory.StartNew(() => + { + System.Threading.Thread.Sleep(1000); + // put placeholder data here to show the transform + + // use logarithmic coordinates + graph.Values = ranks.Select(x => -(float)Math.Log(x)); + }); + } + + public override bool Invalidate(Invalidation invalidation = Invalidation.All, Drawable source = null, bool shallPropagate = true) + { + if ((invalidation & Invalidation.DrawSize) != 0) + { + graph.Height = DrawHeight - 71; + } + + return base.Invalidate(invalidation, source, shallPropagate); + } + } +} diff --git a/osu.Game/osu.Game.csproj b/osu.Game/osu.Game.csproj index 0fe30c0abc..3b15f6890e 100644 --- a/osu.Game/osu.Game.csproj +++ b/osu.Game/osu.Game.csproj @@ -102,6 +102,7 @@ + From 78669a594187059907a5d97aa7e1592d5317edb3 Mon Sep 17 00:00:00 2001 From: Huo Yaoyuan Date: Thu, 15 Jun 2017 02:17:48 +0800 Subject: [PATCH 034/106] Hover for rank history. --- osu.Game/Graphics/UserInterface/LineGraph.cs | 7 ++ osu.Game/Users/Profile/RankChart.cs | 116 ++++++++++++++++--- 2 files changed, 107 insertions(+), 16 deletions(-) diff --git a/osu.Game/Graphics/UserInterface/LineGraph.cs b/osu.Game/Graphics/UserInterface/LineGraph.cs index 3bc4556a27..02e8a8329a 100644 --- a/osu.Game/Graphics/UserInterface/LineGraph.cs +++ b/osu.Game/Graphics/UserInterface/LineGraph.cs @@ -23,6 +23,9 @@ namespace osu.Game.Graphics.UserInterface /// public float? MinValue { get; set; } + public float? ActualMaxValue { get; private set; } + public float? ActualMinValue { get; private set; } + private const double transform_duration = 500; /// @@ -40,6 +43,7 @@ namespace osu.Game.Graphics.UserInterface /// public IEnumerable Values { + get { return values; } set { values = value.ToArray(); @@ -77,6 +81,9 @@ namespace osu.Game.Graphics.UserInterface if (MaxValue > max) max = MaxValue.Value; if (MinValue < min) min = MinValue.Value; + ActualMaxValue = max; + ActualMinValue = min; + for (int i = 0; i < values.Length; i++) { float x = (i + count - values.Length) / (float)(count - 1) * DrawWidth - 1; diff --git a/osu.Game/Users/Profile/RankChart.cs b/osu.Game/Users/Profile/RankChart.cs index 9cb11623da..49f67efbdc 100644 --- a/osu.Game/Users/Profile/RankChart.cs +++ b/osu.Game/Users/Profile/RankChart.cs @@ -2,12 +2,15 @@ // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE using System; +using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; +using OpenTK; using osu.Framework.Allocation; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Sprites; +using osu.Framework.Input; using osu.Game.Graphics; using osu.Game.Graphics.Sprites; using osu.Game.Graphics.UserInterface; @@ -16,24 +19,28 @@ namespace osu.Game.Users.Profile { public class RankChart : Container { - private readonly SpriteText rank, performance, relative; - private readonly LineGraph graph; + private readonly SpriteText rankText, performanceText, relativeText; + private readonly RankChartLineGraph graph; - private readonly int[] ranks, performances; + private int[] ranks, performances; + private int rank, performance, countryRank; + + private readonly User user; public RankChart(User user) { + this.user = user; Padding = new MarginPadding { Vertical = 10 }; Children = new Drawable[] { - rank = new OsuSpriteText + rankText = new OsuSpriteText { Anchor = Anchor.TopCentre, Origin = Anchor.TopCentre, Font = @"Exo2.0-RegularItalic", TextSize = 25 }, - relative = new OsuSpriteText + relativeText = new OsuSpriteText { Anchor = Anchor.TopCentre, Origin = Anchor.TopCentre, @@ -41,29 +48,35 @@ namespace osu.Game.Users.Profile Y = 25, TextSize = 13 }, - performance = new OsuSpriteText + performanceText = new OsuSpriteText { Anchor = Anchor.BottomCentre, Origin = Anchor.BottomCentre, Font = @"Exo2.0-RegularItalic", TextSize = 13 }, - graph = new LineGraph + graph = new RankChartLineGraph { Anchor = Anchor.BottomCentre, Origin = Anchor.BottomCentre, RelativeSizeAxes = Axes.X, Y = -13, - DefaultValueCount = 90 + DefaultValueCount = 90, + BallRelease = () => + { + rankText.Text = $"#{rank:#,#}"; + performanceText.Text = $"{performance:#,#}pp"; + relativeText.Text = $"{this.user.Country?.FullName} #{countryRank:#,#}"; + }, + BallMove = index => + { + rankText.Text = $"#{ranks[index]:#,#}"; + performanceText.Text = $"{performances[index]:#,#}pp"; + relativeText.Text = index == ranks.Length ? "Now" : $"{ranks.Length - index} days ago"; + //plural should be handled in a general way + } } }; - - //placeholder text - rank.Text = "#12,345"; - relative.Text = $"{user.Country?.FullName} #678"; - performance.Text = "4,567pp"; - ranks = Enumerable.Range(1234, 80).ToArray(); - performances = ranks.Select(x => 6000 - x).ToArray(); } [BackgroundDependencyLoader] @@ -73,10 +86,16 @@ namespace osu.Game.Users.Profile Task.Factory.StartNew(() => { System.Threading.Thread.Sleep(1000); - // put placeholder data here to show the transform + // put placeholder data here to show the transform + rank = 12345; + countryRank = 678; + performance = 4567; + ranks = Enumerable.Range(1234, 80).ToArray(); + performances = ranks.Select(x => 6000 - x).ToArray(); // use logarithmic coordinates graph.Values = ranks.Select(x => -(float)Math.Log(x)); + graph.ResetBall(); }); } @@ -89,5 +108,70 @@ namespace osu.Game.Users.Profile return base.Invalidate(invalidation, source, shallPropagate); } + + private class RankChartLineGraph : LineGraph + { + private readonly CircularContainer ball; + private bool ballShown; + + private const double transform_duration = 100; + + public Action BallMove; + public Action BallRelease; + + public RankChartLineGraph() + { + Add(ball = new CircularContainer + { + Size = new Vector2(8), + Masking = true, + Origin = Anchor.Centre, + Alpha = 0, + RelativePositionAxes = Axes.Both, + Children = new Drawable[] + { + new Box { RelativeSizeAxes = Axes.Both } + } + }); + } + + public void ResetBall() + { + ball.MoveTo(new Vector2(1, ((ActualMaxValue - Values.Last()) / (ActualMaxValue - ActualMinValue)).Value), ballShown ? transform_duration : 0, EasingTypes.OutQuint); + ball.Show(); + BallRelease(); + ballShown = true; + } + + protected override bool OnMouseMove(InputState state) + { + if (ballShown) + { + var values = Values as IList; + var position = ToLocalSpace(state.Mouse.NativeState.Position); + int count = Math.Max(values.Count, DefaultValueCount); + int index = (int)Math.Round(position.X / DrawWidth * (count - 1)); + if (index >= count - values.Count) + { + int i = index + values.Count - count; + float value = values[i]; + float y = ((ActualMaxValue - value) / (ActualMaxValue - ActualMinValue)).Value; + if (Math.Abs(y * DrawHeight - position.Y) <= 8f) + { + ball.MoveTo(new Vector2(index / (float)(count - 1), y), transform_duration, EasingTypes.OutQuint); + BallMove(i); + } + } + } + return base.OnMouseMove(state); + } + + protected override void OnHoverLost(InputState state) + { + if (ballShown) + ResetBall(); + base.OnHoverLost(state); + } + } } } From f7a451ed8221efa1ef2ad4f84b955edfca73ecec Mon Sep 17 00:00:00 2001 From: Huo Yaoyuan Date: Thu, 15 Jun 2017 02:38:51 +0800 Subject: [PATCH 035/106] Update test case. --- osu.Desktop.VisualTests/Tests/TestCaseUserProfile.cs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/osu.Desktop.VisualTests/Tests/TestCaseUserProfile.cs b/osu.Desktop.VisualTests/Tests/TestCaseUserProfile.cs index 9eea2cbf19..7fc32442f5 100644 --- a/osu.Desktop.VisualTests/Tests/TestCaseUserProfile.cs +++ b/osu.Desktop.VisualTests/Tests/TestCaseUserProfile.cs @@ -7,6 +7,7 @@ using System.Linq; using System.Text; using System.Threading.Tasks; using osu.Framework.Graphics; +using osu.Framework.Graphics.Containers; using osu.Framework.Testing; using osu.Game.Overlays; using osu.Game.Users; @@ -24,17 +25,17 @@ namespace osu.Desktop.VisualTests.Tests { Username = @"peppy", Id = 2, - Country = new Country { FlagName = @"AU" }, + Country = new Country { FullName = @"Australia", FlagName = @"AU" }, CoverUrl = @"https://osu.ppy.sh/images/headers/profile-covers/c3.jpg" }) { Anchor = Anchor.Centre, Origin = Anchor.Centre, - Width = 800, - Height = 500 + RelativeSizeAxes = Axes.Both, + Padding = new MarginPadding { Horizontal = 50 }, + State = Visibility.Visible }; Add(userpage); - AddStep("Toggle", userpage.ToggleVisibility); } } } From 1737b59d37bf84eabb3d2cadd0baefb484b3a70b Mon Sep 17 00:00:00 2001 From: Huo Yaoyuan Date: Thu, 15 Jun 2017 07:23:30 +0800 Subject: [PATCH 036/106] Slightly update some sizes. --- osu.Game/Users/Profile/ProfileHeader.cs | 4 ++-- osu.Game/Users/Profile/ProfileSection.cs | 2 +- osu.Game/Users/UserProfile.cs | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/osu.Game/Users/Profile/ProfileHeader.cs b/osu.Game/Users/Profile/ProfileHeader.cs index 7772797750..34dc2fb593 100644 --- a/osu.Game/Users/Profile/ProfileHeader.cs +++ b/osu.Game/Users/Profile/ProfileHeader.cs @@ -87,7 +87,7 @@ namespace osu.Game.Users.Profile new OsuSpriteText { Text = user.Username, - TextSize = 25, + TextSize = 30, Font = @"Exo2.0-RegularItalic", Anchor = Anchor.BottomLeft, Origin = Anchor.BottomLeft, @@ -149,7 +149,7 @@ namespace osu.Game.Users.Profile Anchor = Anchor.TopCentre, Origin = Anchor.TopCentre, Y = 11, - TextSize = 18 + TextSize = 20 } } }, diff --git a/osu.Game/Users/Profile/ProfileSection.cs b/osu.Game/Users/Profile/ProfileSection.cs index d8cc2f4e8c..c6f45403e3 100644 --- a/osu.Game/Users/Profile/ProfileSection.cs +++ b/osu.Game/Users/Profile/ProfileSection.cs @@ -27,7 +27,7 @@ namespace osu.Game.Users.Profile new OsuSpriteText { Text = Title, - TextSize = 16, + TextSize = 20, Font = @"Exo2.0-RegularItalic", Margin = new MarginPadding { diff --git a/osu.Game/Users/UserProfile.cs b/osu.Game/Users/UserProfile.cs index 27f18a0f14..629dbbe5a9 100644 --- a/osu.Game/Users/UserProfile.cs +++ b/osu.Game/Users/UserProfile.cs @@ -42,7 +42,7 @@ namespace osu.Game.Users RelativeSizeAxes = Axes.X, Anchor = Anchor.TopCentre, Origin = Anchor.TopCentre, - Height = 24 + Height = 30 }; sections.ForEach(tabs.AddItem); From 1d85578bf59a4fe9efed4daa5b5c3e33141fcf42 Mon Sep 17 00:00:00 2001 From: Huo Yaoyuan Date: Thu, 15 Jun 2017 07:29:32 +0800 Subject: [PATCH 037/106] Fix license header. --- osu.Game/Graphics/Containers/OsuTextFlowContainer.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Graphics/Containers/OsuTextFlowContainer.cs b/osu.Game/Graphics/Containers/OsuTextFlowContainer.cs index 38c1edbc4e..570e682618 100644 --- a/osu.Game/Graphics/Containers/OsuTextFlowContainer.cs +++ b/osu.Game/Graphics/Containers/OsuTextFlowContainer.cs @@ -1,5 +1,5 @@ // Copyright (c) 2007-2017 ppy Pty Ltd . -// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu-framework/master/LICENCE +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE using System; using System.Collections.Generic; From b37c3f8ce159a32f07b37e484124a5e72cc31bd0 Mon Sep 17 00:00:00 2001 From: Huo Yaoyuan Date: Thu, 15 Jun 2017 07:58:20 +0800 Subject: [PATCH 038/106] Some CI fixes. --- .../Tests/TestCaseUserProfile.cs | 6 --- osu.Game/Users/Profile/ProfileHeader.cs | 22 +++++------ osu.Game/Users/Profile/RankChart.cs | 37 ++++++++++++------- osu.Game/Users/UserProfile.cs | 3 +- 4 files changed, 35 insertions(+), 33 deletions(-) diff --git a/osu.Desktop.VisualTests/Tests/TestCaseUserProfile.cs b/osu.Desktop.VisualTests/Tests/TestCaseUserProfile.cs index 7fc32442f5..23091ec35b 100644 --- a/osu.Desktop.VisualTests/Tests/TestCaseUserProfile.cs +++ b/osu.Desktop.VisualTests/Tests/TestCaseUserProfile.cs @@ -1,15 +1,9 @@ // Copyright (c) 2007-2017 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Testing; -using osu.Game.Overlays; using osu.Game.Users; namespace osu.Desktop.VisualTests.Tests diff --git a/osu.Game/Users/Profile/ProfileHeader.cs b/osu.Game/Users/Profile/ProfileHeader.cs index 34dc2fb593..cf294a8863 100644 --- a/osu.Game/Users/Profile/ProfileHeader.cs +++ b/osu.Game/Users/Profile/ProfileHeader.cs @@ -19,7 +19,7 @@ namespace osu.Game.Users.Profile { public class ProfileHeader : Container { - private readonly User user; + //private readonly User user; private readonly OsuTextFlowContainer infoText; private readonly FillFlowContainer scoreText, scoreNumberText; @@ -31,7 +31,7 @@ namespace osu.Game.Users.Profile private const float cover_height = 350, info_height = 150, avatar_size = 110, avatar_bottom_position = -20, level_position = 30, level_height = 60; public ProfileHeader(User user) { - this.user = user; + //this.user = user; RelativeSizeAxes = Axes.X; Height = cover_height + info_height; @@ -191,7 +191,7 @@ namespace osu.Game.Users.Profile Origin = Anchor.BottomCentre, Y = -64, Spacing = new Vector2(20, 0), - Children = new GradeBadge[] + Children = new[] { gradeSSPlus = new GradeBadge("SSPlus") { Count = 12 }, gradeSS = new GradeBadge("SS") { Count = 34 }, @@ -205,7 +205,7 @@ namespace osu.Game.Users.Profile Origin = Anchor.BottomCentre, Y = -18, Spacing = new Vector2(20, 0), - Children = new GradeBadge[] + Children = new[] { gradeSPlus = new GradeBadge("SPlus") { Count = 567 }, gradeS = new GradeBadge("S") { Count = 890 }, @@ -236,13 +236,19 @@ namespace osu.Game.Users.Profile } } }; + } + + [BackgroundDependencyLoader] + private void load(TextureStore textures) + { + levelBadge.Texture = textures.Get(@"Profile/levelbadge"); Action bold = t => { t.Font = @"Exo2.0-Bold"; t.Alpha = 1; }; - // placeholder text + // fill placeholder texts infoText.AddTextAwesome(FontAwesome.fa_map_marker); infoText.AddText(" position "); infoText.AddTextAwesome(FontAwesome.fa_twitter); @@ -282,12 +288,6 @@ namespace osu.Game.Users.Profile scoreNumberText.Add(createScoreNumberText("23")); } - [BackgroundDependencyLoader] - private void load(TextureStore textures) - { - levelBadge.Texture = textures.Get(@"Profile/levelbadge"); - } - private OsuSpriteText createScoreText(string text) => new OsuSpriteText { TextSize = 14, diff --git a/osu.Game/Users/Profile/RankChart.cs b/osu.Game/Users/Profile/RankChart.cs index 49f67efbdc..20700a65df 100644 --- a/osu.Game/Users/Profile/RankChart.cs +++ b/osu.Game/Users/Profile/RankChart.cs @@ -3,6 +3,7 @@ using System; using System.Collections.Generic; +using System.Diagnostics; using System.Linq; using System.Threading.Tasks; using OpenTK; @@ -62,23 +63,27 @@ namespace osu.Game.Users.Profile RelativeSizeAxes = Axes.X, Y = -13, DefaultValueCount = 90, - BallRelease = () => - { - rankText.Text = $"#{rank:#,#}"; - performanceText.Text = $"{performance:#,#}pp"; - relativeText.Text = $"{this.user.Country?.FullName} #{countryRank:#,#}"; - }, - BallMove = index => - { - rankText.Text = $"#{ranks[index]:#,#}"; - performanceText.Text = $"{performances[index]:#,#}pp"; - relativeText.Text = index == ranks.Length ? "Now" : $"{ranks.Length - index} days ago"; - //plural should be handled in a general way - } + BallRelease = updateRankTexts, + BallMove = showHistoryRankTexts } }; } + private void updateRankTexts() + { + rankText.Text = $"#{rank:#,#}"; + performanceText.Text = $"{performance:#,#}pp"; + relativeText.Text = $"{this.user.Country?.FullName} #{countryRank:#,#}"; + } + + private void showHistoryRankTexts(int dayIndex) + { + rankText.Text = $"#{ranks[dayIndex]:#,#}"; + performanceText.Text = $"{performances[dayIndex]:#,#}pp"; + relativeText.Text = dayIndex == ranks.Length ? "Now" : $"{ranks.Length - dayIndex} days ago"; + //plural should be handled in a general way + } + [BackgroundDependencyLoader] private void load(OsuColour colours) { @@ -137,6 +142,8 @@ namespace osu.Game.Users.Profile public void ResetBall() { + Trace.Assert(ActualMaxValue.HasValue); + Trace.Assert(ActualMinValue.HasValue); ball.MoveTo(new Vector2(1, ((ActualMaxValue - Values.Last()) / (ActualMaxValue - ActualMinValue)).Value), ballShown ? transform_duration : 0, EasingTypes.OutQuint); ball.Show(); BallRelease(); @@ -147,7 +154,7 @@ namespace osu.Game.Users.Profile { if (ballShown) { - var values = Values as IList; + var values = (IList)Values; var position = ToLocalSpace(state.Mouse.NativeState.Position); int count = Math.Max(values.Count, DefaultValueCount); int index = (int)Math.Round(position.X / DrawWidth * (count - 1)); @@ -155,6 +162,8 @@ namespace osu.Game.Users.Profile { int i = index + values.Count - count; float value = values[i]; + Trace.Assert(ActualMaxValue.HasValue); + Trace.Assert(ActualMinValue.HasValue); float y = ((ActualMaxValue - value) / (ActualMaxValue - ActualMinValue)).Value; if (Math.Abs(y * DrawHeight - position.Y) <= 8f) { diff --git a/osu.Game/Users/UserProfile.cs b/osu.Game/Users/UserProfile.cs index 629dbbe5a9..2470db1de5 100644 --- a/osu.Game/Users/UserProfile.cs +++ b/osu.Game/Users/UserProfile.cs @@ -20,7 +20,6 @@ namespace osu.Game.Users { private readonly User user; private ProfileSection lastSection; - private readonly ProfileTabControl tabs; public const float CONTENT_X_MARGIN = 50; @@ -37,7 +36,7 @@ namespace osu.Game.Users new BeatmapsSection(user), new KudosuSection(user) }; - tabs = new ProfileTabControl + var tabs = new ProfileTabControl { RelativeSizeAxes = Axes.X, Anchor = Anchor.TopCentre, From 4c8658980b65b0a3b80a7dda613ea6c06450400c Mon Sep 17 00:00:00 2001 From: Huo Yaoyuan Date: Thu, 15 Jun 2017 08:00:15 +0800 Subject: [PATCH 039/106] Remove unused user instance for now. --- osu.Game/Users/Profile/AboutSection.cs | 4 ---- osu.Game/Users/Profile/BeatmapsSection.cs | 4 ---- osu.Game/Users/Profile/HistoricalSection.cs | 4 ---- osu.Game/Users/Profile/KudosuSection.cs | 4 ---- osu.Game/Users/Profile/MedalsSection.cs | 4 ---- osu.Game/Users/Profile/RanksSection.cs | 4 ---- osu.Game/Users/Profile/RecentSection.cs | 4 ---- osu.Game/Users/UserProfile.cs | 16 +++++++--------- 8 files changed, 7 insertions(+), 37 deletions(-) diff --git a/osu.Game/Users/Profile/AboutSection.cs b/osu.Game/Users/Profile/AboutSection.cs index b2e5ae1b35..69ace5fc71 100644 --- a/osu.Game/Users/Profile/AboutSection.cs +++ b/osu.Game/Users/Profile/AboutSection.cs @@ -6,9 +6,5 @@ namespace osu.Game.Users.Profile public class AboutSection : ProfileSection { public override string Title => "me!"; - - public AboutSection(User user) - { - } } } diff --git a/osu.Game/Users/Profile/BeatmapsSection.cs b/osu.Game/Users/Profile/BeatmapsSection.cs index 4068283c73..a69c65c84a 100644 --- a/osu.Game/Users/Profile/BeatmapsSection.cs +++ b/osu.Game/Users/Profile/BeatmapsSection.cs @@ -6,9 +6,5 @@ namespace osu.Game.Users.Profile public class BeatmapsSection : ProfileSection { public override string Title => "Beatmaps"; - - public BeatmapsSection(User user) - { - } } } diff --git a/osu.Game/Users/Profile/HistoricalSection.cs b/osu.Game/Users/Profile/HistoricalSection.cs index 12d6d2a409..c5f357d322 100644 --- a/osu.Game/Users/Profile/HistoricalSection.cs +++ b/osu.Game/Users/Profile/HistoricalSection.cs @@ -6,9 +6,5 @@ namespace osu.Game.Users.Profile public class HistoricalSection : ProfileSection { public override string Title => "Historical"; - - public HistoricalSection(User user) - { - } } } diff --git a/osu.Game/Users/Profile/KudosuSection.cs b/osu.Game/Users/Profile/KudosuSection.cs index 312661f676..b489f6544d 100644 --- a/osu.Game/Users/Profile/KudosuSection.cs +++ b/osu.Game/Users/Profile/KudosuSection.cs @@ -6,9 +6,5 @@ namespace osu.Game.Users.Profile public class KudosuSection : ProfileSection { public override string Title => "Kudosu!"; - - public KudosuSection(User user) - { - } } } diff --git a/osu.Game/Users/Profile/MedalsSection.cs b/osu.Game/Users/Profile/MedalsSection.cs index 7db8c69222..0a52830340 100644 --- a/osu.Game/Users/Profile/MedalsSection.cs +++ b/osu.Game/Users/Profile/MedalsSection.cs @@ -6,9 +6,5 @@ namespace osu.Game.Users.Profile public class MedalsSection : ProfileSection { public override string Title => "Medals"; - - public MedalsSection(User user) - { - } } } diff --git a/osu.Game/Users/Profile/RanksSection.cs b/osu.Game/Users/Profile/RanksSection.cs index 1c51866218..65f3f04c1b 100644 --- a/osu.Game/Users/Profile/RanksSection.cs +++ b/osu.Game/Users/Profile/RanksSection.cs @@ -6,9 +6,5 @@ namespace osu.Game.Users.Profile public class RanksSection : ProfileSection { public override string Title => "Ranks"; - - public RanksSection(User user) - { - } } } diff --git a/osu.Game/Users/Profile/RecentSection.cs b/osu.Game/Users/Profile/RecentSection.cs index 96cf9d7a24..6cd3bf6c49 100644 --- a/osu.Game/Users/Profile/RecentSection.cs +++ b/osu.Game/Users/Profile/RecentSection.cs @@ -6,9 +6,5 @@ namespace osu.Game.Users.Profile public class RecentSection : ProfileSection { public override string Title => "Recent"; - - public RecentSection(User user) - { - } } } diff --git a/osu.Game/Users/UserProfile.cs b/osu.Game/Users/UserProfile.cs index 2470db1de5..03dce36528 100644 --- a/osu.Game/Users/UserProfile.cs +++ b/osu.Game/Users/UserProfile.cs @@ -18,23 +18,21 @@ namespace osu.Game.Users { public class UserProfile : FocusedOverlayContainer { - private readonly User user; private ProfileSection lastSection; public const float CONTENT_X_MARGIN = 50; public UserProfile(User user) { - this.user = user; var sections = new ProfileSection[] { - new AboutSection(user), - new RecentSection(user), - new RanksSection(user), - new MedalsSection(user), - new HistoricalSection(user), - new BeatmapsSection(user), - new KudosuSection(user) + new AboutSection(), + new RecentSection(), + new RanksSection(), + new MedalsSection(), + new HistoricalSection(), + new BeatmapsSection(), + new KudosuSection() }; var tabs = new ProfileTabControl { From 0c9ccaec953b4dc6219e2ffa4643720a78b0f5a2 Mon Sep 17 00:00:00 2001 From: Huo Yaoyuan Date: Thu, 15 Jun 2017 08:27:02 +0800 Subject: [PATCH 040/106] Move placeholder data into load method. --- osu.Game/Users/Profile/ProfileHeader.cs | 18 ++++++++++++------ osu.Game/Users/Profile/RankChart.cs | 2 +- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/osu.Game/Users/Profile/ProfileHeader.cs b/osu.Game/Users/Profile/ProfileHeader.cs index cf294a8863..9ad6a9aad4 100644 --- a/osu.Game/Users/Profile/ProfileHeader.cs +++ b/osu.Game/Users/Profile/ProfileHeader.cs @@ -26,7 +26,7 @@ namespace osu.Game.Users.Profile private readonly Sprite levelBadge; private readonly SpriteText levelText; - private readonly GradeBadge gradeSSPlus, gradeSS, gradeSPlus, gradeS, gradeA; + private readonly GradeBadge gradeDoubleSPlus, gradeDoubleS, gradeSPlus, gradeS, gradeA; private const float cover_height = 350, info_height = 150, avatar_size = 110, avatar_bottom_position = -20, level_position = 30, level_height = 60; public ProfileHeader(User user) @@ -193,8 +193,8 @@ namespace osu.Game.Users.Profile Spacing = new Vector2(20, 0), Children = new[] { - gradeSSPlus = new GradeBadge("SSPlus") { Count = 12 }, - gradeSS = new GradeBadge("SS") { Count = 34 }, + gradeDoubleSPlus = new GradeBadge("SSPlus"), + gradeDoubleS = new GradeBadge("SS"), } }, new FillFlowContainer @@ -207,9 +207,9 @@ namespace osu.Game.Users.Profile Spacing = new Vector2(20, 0), Children = new[] { - gradeSPlus = new GradeBadge("SPlus") { Count = 567 }, - gradeS = new GradeBadge("S") { Count = 890 }, - gradeA = new GradeBadge("A") { Count = 1234 }, + gradeSPlus = new GradeBadge("SPlus"), + gradeS = new GradeBadge("S"), + gradeA = new GradeBadge("A"), } } } @@ -286,6 +286,12 @@ namespace osu.Game.Users.Profile scoreNumberText.Add(createScoreNumberText("2,056")); scoreText.Add(createScoreText("Replay Watched")); scoreNumberText.Add(createScoreNumberText("23")); + + gradeDoubleSPlus.Count = 12; + gradeDoubleS.Count = 34; + gradeSPlus.Count = 567; + gradeS.Count = 890; + gradeA.Count = 1234; } private OsuSpriteText createScoreText(string text) => new OsuSpriteText diff --git a/osu.Game/Users/Profile/RankChart.cs b/osu.Game/Users/Profile/RankChart.cs index 20700a65df..2f78c35b5b 100644 --- a/osu.Game/Users/Profile/RankChart.cs +++ b/osu.Game/Users/Profile/RankChart.cs @@ -73,7 +73,7 @@ namespace osu.Game.Users.Profile { rankText.Text = $"#{rank:#,#}"; performanceText.Text = $"{performance:#,#}pp"; - relativeText.Text = $"{this.user.Country?.FullName} #{countryRank:#,#}"; + relativeText.Text = $"{user.Country?.FullName} #{countryRank:#,#}"; } private void showHistoryRankTexts(int dayIndex) From 1e0653eff9004a9e359e0d7b5c29e44edf2f36e5 Mon Sep 17 00:00:00 2001 From: Huo Yaoyuan Date: Thu, 15 Jun 2017 09:10:23 +0800 Subject: [PATCH 041/106] Add SS as an acronym. --- osu.Game/Users/Profile/ProfileHeader.cs | 10 +++++----- osu.sln.DotSettings | 1 + 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/osu.Game/Users/Profile/ProfileHeader.cs b/osu.Game/Users/Profile/ProfileHeader.cs index 9ad6a9aad4..2a7d99fc22 100644 --- a/osu.Game/Users/Profile/ProfileHeader.cs +++ b/osu.Game/Users/Profile/ProfileHeader.cs @@ -26,7 +26,7 @@ namespace osu.Game.Users.Profile private readonly Sprite levelBadge; private readonly SpriteText levelText; - private readonly GradeBadge gradeDoubleSPlus, gradeDoubleS, gradeSPlus, gradeS, gradeA; + private readonly GradeBadge gradeSSPlus, gradeSS, gradeSPlus, gradeS, gradeA; private const float cover_height = 350, info_height = 150, avatar_size = 110, avatar_bottom_position = -20, level_position = 30, level_height = 60; public ProfileHeader(User user) @@ -193,8 +193,8 @@ namespace osu.Game.Users.Profile Spacing = new Vector2(20, 0), Children = new[] { - gradeDoubleSPlus = new GradeBadge("SSPlus"), - gradeDoubleS = new GradeBadge("SS"), + gradeSSPlus = new GradeBadge("SSPlus"), + gradeSS = new GradeBadge("SS"), } }, new FillFlowContainer @@ -287,8 +287,8 @@ namespace osu.Game.Users.Profile scoreText.Add(createScoreText("Replay Watched")); scoreNumberText.Add(createScoreNumberText("23")); - gradeDoubleSPlus.Count = 12; - gradeDoubleS.Count = 34; + gradeSSPlus.Count = 12; + gradeSS.Count = 34; gradeSPlus.Count = 567; gradeS.Count = 890; gradeA.Count = 1234; diff --git a/osu.sln.DotSettings b/osu.sln.DotSettings index 70bfacd6ef..95c6676455 100644 --- a/osu.sln.DotSettings +++ b/osu.sln.DotSettings @@ -192,6 +192,7 @@ RNG SRGB TK + SS HINT <?xml version="1.0" encoding="utf-16"?> <Patterns xmlns="urn:schemas-jetbrains-com:member-reordering-patterns"> From 74f503874f03a503f5d83c2c719b924d1cc1fb2d Mon Sep 17 00:00:00 2001 From: Huo Yaoyuan Date: Thu, 15 Jun 2017 16:57:34 +0800 Subject: [PATCH 042/106] Move some sizes as consts. --- osu.Game/Users/Profile/RankChart.cs | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/osu.Game/Users/Profile/RankChart.cs b/osu.Game/Users/Profile/RankChart.cs index 2f78c35b5b..8a9719e254 100644 --- a/osu.Game/Users/Profile/RankChart.cs +++ b/osu.Game/Users/Profile/RankChart.cs @@ -26,12 +26,14 @@ namespace osu.Game.Users.Profile private int[] ranks, performances; private int rank, performance, countryRank; + private const float primary_textsize = 25, secondary_textsize = 13, padding = 10; + private readonly User user; public RankChart(User user) { this.user = user; - Padding = new MarginPadding { Vertical = 10 }; + Padding = new MarginPadding { Vertical = padding }; Children = new Drawable[] { rankText = new OsuSpriteText @@ -39,7 +41,7 @@ namespace osu.Game.Users.Profile Anchor = Anchor.TopCentre, Origin = Anchor.TopCentre, Font = @"Exo2.0-RegularItalic", - TextSize = 25 + TextSize = primary_textsize }, relativeText = new OsuSpriteText { @@ -47,21 +49,21 @@ namespace osu.Game.Users.Profile Origin = Anchor.TopCentre, Font = @"Exo2.0-RegularItalic", Y = 25, - TextSize = 13 + TextSize = secondary_textsize }, performanceText = new OsuSpriteText { Anchor = Anchor.BottomCentre, Origin = Anchor.BottomCentre, Font = @"Exo2.0-RegularItalic", - TextSize = 13 + TextSize = secondary_textsize }, graph = new RankChartLineGraph { Anchor = Anchor.BottomCentre, Origin = Anchor.BottomCentre, RelativeSizeAxes = Axes.X, - Y = -13, + Y = -secondary_textsize, DefaultValueCount = 90, BallRelease = updateRankTexts, BallMove = showHistoryRankTexts @@ -108,7 +110,7 @@ namespace osu.Game.Users.Profile { if ((invalidation & Invalidation.DrawSize) != 0) { - graph.Height = DrawHeight - 71; + graph.Height = DrawHeight - padding * 2 - primary_textsize - secondary_textsize * 2; } return base.Invalidate(invalidation, source, shallPropagate); From 13d9f3b9bb3923ace68bda2b070ada27f7bc0c52 Mon Sep 17 00:00:00 2001 From: Huo Yaoyuan Date: Thu, 15 Jun 2017 17:03:33 +0800 Subject: [PATCH 043/106] Move namespace and setup for DI. --- osu.Desktop.VisualTests/Tests/TestCaseUserProfile.cs | 3 ++- osu.Game/OsuGame.cs | 3 +++ .../UserProfile.cs => Overlays/UserProfileOverlay.cs} | 8 ++++---- osu.Game/Users/Profile/ProfileHeader.cs | 9 +++++---- osu.Game/Users/Profile/ProfileSection.cs | 5 +++-- osu.Game/osu.Game.csproj | 2 +- 6 files changed, 18 insertions(+), 12 deletions(-) rename osu.Game/{Users/UserProfile.cs => Overlays/UserProfileOverlay.cs} (93%) diff --git a/osu.Desktop.VisualTests/Tests/TestCaseUserProfile.cs b/osu.Desktop.VisualTests/Tests/TestCaseUserProfile.cs index 23091ec35b..6939692bff 100644 --- a/osu.Desktop.VisualTests/Tests/TestCaseUserProfile.cs +++ b/osu.Desktop.VisualTests/Tests/TestCaseUserProfile.cs @@ -4,6 +4,7 @@ using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Testing; +using osu.Game.Overlays; using osu.Game.Users; namespace osu.Desktop.VisualTests.Tests @@ -15,7 +16,7 @@ namespace osu.Desktop.VisualTests.Tests public override void Reset() { base.Reset(); - var userpage = new UserProfile(new User + var userpage = new UserProfileOverlay(new User { Username = @"peppy", Id = 2, diff --git a/osu.Game/OsuGame.cs b/osu.Game/OsuGame.cs index 7e5b913d10..62f9164fdd 100644 --- a/osu.Game/OsuGame.cs +++ b/osu.Game/OsuGame.cs @@ -45,6 +45,8 @@ namespace osu.Game private SocialOverlay social; + private UserProfileOverlay userProfile; + private Intro intro { get @@ -171,6 +173,7 @@ namespace osu.Game LoadComponentAsync(direct = new DirectOverlay { Depth = -1 }, mainContent.Add); LoadComponentAsync(social = new SocialOverlay { Depth = -1 }, mainContent.Add); LoadComponentAsync(chat = new ChatOverlay { Depth = -1 }, mainContent.Add); + LoadComponentAsync(userProfile = new UserProfileOverlay { Depth = -1 }, mainContent.Add); LoadComponentAsync(settings = new SettingsOverlay { Depth = -1 }, overlayContent.Add); LoadComponentAsync(musicController = new MusicController { diff --git a/osu.Game/Users/UserProfile.cs b/osu.Game/Overlays/UserProfileOverlay.cs similarity index 93% rename from osu.Game/Users/UserProfile.cs rename to osu.Game/Overlays/UserProfileOverlay.cs index 03dce36528..6bdf847d67 100644 --- a/osu.Game/Users/UserProfile.cs +++ b/osu.Game/Overlays/UserProfileOverlay.cs @@ -6,23 +6,23 @@ using OpenTK; using osu.Framework.Allocation; using osu.Framework.Extensions.IEnumerableExtensions; using osu.Framework.Graphics; -using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Sprites; using osu.Framework.Graphics.UserInterface; using osu.Game.Graphics; using osu.Game.Graphics.Containers; using osu.Game.Graphics.UserInterface; +using osu.Game.Users; using osu.Game.Users.Profile; -namespace osu.Game.Users +namespace osu.Game.Overlays { - public class UserProfile : FocusedOverlayContainer + public class UserProfileOverlay : WaveOverlayContainer { private ProfileSection lastSection; public const float CONTENT_X_MARGIN = 50; - public UserProfile(User user) + public UserProfileOverlay(User user) { var sections = new ProfileSection[] { diff --git a/osu.Game/Users/Profile/ProfileHeader.cs b/osu.Game/Users/Profile/ProfileHeader.cs index 2a7d99fc22..43d86950fb 100644 --- a/osu.Game/Users/Profile/ProfileHeader.cs +++ b/osu.Game/Users/Profile/ProfileHeader.cs @@ -14,6 +14,7 @@ using osu.Framework.Graphics.Textures; using osu.Game.Graphics; using osu.Game.Graphics.Containers; using osu.Game.Graphics.Sprites; +using osu.Game.Overlays; namespace osu.Game.Users.Profile { @@ -65,7 +66,7 @@ namespace osu.Game.Users.Profile Size = new Vector2(avatar_size), Anchor = Anchor.BottomLeft, Origin = Anchor.BottomLeft, - X = UserProfile.CONTENT_X_MARGIN, + X = UserProfileOverlay.CONTENT_X_MARGIN, Y = avatar_bottom_position, Masking = true, CornerRadius = 5, @@ -80,7 +81,7 @@ namespace osu.Game.Users.Profile { Anchor = Anchor.BottomLeft, Origin = Anchor.BottomLeft, - X = UserProfile.CONTENT_X_MARGIN + avatar_size + 10, + X = UserProfileOverlay.CONTENT_X_MARGIN + avatar_size + 10, Y = avatar_bottom_position, Children = new Drawable[] { @@ -111,14 +112,14 @@ namespace osu.Game.Users.Profile }) { Y = cover_height + 20, - Margin = new MarginPadding { Horizontal = UserProfile.CONTENT_X_MARGIN }, + Margin = new MarginPadding { Horizontal = UserProfileOverlay.CONTENT_X_MARGIN }, RelativeSizeAxes = Axes.X, AutoSizeAxes = Axes.Y, ParagraphSpacing = 1 }, new Container { - X = -UserProfile.CONTENT_X_MARGIN, + X = -UserProfileOverlay.CONTENT_X_MARGIN, RelativeSizeAxes = Axes.Y, Width = 280, Anchor = Anchor.TopRight, diff --git a/osu.Game/Users/Profile/ProfileSection.cs b/osu.Game/Users/Profile/ProfileSection.cs index c6f45403e3..723024d6a6 100644 --- a/osu.Game/Users/Profile/ProfileSection.cs +++ b/osu.Game/Users/Profile/ProfileSection.cs @@ -7,6 +7,7 @@ using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Sprites; using osu.Game.Graphics; using osu.Game.Graphics.Sprites; +using osu.Game.Overlays; namespace osu.Game.Users.Profile { @@ -31,7 +32,7 @@ namespace osu.Game.Users.Profile Font = @"Exo2.0-RegularItalic", Margin = new MarginPadding { - Horizontal = UserProfile.CONTENT_X_MARGIN, + Horizontal = UserProfileOverlay.CONTENT_X_MARGIN, Vertical = 20 } }, @@ -42,7 +43,7 @@ namespace osu.Game.Users.Profile RelativeSizeAxes = Axes.X, Margin = new MarginPadding { - Horizontal = UserProfile.CONTENT_X_MARGIN, + Horizontal = UserProfileOverlay.CONTENT_X_MARGIN, Bottom = 20 } }, diff --git a/osu.Game/osu.Game.csproj b/osu.Game/osu.Game.csproj index 3b15f6890e..c554ee751b 100644 --- a/osu.Game/osu.Game.csproj +++ b/osu.Game/osu.Game.csproj @@ -106,7 +106,7 @@ - + From 53bd22cf9c1a0037a50366d23faebd422669df34 Mon Sep 17 00:00:00 2001 From: Huo Yaoyuan Date: Thu, 15 Jun 2017 20:01:46 +0800 Subject: [PATCH 044/106] Update usage design. --- .../Tests/TestCaseUserProfile.cs | 28 +++++++++++++------ osu.Game/Overlays/UserProfileOverlay.cs | 5 +++- 2 files changed, 23 insertions(+), 10 deletions(-) diff --git a/osu.Desktop.VisualTests/Tests/TestCaseUserProfile.cs b/osu.Desktop.VisualTests/Tests/TestCaseUserProfile.cs index 6939692bff..e55d881d93 100644 --- a/osu.Desktop.VisualTests/Tests/TestCaseUserProfile.cs +++ b/osu.Desktop.VisualTests/Tests/TestCaseUserProfile.cs @@ -16,21 +16,31 @@ namespace osu.Desktop.VisualTests.Tests public override void Reset() { base.Reset(); - var userpage = new UserProfileOverlay(new User - { - Username = @"peppy", - Id = 2, - Country = new Country { FullName = @"Australia", FlagName = @"AU" }, - CoverUrl = @"https://osu.ppy.sh/images/headers/profile-covers/c3.jpg" - }) + var profile = new UserProfileOverlay { Anchor = Anchor.Centre, Origin = Anchor.Centre, RelativeSizeAxes = Axes.Both, Padding = new MarginPadding { Horizontal = 50 }, - State = Visibility.Visible }; - Add(userpage); + Add(profile); + + AddStep("Show ppy", () => profile.ShowUser(new User + { + Username = @"peppy", + Id = 2, + Country = new Country { FullName = @"Australia", FlagName = @"AU" }, + CoverUrl = @"https://osu.ppy.sh/images/headers/profile-covers/c3.jpg" + })); + AddStep("Show flyte", () => profile.ShowUser(new User + { + Username = @"flyte", + Id = 3103765, + Country = new Country { FullName = @"Japan", FlagName = @"JP" }, + CoverUrl = @"https://osu.ppy.sh/images/headers/profile-covers/c6.jpg" + })); + AddStep("Hide", profile.Hide); + AddStep("Show without reload", profile.Show); } } } diff --git a/osu.Game/Overlays/UserProfileOverlay.cs b/osu.Game/Overlays/UserProfileOverlay.cs index 6bdf847d67..d0c5726cdc 100644 --- a/osu.Game/Overlays/UserProfileOverlay.cs +++ b/osu.Game/Overlays/UserProfileOverlay.cs @@ -22,8 +22,10 @@ namespace osu.Game.Overlays public const float CONTENT_X_MARGIN = 50; - public UserProfileOverlay(User user) + public void ShowUser(User user) { + Clear(); + lastSection = null; var sections = new ProfileSection[] { new AboutSection(), @@ -87,6 +89,7 @@ namespace osu.Game.Overlays sectionsContainer.ScrollContainer.ScrollIntoView(lastSection); } }; + Show(); } private class ProfileTabControl : PageTabControl From 273e2b4a3ca13c27dc1ac404a5a6429ac05b42d8 Mon Sep 17 00:00:00 2001 From: Huo Yaoyuan Date: Thu, 15 Jun 2017 21:13:40 +0800 Subject: [PATCH 045/106] Fill more json fields. --- .../Online/API/Requests/GetUserRequest.cs | 4 +- osu.Game/Users/User.cs | 79 ++++++++++++++++++- osu.Game/Users/UserStatistics.cs | 64 +++++++++++++++ osu.Game/osu.Game.csproj | 1 + 4 files changed, 143 insertions(+), 5 deletions(-) create mode 100644 osu.Game/Users/UserStatistics.cs diff --git a/osu.Game/Online/API/Requests/GetUserRequest.cs b/osu.Game/Online/API/Requests/GetUserRequest.cs index 2fd1ee5efc..2e3e7b01c8 100644 --- a/osu.Game/Online/API/Requests/GetUserRequest.cs +++ b/osu.Game/Online/API/Requests/GetUserRequest.cs @@ -7,9 +7,9 @@ namespace osu.Game.Online.API.Requests { public class GetUserRequest : APIRequest { - private int? userId; + private long? userId; - public GetUserRequest(int? userId = null) + public GetUserRequest(long? userId = null) { this.userId = userId; } diff --git a/osu.Game/Users/User.cs b/osu.Game/Users/User.cs index 93933c8fe9..ffe18dcfdb 100644 --- a/osu.Game/Users/User.cs +++ b/osu.Game/Users/User.cs @@ -1,6 +1,7 @@ // Copyright (c) 2007-2017 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE +using System; using Newtonsoft.Json; using osu.Framework.Configuration; @@ -11,17 +12,20 @@ namespace osu.Game.Users [JsonProperty(@"id")] public long Id = 1; + [JsonProperty(@"joinDate")] + public string JoinDate; + [JsonProperty(@"username")] public string Username; - [JsonProperty(@"country_code")] - public string CountryCode; - [JsonProperty(@"country")] public Country Country; public Bindable Status = new Bindable(); + [JsonProperty(@"age")] + public int Age; + //public Team Team; [JsonProperty(@"profile_colour")] @@ -47,5 +51,74 @@ namespace osu.Game.Users [JsonProperty(@"id")] public int? Id; } + + [JsonProperty(@"isAdmin")] + public bool IsAdmin; + + [JsonProperty(@"isSupporter")] + public bool IsSupporter; + + [JsonProperty(@"isGMT")] + public bool IsGMT; + + [JsonProperty(@"isQAT")] + public bool IsQAT; + + [JsonProperty(@"isBNG")] + public bool IsBNG; + + [JsonProperty(@"is_active")] + public bool Active; + + [JsonProperty(@"interests")] + public string Intrerests; + + [JsonProperty(@"occupation")] + public string Occupation; + + [JsonProperty(@"title")] + public string Title; + + [JsonProperty(@"location")] + public string Location; + + [JsonProperty(@"lastvisit")] + public DateTimeOffset LastVisit; + + [JsonProperty(@"twitter")] + public string Twitter; + + [JsonProperty(@"lastfm")] + public string Lastfm; + + [JsonProperty(@"skype")] + public string Skype; + + [JsonProperty(@"website")] + public string Website; + + [JsonProperty(@"playstyle")] + public string[] PlayStyle; + + [JsonProperty(@"playmode")] + public string PlayMode; + + [JsonProperty(@"profileOrder")] + public string[] ProfileOrder; + + [JsonProperty(@"kudosu")] + public KudosuCount Kudosu; + + public class KudosuCount + { + [JsonProperty(@"total")] + public int Total; + + [JsonProperty(@"available")] + public int Available; + } + + [JsonProperty(@"defaultStatistics")] + public UserStatistics Statistics; } } diff --git a/osu.Game/Users/UserStatistics.cs b/osu.Game/Users/UserStatistics.cs new file mode 100644 index 0000000000..22c5c5cbcc --- /dev/null +++ b/osu.Game/Users/UserStatistics.cs @@ -0,0 +1,64 @@ +// Copyright (c) 2007-2017 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using Newtonsoft.Json; + +namespace osu.Game.Users +{ + public class UserStatistics + { + [JsonProperty(@"level")] + public LevelInfo Level; + + public class LevelInfo + { + [JsonProperty(@"current")] + public int Current; + + [JsonProperty(@"progress")] + public int Progress; + } + + [JsonProperty(@"pp")] + public decimal PP; + + [JsonProperty(@"pp_rank")] + public int Rank; + + [JsonProperty(@"ranked_score")] + public long RankedScore; + + [JsonProperty(@"hit_accuracy")] + public decimal Accuracy; + + [JsonProperty(@"play_count")] + public int PlayCount; + + [JsonProperty(@"total_score")] + public long TotalScore; + + [JsonProperty(@"total_hits")] + public int TotalHits; + + [JsonProperty(@"maximum_combo")] + public int MaxCombo; + + [JsonProperty(@"replays_watched_by_others")] + public int ReplayWatched; + + [JsonProperty(@"grade_counts")] + public Grades GradesCount; + + public class Grades + { + [JsonProperty(@"ss")] + public int SS; + + [JsonProperty(@"s")] + public int S; + + [JsonProperty(@"a")] + public int A; + } + } +} diff --git a/osu.Game/osu.Game.csproj b/osu.Game/osu.Game.csproj index c554ee751b..79d066461b 100644 --- a/osu.Game/osu.Game.csproj +++ b/osu.Game/osu.Game.csproj @@ -471,6 +471,7 @@ + From f03530cdd2bf31681a0fdfdae2b7e148f8bd6891 Mon Sep 17 00:00:00 2001 From: Huo Yaoyuan Date: Thu, 15 Jun 2017 22:33:08 +0800 Subject: [PATCH 046/106] Fetch latest user data. --- osu.Game/Overlays/UserProfileOverlay.cs | 31 +++++++++++++++++++++---- osu.Game/Users/Profile/ProfileHeader.cs | 5 ++++ 2 files changed, 31 insertions(+), 5 deletions(-) diff --git a/osu.Game/Overlays/UserProfileOverlay.cs b/osu.Game/Overlays/UserProfileOverlay.cs index d0c5726cdc..d630e11a99 100644 --- a/osu.Game/Overlays/UserProfileOverlay.cs +++ b/osu.Game/Overlays/UserProfileOverlay.cs @@ -11,6 +11,8 @@ using osu.Framework.Graphics.UserInterface; using osu.Game.Graphics; using osu.Game.Graphics.Containers; using osu.Game.Graphics.UserInterface; +using osu.Game.Online.API; +using osu.Game.Online.API.Requests; using osu.Game.Users; using osu.Game.Users.Profile; @@ -19,13 +21,23 @@ namespace osu.Game.Overlays public class UserProfileOverlay : WaveOverlayContainer { private ProfileSection lastSection; + private GetUserRequest userReq; + private APIAccess api; public const float CONTENT_X_MARGIN = 50; + [BackgroundDependencyLoader] + private void load(APIAccess api) + { + this.api = api; + } + public void ShowUser(User user) { + userReq?.Cancel(); Clear(); lastSection = null; + var sections = new ProfileSection[] { new AboutSection(), @@ -43,7 +55,6 @@ namespace osu.Game.Overlays Origin = Anchor.TopCentre, Height = 30 }; - sections.ForEach(tabs.AddItem); Add(new Box { @@ -51,20 +62,20 @@ namespace osu.Game.Overlays Colour = OsuColour.Gray(0.2f) }); + var header = new ProfileHeader(user); + var sectionsContainer = new SectionsContainer { RelativeSizeAxes = Axes.Both, - ExpandableHeader = new ProfileHeader(user), + ExpandableHeader = header, FixedHeader = tabs, HeaderBackground = new Box { Colour = OsuColour.Gray(34), RelativeSizeAxes = Axes.Both - }, - Children = sections + } }; Add(sectionsContainer); - sectionsContainer.SelectedSection.ValueChanged += s => { if (lastSection != s) @@ -89,6 +100,16 @@ namespace osu.Game.Overlays sectionsContainer.ScrollContainer.ScrollIntoView(lastSection); } }; + + userReq = new GetUserRequest(user.Id); //fetch latest full data + userReq.Success += u => + { + header.FillFullData(u); + sectionsContainer.Children = sections; + sections.ForEach(tabs.AddItem); + }; + api.Queue(userReq); + Show(); } diff --git a/osu.Game/Users/Profile/ProfileHeader.cs b/osu.Game/Users/Profile/ProfileHeader.cs index 43d86950fb..628767271a 100644 --- a/osu.Game/Users/Profile/ProfileHeader.cs +++ b/osu.Game/Users/Profile/ProfileHeader.cs @@ -295,6 +295,11 @@ namespace osu.Game.Users.Profile gradeA.Count = 1234; } + public void FillFullData(User user) + { + + } + private OsuSpriteText createScoreText(string text) => new OsuSpriteText { TextSize = 14, From 3ec5d774df29185cb0583b1b8ee49d29afc8eae5 Mon Sep 17 00:00:00 2001 From: Huo Yaoyuan Date: Thu, 15 Jun 2017 22:42:15 +0800 Subject: [PATCH 047/106] Child control fixes. --- osu.Game/Graphics/Containers/SectionsContainer.cs | 2 ++ osu.Game/Graphics/UserInterface/OsuTabControl.cs | 2 +- osu.Game/Overlays/UserProfileOverlay.cs | 2 ++ 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/osu.Game/Graphics/Containers/SectionsContainer.cs b/osu.Game/Graphics/Containers/SectionsContainer.cs index e11a12d2a1..63cc6f1a85 100644 --- a/osu.Game/Graphics/Containers/SectionsContainer.cs +++ b/osu.Game/Graphics/Containers/SectionsContainer.cs @@ -103,6 +103,8 @@ namespace osu.Game.Graphics.Containers { base.Add(drawable); lastKnownScroll = float.NaN; + headerHeight = float.NaN; + footerHeight = float.NaN; } private float headerHeight, footerHeight; diff --git a/osu.Game/Graphics/UserInterface/OsuTabControl.cs b/osu.Game/Graphics/UserInterface/OsuTabControl.cs index c8cf1b539f..0a1eecd293 100644 --- a/osu.Game/Graphics/UserInterface/OsuTabControl.cs +++ b/osu.Game/Graphics/UserInterface/OsuTabControl.cs @@ -22,7 +22,7 @@ namespace osu.Game.Graphics.UserInterface protected override TabItem CreateTabItem(T value) => new OsuTabItem(value); - protected override bool InternalContains(Vector2 screenSpacePos) => base.InternalContains(screenSpacePos) || Dropdown.Contains(screenSpacePos); + protected override bool InternalContains(Vector2 screenSpacePos) => base.InternalContains(screenSpacePos) || Dropdown?.Contains(screenSpacePos) == true; private static bool isEnumType => typeof(T).IsEnum; diff --git a/osu.Game/Overlays/UserProfileOverlay.cs b/osu.Game/Overlays/UserProfileOverlay.cs index d630e11a99..8be3058166 100644 --- a/osu.Game/Overlays/UserProfileOverlay.cs +++ b/osu.Game/Overlays/UserProfileOverlay.cs @@ -135,6 +135,8 @@ namespace osu.Game.Overlays protected override TabItem CreateTabItem(ProfileSection value) => new ProfileTabItem(value); + protected override Dropdown CreateDropdown() => null; + private class ProfileTabItem : PageTabItem { public ProfileTabItem(ProfileSection value) : base(value) From 2770ccb78206bdfe346a1f5a607429871ffde0cc Mon Sep 17 00:00:00 2001 From: Huo Yaoyuan Date: Thu, 15 Jun 2017 23:25:13 +0800 Subject: [PATCH 048/106] Possible null fields. --- osu.Game/Users/User.cs | 2 +- osu.Game/Users/UserStatistics.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/osu.Game/Users/User.cs b/osu.Game/Users/User.cs index ffe18dcfdb..99484d8ef3 100644 --- a/osu.Game/Users/User.cs +++ b/osu.Game/Users/User.cs @@ -24,7 +24,7 @@ namespace osu.Game.Users public Bindable Status = new Bindable(); [JsonProperty(@"age")] - public int Age; + public int? Age; //public Team Team; diff --git a/osu.Game/Users/UserStatistics.cs b/osu.Game/Users/UserStatistics.cs index 22c5c5cbcc..7e3e5db983 100644 --- a/osu.Game/Users/UserStatistics.cs +++ b/osu.Game/Users/UserStatistics.cs @@ -20,7 +20,7 @@ namespace osu.Game.Users } [JsonProperty(@"pp")] - public decimal PP; + public decimal? PP; [JsonProperty(@"pp_rank")] public int Rank; From 9a77332063f9883ea8a7587e1790fbc434b9f125 Mon Sep 17 00:00:00 2001 From: Huo Yaoyuan Date: Thu, 15 Jun 2017 23:47:34 +0800 Subject: [PATCH 049/106] Order sections. --- osu.Game/Overlays/UserProfileOverlay.cs | 8 +++++--- osu.Game/Users/Profile/AboutSection.cs | 3 +++ osu.Game/Users/Profile/BeatmapsSection.cs | 2 ++ osu.Game/Users/Profile/HistoricalSection.cs | 2 ++ osu.Game/Users/Profile/KudosuSection.cs | 2 ++ osu.Game/Users/Profile/MedalsSection.cs | 2 ++ osu.Game/Users/Profile/ProfileSection.cs | 2 ++ osu.Game/Users/Profile/RanksSection.cs | 2 ++ osu.Game/Users/Profile/RecentSection.cs | 2 ++ 9 files changed, 22 insertions(+), 3 deletions(-) diff --git a/osu.Game/Overlays/UserProfileOverlay.cs b/osu.Game/Overlays/UserProfileOverlay.cs index 8be3058166..2042348d94 100644 --- a/osu.Game/Overlays/UserProfileOverlay.cs +++ b/osu.Game/Overlays/UserProfileOverlay.cs @@ -4,7 +4,6 @@ using System.Linq; using OpenTK; using osu.Framework.Allocation; -using osu.Framework.Extensions.IEnumerableExtensions; using osu.Framework.Graphics; using osu.Framework.Graphics.Sprites; using osu.Framework.Graphics.UserInterface; @@ -105,8 +104,11 @@ namespace osu.Game.Overlays userReq.Success += u => { header.FillFullData(u); - sectionsContainer.Children = sections; - sections.ForEach(tabs.AddItem); + + var reorderedSections = u.ProfileOrder.Select(x => sections.FirstOrDefault(s => s.Identifier == x)).Where(s => s != null).ToList(); + + sectionsContainer.Children = reorderedSections; + reorderedSections.ForEach(tabs.AddItem); }; api.Queue(userReq); diff --git a/osu.Game/Users/Profile/AboutSection.cs b/osu.Game/Users/Profile/AboutSection.cs index 69ace5fc71..572eb1a273 100644 --- a/osu.Game/Users/Profile/AboutSection.cs +++ b/osu.Game/Users/Profile/AboutSection.cs @@ -1,10 +1,13 @@ // Copyright (c) 2007-2017 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + namespace osu.Game.Users.Profile { public class AboutSection : ProfileSection { public override string Title => "me!"; + + public override string Identifier => "me"; } } diff --git a/osu.Game/Users/Profile/BeatmapsSection.cs b/osu.Game/Users/Profile/BeatmapsSection.cs index a69c65c84a..eb460bbbec 100644 --- a/osu.Game/Users/Profile/BeatmapsSection.cs +++ b/osu.Game/Users/Profile/BeatmapsSection.cs @@ -6,5 +6,7 @@ namespace osu.Game.Users.Profile public class BeatmapsSection : ProfileSection { public override string Title => "Beatmaps"; + + public override string Identifier => "beatmaps"; } } diff --git a/osu.Game/Users/Profile/HistoricalSection.cs b/osu.Game/Users/Profile/HistoricalSection.cs index c5f357d322..1b767662cf 100644 --- a/osu.Game/Users/Profile/HistoricalSection.cs +++ b/osu.Game/Users/Profile/HistoricalSection.cs @@ -6,5 +6,7 @@ namespace osu.Game.Users.Profile public class HistoricalSection : ProfileSection { public override string Title => "Historical"; + + public override string Identifier => "historical"; } } diff --git a/osu.Game/Users/Profile/KudosuSection.cs b/osu.Game/Users/Profile/KudosuSection.cs index b489f6544d..3502c61822 100644 --- a/osu.Game/Users/Profile/KudosuSection.cs +++ b/osu.Game/Users/Profile/KudosuSection.cs @@ -6,5 +6,7 @@ namespace osu.Game.Users.Profile public class KudosuSection : ProfileSection { public override string Title => "Kudosu!"; + + public override string Identifier => "kudosu"; } } diff --git a/osu.Game/Users/Profile/MedalsSection.cs b/osu.Game/Users/Profile/MedalsSection.cs index 0a52830340..18ef779f83 100644 --- a/osu.Game/Users/Profile/MedalsSection.cs +++ b/osu.Game/Users/Profile/MedalsSection.cs @@ -6,5 +6,7 @@ namespace osu.Game.Users.Profile public class MedalsSection : ProfileSection { public override string Title => "Medals"; + + public override string Identifier => "medals"; } } diff --git a/osu.Game/Users/Profile/ProfileSection.cs b/osu.Game/Users/Profile/ProfileSection.cs index 723024d6a6..ec938c13ac 100644 --- a/osu.Game/Users/Profile/ProfileSection.cs +++ b/osu.Game/Users/Profile/ProfileSection.cs @@ -15,6 +15,8 @@ namespace osu.Game.Users.Profile { public abstract string Title { get; } + public abstract string Identifier { get; } + private readonly FillFlowContainer content; protected override Container Content => content; diff --git a/osu.Game/Users/Profile/RanksSection.cs b/osu.Game/Users/Profile/RanksSection.cs index 65f3f04c1b..b2a35dbd21 100644 --- a/osu.Game/Users/Profile/RanksSection.cs +++ b/osu.Game/Users/Profile/RanksSection.cs @@ -6,5 +6,7 @@ namespace osu.Game.Users.Profile public class RanksSection : ProfileSection { public override string Title => "Ranks"; + + public override string Identifier => "top_ranks"; } } diff --git a/osu.Game/Users/Profile/RecentSection.cs b/osu.Game/Users/Profile/RecentSection.cs index 6cd3bf6c49..b1961491bb 100644 --- a/osu.Game/Users/Profile/RecentSection.cs +++ b/osu.Game/Users/Profile/RecentSection.cs @@ -6,5 +6,7 @@ namespace osu.Game.Users.Profile public class RecentSection : ProfileSection { public override string Title => "Recent"; + + public override string Identifier => "recent_activities"; } } From a7e31573636a69c9980edf7f78f64440c6bb2c04 Mon Sep 17 00:00:00 2001 From: Huo Yaoyuan Date: Fri, 16 Jun 2017 01:04:20 +0800 Subject: [PATCH 050/106] Fill statistic area. --- osu.Game/Users/Profile/ProfileHeader.cs | 91 +++++++++++++------------ 1 file changed, 46 insertions(+), 45 deletions(-) diff --git a/osu.Game/Users/Profile/ProfileHeader.cs b/osu.Game/Users/Profile/ProfileHeader.cs index 628767271a..2fd8ed77f0 100644 --- a/osu.Game/Users/Profile/ProfileHeader.cs +++ b/osu.Game/Users/Profile/ProfileHeader.cs @@ -20,11 +20,10 @@ namespace osu.Game.Users.Profile { public class ProfileHeader : Container { - //private readonly User user; - private readonly OsuTextFlowContainer infoText; private readonly FillFlowContainer scoreText, scoreNumberText; + private readonly Container coverContainer; private readonly Sprite levelBadge; private readonly SpriteText levelText; private readonly GradeBadge gradeSSPlus, gradeSS, gradeSPlus, gradeS, gradeA; @@ -32,29 +31,17 @@ namespace osu.Game.Users.Profile private const float cover_height = 350, info_height = 150, avatar_size = 110, avatar_bottom_position = -20, level_position = 30, level_height = 60; public ProfileHeader(User user) { - //this.user = user; RelativeSizeAxes = Axes.X; Height = cover_height + info_height; Children = new Drawable[] { - new Container + coverContainer = new Container { RelativeSizeAxes = Axes.X, Height = cover_height, Children = new Drawable[] { - new AsyncLoadWrapper(new UserCoverBackground(user) - { - Anchor = Anchor.Centre, - Origin = Anchor.Centre, - FillMode = FillMode.Fill, - OnLoadComplete = d => d.FadeInFromZero(200) - }) - { - Masking = true, - RelativeSizeAxes = Axes.Both - }, new Box { RelativeSizeAxes = Axes.Both, @@ -143,7 +130,8 @@ namespace osu.Game.Users.Profile Anchor = Anchor.Centre, Origin = Anchor.Centre, Height = 50, - Width = 50 + Width = 50, + Alpha = 0 }, levelText = new OsuSpriteText { @@ -194,8 +182,8 @@ namespace osu.Game.Users.Profile Spacing = new Vector2(20, 0), Children = new[] { - gradeSSPlus = new GradeBadge("SSPlus"), - gradeSS = new GradeBadge("SS"), + gradeSSPlus = new GradeBadge("SSPlus") { Alpha = 0 }, + gradeSS = new GradeBadge("SS") { Alpha = 0 }, } }, new FillFlowContainer @@ -208,9 +196,9 @@ namespace osu.Game.Users.Profile Spacing = new Vector2(20, 0), Children = new[] { - gradeSPlus = new GradeBadge("SPlus"), - gradeS = new GradeBadge("S"), - gradeA = new GradeBadge("A"), + gradeSPlus = new GradeBadge("SPlus") { Alpha = 0 }, + gradeS = new GradeBadge("S") { Alpha = 0 }, + gradeA = new GradeBadge("A") { Alpha = 0 }, } } } @@ -270,34 +258,47 @@ namespace osu.Game.Users.Profile infoText.NewParagraph(); infoText.AddText("Play with "); infoText.AddText("Mouse, Keyboard, Tablet", bold); - - levelText.Text = "98"; - - scoreText.Add(createScoreText("Ranked Score")); - scoreNumberText.Add(createScoreNumberText("1,870,716,897")); - scoreText.Add(createScoreText("Accuracy")); - scoreNumberText.Add(createScoreNumberText("98.51%")); - scoreText.Add(createScoreText("Play Count")); - scoreNumberText.Add(createScoreNumberText("25,287")); - scoreText.Add(createScoreText("Total Score")); - scoreNumberText.Add(createScoreNumberText("28,444,797,570")); - scoreText.Add(createScoreText("Total Hits")); - scoreNumberText.Add(createScoreNumberText("4,612,765")); - scoreText.Add(createScoreText("Max Combo")); - scoreNumberText.Add(createScoreNumberText("2,056")); - scoreText.Add(createScoreText("Replay Watched")); - scoreNumberText.Add(createScoreNumberText("23")); - - gradeSSPlus.Count = 12; - gradeSS.Count = 34; - gradeSPlus.Count = 567; - gradeS.Count = 890; - gradeA.Count = 1234; } public void FillFullData(User user) { + coverContainer.Add(new AsyncLoadWrapper(new UserCoverBackground(user) + { + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + FillMode = FillMode.Fill, + OnLoadComplete = d => d.FadeInFromZero(200) + }) + { + Masking = true, + RelativeSizeAxes = Axes.Both, + Depth = float.MaxValue + }); + levelBadge.Show(); + levelText.Text = user.Statistics.Level.Current.ToString(); + + scoreText.Add(createScoreText("Ranked Score")); + scoreNumberText.Add(createScoreNumberText(user.Statistics.RankedScore.ToString(@"#,0"))); + scoreText.Add(createScoreText("Accuracy")); + scoreNumberText.Add(createScoreNumberText($"{user.Statistics.Accuracy}%")); + scoreText.Add(createScoreText("Play Count")); + scoreNumberText.Add(createScoreNumberText(user.Statistics.PlayCount.ToString(@"#,0"))); + scoreText.Add(createScoreText("Total Score")); + scoreNumberText.Add(createScoreNumberText(user.Statistics.TotalScore.ToString(@"#,0"))); + scoreText.Add(createScoreText("Total Hits")); + scoreNumberText.Add(createScoreNumberText(user.Statistics.TotalHits.ToString(@"#,0"))); + scoreText.Add(createScoreText("Max Combo")); + scoreNumberText.Add(createScoreNumberText(user.Statistics.MaxCombo.ToString(@"#,0"))); + scoreText.Add(createScoreText("Replay Watched by Others")); + scoreNumberText.Add(createScoreNumberText(user.Statistics.ReplayWatched.ToString(@"#,0"))); + + gradeSS.Count = user.Statistics.GradesCount.SS; + gradeSS.Show(); + gradeS.Count = user.Statistics.GradesCount.S; + gradeS.Show(); + gradeA.Count = user.Statistics.GradesCount.A; + gradeA.Show(); } private OsuSpriteText createScoreText(string text) => new OsuSpriteText @@ -326,7 +327,7 @@ namespace osu.Game.Users.Profile { set { - numberText.Text = value.ToString(@"#,#"); + numberText.Text = value.ToString(@"#,0"); } } From 6967fb11057bca487ffb47f82d309a2c2023fb14 Mon Sep 17 00:00:00 2001 From: Huo Yaoyuan Date: Fri, 16 Jun 2017 13:27:22 +0800 Subject: [PATCH 051/106] Fill user informations. --- osu.Game/Users/Profile/ProfileHeader.cs | 153 +++++++++++++++--------- 1 file changed, 98 insertions(+), 55 deletions(-) diff --git a/osu.Game/Users/Profile/ProfileHeader.cs b/osu.Game/Users/Profile/ProfileHeader.cs index 2fd8ed77f0..a3b8caf579 100644 --- a/osu.Game/Users/Profile/ProfileHeader.cs +++ b/osu.Game/Users/Profile/ProfileHeader.cs @@ -20,7 +20,7 @@ namespace osu.Game.Users.Profile { public class ProfileHeader : Container { - private readonly OsuTextFlowContainer infoText; + private readonly OsuTextFlowContainer infoTextLeft, infoTextRight; private readonly FillFlowContainer scoreText, scoreNumberText; private readonly Container coverContainer; @@ -28,7 +28,7 @@ namespace osu.Game.Users.Profile private readonly SpriteText levelText; private readonly GradeBadge gradeSSPlus, gradeSS, gradeSPlus, gradeS, gradeA; - private const float cover_height = 350, info_height = 150, avatar_size = 110, avatar_bottom_position = -20, level_position = 30, level_height = 60; + private const float cover_height = 350, info_height = 150, info_width = 250, avatar_size = 110, avatar_bottom_position = -20, level_position = 30, level_height = 60; public ProfileHeader(User user) { RelativeSizeAxes = Axes.X; @@ -92,17 +92,31 @@ namespace osu.Game.Users.Profile } } }, - infoText = new OsuTextFlowContainer(t => + infoTextLeft = new OsuTextFlowContainer(t => { t.TextSize = 14; t.Alpha = 0.8f; }) { + X = UserProfileOverlay.CONTENT_X_MARGIN, Y = cover_height + 20, - Margin = new MarginPadding { Horizontal = UserProfileOverlay.CONTENT_X_MARGIN }, - RelativeSizeAxes = Axes.X, + Width = info_width, AutoSizeAxes = Axes.Y, - ParagraphSpacing = 1 + ParagraphSpacing = 0.8f, + LineSpacing = 0.2f + }, + infoTextRight = new OsuTextFlowContainer(t => + { + t.TextSize = 14; + t.Alpha = 0.8f; + }) + { + X = UserProfileOverlay.CONTENT_X_MARGIN + info_width + 20, + Y = cover_height + 20, + Width = info_width, + AutoSizeAxes = Axes.Y, + ParagraphSpacing = 0.8f, + LineSpacing = 0.2f }, new Container { @@ -231,33 +245,6 @@ namespace osu.Game.Users.Profile private void load(TextureStore textures) { levelBadge.Texture = textures.Get(@"Profile/levelbadge"); - - Action bold = t => - { - t.Font = @"Exo2.0-Bold"; - t.Alpha = 1; - }; - // fill placeholder texts - infoText.AddTextAwesome(FontAwesome.fa_map_marker); - infoText.AddText(" position "); - infoText.AddTextAwesome(FontAwesome.fa_twitter); - infoText.AddText(" tweet "); - infoText.AddTextAwesome(FontAwesome.fa_heart_o); - infoText.AddText(" favorite "); - infoText.NewParagraph(); - infoText.AddText("0 years old"); - infoText.NewLine(); - infoText.AddText("Commander of "); - infoText.AddText("The Color Scribbles", bold); - infoText.NewParagraph(); - infoText.AddText("Joined since "); - infoText.AddText("June 2017", bold); - infoText.NewLine(); - infoText.AddText("Last seen "); - infoText.AddText("0 minutes ago", bold); - infoText.NewParagraph(); - infoText.AddText("Play with "); - infoText.AddText("Mouse, Keyboard, Tablet", bold); } public void FillFullData(User user) @@ -275,32 +262,76 @@ namespace osu.Game.Users.Profile Depth = float.MaxValue }); - levelBadge.Show(); - levelText.Text = user.Statistics.Level.Current.ToString(); + Action boldItalic = t => + { + t.Font = @"Exo2.0-BoldItalic"; + t.Alpha = 1; + }; - scoreText.Add(createScoreText("Ranked Score")); - scoreNumberText.Add(createScoreNumberText(user.Statistics.RankedScore.ToString(@"#,0"))); - scoreText.Add(createScoreText("Accuracy")); - scoreNumberText.Add(createScoreNumberText($"{user.Statistics.Accuracy}%")); - scoreText.Add(createScoreText("Play Count")); - scoreNumberText.Add(createScoreNumberText(user.Statistics.PlayCount.ToString(@"#,0"))); - scoreText.Add(createScoreText("Total Score")); - scoreNumberText.Add(createScoreNumberText(user.Statistics.TotalScore.ToString(@"#,0"))); - scoreText.Add(createScoreText("Total Hits")); - scoreNumberText.Add(createScoreNumberText(user.Statistics.TotalHits.ToString(@"#,0"))); - scoreText.Add(createScoreText("Max Combo")); - scoreNumberText.Add(createScoreNumberText(user.Statistics.MaxCombo.ToString(@"#,0"))); - scoreText.Add(createScoreText("Replay Watched by Others")); - scoreNumberText.Add(createScoreNumberText(user.Statistics.ReplayWatched.ToString(@"#,0"))); + if (user.Age != null) + { + infoTextLeft.AddText($"{user.Age} years old", boldItalic); + } + if (user.Country != null) + { + infoTextLeft.AddText(" from "); + infoTextLeft.AddText(user.Country.FullName, boldItalic); + } + infoTextLeft.NewParagraph(); - gradeSS.Count = user.Statistics.GradesCount.SS; - gradeSS.Show(); - gradeS.Count = user.Statistics.GradesCount.S; - gradeS.Show(); - gradeA.Count = user.Statistics.GradesCount.A; - gradeA.Show(); + infoTextLeft.AddText("Joined "); + infoTextLeft.AddText(user.JoinDate, boldItalic); + infoTextLeft.NewLine(); + infoTextLeft.AddText("Last seen "); + infoTextLeft.AddText(user.LastVisit.LocalDateTime.ToShortDateString(), boldItalic); + infoTextLeft.NewParagraph(); + + if (user.PlayStyle?.Length > 0) + { + infoTextLeft.AddText("Plays with "); + infoTextLeft.AddText(string.Join(", ", user.PlayStyle), boldItalic); + } + + tryAddInfoRightLine(FontAwesome.fa_map_marker, user.Location); + tryAddInfoRightLine(FontAwesome.fa_heart_o, user.Intrerests); + tryAddInfoRightLine(FontAwesome.fa_suitcase, user.Occupation); + infoTextRight.NewParagraph(); + if (!string.IsNullOrEmpty(user.Twitter)) + tryAddInfoRightLine(FontAwesome.fa_twitter, "@" + user.Twitter); + tryAddInfoRightLine(FontAwesome.fa_globe, user.Website); + tryAddInfoRightLine(FontAwesome.fa_skype, user.Skype); + + if (user.Statistics != null) + { + levelBadge.Show(); + levelText.Text = user.Statistics.Level.Current.ToString(); + + scoreText.Add(createScoreText("Ranked Score")); + scoreNumberText.Add(createScoreNumberText(user.Statistics.RankedScore.ToString(@"#,0"))); + scoreText.Add(createScoreText("Accuracy")); + scoreNumberText.Add(createScoreNumberText($"{user.Statistics.Accuracy}%")); + scoreText.Add(createScoreText("Play Count")); + scoreNumberText.Add(createScoreNumberText(user.Statistics.PlayCount.ToString(@"#,0"))); + scoreText.Add(createScoreText("Total Score")); + scoreNumberText.Add(createScoreNumberText(user.Statistics.TotalScore.ToString(@"#,0"))); + scoreText.Add(createScoreText("Total Hits")); + scoreNumberText.Add(createScoreNumberText(user.Statistics.TotalHits.ToString(@"#,0"))); + scoreText.Add(createScoreText("Max Combo")); + scoreNumberText.Add(createScoreNumberText(user.Statistics.MaxCombo.ToString(@"#,0"))); + scoreText.Add(createScoreText("Replay Watched by Others")); + scoreNumberText.Add(createScoreNumberText(user.Statistics.ReplayWatched.ToString(@"#,0"))); + + gradeSS.Count = user.Statistics.GradesCount.SS; + gradeSS.Show(); + gradeS.Count = user.Statistics.GradesCount.S; + gradeS.Show(); + gradeA.Count = user.Statistics.GradesCount.A; + gradeA.Show(); + } } + // These could be local functions when C# 7 enabled + private OsuSpriteText createScoreText(string text) => new OsuSpriteText { TextSize = 14, @@ -316,6 +347,18 @@ namespace osu.Game.Users.Profile Text = text }; + private void tryAddInfoRightLine(FontAwesome icon, string str) + { + if (string.IsNullOrEmpty(str)) return; + infoTextRight.AddTextAwesome(icon); + infoTextRight.AddText(" " + str, t => + { + t.Font = @"Exo2.0-RegularItalic"; + t.Alpha = 1; + }); + infoTextRight.NewLine(); + } + private class GradeBadge : Container { private const float width = 50; From 9e3935a73284ab432a77259e78d8712ba57d0774 Mon Sep 17 00:00:00 2001 From: Huo Yaoyuan Date: Fri, 16 Jun 2017 14:34:08 +0800 Subject: [PATCH 052/106] Show available information in RankChart. --- osu.Game/Users/Profile/ProfileHeader.cs | 10 +++---- osu.Game/Users/Profile/RankChart.cs | 36 ++++++++++--------------- 2 files changed, 18 insertions(+), 28 deletions(-) diff --git a/osu.Game/Users/Profile/ProfileHeader.cs b/osu.Game/Users/Profile/ProfileHeader.cs index a3b8caf579..ad23b8e522 100644 --- a/osu.Game/Users/Profile/ProfileHeader.cs +++ b/osu.Game/Users/Profile/ProfileHeader.cs @@ -23,7 +23,7 @@ namespace osu.Game.Users.Profile private readonly OsuTextFlowContainer infoTextLeft, infoTextRight; private readonly FillFlowContainer scoreText, scoreNumberText; - private readonly Container coverContainer; + private readonly Container coverContainer, chartContainer; private readonly Sprite levelBadge; private readonly SpriteText levelText; private readonly GradeBadge gradeSSPlus, gradeSS, gradeSPlus, gradeS, gradeA; @@ -217,7 +217,7 @@ namespace osu.Game.Users.Profile } } }, - new Container + chartContainer = new Container { RelativeSizeAxes = Axes.X, Anchor = Anchor.BottomCentre, @@ -229,10 +229,6 @@ namespace osu.Game.Users.Profile { Colour = Color4.Black.Opacity(0.25f), RelativeSizeAxes = Axes.Both - }, - new RankChart(user) - { - RelativeSizeAxes = Axes.Both } } } @@ -327,6 +323,8 @@ namespace osu.Game.Users.Profile gradeS.Show(); gradeA.Count = user.Statistics.GradesCount.A; gradeA.Show(); + + chartContainer.Add(new RankChart(user) { RelativeSizeAxes = Axes.Both }); } } diff --git a/osu.Game/Users/Profile/RankChart.cs b/osu.Game/Users/Profile/RankChart.cs index 8a9719e254..fde7379628 100644 --- a/osu.Game/Users/Profile/RankChart.cs +++ b/osu.Game/Users/Profile/RankChart.cs @@ -5,7 +5,6 @@ using System; using System.Collections.Generic; using System.Diagnostics; using System.Linq; -using System.Threading.Tasks; using OpenTK; using osu.Framework.Allocation; using osu.Framework.Graphics; @@ -23,8 +22,8 @@ namespace osu.Game.Users.Profile private readonly SpriteText rankText, performanceText, relativeText; private readonly RankChartLineGraph graph; - private int[] ranks, performances; - private int rank, performance, countryRank; + private int[] ranks; + private decimal?[] performances; private const float primary_textsize = 25, secondary_textsize = 13, padding = 10; @@ -33,6 +32,7 @@ namespace osu.Game.Users.Profile public RankChart(User user) { this.user = user; + Padding = new MarginPadding { Vertical = padding }; Children = new Drawable[] { @@ -69,20 +69,22 @@ namespace osu.Game.Users.Profile BallMove = showHistoryRankTexts } }; + ranks = new[] { user.Statistics.Rank }; + performances = new decimal?[] { user.Statistics.PP }; } private void updateRankTexts() { - rankText.Text = $"#{rank:#,#}"; - performanceText.Text = $"{performance:#,#}pp"; - relativeText.Text = $"{user.Country?.FullName} #{countryRank:#,#}"; + rankText.Text = user.Statistics.Rank > 0 ? $"#{user.Statistics.Rank:#,0}" : "no rank"; + performanceText.Text = user.Statistics.PP != null ? $"{user.Statistics.PP:#,0}pp" : string.Empty; + //relativeText.Text = $"{user.Country?.FullName} #{countryRank:#,0}"; } private void showHistoryRankTexts(int dayIndex) { - rankText.Text = $"#{ranks[dayIndex]:#,#}"; - performanceText.Text = $"{performances[dayIndex]:#,#}pp"; - relativeText.Text = dayIndex == ranks.Length ? "Now" : $"{ranks.Length - dayIndex} days ago"; + rankText.Text = ranks[dayIndex] > 0 ? $"#{ranks[dayIndex]:#,0}" : "no rank"; + performanceText.Text = performances[dayIndex] != null ? $"{performances[dayIndex]:#,0}pp" : string.Empty; + //relativeText.Text = dayIndex == ranks.Length ? "Now" : $"{ranks.Length - dayIndex} days ago"; //plural should be handled in a general way } @@ -90,20 +92,10 @@ namespace osu.Game.Users.Profile private void load(OsuColour colours) { graph.Colour = colours.Yellow; - Task.Factory.StartNew(() => - { - System.Threading.Thread.Sleep(1000); - // put placeholder data here to show the transform - rank = 12345; - countryRank = 678; - performance = 4567; - ranks = Enumerable.Range(1234, 80).ToArray(); - performances = ranks.Select(x => 6000 - x).ToArray(); - // use logarithmic coordinates - graph.Values = ranks.Select(x => -(float)Math.Log(x)); - graph.ResetBall(); - }); + // use logarithmic coordinates + graph.Values = ranks.Select(x => -(float)Math.Log(x)); + graph.ResetBall(); } public override bool Invalidate(Invalidation invalidation = Invalidation.All, Drawable source = null, bool shallPropagate = true) From fa98cfa9e5e32ed52f2538ddce1179e252fcfbfc Mon Sep 17 00:00:00 2001 From: Huo Yaoyuan Date: Fri, 16 Jun 2017 14:47:14 +0800 Subject: [PATCH 053/106] Handle max==min in LineGraph. --- osu.Game/Graphics/UserInterface/LineGraph.cs | 12 +++++++++--- osu.Game/Users/Profile/RankChart.cs | 19 ++++++++----------- 2 files changed, 17 insertions(+), 14 deletions(-) diff --git a/osu.Game/Graphics/UserInterface/LineGraph.cs b/osu.Game/Graphics/UserInterface/LineGraph.cs index 02e8a8329a..28b62ff957 100644 --- a/osu.Game/Graphics/UserInterface/LineGraph.cs +++ b/osu.Game/Graphics/UserInterface/LineGraph.cs @@ -23,8 +23,8 @@ namespace osu.Game.Graphics.UserInterface /// public float? MinValue { get; set; } - public float? ActualMaxValue { get; private set; } - public float? ActualMinValue { get; private set; } + public float ActualMaxValue { get; private set; } = float.NaN; + public float ActualMinValue { get; private set; } = float.NaN; private const double transform_duration = 500; @@ -87,10 +87,16 @@ namespace osu.Game.Graphics.UserInterface for (int i = 0; i < values.Length; i++) { float x = (i + count - values.Length) / (float)(count - 1) * DrawWidth - 1; - float y = (max - values[i]) / (max - min) * DrawHeight - 1; + float y = GetYPosition(values[i]) * DrawHeight - 1; // the -1 is for inner offset in path (actually -PathWidth) path.AddVertex(new Vector2(x, y)); } } + + protected float GetYPosition(float value) + { + if (ActualMaxValue == ActualMinValue) return 0; + return (ActualMaxValue - value) / (ActualMaxValue - ActualMinValue); + } } } diff --git a/osu.Game/Users/Profile/RankChart.cs b/osu.Game/Users/Profile/RankChart.cs index fde7379628..8581635cd7 100644 --- a/osu.Game/Users/Profile/RankChart.cs +++ b/osu.Game/Users/Profile/RankChart.cs @@ -3,7 +3,6 @@ using System; using System.Collections.Generic; -using System.Diagnostics; using System.Linq; using OpenTK; using osu.Framework.Allocation; @@ -93,9 +92,12 @@ namespace osu.Game.Users.Profile { graph.Colour = colours.Yellow; - // use logarithmic coordinates - graph.Values = ranks.Select(x => -(float)Math.Log(x)); - graph.ResetBall(); + if (user.Statistics.Rank > 0) + { + // use logarithmic coordinates + graph.Values = ranks.Select(x => -(float)Math.Log(x)); + graph.ResetBall(); + } } public override bool Invalidate(Invalidation invalidation = Invalidation.All, Drawable source = null, bool shallPropagate = true) @@ -136,9 +138,7 @@ namespace osu.Game.Users.Profile public void ResetBall() { - Trace.Assert(ActualMaxValue.HasValue); - Trace.Assert(ActualMinValue.HasValue); - ball.MoveTo(new Vector2(1, ((ActualMaxValue - Values.Last()) / (ActualMaxValue - ActualMinValue)).Value), ballShown ? transform_duration : 0, EasingTypes.OutQuint); + ball.MoveTo(new Vector2(1, GetYPosition(Values.Last())), ballShown ? transform_duration : 0, EasingTypes.OutQuint); ball.Show(); BallRelease(); ballShown = true; @@ -155,10 +155,7 @@ namespace osu.Game.Users.Profile if (index >= count - values.Count) { int i = index + values.Count - count; - float value = values[i]; - Trace.Assert(ActualMaxValue.HasValue); - Trace.Assert(ActualMinValue.HasValue); - float y = ((ActualMaxValue - value) / (ActualMaxValue - ActualMinValue)).Value; + float y = GetYPosition(values[i]); if (Math.Abs(y * DrawHeight - position.Y) <= 8f) { ball.MoveTo(new Vector2(index / (float)(count - 1), y), transform_duration, EasingTypes.OutQuint); From a08d35ec4c85bb37c6ddeaff9c876e7fd1d55d46 Mon Sep 17 00:00:00 2001 From: Huo Yaoyuan Date: Fri, 16 Jun 2017 15:01:09 +0800 Subject: [PATCH 054/106] Update some container structure. --- osu.Game/Users/Profile/ProfileHeader.cs | 75 +++++++++++++------------ 1 file changed, 40 insertions(+), 35 deletions(-) diff --git a/osu.Game/Users/Profile/ProfileHeader.cs b/osu.Game/Users/Profile/ProfileHeader.cs index ad23b8e522..7d57bde963 100644 --- a/osu.Game/Users/Profile/ProfileHeader.cs +++ b/osu.Game/Users/Profile/ProfileHeader.cs @@ -28,7 +28,7 @@ namespace osu.Game.Users.Profile private readonly SpriteText levelText; private readonly GradeBadge gradeSSPlus, gradeSS, gradeSPlus, gradeS, gradeA; - private const float cover_height = 350, info_height = 150, info_width = 250, avatar_size = 110, avatar_bottom_position = -20, level_position = 30, level_height = 60; + private const float cover_height = 350, info_height = 150, info_width = 250, avatar_size = 110, level_position = 30, level_height = 60; public ProfileHeader(User user) { RelativeSizeAxes = Axes.X; @@ -47,49 +47,58 @@ namespace osu.Game.Users.Profile RelativeSizeAxes = Axes.Both, ColourInfo = ColourInfo.GradientVertical(Color4.Black.Opacity(0.1f), Color4.Black.Opacity(0.75f)) }, - new UpdateableAvatar - { - User = user, - Size = new Vector2(avatar_size), - Anchor = Anchor.BottomLeft, - Origin = Anchor.BottomLeft, - X = UserProfileOverlay.CONTENT_X_MARGIN, - Y = avatar_bottom_position, - Masking = true, - CornerRadius = 5, - EdgeEffect = new EdgeEffectParameters - { - Type = EdgeEffectType.Shadow, - Colour = Color4.Black.Opacity(0.25f), - Radius = 4, - }, - }, new Container { Anchor = Anchor.BottomLeft, Origin = Anchor.BottomLeft, - X = UserProfileOverlay.CONTENT_X_MARGIN + avatar_size + 10, - Y = avatar_bottom_position, + X = UserProfileOverlay.CONTENT_X_MARGIN, + Y = -20, + AutoSizeAxes = Axes.Both, Children = new Drawable[] { - new OsuSpriteText + new UpdateableAvatar { - Text = user.Username, - TextSize = 30, - Font = @"Exo2.0-RegularItalic", + User = user, + Size = new Vector2(avatar_size), Anchor = Anchor.BottomLeft, Origin = Anchor.BottomLeft, - Y = -55 + Masking = true, + CornerRadius = 5, + EdgeEffect = new EdgeEffectParameters + { + Type = EdgeEffectType.Shadow, + Colour = Color4.Black.Opacity(0.25f), + Radius = 4, + }, }, - new DrawableFlag(user.Country?.FlagName ?? "__") + new Container { Anchor = Anchor.BottomLeft, Origin = Anchor.BottomLeft, - Width = 30, - Height = 20 + X = avatar_size + 10, + AutoSizeAxes = Axes.Both, + Children = new Drawable[] + { + new OsuSpriteText + { + Text = user.Username, + TextSize = 30, + Font = @"Exo2.0-RegularItalic", + Anchor = Anchor.BottomLeft, + Origin = Anchor.BottomLeft, + Y = -55 + }, + new DrawableFlag(user.Country?.FlagName ?? "__") + { + Anchor = Anchor.BottomLeft, + Origin = Anchor.BottomLeft, + Width = 30, + Height = 20 + } + } } } - } + }, } }, infoTextLeft = new OsuTextFlowContainer(t => @@ -108,7 +117,7 @@ namespace osu.Game.Users.Profile infoTextRight = new OsuTextFlowContainer(t => { t.TextSize = 14; - t.Alpha = 0.8f; + t.Font = @"Exo2.0-RegularItalic"; }) { X = UserProfileOverlay.CONTENT_X_MARGIN + info_width + 20, @@ -349,11 +358,7 @@ namespace osu.Game.Users.Profile { if (string.IsNullOrEmpty(str)) return; infoTextRight.AddTextAwesome(icon); - infoTextRight.AddText(" " + str, t => - { - t.Font = @"Exo2.0-RegularItalic"; - t.Alpha = 1; - }); + infoTextRight.AddText(" " + str); infoTextRight.NewLine(); } From bd49ae622ac4228c9066fd7029526c5b524b6fd9 Mon Sep 17 00:00:00 2001 From: Huo Yaoyuan Date: Fri, 16 Jun 2017 15:54:55 +0800 Subject: [PATCH 055/106] Add color bar and supporter tag. --- osu.Game/Users/Profile/ProfileHeader.cs | 49 ++++++++++++++++++++++++- 1 file changed, 47 insertions(+), 2 deletions(-) diff --git a/osu.Game/Users/Profile/ProfileHeader.cs b/osu.Game/Users/Profile/ProfileHeader.cs index 7d57bde963..faedc18d09 100644 --- a/osu.Game/Users/Profile/ProfileHeader.cs +++ b/osu.Game/Users/Profile/ProfileHeader.cs @@ -23,10 +23,11 @@ namespace osu.Game.Users.Profile private readonly OsuTextFlowContainer infoTextLeft, infoTextRight; private readonly FillFlowContainer scoreText, scoreNumberText; - private readonly Container coverContainer, chartContainer; + private readonly Container coverContainer, chartContainer, supporterTag; private readonly Sprite levelBadge; private readonly SpriteText levelText; private readonly GradeBadge gradeSSPlus, gradeSS, gradeSPlus, gradeS, gradeA; + private readonly Box colourBar; private const float cover_height = 350, info_height = 150, info_width = 250, avatar_size = 110, level_position = 30, level_height = 60; public ProfileHeader(User user) @@ -79,6 +80,33 @@ namespace osu.Game.Users.Profile AutoSizeAxes = Axes.Both, Children = new Drawable[] { + supporterTag = new CircularContainer + { + Anchor = Anchor.BottomLeft, + Origin = Anchor.BottomLeft, + Y = -75, + Size = new Vector2(25, 25), + Masking = true, + BorderThickness = 3, + BorderColour = Color4.White, + Alpha = 0, + Children = new Drawable[] + { + new Box + { + RelativeSizeAxes = Axes.Both, + Alpha = 0, + AlwaysPresent = true + }, + new TextAwesome + { + Icon = FontAwesome.fa_heart, + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + TextSize = 12 + } + } + }, new OsuSpriteText { Text = user.Username, @@ -86,7 +114,7 @@ namespace osu.Game.Users.Profile Font = @"Exo2.0-RegularItalic", Anchor = Anchor.BottomLeft, Origin = Anchor.BottomLeft, - Y = -55 + Y = -48 }, new DrawableFlag(user.Country?.FlagName ?? "__") { @@ -99,6 +127,15 @@ namespace osu.Game.Users.Profile } } }, + colourBar = new Box + { + Anchor = Anchor.BottomLeft, + Origin = Anchor.BottomLeft, + X = UserProfileOverlay.CONTENT_X_MARGIN, + Height = 5, + Width = info_width, + Alpha = 0 + } } }, infoTextLeft = new OsuTextFlowContainer(t => @@ -267,6 +304,14 @@ namespace osu.Game.Users.Profile Depth = float.MaxValue }); + if (user.IsSupporter) supporterTag.Show(); + + if(!string.IsNullOrEmpty(user.Colour)) + { + colourBar.Colour = OsuColour.FromHex(user.Colour); + colourBar.Show(); + } + Action boldItalic = t => { t.Font = @"Exo2.0-BoldItalic"; From 43569d69a76822b2133fee8e6d3430c6fcb4a07a Mon Sep 17 00:00:00 2001 From: Huo Yaoyuan Date: Fri, 16 Jun 2017 16:13:23 +0800 Subject: [PATCH 056/106] Update transforms. --- .../Tests/TestCaseUserProfile.cs | 8 +----- osu.Game/Overlays/UserProfileOverlay.cs | 27 ++++++++++++++++++- 2 files changed, 27 insertions(+), 8 deletions(-) diff --git a/osu.Desktop.VisualTests/Tests/TestCaseUserProfile.cs b/osu.Desktop.VisualTests/Tests/TestCaseUserProfile.cs index e55d881d93..1dc880ea90 100644 --- a/osu.Desktop.VisualTests/Tests/TestCaseUserProfile.cs +++ b/osu.Desktop.VisualTests/Tests/TestCaseUserProfile.cs @@ -16,13 +16,7 @@ namespace osu.Desktop.VisualTests.Tests public override void Reset() { base.Reset(); - var profile = new UserProfileOverlay - { - Anchor = Anchor.Centre, - Origin = Anchor.Centre, - RelativeSizeAxes = Axes.Both, - Padding = new MarginPadding { Horizontal = 50 }, - }; + var profile = new UserProfileOverlay(); Add(profile); AddStep("Show ppy", () => profile.ShowUser(new User diff --git a/osu.Game/Overlays/UserProfileOverlay.cs b/osu.Game/Overlays/UserProfileOverlay.cs index 2042348d94..a44ffd0319 100644 --- a/osu.Game/Overlays/UserProfileOverlay.cs +++ b/osu.Game/Overlays/UserProfileOverlay.cs @@ -5,6 +5,7 @@ using System.Linq; using OpenTK; using osu.Framework.Allocation; using osu.Framework.Graphics; +using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Sprites; using osu.Framework.Graphics.UserInterface; using osu.Game.Graphics; @@ -17,13 +18,21 @@ using osu.Game.Users.Profile; namespace osu.Game.Overlays { - public class UserProfileOverlay : WaveOverlayContainer + public class UserProfileOverlay : FocusedOverlayContainer { private ProfileSection lastSection; private GetUserRequest userReq; private APIAccess api; public const float CONTENT_X_MARGIN = 50; + private const float transition_length = 500; + + public UserProfileOverlay() + { + RelativeSizeAxes = Axes.Both; + RelativePositionAxes = Axes.Both; + Padding = new MarginPadding { Horizontal = 50 }; + } [BackgroundDependencyLoader] private void load(APIAccess api) @@ -115,6 +124,22 @@ namespace osu.Game.Overlays Show(); } + protected override void PopIn() + { + MoveToY(0, transition_length, EasingTypes.OutQuint); + FadeIn(transition_length, EasingTypes.OutQuint); + + base.PopIn(); + } + + protected override void PopOut() + { + MoveToY(Height, transition_length, EasingTypes.OutQuint); + FadeOut(transition_length, EasingTypes.OutQuint); + + base.PopOut(); + } + private class ProfileTabControl : PageTabControl { private readonly Box bottom; From 3883f4a74642b999c162d81d33be12f7b7c755b2 Mon Sep 17 00:00:00 2001 From: Huo Yaoyuan Date: Fri, 16 Jun 2017 16:23:20 +0800 Subject: [PATCH 057/106] Show profile when click on user panel. --- osu.Game/OsuGame.cs | 1 + osu.Game/Users/UserPanel.cs | 10 +++++++--- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/osu.Game/OsuGame.cs b/osu.Game/OsuGame.cs index 62f9164fdd..4692c89048 100644 --- a/osu.Game/OsuGame.cs +++ b/osu.Game/OsuGame.cs @@ -208,6 +208,7 @@ namespace osu.Game Dependencies.Cache(settings); Dependencies.Cache(social); Dependencies.Cache(chat); + Dependencies.Cache(userProfile); Dependencies.Cache(musicController); Dependencies.Cache(notificationManager); Dependencies.Cache(dialogOverlay); diff --git a/osu.Game/Users/UserPanel.cs b/osu.Game/Users/UserPanel.cs index 19ed2c3394..c0adaa19fb 100644 --- a/osu.Game/Users/UserPanel.cs +++ b/osu.Game/Users/UserPanel.cs @@ -11,6 +11,7 @@ using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Sprites; using osu.Game.Graphics; using osu.Game.Graphics.Sprites; +using osu.Game.Overlays; namespace osu.Game.Users { @@ -21,6 +22,7 @@ namespace osu.Game.Users private const float status_height = 30; private OsuColour colours; + private UserProfileOverlay profile; private readonly Container statusBar; private readonly Box statusBg; @@ -74,7 +76,7 @@ namespace osu.Game.Users Radius = 4, }, }, - new Container + new ClickableContainer { RelativeSizeAxes = Axes.Both, Padding = new MarginPadding { Left = height - status_height - content_padding }, @@ -114,6 +116,7 @@ namespace osu.Game.Users }, }, }, + Action = () => profile?.ShowUser(user) }, }, }, @@ -159,10 +162,11 @@ namespace osu.Game.Users }; } - [BackgroundDependencyLoader] - private void load(OsuColour colours) + [BackgroundDependencyLoader(permitNulls:true)] + private void load(OsuColour colours, UserProfileOverlay profile) { this.colours = colours; + this.profile = profile; Status.ValueChanged += displayStatus; } From 6372cd0a13e11b1f2c9048bcc0645164aceb8c90 Mon Sep 17 00:00:00 2001 From: Huo Yaoyuan Date: Fri, 16 Jun 2017 16:36:23 +0800 Subject: [PATCH 058/106] Move namespace under Overlays. --- .../Profile/AboutSection.cs | 2 +- .../Profile/BeatmapsSection.cs | 2 +- .../Profile/HistoricalSection.cs | 2 +- .../Profile/KudosuSection.cs | 2 +- .../Profile/MedalsSection.cs | 2 +- .../Profile/ProfileHeader.cs | 4 ++-- .../Profile/ProfileSection.cs | 2 +- .../{Users => Overlays}/Profile/RankChart.cs | 3 ++- .../Profile/RanksSection.cs | 2 +- .../Profile/RecentSection.cs | 2 +- osu.Game/Overlays/UserProfileOverlay.cs | 2 +- osu.Game/osu.Game.csproj | 20 +++++++++---------- 12 files changed, 23 insertions(+), 22 deletions(-) rename osu.Game/{Users => Overlays}/Profile/AboutSection.cs (86%) rename osu.Game/{Users => Overlays}/Profile/BeatmapsSection.cs (87%) rename osu.Game/{Users => Overlays}/Profile/HistoricalSection.cs (87%) rename osu.Game/{Users => Overlays}/Profile/KudosuSection.cs (87%) rename osu.Game/{Users => Overlays}/Profile/MedalsSection.cs (87%) rename osu.Game/{Users => Overlays}/Profile/ProfileHeader.cs (97%) rename osu.Game/{Users => Overlays}/Profile/ProfileSection.cs (95%) rename osu.Game/{Users => Overlays}/Profile/RankChart.cs (96%) rename osu.Game/{Users => Overlays}/Profile/RanksSection.cs (87%) rename osu.Game/{Users => Overlays}/Profile/RecentSection.cs (87%) diff --git a/osu.Game/Users/Profile/AboutSection.cs b/osu.Game/Overlays/Profile/AboutSection.cs similarity index 86% rename from osu.Game/Users/Profile/AboutSection.cs rename to osu.Game/Overlays/Profile/AboutSection.cs index 572eb1a273..8dc27b1fdf 100644 --- a/osu.Game/Users/Profile/AboutSection.cs +++ b/osu.Game/Overlays/Profile/AboutSection.cs @@ -2,7 +2,7 @@ // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE -namespace osu.Game.Users.Profile +namespace osu.Game.Overlays.Profile { public class AboutSection : ProfileSection { diff --git a/osu.Game/Users/Profile/BeatmapsSection.cs b/osu.Game/Overlays/Profile/BeatmapsSection.cs similarity index 87% rename from osu.Game/Users/Profile/BeatmapsSection.cs rename to osu.Game/Overlays/Profile/BeatmapsSection.cs index eb460bbbec..0748b7d943 100644 --- a/osu.Game/Users/Profile/BeatmapsSection.cs +++ b/osu.Game/Overlays/Profile/BeatmapsSection.cs @@ -1,7 +1,7 @@ // Copyright (c) 2007-2017 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE -namespace osu.Game.Users.Profile +namespace osu.Game.Overlays.Profile { public class BeatmapsSection : ProfileSection { diff --git a/osu.Game/Users/Profile/HistoricalSection.cs b/osu.Game/Overlays/Profile/HistoricalSection.cs similarity index 87% rename from osu.Game/Users/Profile/HistoricalSection.cs rename to osu.Game/Overlays/Profile/HistoricalSection.cs index 1b767662cf..a4d03d1938 100644 --- a/osu.Game/Users/Profile/HistoricalSection.cs +++ b/osu.Game/Overlays/Profile/HistoricalSection.cs @@ -1,7 +1,7 @@ // Copyright (c) 2007-2017 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE -namespace osu.Game.Users.Profile +namespace osu.Game.Overlays.Profile { public class HistoricalSection : ProfileSection { diff --git a/osu.Game/Users/Profile/KudosuSection.cs b/osu.Game/Overlays/Profile/KudosuSection.cs similarity index 87% rename from osu.Game/Users/Profile/KudosuSection.cs rename to osu.Game/Overlays/Profile/KudosuSection.cs index 3502c61822..bb3988230c 100644 --- a/osu.Game/Users/Profile/KudosuSection.cs +++ b/osu.Game/Overlays/Profile/KudosuSection.cs @@ -1,7 +1,7 @@ // Copyright (c) 2007-2017 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE -namespace osu.Game.Users.Profile +namespace osu.Game.Overlays.Profile { public class KudosuSection : ProfileSection { diff --git a/osu.Game/Users/Profile/MedalsSection.cs b/osu.Game/Overlays/Profile/MedalsSection.cs similarity index 87% rename from osu.Game/Users/Profile/MedalsSection.cs rename to osu.Game/Overlays/Profile/MedalsSection.cs index 18ef779f83..eaefc4cc42 100644 --- a/osu.Game/Users/Profile/MedalsSection.cs +++ b/osu.Game/Overlays/Profile/MedalsSection.cs @@ -1,7 +1,7 @@ // Copyright (c) 2007-2017 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE -namespace osu.Game.Users.Profile +namespace osu.Game.Overlays.Profile { public class MedalsSection : ProfileSection { diff --git a/osu.Game/Users/Profile/ProfileHeader.cs b/osu.Game/Overlays/Profile/ProfileHeader.cs similarity index 97% rename from osu.Game/Users/Profile/ProfileHeader.cs rename to osu.Game/Overlays/Profile/ProfileHeader.cs index faedc18d09..3ea4d66008 100644 --- a/osu.Game/Users/Profile/ProfileHeader.cs +++ b/osu.Game/Overlays/Profile/ProfileHeader.cs @@ -14,9 +14,9 @@ using osu.Framework.Graphics.Textures; using osu.Game.Graphics; using osu.Game.Graphics.Containers; using osu.Game.Graphics.Sprites; -using osu.Game.Overlays; +using osu.Game.Users; -namespace osu.Game.Users.Profile +namespace osu.Game.Overlays.Profile { public class ProfileHeader : Container { diff --git a/osu.Game/Users/Profile/ProfileSection.cs b/osu.Game/Overlays/Profile/ProfileSection.cs similarity index 95% rename from osu.Game/Users/Profile/ProfileSection.cs rename to osu.Game/Overlays/Profile/ProfileSection.cs index ec938c13ac..dfefe7fba1 100644 --- a/osu.Game/Users/Profile/ProfileSection.cs +++ b/osu.Game/Overlays/Profile/ProfileSection.cs @@ -9,7 +9,7 @@ using osu.Game.Graphics; using osu.Game.Graphics.Sprites; using osu.Game.Overlays; -namespace osu.Game.Users.Profile +namespace osu.Game.Overlays.Profile { public abstract class ProfileSection : FillFlowContainer { diff --git a/osu.Game/Users/Profile/RankChart.cs b/osu.Game/Overlays/Profile/RankChart.cs similarity index 96% rename from osu.Game/Users/Profile/RankChart.cs rename to osu.Game/Overlays/Profile/RankChart.cs index 8581635cd7..26fba0dba5 100644 --- a/osu.Game/Users/Profile/RankChart.cs +++ b/osu.Game/Overlays/Profile/RankChart.cs @@ -13,8 +13,9 @@ using osu.Framework.Input; using osu.Game.Graphics; using osu.Game.Graphics.Sprites; using osu.Game.Graphics.UserInterface; +using osu.Game.Users; -namespace osu.Game.Users.Profile +namespace osu.Game.Overlays.Profile { public class RankChart : Container { diff --git a/osu.Game/Users/Profile/RanksSection.cs b/osu.Game/Overlays/Profile/RanksSection.cs similarity index 87% rename from osu.Game/Users/Profile/RanksSection.cs rename to osu.Game/Overlays/Profile/RanksSection.cs index b2a35dbd21..df41077996 100644 --- a/osu.Game/Users/Profile/RanksSection.cs +++ b/osu.Game/Overlays/Profile/RanksSection.cs @@ -1,7 +1,7 @@ // Copyright (c) 2007-2017 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE -namespace osu.Game.Users.Profile +namespace osu.Game.Overlays.Profile { public class RanksSection : ProfileSection { diff --git a/osu.Game/Users/Profile/RecentSection.cs b/osu.Game/Overlays/Profile/RecentSection.cs similarity index 87% rename from osu.Game/Users/Profile/RecentSection.cs rename to osu.Game/Overlays/Profile/RecentSection.cs index b1961491bb..7bc1b5def1 100644 --- a/osu.Game/Users/Profile/RecentSection.cs +++ b/osu.Game/Overlays/Profile/RecentSection.cs @@ -1,7 +1,7 @@ // Copyright (c) 2007-2017 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE -namespace osu.Game.Users.Profile +namespace osu.Game.Overlays.Profile { public class RecentSection : ProfileSection { diff --git a/osu.Game/Overlays/UserProfileOverlay.cs b/osu.Game/Overlays/UserProfileOverlay.cs index a44ffd0319..1b91075e9c 100644 --- a/osu.Game/Overlays/UserProfileOverlay.cs +++ b/osu.Game/Overlays/UserProfileOverlay.cs @@ -13,8 +13,8 @@ using osu.Game.Graphics.Containers; using osu.Game.Graphics.UserInterface; using osu.Game.Online.API; using osu.Game.Online.API.Requests; +using osu.Game.Overlays.Profile; using osu.Game.Users; -using osu.Game.Users.Profile; namespace osu.Game.Overlays { diff --git a/osu.Game/osu.Game.csproj b/osu.Game/osu.Game.csproj index c592a1dcd3..819fb83c60 100644 --- a/osu.Game/osu.Game.csproj +++ b/osu.Game/osu.Game.csproj @@ -97,18 +97,18 @@ - - - - - - - - + + + + + + + + - - + + From f00ee92143200a3ce82e4885f9332421de2fe092 Mon Sep 17 00:00:00 2001 From: Huo Yaoyuan Date: Fri, 16 Jun 2017 16:48:35 +0800 Subject: [PATCH 059/106] Add more acronyms. --- osu.sln.DotSettings | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/osu.sln.DotSettings b/osu.sln.DotSettings index 95c6676455..a4dbeef25d 100644 --- a/osu.sln.DotSettings +++ b/osu.sln.DotSettings @@ -193,6 +193,10 @@ SRGB TK SS + PP + GMT + QAT + BNG HINT <?xml version="1.0" encoding="utf-16"?> <Patterns xmlns="urn:schemas-jetbrains-com:member-reordering-patterns"> From 69270814d581ade70e86746b67cc605f02343dee Mon Sep 17 00:00:00 2001 From: Huo Yaoyuan Date: Fri, 16 Jun 2017 16:48:46 +0800 Subject: [PATCH 060/106] CI fixes. --- osu.Desktop.VisualTests/Tests/TestCaseUserProfile.cs | 2 -- osu.Game/Overlays/Profile/ProfileHeader.cs | 3 +++ osu.Game/Overlays/Profile/ProfileSection.cs | 1 - osu.Game/Overlays/Profile/RankChart.cs | 9 +++++---- 4 files changed, 8 insertions(+), 7 deletions(-) diff --git a/osu.Desktop.VisualTests/Tests/TestCaseUserProfile.cs b/osu.Desktop.VisualTests/Tests/TestCaseUserProfile.cs index 1dc880ea90..f932b01d2c 100644 --- a/osu.Desktop.VisualTests/Tests/TestCaseUserProfile.cs +++ b/osu.Desktop.VisualTests/Tests/TestCaseUserProfile.cs @@ -1,8 +1,6 @@ // Copyright (c) 2007-2017 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE -using osu.Framework.Graphics; -using osu.Framework.Graphics.Containers; using osu.Framework.Testing; using osu.Game.Overlays; using osu.Game.Users; diff --git a/osu.Game/Overlays/Profile/ProfileHeader.cs b/osu.Game/Overlays/Profile/ProfileHeader.cs index 3ea4d66008..5fbbd531ce 100644 --- a/osu.Game/Overlays/Profile/ProfileHeader.cs +++ b/osu.Game/Overlays/Profile/ProfileHeader.cs @@ -378,6 +378,9 @@ namespace osu.Game.Overlays.Profile gradeA.Count = user.Statistics.GradesCount.A; gradeA.Show(); + gradeSPlus.Count = 0; + gradeSSPlus.Count = 0; + chartContainer.Add(new RankChart(user) { RelativeSizeAxes = Axes.Both }); } } diff --git a/osu.Game/Overlays/Profile/ProfileSection.cs b/osu.Game/Overlays/Profile/ProfileSection.cs index dfefe7fba1..84668d8675 100644 --- a/osu.Game/Overlays/Profile/ProfileSection.cs +++ b/osu.Game/Overlays/Profile/ProfileSection.cs @@ -7,7 +7,6 @@ using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Sprites; using osu.Game.Graphics; using osu.Game.Graphics.Sprites; -using osu.Game.Overlays; namespace osu.Game.Overlays.Profile { diff --git a/osu.Game/Overlays/Profile/RankChart.cs b/osu.Game/Overlays/Profile/RankChart.cs index 26fba0dba5..dc28ec1ffd 100644 --- a/osu.Game/Overlays/Profile/RankChart.cs +++ b/osu.Game/Overlays/Profile/RankChart.cs @@ -22,8 +22,8 @@ namespace osu.Game.Overlays.Profile private readonly SpriteText rankText, performanceText, relativeText; private readonly RankChartLineGraph graph; - private int[] ranks; - private decimal?[] performances; + private readonly int[] ranks; + private readonly decimal?[] performances; private const float primary_textsize = 25, secondary_textsize = 13, padding = 10; @@ -70,7 +70,7 @@ namespace osu.Game.Overlays.Profile } }; ranks = new[] { user.Statistics.Rank }; - performances = new decimal?[] { user.Statistics.PP }; + performances = new [] { user.Statistics.PP }; } private void updateRankTexts() @@ -78,13 +78,14 @@ namespace osu.Game.Overlays.Profile rankText.Text = user.Statistics.Rank > 0 ? $"#{user.Statistics.Rank:#,0}" : "no rank"; performanceText.Text = user.Statistics.PP != null ? $"{user.Statistics.PP:#,0}pp" : string.Empty; //relativeText.Text = $"{user.Country?.FullName} #{countryRank:#,0}"; + relativeText.Text = string.Empty; } private void showHistoryRankTexts(int dayIndex) { rankText.Text = ranks[dayIndex] > 0 ? $"#{ranks[dayIndex]:#,0}" : "no rank"; performanceText.Text = performances[dayIndex] != null ? $"{performances[dayIndex]:#,0}pp" : string.Empty; - //relativeText.Text = dayIndex == ranks.Length ? "Now" : $"{ranks.Length - dayIndex} days ago"; + relativeText.Text = dayIndex == ranks.Length ? "Now" : $"{ranks.Length - dayIndex} days ago"; //plural should be handled in a general way } From fe3cbb70729d3b5f708414ab8fbd347f7c29d845 Mon Sep 17 00:00:00 2001 From: Huo Yaoyuan Date: Fri, 16 Jun 2017 20:32:11 +0800 Subject: [PATCH 061/106] Update join date definition. --- osu.Game/Overlays/Profile/ProfileHeader.cs | 13 ++++++++++--- osu.Game/Users/User.cs | 4 ++-- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/osu.Game/Overlays/Profile/ProfileHeader.cs b/osu.Game/Overlays/Profile/ProfileHeader.cs index 5fbbd531ce..3471b27fac 100644 --- a/osu.Game/Overlays/Profile/ProfileHeader.cs +++ b/osu.Game/Overlays/Profile/ProfileHeader.cs @@ -306,7 +306,7 @@ namespace osu.Game.Overlays.Profile if (user.IsSupporter) supporterTag.Show(); - if(!string.IsNullOrEmpty(user.Colour)) + if (!string.IsNullOrEmpty(user.Colour)) { colourBar.Colour = OsuColour.FromHex(user.Colour); colourBar.Show(); @@ -329,8 +329,15 @@ namespace osu.Game.Overlays.Profile } infoTextLeft.NewParagraph(); - infoTextLeft.AddText("Joined "); - infoTextLeft.AddText(user.JoinDate, boldItalic); + if (user.JoinDate.ToUniversalTime().Year < 2008) + { + infoTextLeft.AddText("Here since the beginning", boldItalic); + } + else + { + infoTextLeft.AddText("Joined "); + infoTextLeft.AddText(user.JoinDate.LocalDateTime.ToShortDateString(), boldItalic); + } infoTextLeft.NewLine(); infoTextLeft.AddText("Last seen "); infoTextLeft.AddText(user.LastVisit.LocalDateTime.ToShortDateString(), boldItalic); diff --git a/osu.Game/Users/User.cs b/osu.Game/Users/User.cs index 99484d8ef3..69a0e9c98b 100644 --- a/osu.Game/Users/User.cs +++ b/osu.Game/Users/User.cs @@ -12,8 +12,8 @@ namespace osu.Game.Users [JsonProperty(@"id")] public long Id = 1; - [JsonProperty(@"joinDate")] - public string JoinDate; + [JsonProperty(@"join_date")] + public DateTimeOffset JoinDate; [JsonProperty(@"username")] public string Username; From 23d1c89a670b0426d414b197c83b74193c16e3d9 Mon Sep 17 00:00:00 2001 From: MrTheMake Date: Sun, 18 Jun 2017 20:12:28 +0200 Subject: [PATCH 062/106] Fix not applying song select preview seek --- osu.Game/Screens/Select/SongSelect.cs | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/osu.Game/Screens/Select/SongSelect.cs b/osu.Game/Screens/Select/SongSelect.cs index dc6dfdfd81..2ff0635be0 100644 --- a/osu.Game/Screens/Select/SongSelect.cs +++ b/osu.Game/Screens/Select/SongSelect.cs @@ -321,21 +321,19 @@ namespace osu.Game.Screens.Select if (beatmap.Equals(Beatmap?.BeatmapInfo)) return; - bool beatmapSetChange = false; + bool preview = beatmap.BeatmapSetInfoID != Beatmap.BeatmapInfo.BeatmapSetInfoID; + if (beatmap.BeatmapSetInfoID == selectionChangeNoBounce?.BeatmapSetInfoID) sampleChangeDifficulty.Play(); else - { sampleChangeBeatmap.Play(); - beatmapSetChange = true; - } selectionChangeNoBounce = beatmap; selectionChangedDebounce = Scheduler.AddDelayed(delegate { Beatmap = database.GetWorkingBeatmap(beatmap, Beatmap); - ensurePlayingSelected(beatmapSetChange); + ensurePlayingSelected(preview); }, 100); } @@ -346,6 +344,7 @@ namespace osu.Game.Screens.Select if (track != null) { trackManager.SetExclusive(track); + System.Diagnostics.Debug.WriteLine("Preview: {0}", preview); if (preview) track.Seek(Beatmap.Metadata.PreviewTime); track.Start(); From 3b3cc59471bfa83ea8968afbb9c014b849bf12b0 Mon Sep 17 00:00:00 2001 From: MrTheMake Date: Sun, 18 Jun 2017 20:21:24 +0200 Subject: [PATCH 063/106] Fix NullReferenceException --- osu.Game/Screens/Select/SongSelect.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Screens/Select/SongSelect.cs b/osu.Game/Screens/Select/SongSelect.cs index 2ff0635be0..b5d50664fc 100644 --- a/osu.Game/Screens/Select/SongSelect.cs +++ b/osu.Game/Screens/Select/SongSelect.cs @@ -321,7 +321,7 @@ namespace osu.Game.Screens.Select if (beatmap.Equals(Beatmap?.BeatmapInfo)) return; - bool preview = beatmap.BeatmapSetInfoID != Beatmap.BeatmapInfo.BeatmapSetInfoID; + bool preview = beatmap.BeatmapSetInfoID != Beatmap?.BeatmapInfo.BeatmapSetInfoID; if (beatmap.BeatmapSetInfoID == selectionChangeNoBounce?.BeatmapSetInfoID) sampleChangeDifficulty.Play(); From a399b188379876b10f97f145a6314b5bb24dade5 Mon Sep 17 00:00:00 2001 From: MrTheMake Date: Mon, 19 Jun 2017 00:11:47 +0200 Subject: [PATCH 064/106] Removed debug line --- osu.Game/Screens/Select/SongSelect.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/osu.Game/Screens/Select/SongSelect.cs b/osu.Game/Screens/Select/SongSelect.cs index b5d50664fc..801eb72ba5 100644 --- a/osu.Game/Screens/Select/SongSelect.cs +++ b/osu.Game/Screens/Select/SongSelect.cs @@ -344,7 +344,6 @@ namespace osu.Game.Screens.Select if (track != null) { trackManager.SetExclusive(track); - System.Diagnostics.Debug.WriteLine("Preview: {0}", preview); if (preview) track.Seek(Beatmap.Metadata.PreviewTime); track.Start(); From 89986e8e77459a796d3f07d71d1da4bffdc9d936 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Wed, 21 Jun 2017 17:03:47 +0900 Subject: [PATCH 065/106] Fix namespaces --- osu.Game/Graphics/UserInterface/PageTabControl.cs | 1 + osu.Game/Overlays/Profile/ProfileHeader.cs | 1 + osu.Game/Overlays/Profile/ProfileSection.cs | 2 +- osu.Game/Overlays/Profile/RankChart.cs | 3 ++- osu.Game/Overlays/UserProfileOverlay.cs | 2 +- osu.Game/Users/UserPanel.cs | 3 +-- 6 files changed, 7 insertions(+), 5 deletions(-) diff --git a/osu.Game/Graphics/UserInterface/PageTabControl.cs b/osu.Game/Graphics/UserInterface/PageTabControl.cs index c4daaeb6d8..6b97e54ecd 100644 --- a/osu.Game/Graphics/UserInterface/PageTabControl.cs +++ b/osu.Game/Graphics/UserInterface/PageTabControl.cs @@ -8,6 +8,7 @@ using osu.Framework.Allocation; using osu.Framework.Extensions; using osu.Framework.Graphics; using osu.Framework.Graphics.Shapes; +using osu.Framework.Graphics.Sprites; using osu.Framework.Graphics.UserInterface; using osu.Framework.Input; using osu.Game.Graphics.Sprites; diff --git a/osu.Game/Overlays/Profile/ProfileHeader.cs b/osu.Game/Overlays/Profile/ProfileHeader.cs index 3471b27fac..193fa2dfda 100644 --- a/osu.Game/Overlays/Profile/ProfileHeader.cs +++ b/osu.Game/Overlays/Profile/ProfileHeader.cs @@ -9,6 +9,7 @@ using osu.Framework.Extensions.Color4Extensions; using osu.Framework.Graphics; using osu.Framework.Graphics.Colour; using osu.Framework.Graphics.Containers; +using osu.Framework.Graphics.Shapes; using osu.Framework.Graphics.Sprites; using osu.Framework.Graphics.Textures; using osu.Game.Graphics; diff --git a/osu.Game/Overlays/Profile/ProfileSection.cs b/osu.Game/Overlays/Profile/ProfileSection.cs index 84668d8675..a840eea504 100644 --- a/osu.Game/Overlays/Profile/ProfileSection.cs +++ b/osu.Game/Overlays/Profile/ProfileSection.cs @@ -4,7 +4,7 @@ using OpenTK; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; -using osu.Framework.Graphics.Sprites; +using osu.Framework.Graphics.Shapes; using osu.Game.Graphics; using osu.Game.Graphics.Sprites; diff --git a/osu.Game/Overlays/Profile/RankChart.cs b/osu.Game/Overlays/Profile/RankChart.cs index dc28ec1ffd..9a3d88cf62 100644 --- a/osu.Game/Overlays/Profile/RankChart.cs +++ b/osu.Game/Overlays/Profile/RankChart.cs @@ -8,6 +8,7 @@ using OpenTK; using osu.Framework.Allocation; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; +using osu.Framework.Graphics.Shapes; using osu.Framework.Graphics.Sprites; using osu.Framework.Input; using osu.Game.Graphics; @@ -70,7 +71,7 @@ namespace osu.Game.Overlays.Profile } }; ranks = new[] { user.Statistics.Rank }; - performances = new [] { user.Statistics.PP }; + performances = new[] { user.Statistics.PP }; } private void updateRankTexts() diff --git a/osu.Game/Overlays/UserProfileOverlay.cs b/osu.Game/Overlays/UserProfileOverlay.cs index 1b91075e9c..bfae071e93 100644 --- a/osu.Game/Overlays/UserProfileOverlay.cs +++ b/osu.Game/Overlays/UserProfileOverlay.cs @@ -6,7 +6,7 @@ using OpenTK; using osu.Framework.Allocation; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; -using osu.Framework.Graphics.Sprites; +using osu.Framework.Graphics.Shapes; using osu.Framework.Graphics.UserInterface; using osu.Game.Graphics; using osu.Game.Graphics.Containers; diff --git a/osu.Game/Users/UserPanel.cs b/osu.Game/Users/UserPanel.cs index 06cd7919e5..ecce411819 100644 --- a/osu.Game/Users/UserPanel.cs +++ b/osu.Game/Users/UserPanel.cs @@ -9,7 +9,6 @@ using osu.Framework.Extensions.Color4Extensions; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Shapes; -using osu.Framework.Graphics.Sprites; using osu.Game.Graphics; using osu.Game.Graphics.Sprites; using osu.Game.Overlays; @@ -163,7 +162,7 @@ namespace osu.Game.Users }; } - [BackgroundDependencyLoader(permitNulls:true)] + [BackgroundDependencyLoader(permitNulls: true)] private void load(OsuColour colours, UserProfileOverlay profile) { this.colours = colours; From bcfb1392d72635420cd1651531a900a490186ca9 Mon Sep 17 00:00:00 2001 From: Huo Yaoyuan Date: Wed, 21 Jun 2017 17:17:54 +0800 Subject: [PATCH 066/106] Hide scroll bar. --- osu.Game/Overlays/UserProfileOverlay.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/osu.Game/Overlays/UserProfileOverlay.cs b/osu.Game/Overlays/UserProfileOverlay.cs index bfae071e93..3246b88c9d 100644 --- a/osu.Game/Overlays/UserProfileOverlay.cs +++ b/osu.Game/Overlays/UserProfileOverlay.cs @@ -83,6 +83,7 @@ namespace osu.Game.Overlays RelativeSizeAxes = Axes.Both } }; + sectionsContainer.ScrollContainer.ScrollbarVisible = false; Add(sectionsContainer); sectionsContainer.SelectedSection.ValueChanged += s => { From 1d4add907950a1274a449773a0657a05e9892854 Mon Sep 17 00:00:00 2001 From: Huo Yaoyuan Date: Thu, 22 Jun 2017 20:23:49 +0800 Subject: [PATCH 067/106] Assign an explicit depth when reordering. --- osu.Game/Overlays/UserProfileOverlay.cs | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/osu.Game/Overlays/UserProfileOverlay.cs b/osu.Game/Overlays/UserProfileOverlay.cs index 3246b88c9d..f52f88bc07 100644 --- a/osu.Game/Overlays/UserProfileOverlay.cs +++ b/osu.Game/Overlays/UserProfileOverlay.cs @@ -115,10 +115,16 @@ namespace osu.Game.Overlays { header.FillFullData(u); - var reorderedSections = u.ProfileOrder.Select(x => sections.FirstOrDefault(s => s.Identifier == x)).Where(s => s != null).ToList(); - - sectionsContainer.Children = reorderedSections; - reorderedSections.ForEach(tabs.AddItem); + for (int i = 0; i < u.ProfileOrder.Length; i++) + { + var sec = sections.FirstOrDefault(s => s.Identifier == u.ProfileOrder[i]); + if (sec != null) + { + sec.Depth = -i; + sectionsContainer.Add(sec); + tabs.AddItem(sec); + } + } }; api.Queue(userReq); From bb2e63e714162d244d4692f716900ef178f64a56 Mon Sep 17 00:00:00 2001 From: Huo Yaoyuan Date: Thu, 22 Jun 2017 20:34:28 +0800 Subject: [PATCH 068/106] Avoid unverifiable capture. --- osu.Game/Overlays/UserProfileOverlay.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/osu.Game/Overlays/UserProfileOverlay.cs b/osu.Game/Overlays/UserProfileOverlay.cs index f52f88bc07..52edcf6d6e 100644 --- a/osu.Game/Overlays/UserProfileOverlay.cs +++ b/osu.Game/Overlays/UserProfileOverlay.cs @@ -117,7 +117,8 @@ namespace osu.Game.Overlays for (int i = 0; i < u.ProfileOrder.Length; i++) { - var sec = sections.FirstOrDefault(s => s.Identifier == u.ProfileOrder[i]); + string id = u.ProfileOrder[i]; + var sec = sections.FirstOrDefault(s => s.Identifier == id); if (sec != null) { sec.Depth = -i; From 4297c1a376f58b92912dd69e571a5e1b1b0f3c9e Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 22 Jun 2017 21:38:43 +0900 Subject: [PATCH 069/106] Use WaveOverlayContainer --- osu.Game/Overlays/UserProfileOverlay.cs | 24 ++++++------------------ 1 file changed, 6 insertions(+), 18 deletions(-) diff --git a/osu.Game/Overlays/UserProfileOverlay.cs b/osu.Game/Overlays/UserProfileOverlay.cs index 52edcf6d6e..d67c99ec24 100644 --- a/osu.Game/Overlays/UserProfileOverlay.cs +++ b/osu.Game/Overlays/UserProfileOverlay.cs @@ -5,7 +5,6 @@ using System.Linq; using OpenTK; using osu.Framework.Allocation; using osu.Framework.Graphics; -using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Shapes; using osu.Framework.Graphics.UserInterface; using osu.Game.Graphics; @@ -18,7 +17,7 @@ using osu.Game.Users; namespace osu.Game.Overlays { - public class UserProfileOverlay : FocusedOverlayContainer + public class UserProfileOverlay : WaveOverlayContainer { private ProfileSection lastSection; private GetUserRequest userReq; @@ -29,6 +28,11 @@ namespace osu.Game.Overlays public UserProfileOverlay() { + FirstWaveColour = OsuColour.Gray(0.4f); + SecondWaveColour = OsuColour.Gray(0.3f); + ThirdWaveColour = OsuColour.Gray(0.2f); + FourthWaveColour = OsuColour.Gray(0.1f); + RelativeSizeAxes = Axes.Both; RelativePositionAxes = Axes.Both; Padding = new MarginPadding { Horizontal = 50 }; @@ -132,22 +136,6 @@ namespace osu.Game.Overlays Show(); } - protected override void PopIn() - { - MoveToY(0, transition_length, EasingTypes.OutQuint); - FadeIn(transition_length, EasingTypes.OutQuint); - - base.PopIn(); - } - - protected override void PopOut() - { - MoveToY(Height, transition_length, EasingTypes.OutQuint); - FadeOut(transition_length, EasingTypes.OutQuint); - - base.PopOut(); - } - private class ProfileTabControl : PageTabControl { private readonly Box bottom; From 8b8954b8253aa46ec85e1c456e7b6cdd995989a7 Mon Sep 17 00:00:00 2001 From: Huo Yaoyuan Date: Thu, 22 Jun 2017 21:42:06 +0800 Subject: [PATCH 070/106] Add edge effect and adjust positioning. --- osu.Game/Overlays/UserProfileOverlay.cs | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/osu.Game/Overlays/UserProfileOverlay.cs b/osu.Game/Overlays/UserProfileOverlay.cs index d67c99ec24..aac7fe97f5 100644 --- a/osu.Game/Overlays/UserProfileOverlay.cs +++ b/osu.Game/Overlays/UserProfileOverlay.cs @@ -3,8 +3,11 @@ using System.Linq; using OpenTK; +using OpenTK.Graphics; using osu.Framework.Allocation; +using osu.Framework.Extensions.Color4Extensions; using osu.Framework.Graphics; +using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Shapes; using osu.Framework.Graphics.UserInterface; using osu.Game.Graphics; @@ -35,7 +38,17 @@ namespace osu.Game.Overlays RelativeSizeAxes = Axes.Both; RelativePositionAxes = Axes.Both; - Padding = new MarginPadding { Horizontal = 50 }; + Width = 0.85f; + Anchor = Anchor.TopCentre; + Origin = Anchor.TopCentre; + + Masking = true; + EdgeEffect = new EdgeEffectParameters + { + Colour = Color4.Black.Opacity(0.5f), + Type = EdgeEffectType.Shadow, + Radius = 10 + }; } [BackgroundDependencyLoader] From 35bec7ddc065da307e7fce5ca7630feb3645a8b1 Mon Sep 17 00:00:00 2001 From: Huo Yaoyuan Date: Thu, 22 Jun 2017 21:43:58 +0800 Subject: [PATCH 071/106] Hide profile when not showing overlays. --- osu.Game/OsuGame.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/osu.Game/OsuGame.cs b/osu.Game/OsuGame.cs index 4692c89048..7ef01e8053 100644 --- a/osu.Game/OsuGame.cs +++ b/osu.Game/OsuGame.cs @@ -324,6 +324,7 @@ namespace osu.Game chat.State = Visibility.Hidden; direct.State = Visibility.Hidden; social.State = Visibility.Hidden; + userProfile.State = Visibility.Hidden; } else { From ce2242a979e900b19e7e3394f8ed2d4f02af9d11 Mon Sep 17 00:00:00 2001 From: Jai Sharma Date: Thu, 22 Jun 2017 16:32:50 +0100 Subject: [PATCH 072/106] Removed dragbar from MusicController --- osu.Game/Overlays/MusicController.cs | 73 +++++++++++++++++++++++----- 1 file changed, 60 insertions(+), 13 deletions(-) diff --git a/osu.Game/Overlays/MusicController.cs b/osu.Game/Overlays/MusicController.cs index e1e920ec0f..35a683d1d4 100644 --- a/osu.Game/Overlays/MusicController.cs +++ b/osu.Game/Overlays/MusicController.cs @@ -8,12 +8,14 @@ using System.Threading.Tasks; using OpenTK; using OpenTK.Graphics; using osu.Framework.Allocation; +using osu.Framework.Audio.Track; 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.Framework.Graphics.UserInterface; using osu.Framework.Input; using osu.Framework.Localisation; using osu.Game.Beatmaps; @@ -38,7 +40,7 @@ namespace osu.Game.Overlays private const float bottom_black_area_height = 55; private Drawable currentBackground; - private DragBar progressBar; + private ProgressBar progressBar; private IconButton playButton; private IconButton playlistButton; @@ -183,13 +185,13 @@ namespace osu.Game.Overlays }, } }, - progressBar = new DragBar + progressBar = new ProgressBar { Origin = Anchor.BottomCentre, Anchor = Anchor.BottomCentre, Height = progress_height, - Colour = colours.Yellow, - SeekRequested = seek + FillColour = colours.Yellow, + OnSeek = progress => current?.Track.Seek(progress) } }, }, @@ -224,7 +226,7 @@ namespace osu.Game.Overlays { var track = current.Track; - progressBar.UpdatePosition(track.Length == 0 ? 0 : (float)(track.CurrentTime / track.Length)); + progressBar.Progress = track.CurrentTime; playButton.Icon = track.IsRunning ? FontAwesome.fa_pause_circle_o : FontAwesome.fa_play_circle_o; if (track.HasCompleted && !track.Looping) next(); @@ -266,8 +268,6 @@ namespace osu.Game.Overlays private void beatmapChanged(WorkingBeatmap beatmap) { - progressBar.IsEnabled = beatmap != null; - TransformDirection direction = TransformDirection.None; if (current != null) @@ -293,10 +293,19 @@ namespace osu.Game.Overlays current = beatmapBacking.Value; + updateProgressBar(current?.Track); updateDisplay(beatmapBacking, direction); queuedDirection = null; } + private void updateProgressBar(Track t) + { + if (t?.IsLoaded ?? false) + progressBar.EndTime = t.Length; + else if (t != null) + t.OnLoaded += loadedTrack => progressBar.EndTime = loadedTrack.Length; + } + private ScheduledDelegate pendingBeatmapSwitch; private void updateDisplay(WorkingBeatmap beatmap, TransformDirection direction) @@ -352,12 +361,6 @@ namespace osu.Game.Overlays }); } - private void seek(float position) - { - var track = current?.Track; - track?.Seek(track.Length * position); - } - protected override void PopIn() { base.PopIn(); @@ -417,5 +420,49 @@ namespace osu.Game.Overlays sprite.Texture = beatmap?.Background ?? textures.Get(@"Backgrounds/bg4"); } } + + private class ProgressBar : SliderBar + { + public Action OnSeek; + + private Box fill; + + public Color4 FillColour + { + set { fill.Colour = value; } + } + + public double EndTime + { + set { CurrentNumber.MaxValue = value; } + } + + public double Progress + { + set { CurrentNumber.Value = value; } + } + + public ProgressBar() + { + CurrentNumber.MinValue = 0; + CurrentNumber.MaxValue = 1; + RelativeSizeAxes = Axes.X; + + Children = new Drawable[] + { + fill = new Box + { + RelativeSizeAxes = Axes.Y + } + }; + } + + protected override void UpdateValue(float value) + { + fill.Width = value * UsableWidth; + } + + protected override void OnUserChange() => OnSeek?.Invoke(Current); + } } } From 73c004fb71e9334ba6b6512b09098edac2350f8b Mon Sep 17 00:00:00 2001 From: Jai Sharma Date: Thu, 22 Jun 2017 17:42:29 +0100 Subject: [PATCH 073/106] Removed DragBar from song progress --- osu.Game/Overlays/DragBar.cs | 110 ------------------- osu.Game/Overlays/MusicController.cs | 6 +- osu.Game/Screens/Play/SongProgress.cs | 13 +-- osu.Game/Screens/Play/SongProgressBar.cs | 128 +++++++++++++++-------- osu.Game/osu.Game.csproj | 3 +- 5 files changed, 97 insertions(+), 163 deletions(-) delete mode 100644 osu.Game/Overlays/DragBar.cs diff --git a/osu.Game/Overlays/DragBar.cs b/osu.Game/Overlays/DragBar.cs deleted file mode 100644 index 07e0c76396..0000000000 --- a/osu.Game/Overlays/DragBar.cs +++ /dev/null @@ -1,110 +0,0 @@ -// Copyright (c) 2007-2017 ppy Pty Ltd . -// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE - -using System; -using osu.Framework.Graphics; -using osu.Framework.Graphics.Containers; -using osu.Framework.Graphics.Transforms; -using osu.Framework.Input; -using OpenTK; -using osu.Framework.Graphics.Shapes; - -namespace osu.Game.Overlays -{ - public class DragBar : Container - { - protected readonly Container Fill; - - public Action SeekRequested; - - public bool IsSeeking { get; private set; } - - private bool enabled = true; - public bool IsEnabled - { - get { return enabled; } - set - { - enabled = value; - if (!enabled) - Fill.Width = 0; - } - } - - public DragBar() - { - RelativeSizeAxes = Axes.X; - - Children = new Drawable[] - { - Fill = new Container - { - Name = "FillContainer", - Origin = Anchor.BottomLeft, - Anchor = Anchor.BottomLeft, - RelativeSizeAxes = Axes.Both, - Width = 0, - Children = new Drawable[] - { - new Box - { - RelativeSizeAxes = Axes.Both - } - } - } - }; - } - - public void UpdatePosition(float position) - { - if (IsSeeking || !IsEnabled) return; - - updatePosition(position, false); - } - - private void seek(InputState state) - { - float seekLocation = state.Mouse.Position.X / DrawWidth; - - if (!IsEnabled) return; - - SeekRequested?.Invoke(seekLocation); - updatePosition(seekLocation); - } - - private void updatePosition(float position, bool easing = true) - { - position = MathHelper.Clamp(position, 0, 1); - Fill.TransformTo(() => Fill.Width, position, easing ? 200 : 0, EasingTypes.OutQuint, new TransformSeek()); - } - - protected override bool OnMouseDown(InputState state, MouseDownEventArgs args) - { - seek(state); - return true; - } - - protected override bool OnDrag(InputState state) - { - seek(state); - return true; - } - - protected override bool OnDragStart(InputState state) => IsSeeking = true; - - protected override bool OnDragEnd(InputState state) - { - IsSeeking = false; - return true; - } - - private class TransformSeek : TransformFloat - { - public override void Apply(Drawable d) - { - base.Apply(d); - d.Width = CurrentValue; - } - } - } -} diff --git a/osu.Game/Overlays/MusicController.cs b/osu.Game/Overlays/MusicController.cs index 35a683d1d4..8e9ac22925 100644 --- a/osu.Game/Overlays/MusicController.cs +++ b/osu.Game/Overlays/MusicController.cs @@ -226,7 +226,7 @@ namespace osu.Game.Overlays { var track = current.Track; - progressBar.Progress = track.CurrentTime; + progressBar.CurrentTime = track.CurrentTime; playButton.Icon = track.IsRunning ? FontAwesome.fa_pause_circle_o : FontAwesome.fa_play_circle_o; if (track.HasCompleted && !track.Looping) next(); @@ -437,7 +437,7 @@ namespace osu.Game.Overlays set { CurrentNumber.MaxValue = value; } } - public double Progress + public double CurrentTime { set { CurrentNumber.Value = value; } } @@ -445,7 +445,7 @@ namespace osu.Game.Overlays public ProgressBar() { CurrentNumber.MinValue = 0; - CurrentNumber.MaxValue = 1; + CurrentNumber.MinValue = 1; RelativeSizeAxes = Axes.X; Children = new Drawable[] diff --git a/osu.Game/Screens/Play/SongProgress.cs b/osu.Game/Screens/Play/SongProgress.cs index e5b18292ab..5fc83eddb4 100644 --- a/osu.Game/Screens/Play/SongProgress.cs +++ b/osu.Game/Screens/Play/SongProgress.cs @@ -50,6 +50,9 @@ namespace osu.Game.Screens.Play info.StartTime = firstHitTime; info.EndTime = lastHitTime; + + bar.StartTime = firstHitTime; + bar.EndTime = lastHitTime; } } @@ -89,10 +92,7 @@ namespace osu.Game.Screens.Play Alpha = 0, Anchor = Anchor.BottomLeft, Origin = Anchor.BottomLeft, - SeekRequested = delegate (float position) - { - OnSeek?.Invoke(firstHitTime + position * (lastHitTime - firstHitTime)); - }, + OnSeek = position => this.OnSeek?.Invoke(position), }, }; } @@ -144,11 +144,12 @@ namespace osu.Game.Screens.Play if (objects == null) return; - double progress = ((audioClock?.CurrentTime ?? Time.Current) - firstHitTime) / (lastHitTime - firstHitTime); + double position = audioClock?.CurrentTime ?? Time.Current; + double progress = (position - firstHitTime) / (lastHitTime - firstHitTime); if (progress < 1) { - bar.UpdatePosition((float)progress); + bar.CurrentTime = position; graph.Progress = (int)(graph.ColumnCount * progress); } } diff --git a/osu.Game/Screens/Play/SongProgressBar.cs b/osu.Game/Screens/Play/SongProgressBar.cs index 730cf471da..84928f437a 100644 --- a/osu.Game/Screens/Play/SongProgressBar.cs +++ b/osu.Game/Screens/Play/SongProgressBar.cs @@ -1,74 +1,118 @@ // Copyright (c) 2007-2017 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE +using System; using OpenTK; using OpenTK.Graphics; -using osu.Game.Overlays; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics; using osu.Framework.Graphics.Shapes; +using osu.Framework.Graphics.UserInterface; namespace osu.Game.Screens.Play { - public class SongProgressBar : DragBar + public class SongProgressBar : SliderBar { + public Action OnSeek; + + private Box fill; + private Box background; + private Container handleBase; + public Color4 FillColour { - get { return Fill.Colour; } - set { Fill.Colour = value; } + set { fill.Colour = value; } + } + + public double StartTime + { + set { CurrentNumber.MinValue = value; } + } + + public double EndTime + { + set { CurrentNumber.MaxValue = value; } + } + + public double CurrentTime + { + set { CurrentNumber.Value = value; } } public SongProgressBar(float barHeight, float handleBarHeight, Vector2 handleSize) { + CurrentNumber.MinValue = 0; + CurrentNumber.MaxValue = 1; + + RelativeSizeAxes = Axes.X; Height = barHeight + handleBarHeight + handleSize.Y; - Fill.RelativeSizeAxes = Axes.X; - Fill.Height = barHeight; - - Add(new Box + Children = new Drawable[] { - Name = "Background", - Anchor = Anchor.BottomLeft, - Origin = Anchor.BottomLeft, - RelativeSizeAxes = Axes.X, - Height = barHeight, - Colour = Color4.Black, - Alpha = 0.5f, - Depth = 1 - }); - - Fill.Add(new Container - { - Origin = Anchor.BottomRight, - Anchor = Anchor.BottomRight, - Width = 2, - Height = barHeight + handleBarHeight, - Colour = Color4.White, - Position = new Vector2(2, 0), - Children = new Drawable[] + background = new Box { - new Box + Name = "Background", + Anchor = Anchor.BottomLeft, + Origin = Anchor.BottomLeft, + RelativeSizeAxes = Axes.X, + Height = barHeight, + Colour = Color4.Black, + Alpha = 0.5f, + Depth = 1, + }, + fill = new Box + { + Name = "Fill", + Anchor = Anchor.BottomLeft, + Origin = Anchor.BottomLeft, + Height = barHeight, + }, + handleBase = new Container + { + Name = "HandleBar container", + Origin = Anchor.BottomLeft, + Anchor = Anchor.BottomLeft, + Width = 2, + Height = barHeight + handleBarHeight, + Colour = Color4.White, + Position = new Vector2(2, 0), + Children = new Drawable[] { - RelativeSizeAxes = Axes.Both, - }, - new Container - { - Origin = Anchor.BottomCentre, - Anchor = Anchor.TopCentre, - Size = handleSize, - CornerRadius = 5, - Masking = true, - Children = new Drawable[] + new Box { - new Box + Name = "HandleBar box", + RelativeSizeAxes = Axes.Both, + }, + new Container + { + Name = "Handle container", + Origin = Anchor.BottomCentre, + Anchor = Anchor.TopCentre, + Size = handleSize, + CornerRadius = 5, + Masking = true, + Children = new Drawable[] { - RelativeSizeAxes = Axes.Both, - Colour = Color4.White + new Box + { + Name = "Handle box", + RelativeSizeAxes = Axes.Both, + Colour = Color4.White + } } } } } - }); + }; } + + protected override void UpdateValue(float value) + { + var xFill = value * UsableWidth; + fill.Width = xFill; + handleBase.MoveToX(xFill); + } + + protected override void OnUserChange() => OnSeek?.Invoke(Current); } } diff --git a/osu.Game/osu.Game.csproj b/osu.Game/osu.Game.csproj index 45dc47f842..4646eeb79d 100644 --- a/osu.Game/osu.Game.csproj +++ b/osu.Game/osu.Game.csproj @@ -214,7 +214,6 @@ - @@ -517,4 +516,4 @@ --> - \ No newline at end of file + From 62aae899fa6333c906d302cf23d115d98a705518 Mon Sep 17 00:00:00 2001 From: Jai Sharma Date: Thu, 22 Jun 2017 19:03:31 +0100 Subject: [PATCH 074/106] Fixed non-assigned MaxValue --- osu.Game/Overlays/MusicController.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Overlays/MusicController.cs b/osu.Game/Overlays/MusicController.cs index 8e9ac22925..aec5e03b8f 100644 --- a/osu.Game/Overlays/MusicController.cs +++ b/osu.Game/Overlays/MusicController.cs @@ -445,7 +445,7 @@ namespace osu.Game.Overlays public ProgressBar() { CurrentNumber.MinValue = 0; - CurrentNumber.MinValue = 1; + CurrentNumber.MaxValue = 1; RelativeSizeAxes = Axes.X; Children = new Drawable[] From eafd05e98f09f1862829ffcacfb68cd0e53f1a73 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 23 Jun 2017 11:54:32 +0900 Subject: [PATCH 075/106] Fade shadow effect in to avoid appearing too early in transition --- osu.Game/Overlays/UserProfileOverlay.cs | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/osu.Game/Overlays/UserProfileOverlay.cs b/osu.Game/Overlays/UserProfileOverlay.cs index aac7fe97f5..fc6a050d3e 100644 --- a/osu.Game/Overlays/UserProfileOverlay.cs +++ b/osu.Game/Overlays/UserProfileOverlay.cs @@ -45,7 +45,7 @@ namespace osu.Game.Overlays Masking = true; EdgeEffect = new EdgeEffectParameters { - Colour = Color4.Black.Opacity(0.5f), + Colour = Color4.Black.Opacity(0), Type = EdgeEffectType.Shadow, Radius = 10 }; @@ -57,6 +57,18 @@ namespace osu.Game.Overlays this.api = api; } + protected override void PopIn() + { + base.PopIn(); + FadeEdgeEffectTo(0.5f, APPEAR_DURATION, EasingTypes.In); + } + + protected override void PopOut() + { + base.PopOut(); + FadeEdgeEffectTo(0, DISAPPEAR_DURATION, EasingTypes.Out); + } + public void ShowUser(User user) { userReq?.Cancel(); From 5dc0b87ef5f175396347164bb3d6ba113997a34e Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 23 Jun 2017 14:02:19 +0900 Subject: [PATCH 076/106] Apply some fixes for my own comments --- osu.Game/Graphics/UserInterface/LineGraph.cs | 9 ++++++--- osu.Game/Overlays/Profile/ProfileSection.cs | 11 ++++++++++- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/osu.Game/Graphics/UserInterface/LineGraph.cs b/osu.Game/Graphics/UserInterface/LineGraph.cs index 28b62ff957..8817d79bdd 100644 --- a/osu.Game/Graphics/UserInterface/LineGraph.cs +++ b/osu.Game/Graphics/UserInterface/LineGraph.cs @@ -58,9 +58,12 @@ namespace osu.Game.Graphics.UserInterface Add(maskingContainer = new Container { Masking = true, - RelativeSizeAxes = Axes.Both + RelativeSizeAxes = Axes.Both, + Children = new[] + { + path = new Path { RelativeSizeAxes = Axes.Both, PathWidth = 1 } + } }); - maskingContainer.Add(path = new Path { RelativeSizeAxes = Axes.Both, PathWidth = 1 }); } public override bool Invalidate(Invalidation invalidation = Invalidation.All, Drawable source = null, bool shallPropagate = true) @@ -72,9 +75,9 @@ namespace osu.Game.Graphics.UserInterface private void applyPath() { + path.ClearVertices(); if (values == null) return; - path.ClearVertices(); int count = Math.Max(values.Length, DefaultValueCount); float max = values.Max(), min = values.Min(); diff --git a/osu.Game/Overlays/Profile/ProfileSection.cs b/osu.Game/Overlays/Profile/ProfileSection.cs index a840eea504..63c5263a72 100644 --- a/osu.Game/Overlays/Profile/ProfileSection.cs +++ b/osu.Game/Overlays/Profile/ProfileSection.cs @@ -45,7 +45,16 @@ namespace osu.Game.Overlays.Profile Margin = new MarginPadding { Horizontal = UserProfileOverlay.CONTENT_X_MARGIN, - Bottom = 20 + Bottom = 200 + }, + Children = new Drawable[] + { + new TextFlowContainer + { + AutoSizeAxes = Axes.Y, + RelativeSizeAxes = Axes.X, + Text = "Coming soon!" + } } }, new Box From 674e2a43955719ace56bd9d2cbd9aa2bc8f61aad Mon Sep 17 00:00:00 2001 From: Huo Yaoyuan Date: Fri, 23 Jun 2017 21:59:22 +0800 Subject: [PATCH 077/106] Align placeholder. --- osu.Game/Overlays/Profile/ProfileHeader.cs | 4 ++-- osu.Game/Overlays/Profile/ProfileSection.cs | 24 +++++++++++---------- 2 files changed, 15 insertions(+), 13 deletions(-) diff --git a/osu.Game/Overlays/Profile/ProfileHeader.cs b/osu.Game/Overlays/Profile/ProfileHeader.cs index 193fa2dfda..a85486b0eb 100644 --- a/osu.Game/Overlays/Profile/ProfileHeader.cs +++ b/osu.Game/Overlays/Profile/ProfileHeader.cs @@ -321,11 +321,11 @@ namespace osu.Game.Overlays.Profile if (user.Age != null) { - infoTextLeft.AddText($"{user.Age} years old", boldItalic); + infoTextLeft.AddText($"{user.Age} years old ", boldItalic); } if (user.Country != null) { - infoTextLeft.AddText(" from "); + infoTextLeft.AddText("from "); infoTextLeft.AddText(user.Country.FullName, boldItalic); } infoTextLeft.NewParagraph(); diff --git a/osu.Game/Overlays/Profile/ProfileSection.cs b/osu.Game/Overlays/Profile/ProfileSection.cs index 63c5263a72..5bbdccbbf0 100644 --- a/osu.Game/Overlays/Profile/ProfileSection.cs +++ b/osu.Game/Overlays/Profile/ProfileSection.cs @@ -42,19 +42,10 @@ namespace osu.Game.Overlays.Profile Direction = FillDirection.Vertical, AutoSizeAxes = Axes.Y, RelativeSizeAxes = Axes.X, - Margin = new MarginPadding + Padding = new MarginPadding { Horizontal = UserProfileOverlay.CONTENT_X_MARGIN, - Bottom = 200 - }, - Children = new Drawable[] - { - new TextFlowContainer - { - AutoSizeAxes = Axes.Y, - RelativeSizeAxes = Axes.X, - Text = "Coming soon!" - } + Bottom = 20 } }, new Box @@ -65,6 +56,17 @@ namespace osu.Game.Overlays.Profile EdgeSmoothness = new Vector2(1) } }; + + // placeholder + Add(new OsuSpriteText + { + Text = @"Coming soon!", + TextSize = 36, + Font = @"Exo2.0-RegularItalic", + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + Margin = new MarginPadding { Bottom = 200 } + }); } } } From a327f49d68b72c8dd5fe322244c450a3a2721e66 Mon Sep 17 00:00:00 2001 From: Jai Sharma Date: Fri, 23 Jun 2017 18:24:46 +0100 Subject: [PATCH 078/106] Updating progressBar.EndTime is more thread safe --- osu.Game/Overlays/MusicController.cs | 15 ++++++++++----- osu.Game/Screens/Play/SongProgress.cs | 3 +-- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/osu.Game/Overlays/MusicController.cs b/osu.Game/Overlays/MusicController.cs index aec5e03b8f..c9bbb97032 100644 --- a/osu.Game/Overlays/MusicController.cs +++ b/osu.Game/Overlays/MusicController.cs @@ -293,17 +293,22 @@ namespace osu.Game.Overlays current = beatmapBacking.Value; - updateProgressBar(current?.Track); + updateProgressBarLimit(current?.Track); updateDisplay(beatmapBacking, direction); queuedDirection = null; } - private void updateProgressBar(Track t) + private void updateProgressBarLimit(Track t) { - if (t?.IsLoaded ?? false) - progressBar.EndTime = t.Length; - else if (t != null) + if (t != null) + { t.OnLoaded += loadedTrack => progressBar.EndTime = loadedTrack.Length; + if (t.IsLoaded) + { + progressBar.EndTime = t.Length; + t.OnLoaded = null; + } + } } private ScheduledDelegate pendingBeatmapSwitch; diff --git a/osu.Game/Screens/Play/SongProgress.cs b/osu.Game/Screens/Play/SongProgress.cs index 5fc83eddb4..ea91089aa4 100644 --- a/osu.Game/Screens/Play/SongProgress.cs +++ b/osu.Game/Screens/Play/SongProgress.cs @@ -12,7 +12,6 @@ using System.Linq; using osu.Framework.Timing; using osu.Game.Rulesets.Objects; using osu.Game.Rulesets.Objects.Types; - namespace osu.Game.Screens.Play { public class SongProgress : OverlayContainer @@ -92,7 +91,7 @@ namespace osu.Game.Screens.Play Alpha = 0, Anchor = Anchor.BottomLeft, Origin = Anchor.BottomLeft, - OnSeek = position => this.OnSeek?.Invoke(position), + OnSeek = position => OnSeek?.Invoke(position), }, }; } From e16b646014e41262a797a4cdcad17e7d76aea3ab Mon Sep 17 00:00:00 2001 From: Jai Sharma Date: Sat, 24 Jun 2017 09:14:55 +0100 Subject: [PATCH 079/106] Add readonly to fill --- osu.Game/Overlays/MusicController.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Overlays/MusicController.cs b/osu.Game/Overlays/MusicController.cs index c9bbb97032..72e2e3a36a 100644 --- a/osu.Game/Overlays/MusicController.cs +++ b/osu.Game/Overlays/MusicController.cs @@ -430,7 +430,7 @@ namespace osu.Game.Overlays { public Action OnSeek; - private Box fill; + private readonly Box fill; public Color4 FillColour { From a0262e32b1fb2a4fadf96da3c87d158619562f34 Mon Sep 17 00:00:00 2001 From: Jai Sharma Date: Sat, 24 Jun 2017 09:15:53 +0100 Subject: [PATCH 080/106] CI Fixes --- osu.Game/Screens/Play/SongProgressBar.cs | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/osu.Game/Screens/Play/SongProgressBar.cs b/osu.Game/Screens/Play/SongProgressBar.cs index 84928f437a..7fabf2e80e 100644 --- a/osu.Game/Screens/Play/SongProgressBar.cs +++ b/osu.Game/Screens/Play/SongProgressBar.cs @@ -15,9 +15,8 @@ namespace osu.Game.Screens.Play { public Action OnSeek; - private Box fill; - private Box background; - private Container handleBase; + private readonly Box fill; + private readonly Container handleBase; public Color4 FillColour { @@ -49,7 +48,7 @@ namespace osu.Game.Screens.Play Children = new Drawable[] { - background = new Box + new Box { Name = "Background", Anchor = Anchor.BottomLeft, From 18295a9b97cc84d7f87a3c39d5f6b7897007ebc4 Mon Sep 17 00:00:00 2001 From: Huo Yaoyuan Date: Sun, 25 Jun 2017 10:06:54 +0800 Subject: [PATCH 081/106] Handle scrolling in SectionsContainer. --- .../Graphics/Containers/SectionsContainer.cs | 23 ++++++++++++++----- osu.Game/Overlays/SettingsOverlay.cs | 3 +-- osu.Game/Overlays/UserProfileOverlay.cs | 3 +-- 3 files changed, 19 insertions(+), 10 deletions(-) diff --git a/osu.Game/Graphics/Containers/SectionsContainer.cs b/osu.Game/Graphics/Containers/SectionsContainer.cs index 63cc6f1a85..8221c5d3a6 100644 --- a/osu.Game/Graphics/Containers/SectionsContainer.cs +++ b/osu.Game/Graphics/Containers/SectionsContainer.cs @@ -16,7 +16,7 @@ namespace osu.Game.Graphics.Containers where T : Drawable { private Drawable expandableHeader, fixedHeader, footer, headerBackground; - public readonly ScrollContainer ScrollContainer; + private readonly ScrollContainer scrollContainer; private readonly Container headerBackgroundContainer; private readonly FlowContainer scrollContentContainer; @@ -62,13 +62,13 @@ namespace osu.Game.Graphics.Containers if (value == footer) return; if (footer != null) - ScrollContainer.Remove(footer); + scrollContainer.Remove(footer); footer = value; if (value == null) return; footer.Anchor |= Anchor.y2; footer.Origin |= Anchor.y2; - ScrollContainer.Add(footer); + scrollContainer.Add(footer); lastKnownScroll = float.NaN; } } @@ -122,10 +122,11 @@ namespace osu.Game.Graphics.Containers public SectionsContainer() { - AddInternal(ScrollContainer = new ScrollContainer() + AddInternal(scrollContainer = new ScrollContainer() { RelativeSizeAxes = Axes.Both, Masking = true, + ScrollbarVisible = false, Children = new Drawable[] { scrollContentContainer = CreateScrollContentContainer() }, Depth = float.MaxValue }); @@ -137,6 +138,15 @@ namespace osu.Game.Graphics.Containers originalSectionsMargin = scrollContentContainer.Margin; } + public void ScrollToTop(T section) + { + float pos = scrollContainer.GetChildPosInContent(section); + float current = scrollContainer.Current; + float scrollOffset = FixedHeader?.LayoutSize.Y ?? 0; + if (section == Children.First() && current < pos - scrollOffset) return; + scrollContainer.ScrollTo(pos - scrollOffset); + } + private float lastKnownScroll; protected override void UpdateAfterChildren() { @@ -151,7 +161,7 @@ namespace osu.Game.Graphics.Containers updateSectionsMargin(); } - float currentScroll = Math.Max(0, ScrollContainer.Current); + float currentScroll = Math.Max(0, scrollContainer.Current); if (currentScroll != lastKnownScroll) { lastKnownScroll = currentScroll; @@ -169,10 +179,11 @@ namespace osu.Game.Graphics.Containers T bestMatch = null; float minDiff = float.MaxValue; + float scrollOffset = FixedHeader?.LayoutSize.Y ?? 0; foreach (var section in Children) { - float diff = Math.Abs(ScrollContainer.GetChildPosInContent(section) - currentScroll); + float diff = Math.Abs(scrollContainer.GetChildPosInContent(section) - currentScroll - scrollOffset); if (diff < minDiff) { minDiff = diff; diff --git a/osu.Game/Overlays/SettingsOverlay.cs b/osu.Game/Overlays/SettingsOverlay.cs index 267489fc79..2734aa642d 100644 --- a/osu.Game/Overlays/SettingsOverlay.cs +++ b/osu.Game/Overlays/SettingsOverlay.cs @@ -93,7 +93,7 @@ namespace osu.Game.Overlays new SidebarButton { Section = section, - Action = sectionsContainer.ScrollContainer.ScrollIntoView, + Action = sectionsContainer.ScrollToTop } ).ToArray() } @@ -162,7 +162,6 @@ namespace osu.Game.Overlays public SettingsSectionsContainer() { - ScrollContainer.ScrollbarVisible = false; HeaderBackground = new Box { Colour = Color4.Black, diff --git a/osu.Game/Overlays/UserProfileOverlay.cs b/osu.Game/Overlays/UserProfileOverlay.cs index fc6a050d3e..1cc11bc4e9 100644 --- a/osu.Game/Overlays/UserProfileOverlay.cs +++ b/osu.Game/Overlays/UserProfileOverlay.cs @@ -112,7 +112,6 @@ namespace osu.Game.Overlays RelativeSizeAxes = Axes.Both } }; - sectionsContainer.ScrollContainer.ScrollbarVisible = false; Add(sectionsContainer); sectionsContainer.SelectedSection.ValueChanged += s => { @@ -135,7 +134,7 @@ namespace osu.Game.Overlays if (lastSection != s) { lastSection = s; - sectionsContainer.ScrollContainer.ScrollIntoView(lastSection); + sectionsContainer.ScrollToTop(lastSection); } }; From a187e50889c7671720a8363886798dd85637432c Mon Sep 17 00:00:00 2001 From: Huo Yaoyuan Date: Sun, 25 Jun 2017 10:07:54 +0800 Subject: [PATCH 082/106] Unify usages of field and property. --- osu.Game/Graphics/Containers/SectionsContainer.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/osu.Game/Graphics/Containers/SectionsContainer.cs b/osu.Game/Graphics/Containers/SectionsContainer.cs index 8221c5d3a6..21ffa04351 100644 --- a/osu.Game/Graphics/Containers/SectionsContainer.cs +++ b/osu.Game/Graphics/Containers/SectionsContainer.cs @@ -166,12 +166,12 @@ namespace osu.Game.Graphics.Containers { lastKnownScroll = currentScroll; - if (expandableHeader != null && fixedHeader != null) + if (ExpandableHeader != null && FixedHeader != null) { - float offset = Math.Min(expandableHeader.LayoutSize.Y, currentScroll); + float offset = Math.Min(ExpandableHeader.LayoutSize.Y, currentScroll); - expandableHeader.Y = -offset; - fixedHeader.Y = -offset + expandableHeader.LayoutSize.Y; + ExpandableHeader.Y = -offset; + FixedHeader.Y = -offset + ExpandableHeader.LayoutSize.Y; } headerBackgroundContainer.Height = (ExpandableHeader?.LayoutSize.Y ?? 0) + (FixedHeader?.LayoutSize.Y ?? 0); From be12f318e94112e49a6d1dc8ffbc79f80c896fc2 Mon Sep 17 00:00:00 2001 From: Huo Yaoyuan Date: Sun, 25 Jun 2017 10:40:45 +0800 Subject: [PATCH 083/106] Allow showing offline data only in profile. --- osu.Game/Overlays/UserProfileOverlay.cs | 61 +++++++++++++++---------- 1 file changed, 37 insertions(+), 24 deletions(-) diff --git a/osu.Game/Overlays/UserProfileOverlay.cs b/osu.Game/Overlays/UserProfileOverlay.cs index 1cc11bc4e9..854382c5d5 100644 --- a/osu.Game/Overlays/UserProfileOverlay.cs +++ b/osu.Game/Overlays/UserProfileOverlay.cs @@ -23,8 +23,12 @@ namespace osu.Game.Overlays public class UserProfileOverlay : WaveOverlayContainer { private ProfileSection lastSection; + private ProfileSection[] sections; private GetUserRequest userReq; private APIAccess api; + private ProfileHeader header; + private SectionsContainer sectionsContainer; + private ProfileTabControl tabs; public const float CONTENT_X_MARGIN = 50; private const float transition_length = 500; @@ -69,13 +73,13 @@ namespace osu.Game.Overlays FadeEdgeEffectTo(0, DISAPPEAR_DURATION, EasingTypes.Out); } - public void ShowUser(User user) + public void ShowUser(User user, bool fetchOnline = true) { userReq?.Cancel(); Clear(); lastSection = null; - var sections = new ProfileSection[] + sections = new ProfileSection[] { new AboutSection(), new RecentSection(), @@ -85,7 +89,7 @@ namespace osu.Game.Overlays new BeatmapsSection(), new KudosuSection() }; - var tabs = new ProfileTabControl + tabs = new ProfileTabControl { RelativeSizeAxes = Axes.X, Anchor = Anchor.TopCentre, @@ -99,9 +103,9 @@ namespace osu.Game.Overlays Colour = OsuColour.Gray(0.2f) }); - var header = new ProfileHeader(user); + header = new ProfileHeader(user); - var sectionsContainer = new SectionsContainer + Add(sectionsContainer = new SectionsContainer { RelativeSizeAxes = Axes.Both, ExpandableHeader = header, @@ -111,8 +115,7 @@ namespace osu.Game.Overlays Colour = OsuColour.Gray(34), RelativeSizeAxes = Axes.Both } - }; - Add(sectionsContainer); + }); sectionsContainer.SelectedSection.ValueChanged += s => { if (lastSection != s) @@ -138,28 +141,38 @@ namespace osu.Game.Overlays } }; - userReq = new GetUserRequest(user.Id); //fetch latest full data - userReq.Success += u => + if (fetchOnline) { - header.FillFullData(u); - - for (int i = 0; i < u.ProfileOrder.Length; i++) - { - string id = u.ProfileOrder[i]; - var sec = sections.FirstOrDefault(s => s.Identifier == id); - if (sec != null) - { - sec.Depth = -i; - sectionsContainer.Add(sec); - tabs.AddItem(sec); - } - } - }; - api.Queue(userReq); + userReq = new GetUserRequest(user.Id); + userReq.Success += fillData; + api.Queue(userReq); + } + else + { + userReq = null; + fillData(user); + } Show(); } + private void fillData(User user) + { + header.FillFullData(user); + + for (int i = 0; i < user.ProfileOrder.Length; i++) + { + string id = user.ProfileOrder[i]; + var sec = sections.FirstOrDefault(s => s.Identifier == id); + if (sec != null) + { + sec.Depth = -i; + sectionsContainer.Add(sec); + tabs.AddItem(sec); + } + } + } + private class ProfileTabControl : PageTabControl { private readonly Box bottom; From bfa275ad1c32e0cda7eab918a8de14d7269f0491 Mon Sep 17 00:00:00 2001 From: Huo Yaoyuan Date: Sun, 25 Jun 2017 10:51:54 +0800 Subject: [PATCH 084/106] Change some small classes to struct to avoid potential null check. --- osu.Game/Users/UserStatistics.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/osu.Game/Users/UserStatistics.cs b/osu.Game/Users/UserStatistics.cs index 7e3e5db983..05f3d65f30 100644 --- a/osu.Game/Users/UserStatistics.cs +++ b/osu.Game/Users/UserStatistics.cs @@ -10,7 +10,7 @@ namespace osu.Game.Users [JsonProperty(@"level")] public LevelInfo Level; - public class LevelInfo + public struct LevelInfo { [JsonProperty(@"current")] public int Current; @@ -49,7 +49,7 @@ namespace osu.Game.Users [JsonProperty(@"grade_counts")] public Grades GradesCount; - public class Grades + public struct Grades { [JsonProperty(@"ss")] public int SS; From cad594018f925e7fd51581833ebc0a1fb50cd3da Mon Sep 17 00:00:00 2001 From: Huo Yaoyuan Date: Mon, 26 Jun 2017 00:38:00 +0800 Subject: [PATCH 085/106] Add dummy data in test case. --- .../Tests/TestCaseUserProfile.cs | 27 +++++++++++++++++++ osu.Game/Users/User.cs | 27 +++++++++++++++++++ 2 files changed, 54 insertions(+) diff --git a/osu.Desktop.VisualTests/Tests/TestCaseUserProfile.cs b/osu.Desktop.VisualTests/Tests/TestCaseUserProfile.cs index f932b01d2c..a41834b647 100644 --- a/osu.Desktop.VisualTests/Tests/TestCaseUserProfile.cs +++ b/osu.Desktop.VisualTests/Tests/TestCaseUserProfile.cs @@ -1,6 +1,8 @@ // Copyright (c) 2007-2017 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE +using System; +using System.Linq; using osu.Framework.Testing; using osu.Game.Overlays; using osu.Game.Users; @@ -17,6 +19,31 @@ namespace osu.Desktop.VisualTests.Tests var profile = new UserProfileOverlay(); Add(profile); + AddStep("Show offline dummy", () => profile.ShowUser(new User + { + Username = @"Somebody", + Id = 1, + Country = new Country { FullName = @"Alien" }, + CoverUrl = @"https://osu.ppy.sh/images/headers/profile-covers/c1.jpg", + JoinDate = DateTimeOffset.Now.AddDays(-1), + LastVisit = DateTimeOffset.Now, + Age = 1, + ProfileOrder = new[] { "me" }, + CountryRank = 1, + Statistics = new UserStatistics + { + Rank = 2148, + PP = 4567.89m + }, + AllRankHistories = new User.RankHistories + { + Osu = new User.RankHistory + { + Mode = @"osu", + Data = Enumerable.Range(2345,45).Concat(Enumerable.Range(2109,40)).ToArray() + } + } + }, false)); AddStep("Show ppy", () => profile.ShowUser(new User { Username = @"peppy", diff --git a/osu.Game/Users/User.cs b/osu.Game/Users/User.cs index bf78565e28..37b426ac2c 100644 --- a/osu.Game/Users/User.cs +++ b/osu.Game/Users/User.cs @@ -124,5 +124,32 @@ namespace osu.Game.Users [JsonProperty(@"defaultStatistics")] public UserStatistics Statistics; + + public class RankHistories + { + [JsonProperty(@"osu")] + public RankHistory Osu; + + [JsonProperty(@"taiko")] + public RankHistory Taiko; + + [JsonProperty(@"fruits")] + public RankHistory Fruits; + + [JsonProperty(@"mania")] + public RankHistory Mania; + } + + public class RankHistory + { + [JsonProperty(@"mode")] + public string Mode; + + [JsonProperty(@"data")] + public int[] Data; + } + + [JsonProperty(@"allRankHistories")] + public RankHistories AllRankHistories; } } From d6a720604142e9fbdd8f957f50c90aee5ce5dd9c Mon Sep 17 00:00:00 2001 From: Huo Yaoyuan Date: Mon, 26 Jun 2017 00:43:49 +0800 Subject: [PATCH 086/106] Show rank chart with dummy data. --- osu.Game/Overlays/Profile/RankChart.cs | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/osu.Game/Overlays/Profile/RankChart.cs b/osu.Game/Overlays/Profile/RankChart.cs index 9a3d88cf62..3335f7ca9a 100644 --- a/osu.Game/Overlays/Profile/RankChart.cs +++ b/osu.Game/Overlays/Profile/RankChart.cs @@ -24,7 +24,6 @@ namespace osu.Game.Overlays.Profile private readonly RankChartLineGraph graph; private readonly int[] ranks; - private readonly decimal?[] performances; private const float primary_textsize = 25, secondary_textsize = 13, padding = 10; @@ -70,22 +69,19 @@ namespace osu.Game.Overlays.Profile BallMove = showHistoryRankTexts } }; - ranks = new[] { user.Statistics.Rank }; - performances = new[] { user.Statistics.PP }; + ranks = user.AllRankHistories?.Osu?.Data ?? new[] { user.Statistics.Rank }; } private void updateRankTexts() { rankText.Text = user.Statistics.Rank > 0 ? $"#{user.Statistics.Rank:#,0}" : "no rank"; performanceText.Text = user.Statistics.PP != null ? $"{user.Statistics.PP:#,0}pp" : string.Empty; - //relativeText.Text = $"{user.Country?.FullName} #{countryRank:#,0}"; - relativeText.Text = string.Empty; + relativeText.Text = $"{user.Country?.FullName} #{user.CountryRank:#,0}"; } private void showHistoryRankTexts(int dayIndex) { rankText.Text = ranks[dayIndex] > 0 ? $"#{ranks[dayIndex]:#,0}" : "no rank"; - performanceText.Text = performances[dayIndex] != null ? $"{performances[dayIndex]:#,0}pp" : string.Empty; relativeText.Text = dayIndex == ranks.Length ? "Now" : $"{ranks.Length - dayIndex} days ago"; //plural should be handled in a general way } From 0582eddcba365dec197ffc51c952b0996d6d37bc Mon Sep 17 00:00:00 2001 From: Huo Yaoyuan Date: Mon, 26 Jun 2017 00:52:03 +0800 Subject: [PATCH 087/106] Slightly update text position. --- osu.Game/Overlays/Profile/ProfileHeader.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Overlays/Profile/ProfileHeader.cs b/osu.Game/Overlays/Profile/ProfileHeader.cs index a85486b0eb..c15afb080c 100644 --- a/osu.Game/Overlays/Profile/ProfileHeader.cs +++ b/osu.Game/Overlays/Profile/ProfileHeader.cs @@ -30,7 +30,7 @@ namespace osu.Game.Overlays.Profile private readonly GradeBadge gradeSSPlus, gradeSS, gradeSPlus, gradeS, gradeA; private readonly Box colourBar; - private const float cover_height = 350, info_height = 150, info_width = 250, avatar_size = 110, level_position = 30, level_height = 60; + private const float cover_height = 350, info_height = 150, info_width = 220, avatar_size = 110, level_position = 30, level_height = 60; public ProfileHeader(User user) { RelativeSizeAxes = Axes.X; From 684d1887522ebbdb489409af77dabfebc4410221 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Mon, 26 Jun 2017 16:26:43 +0900 Subject: [PATCH 088/106] Adjust transition duration slightly --- osu.Game/Graphics/UserInterface/LineGraph.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Graphics/UserInterface/LineGraph.cs b/osu.Game/Graphics/UserInterface/LineGraph.cs index 8817d79bdd..b135d8004d 100644 --- a/osu.Game/Graphics/UserInterface/LineGraph.cs +++ b/osu.Game/Graphics/UserInterface/LineGraph.cs @@ -26,7 +26,7 @@ namespace osu.Game.Graphics.UserInterface public float ActualMaxValue { get; private set; } = float.NaN; public float ActualMinValue { get; private set; } = float.NaN; - private const double transform_duration = 500; + private const double transform_duration = 1500; /// /// Hold an empty area if values are less. From b5cf02267659184cd8dad2183d44149e413d4f27 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Mon, 26 Jun 2017 16:26:50 +0900 Subject: [PATCH 089/106] Add missing newline --- osu.Game/Overlays/Profile/RankChart.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/osu.Game/Overlays/Profile/RankChart.cs b/osu.Game/Overlays/Profile/RankChart.cs index 3335f7ca9a..dfd2219e1f 100644 --- a/osu.Game/Overlays/Profile/RankChart.cs +++ b/osu.Game/Overlays/Profile/RankChart.cs @@ -69,6 +69,7 @@ namespace osu.Game.Overlays.Profile BallMove = showHistoryRankTexts } }; + ranks = user.AllRankHistories?.Osu?.Data ?? new[] { user.Statistics.Rank }; } From 3290f5a9778a731ec0b2ac5768cfa6114036d849 Mon Sep 17 00:00:00 2001 From: Huo Yaoyuan Date: Mon, 10 Jul 2017 10:42:55 +0800 Subject: [PATCH 090/106] Update test case for profile. --- osu.Desktop.VisualTests/Tests/TestCaseUserProfile.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/osu.Desktop.VisualTests/Tests/TestCaseUserProfile.cs b/osu.Desktop.VisualTests/Tests/TestCaseUserProfile.cs index a41834b647..d7a2c8e47d 100644 --- a/osu.Desktop.VisualTests/Tests/TestCaseUserProfile.cs +++ b/osu.Desktop.VisualTests/Tests/TestCaseUserProfile.cs @@ -13,9 +13,8 @@ namespace osu.Desktop.VisualTests.Tests { public override string Description => "Tests user's profile page."; - public override void Reset() + public TestCaseUserProfile() { - base.Reset(); var profile = new UserProfileOverlay(); Add(profile); From 752f625a62dc2a434689a438724b937454441076 Mon Sep 17 00:00:00 2001 From: Huo Yaoyuan Date: Tue, 11 Jul 2017 09:19:36 +0800 Subject: [PATCH 091/106] Set relative axes inside AsyncLoadWrapper. --- osu.Game/Overlays/Profile/ProfileHeader.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/osu.Game/Overlays/Profile/ProfileHeader.cs b/osu.Game/Overlays/Profile/ProfileHeader.cs index c15afb080c..0071c8e4ab 100644 --- a/osu.Game/Overlays/Profile/ProfileHeader.cs +++ b/osu.Game/Overlays/Profile/ProfileHeader.cs @@ -294,6 +294,7 @@ namespace osu.Game.Overlays.Profile { coverContainer.Add(new AsyncLoadWrapper(new UserCoverBackground(user) { + RelativeSizeAxes = Axes.Both, Anchor = Anchor.Centre, Origin = Anchor.Centre, FillMode = FillMode.Fill, From c02a85bc4ab82d1348cb2a9df3bc30b78444e5bd Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 13 Jul 2017 13:52:40 +0900 Subject: [PATCH 092/106] Formatting --- osu.Game/Graphics/Containers/OsuTextFlowContainer.cs | 3 +-- osu.Game/Graphics/UserInterface/LineGraph.cs | 5 +---- osu.Game/Overlays/Profile/ProfileHeader.cs | 9 ++++----- osu.Game/Overlays/UserProfileOverlay.cs | 1 - 4 files changed, 6 insertions(+), 12 deletions(-) diff --git a/osu.Game/Graphics/Containers/OsuTextFlowContainer.cs b/osu.Game/Graphics/Containers/OsuTextFlowContainer.cs index 570e682618..143f38ced4 100644 --- a/osu.Game/Graphics/Containers/OsuTextFlowContainer.cs +++ b/osu.Game/Graphics/Containers/OsuTextFlowContainer.cs @@ -2,7 +2,6 @@ // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE using System; -using System.Collections.Generic; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Sprites; using osu.Game.Graphics.Sprites; @@ -17,6 +16,6 @@ namespace osu.Game.Graphics.Containers protected override SpriteText CreateSpriteText() => new OsuSpriteText(); - public IEnumerable AddTextAwesome(FontAwesome icon, Action creationParameters = null) => AddText(((char)icon).ToString(), creationParameters); + public void AddIcon(FontAwesome icon, Action creationParameters = null) => AddText(((char)icon).ToString(), creationParameters); } } diff --git a/osu.Game/Graphics/UserInterface/LineGraph.cs b/osu.Game/Graphics/UserInterface/LineGraph.cs index b135d8004d..cd8ba96dc8 100644 --- a/osu.Game/Graphics/UserInterface/LineGraph.cs +++ b/osu.Game/Graphics/UserInterface/LineGraph.cs @@ -59,10 +59,7 @@ namespace osu.Game.Graphics.UserInterface { Masking = true, RelativeSizeAxes = Axes.Both, - Children = new[] - { - path = new Path { RelativeSizeAxes = Axes.Both, PathWidth = 1 } - } + Child = path = new Path { RelativeSizeAxes = Axes.Both, PathWidth = 1 } }); } diff --git a/osu.Game/Overlays/Profile/ProfileHeader.cs b/osu.Game/Overlays/Profile/ProfileHeader.cs index 3cc0e5bdb7..61da9560dc 100644 --- a/osu.Game/Overlays/Profile/ProfileHeader.cs +++ b/osu.Game/Overlays/Profile/ProfileHeader.cs @@ -31,6 +31,7 @@ namespace osu.Game.Overlays.Profile private readonly Box colourBar; private const float cover_height = 350, info_height = 150, info_width = 220, avatar_size = 110, level_position = 30, level_height = 60; + public ProfileHeader(User user) { RelativeSizeAxes = Axes.X; @@ -414,7 +415,8 @@ namespace osu.Game.Overlays.Profile private void tryAddInfoRightLine(FontAwesome icon, string str) { if (string.IsNullOrEmpty(str)) return; - infoTextRight.AddTextAwesome(icon); + + infoTextRight.AddIcon(icon); infoTextRight.AddText(" " + str); infoTextRight.NewLine(); } @@ -428,10 +430,7 @@ namespace osu.Game.Overlays.Profile public int DisplayCount { - set - { - numberText.Text = value.ToString(@"#,0"); - } + set { numberText.Text = value.ToString(@"#,0"); } } public GradeBadge(string grade) diff --git a/osu.Game/Overlays/UserProfileOverlay.cs b/osu.Game/Overlays/UserProfileOverlay.cs index 854382c5d5..2cf049dd89 100644 --- a/osu.Game/Overlays/UserProfileOverlay.cs +++ b/osu.Game/Overlays/UserProfileOverlay.cs @@ -31,7 +31,6 @@ namespace osu.Game.Overlays private ProfileTabControl tabs; public const float CONTENT_X_MARGIN = 50; - private const float transition_length = 500; public UserProfileOverlay() { From c7a13740f96886c69b8f8a47583465d0778a8002 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 13 Jul 2017 13:53:45 +0900 Subject: [PATCH 093/106] Move sections to own namespace --- .../Profile/{ => Sections}/AboutSection.cs | 3 +-- .../Profile/{ => Sections}/BeatmapsSection.cs | 2 +- .../Profile/{ => Sections}/HistoricalSection.cs | 2 +- .../Profile/{ => Sections}/KudosuSection.cs | 2 +- .../Profile/{ => Sections}/MedalsSection.cs | 2 +- .../Profile/{ => Sections}/RanksSection.cs | 2 +- .../Profile/{ => Sections}/RecentSection.cs | 2 +- osu.Game/Overlays/UserProfileOverlay.cs | 1 + osu.Game/osu.Game.csproj | 14 +++++++------- 9 files changed, 15 insertions(+), 15 deletions(-) rename osu.Game/Overlays/Profile/{ => Sections}/AboutSection.cs (84%) rename osu.Game/Overlays/Profile/{ => Sections}/BeatmapsSection.cs (85%) rename osu.Game/Overlays/Profile/{ => Sections}/HistoricalSection.cs (85%) rename osu.Game/Overlays/Profile/{ => Sections}/KudosuSection.cs (85%) rename osu.Game/Overlays/Profile/{ => Sections}/MedalsSection.cs (85%) rename osu.Game/Overlays/Profile/{ => Sections}/RanksSection.cs (85%) rename osu.Game/Overlays/Profile/{ => Sections}/RecentSection.cs (85%) diff --git a/osu.Game/Overlays/Profile/AboutSection.cs b/osu.Game/Overlays/Profile/Sections/AboutSection.cs similarity index 84% rename from osu.Game/Overlays/Profile/AboutSection.cs rename to osu.Game/Overlays/Profile/Sections/AboutSection.cs index 8dc27b1fdf..1d15300eca 100644 --- a/osu.Game/Overlays/Profile/AboutSection.cs +++ b/osu.Game/Overlays/Profile/Sections/AboutSection.cs @@ -1,8 +1,7 @@ // Copyright (c) 2007-2017 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE - -namespace osu.Game.Overlays.Profile +namespace osu.Game.Overlays.Profile.Sections { public class AboutSection : ProfileSection { diff --git a/osu.Game/Overlays/Profile/BeatmapsSection.cs b/osu.Game/Overlays/Profile/Sections/BeatmapsSection.cs similarity index 85% rename from osu.Game/Overlays/Profile/BeatmapsSection.cs rename to osu.Game/Overlays/Profile/Sections/BeatmapsSection.cs index 0748b7d943..1c39223e6f 100644 --- a/osu.Game/Overlays/Profile/BeatmapsSection.cs +++ b/osu.Game/Overlays/Profile/Sections/BeatmapsSection.cs @@ -1,7 +1,7 @@ // Copyright (c) 2007-2017 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE -namespace osu.Game.Overlays.Profile +namespace osu.Game.Overlays.Profile.Sections { public class BeatmapsSection : ProfileSection { diff --git a/osu.Game/Overlays/Profile/HistoricalSection.cs b/osu.Game/Overlays/Profile/Sections/HistoricalSection.cs similarity index 85% rename from osu.Game/Overlays/Profile/HistoricalSection.cs rename to osu.Game/Overlays/Profile/Sections/HistoricalSection.cs index a4d03d1938..78ed6bf846 100644 --- a/osu.Game/Overlays/Profile/HistoricalSection.cs +++ b/osu.Game/Overlays/Profile/Sections/HistoricalSection.cs @@ -1,7 +1,7 @@ // Copyright (c) 2007-2017 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE -namespace osu.Game.Overlays.Profile +namespace osu.Game.Overlays.Profile.Sections { public class HistoricalSection : ProfileSection { diff --git a/osu.Game/Overlays/Profile/KudosuSection.cs b/osu.Game/Overlays/Profile/Sections/KudosuSection.cs similarity index 85% rename from osu.Game/Overlays/Profile/KudosuSection.cs rename to osu.Game/Overlays/Profile/Sections/KudosuSection.cs index bb3988230c..3c36368fd7 100644 --- a/osu.Game/Overlays/Profile/KudosuSection.cs +++ b/osu.Game/Overlays/Profile/Sections/KudosuSection.cs @@ -1,7 +1,7 @@ // Copyright (c) 2007-2017 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE -namespace osu.Game.Overlays.Profile +namespace osu.Game.Overlays.Profile.Sections { public class KudosuSection : ProfileSection { diff --git a/osu.Game/Overlays/Profile/MedalsSection.cs b/osu.Game/Overlays/Profile/Sections/MedalsSection.cs similarity index 85% rename from osu.Game/Overlays/Profile/MedalsSection.cs rename to osu.Game/Overlays/Profile/Sections/MedalsSection.cs index eaefc4cc42..47a3e6f4d0 100644 --- a/osu.Game/Overlays/Profile/MedalsSection.cs +++ b/osu.Game/Overlays/Profile/Sections/MedalsSection.cs @@ -1,7 +1,7 @@ // Copyright (c) 2007-2017 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE -namespace osu.Game.Overlays.Profile +namespace osu.Game.Overlays.Profile.Sections { public class MedalsSection : ProfileSection { diff --git a/osu.Game/Overlays/Profile/RanksSection.cs b/osu.Game/Overlays/Profile/Sections/RanksSection.cs similarity index 85% rename from osu.Game/Overlays/Profile/RanksSection.cs rename to osu.Game/Overlays/Profile/Sections/RanksSection.cs index df41077996..5ea135fcac 100644 --- a/osu.Game/Overlays/Profile/RanksSection.cs +++ b/osu.Game/Overlays/Profile/Sections/RanksSection.cs @@ -1,7 +1,7 @@ // Copyright (c) 2007-2017 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE -namespace osu.Game.Overlays.Profile +namespace osu.Game.Overlays.Profile.Sections { public class RanksSection : ProfileSection { diff --git a/osu.Game/Overlays/Profile/RecentSection.cs b/osu.Game/Overlays/Profile/Sections/RecentSection.cs similarity index 85% rename from osu.Game/Overlays/Profile/RecentSection.cs rename to osu.Game/Overlays/Profile/Sections/RecentSection.cs index 7bc1b5def1..7bd41eac79 100644 --- a/osu.Game/Overlays/Profile/RecentSection.cs +++ b/osu.Game/Overlays/Profile/Sections/RecentSection.cs @@ -1,7 +1,7 @@ // Copyright (c) 2007-2017 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE -namespace osu.Game.Overlays.Profile +namespace osu.Game.Overlays.Profile.Sections { public class RecentSection : ProfileSection { diff --git a/osu.Game/Overlays/UserProfileOverlay.cs b/osu.Game/Overlays/UserProfileOverlay.cs index 2cf049dd89..d2e9bdcb46 100644 --- a/osu.Game/Overlays/UserProfileOverlay.cs +++ b/osu.Game/Overlays/UserProfileOverlay.cs @@ -16,6 +16,7 @@ using osu.Game.Graphics.UserInterface; using osu.Game.Online.API; using osu.Game.Online.API.Requests; using osu.Game.Overlays.Profile; +using osu.Game.Overlays.Profile.Sections; using osu.Game.Users; namespace osu.Game.Overlays diff --git a/osu.Game/osu.Game.csproj b/osu.Game/osu.Game.csproj index a35761a9d6..bc01b93c44 100644 --- a/osu.Game/osu.Game.csproj +++ b/osu.Game/osu.Game.csproj @@ -99,14 +99,14 @@ - - - - - + + + + + - - + + From 4cf409ab353cafa1be6d2563dac30f1671ee3dcf Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 13 Jul 2017 14:23:52 +0900 Subject: [PATCH 094/106] Adjust padding slightly --- osu.Game/Overlays/Profile/ProfileSection.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Overlays/Profile/ProfileSection.cs b/osu.Game/Overlays/Profile/ProfileSection.cs index 5bbdccbbf0..678e79c757 100644 --- a/osu.Game/Overlays/Profile/ProfileSection.cs +++ b/osu.Game/Overlays/Profile/ProfileSection.cs @@ -34,7 +34,7 @@ namespace osu.Game.Overlays.Profile Margin = new MarginPadding { Horizontal = UserProfileOverlay.CONTENT_X_MARGIN, - Vertical = 20 + Vertical = 10 } }, content = new FillFlowContainer From 3c7cd97d429e0059e5db7e68c3162eb07928a3d3 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 13 Jul 2017 14:24:08 +0900 Subject: [PATCH 095/106] Vertically center "coming soon" text --- osu.Game/Overlays/Profile/ProfileSection.cs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/osu.Game/Overlays/Profile/ProfileSection.cs b/osu.Game/Overlays/Profile/ProfileSection.cs index 678e79c757..2b5084e321 100644 --- a/osu.Game/Overlays/Profile/ProfileSection.cs +++ b/osu.Game/Overlays/Profile/ProfileSection.cs @@ -7,6 +7,7 @@ using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Shapes; using osu.Game.Graphics; using osu.Game.Graphics.Sprites; +using OpenTK.Graphics; namespace osu.Game.Overlays.Profile { @@ -60,12 +61,13 @@ namespace osu.Game.Overlays.Profile // placeholder Add(new OsuSpriteText { - Text = @"Coming soon!", - TextSize = 36, - Font = @"Exo2.0-RegularItalic", + Text = @"coming soon!", + TextSize = 16, + Font = @"Exo2.0-Medium", + Colour = Color4.Gray, Anchor = Anchor.Centre, Origin = Anchor.Centre, - Margin = new MarginPadding { Bottom = 200 } + Margin = new MarginPadding { Top = 100, Bottom = 100 } }); } } From b79e309c2f8d127071b19c2b62a025352878b469 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 13 Jul 2017 14:24:41 +0900 Subject: [PATCH 096/106] Don't lock scroll position of SectionsContainer header elements on negative scroll Feels better in all cases. --- osu.Game/Graphics/Containers/SectionsContainer.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/osu.Game/Graphics/Containers/SectionsContainer.cs b/osu.Game/Graphics/Containers/SectionsContainer.cs index 617c7eeb2c..cee7bb6011 100644 --- a/osu.Game/Graphics/Containers/SectionsContainer.cs +++ b/osu.Game/Graphics/Containers/SectionsContainer.cs @@ -162,7 +162,8 @@ namespace osu.Game.Graphics.Containers updateSectionsMargin(); } - float currentScroll = Math.Max(0, scrollContainer.Current); + float currentScroll = scrollContainer.Current; + if (currentScroll != lastKnownScroll) { lastKnownScroll = currentScroll; From d1a5a042d738d09507f636069165d92577abab47 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 13 Jul 2017 14:32:47 +0900 Subject: [PATCH 097/106] Avoid storing locals in UserPanel. Also make clickable region more correct. --- osu.Game/Users/UserPanel.cs | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/osu.Game/Users/UserPanel.cs b/osu.Game/Users/UserPanel.cs index 79d6d14942..f2b2b0947a 100644 --- a/osu.Game/Users/UserPanel.cs +++ b/osu.Game/Users/UserPanel.cs @@ -1,6 +1,7 @@ // Copyright (c) 2007-2017 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE +using System; using OpenTK; using OpenTK.Graphics; using osu.Framework.Allocation; @@ -15,23 +16,25 @@ using osu.Game.Overlays; namespace osu.Game.Users { - public class UserPanel : Container + public class UserPanel : ClickableContainer { + private readonly User user; private const float height = 100; private const float content_padding = 10; private const float status_height = 30; - private OsuColour colours; - private UserProfileOverlay profile; - private readonly Container statusBar; private readonly Box statusBg; private readonly OsuSpriteText statusMessage; public readonly Bindable Status = new Bindable(); + public new Action Action; + public UserPanel(User user) { + this.user = user; + Height = height - status_height; Masking = true; CornerRadius = 5; @@ -77,7 +80,7 @@ namespace osu.Game.Users Radius = 4, }, }, - new ClickableContainer + new Container { RelativeSizeAxes = Axes.Both, Padding = new MarginPadding { Left = height - status_height - content_padding }, @@ -117,7 +120,6 @@ namespace osu.Game.Users }, }, }, - Action = () => profile?.ShowUser(user) }, }, }, @@ -166,9 +168,14 @@ namespace osu.Game.Users [BackgroundDependencyLoader(permitNulls: true)] private void load(OsuColour colours, UserProfileOverlay profile) { - this.colours = colours; - this.profile = profile; Status.ValueChanged += displayStatus; + Status.ValueChanged += status => statusBg.FadeColour(status.GetAppropriateColour(colours), 500, EasingTypes.OutQuint); + + base.Action = () => + { + Action?.Invoke(); + profile?.ShowUser(user); + }; } protected override void LoadComplete() @@ -193,7 +200,6 @@ namespace osu.Game.Users statusBar.FadeIn(transition_duration, EasingTypes.OutQuint); ResizeHeightTo(height, transition_duration, EasingTypes.OutQuint); - statusBg.FadeColour(status.GetAppropriateColour(colours), 500, EasingTypes.OutQuint); statusMessage.Text = status.Message; } } From b13e8599f12991d2f19fae57d9cfdb3d19d88b5a Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 13 Jul 2017 14:46:17 +0900 Subject: [PATCH 098/106] Hide the login overlay when the user panel container by it is clicked --- osu.Game/Overlays/LoginOverlay.cs | 1 + .../Settings/Sections/General/LoginSettings.cs | 13 ++++++++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/osu.Game/Overlays/LoginOverlay.cs b/osu.Game/Overlays/LoginOverlay.cs index 790530342f..d9d5a44fd5 100644 --- a/osu.Game/Overlays/LoginOverlay.cs +++ b/osu.Game/Overlays/LoginOverlay.cs @@ -46,6 +46,7 @@ namespace osu.Game.Overlays settingsSection = new LoginSettings { Padding = new MarginPadding(10), + RequestHide = Hide, }, new Box { diff --git a/osu.Game/Overlays/Settings/Sections/General/LoginSettings.cs b/osu.Game/Overlays/Settings/Sections/General/LoginSettings.cs index 43d89eebf0..bbecdff29a 100644 --- a/osu.Game/Overlays/Settings/Sections/General/LoginSettings.cs +++ b/osu.Game/Overlays/Settings/Sections/General/LoginSettings.cs @@ -1,6 +1,7 @@ // Copyright (c) 2007-2017 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE +using System; using osu.Framework.Allocation; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; @@ -31,6 +32,11 @@ namespace osu.Game.Overlays.Settings.Sections.General private UserPanel panel; private UserDropdown dropdown; + /// + /// Called to request a hide of a parent displaying this container. + /// + public Action RequestHide; + public override RectangleF BoundingBox => bounding ? base.BoundingBox : RectangleF.Empty; public bool Bounding @@ -58,6 +64,7 @@ namespace osu.Game.Overlays.Settings.Sections.General { this.inputManager = inputManager; this.colours = colours; + api?.Register(this); } @@ -129,7 +136,11 @@ namespace osu.Game.Overlays.Settings.Sections.General }, }, }, - panel = new UserPanel(api.LocalUser.Value) { RelativeSizeAxes = Axes.X }, + panel = new UserPanel(api.LocalUser.Value) + { + RelativeSizeAxes = Axes.X, + Action = RequestHide + }, dropdown = new UserDropdown { RelativeSizeAxes = Axes.X }, }, }, From 03e4b2a5990a42afaf5f97012b89fc8292e3fe30 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 13 Jul 2017 14:55:19 +0900 Subject: [PATCH 099/106] Add default status colour --- 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 f2b2b0947a..0780c2ffd0 100644 --- a/osu.Game/Users/UserPanel.cs +++ b/osu.Game/Users/UserPanel.cs @@ -169,7 +169,7 @@ namespace osu.Game.Users private void load(OsuColour colours, UserProfileOverlay profile) { Status.ValueChanged += displayStatus; - Status.ValueChanged += status => statusBg.FadeColour(status.GetAppropriateColour(colours), 500, EasingTypes.OutQuint); + Status.ValueChanged += status => statusBg.FadeColour(status?.GetAppropriateColour(colours) ?? colours.Gray5, 500, EasingTypes.OutQuint); base.Action = () => { From 26b36c08a33ef6ffdd421e4678207dea21d30500 Mon Sep 17 00:00:00 2001 From: Huo Yaoyuan Date: Fri, 14 Jul 2017 22:56:27 +0800 Subject: [PATCH 100/106] Prefer ScrollTo in SectionsContainer. --- osu.Game/Graphics/Containers/SectionsContainer.cs | 11 +---------- osu.Game/Overlays/UserProfileOverlay.cs | 2 +- 2 files changed, 2 insertions(+), 11 deletions(-) diff --git a/osu.Game/Graphics/Containers/SectionsContainer.cs b/osu.Game/Graphics/Containers/SectionsContainer.cs index b057cbfaca..6dadf0b0b0 100644 --- a/osu.Game/Graphics/Containers/SectionsContainer.cs +++ b/osu.Game/Graphics/Containers/SectionsContainer.cs @@ -139,16 +139,7 @@ namespace osu.Game.Graphics.Containers originalSectionsMargin = scrollContentContainer.Margin; } - public void ScrollToTop(T section) - { - float pos = scrollContainer.GetChildPosInContent(section); - float current = scrollContainer.Current; - float scrollOffset = FixedHeader?.LayoutSize.Y ?? 0; - if (section == Children.First() && current < pos - scrollOffset) return; - scrollContainer.ScrollTo(pos - scrollOffset); - } - - public void ScrollTo(Drawable section) => ScrollContainer.ScrollTo(ScrollContainer.GetChildPosInContent(section) - FixedHeader.BoundingBox.Height); + public void ScrollTo(Drawable section) => scrollContainer.ScrollTo(scrollContainer.GetChildPosInContent(section) - (FixedHeader?.BoundingBox.Height ?? 0)); private float lastKnownScroll; protected override void UpdateAfterChildren() diff --git a/osu.Game/Overlays/UserProfileOverlay.cs b/osu.Game/Overlays/UserProfileOverlay.cs index d2e9bdcb46..df339ad23e 100644 --- a/osu.Game/Overlays/UserProfileOverlay.cs +++ b/osu.Game/Overlays/UserProfileOverlay.cs @@ -137,7 +137,7 @@ namespace osu.Game.Overlays if (lastSection != s) { lastSection = s; - sectionsContainer.ScrollToTop(lastSection); + sectionsContainer.ScrollTo(lastSection); } }; From 5d77a5f9882be83e618f2346315ea269a4b558b4 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Mon, 17 Jul 2017 10:15:55 +0900 Subject: [PATCH 101/106] Allow closing profile by clicking basically anywhere --- osu.Game/Overlays/UserProfileOverlay.cs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/osu.Game/Overlays/UserProfileOverlay.cs b/osu.Game/Overlays/UserProfileOverlay.cs index df339ad23e..30cd061674 100644 --- a/osu.Game/Overlays/UserProfileOverlay.cs +++ b/osu.Game/Overlays/UserProfileOverlay.cs @@ -10,6 +10,7 @@ using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Shapes; using osu.Framework.Graphics.UserInterface; +using osu.Framework.Input; using osu.Game.Graphics; using osu.Game.Graphics.Containers; using osu.Game.Graphics.UserInterface; @@ -33,6 +34,14 @@ namespace osu.Game.Overlays public const float CONTENT_X_MARGIN = 50; + public override bool ReceiveMouseInputAt(Vector2 screenSpacePos) => true; + + protected override bool OnClick(InputState state) + { + State = Visibility.Hidden; + return true; + } + public UserProfileOverlay() { FirstWaveColour = OsuColour.Gray(0.4f); From f322c264a0e0f7aeb18ba660c627804527aa6173 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Mon, 17 Jul 2017 13:24:05 +0900 Subject: [PATCH 102/106] One constant per line --- osu.Game/Overlays/Profile/ProfileHeader.cs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/osu.Game/Overlays/Profile/ProfileHeader.cs b/osu.Game/Overlays/Profile/ProfileHeader.cs index 61da9560dc..3fa6243df4 100644 --- a/osu.Game/Overlays/Profile/ProfileHeader.cs +++ b/osu.Game/Overlays/Profile/ProfileHeader.cs @@ -30,7 +30,12 @@ namespace osu.Game.Overlays.Profile private readonly GradeBadge gradeSSPlus, gradeSS, gradeSPlus, gradeS, gradeA; private readonly Box colourBar; - private const float cover_height = 350, info_height = 150, info_width = 220, avatar_size = 110, level_position = 30, level_height = 60; + private const float cover_height = 350; + private const float info_height = 150; + private const float info_width = 220; + private const float avatar_size = 110; + private const float level_position = 30; + private const float level_height = 60; public ProfileHeader(User user) { From a63124c93530a64ac5232050611809ab45955b40 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Mon, 17 Jul 2017 13:39:29 +0900 Subject: [PATCH 103/106] User property instead of weirdly named method --- osu.Game/Overlays/Profile/ProfileHeader.cs | 18 +++++++++++++++++- osu.Game/Overlays/UserProfileOverlay.cs | 2 +- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/osu.Game/Overlays/Profile/ProfileHeader.cs b/osu.Game/Overlays/Profile/ProfileHeader.cs index 3fa6243df4..17493d5078 100644 --- a/osu.Game/Overlays/Profile/ProfileHeader.cs +++ b/osu.Game/Overlays/Profile/ProfileHeader.cs @@ -296,7 +296,23 @@ namespace osu.Game.Overlays.Profile levelBadge.Texture = textures.Get(@"Profile/levelbadge"); } - public void FillFullData(User user) + private User user; + + public User User + { + get + { + return user; + } + + set + { + user = value; + loadUser(); + } + } + + private void loadUser() { coverContainer.Add(new AsyncLoadWrapper(new UserCoverBackground(user) { diff --git a/osu.Game/Overlays/UserProfileOverlay.cs b/osu.Game/Overlays/UserProfileOverlay.cs index 30cd061674..ff8b2e8d8d 100644 --- a/osu.Game/Overlays/UserProfileOverlay.cs +++ b/osu.Game/Overlays/UserProfileOverlay.cs @@ -167,7 +167,7 @@ namespace osu.Game.Overlays private void fillData(User user) { - header.FillFullData(user); + header.User = user; for (int i = 0; i < user.ProfileOrder.Length; i++) { From 93290ef9660eb30a68e66ff9e674ccb2d91cdd3c Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Mon, 17 Jul 2017 13:56:50 +0900 Subject: [PATCH 104/106] Rename populate method --- osu.Game/Overlays/UserProfileOverlay.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/osu.Game/Overlays/UserProfileOverlay.cs b/osu.Game/Overlays/UserProfileOverlay.cs index ff8b2e8d8d..f26b143088 100644 --- a/osu.Game/Overlays/UserProfileOverlay.cs +++ b/osu.Game/Overlays/UserProfileOverlay.cs @@ -153,19 +153,19 @@ namespace osu.Game.Overlays if (fetchOnline) { userReq = new GetUserRequest(user.Id); - userReq.Success += fillData; + userReq.Success += userLoadComplete; api.Queue(userReq); } else { userReq = null; - fillData(user); + userLoadComplete(user); } Show(); } - private void fillData(User user) + private void userLoadComplete(User user) { header.User = user; From 82217be9886beff7bd8bf2ae7eb0b5928eb05464 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Tue, 18 Jul 2017 15:24:45 +0900 Subject: [PATCH 105/106] Fix dodgy event clearing Also use local ariables where possible. --- osu.Game/Overlays/MusicController.cs | 33 +++++++++++++--------------- 1 file changed, 15 insertions(+), 18 deletions(-) diff --git a/osu.Game/Overlays/MusicController.cs b/osu.Game/Overlays/MusicController.cs index 2149be09dd..47d305aecd 100644 --- a/osu.Game/Overlays/MusicController.cs +++ b/osu.Game/Overlays/MusicController.cs @@ -8,7 +8,6 @@ using System.Threading.Tasks; using OpenTK; using OpenTK.Graphics; using osu.Framework.Allocation; -using osu.Framework.Audio.Track; using osu.Framework.Configuration; using osu.Framework.Extensions.Color4Extensions; using osu.Framework.Graphics; @@ -280,7 +279,7 @@ namespace osu.Game.Overlays if (current != null) { - bool audioEquals = beatmapBacking.Value?.BeatmapInfo?.AudioEquals(current.BeatmapInfo) ?? false; + bool audioEquals = beatmap?.BeatmapInfo?.AudioEquals(current.BeatmapInfo) ?? false; if (audioEquals) direction = TransformDirection.None; @@ -293,30 +292,28 @@ namespace osu.Game.Overlays { //figure out the best direction based on order in playlist. var last = playlist.BeatmapSets.TakeWhile(b => b.ID != current.BeatmapSetInfo.ID).Count(); - var next = beatmapBacking.Value == null ? -1 : playlist.BeatmapSets.TakeWhile(b => b.ID != beatmapBacking.Value.BeatmapSetInfo.ID).Count(); + var next = beatmap == null ? -1 : playlist.BeatmapSets.TakeWhile(b => b.ID != beatmap.BeatmapSetInfo.ID).Count(); direction = last > next ? TransformDirection.Prev : TransformDirection.Next; } } - current = beatmapBacking.Value; + current = beatmap; - updateProgressBarLimit(current?.Track); - updateDisplay(beatmapBacking, direction); - queuedDirection = null; - } - - private void updateProgressBarLimit(Track t) - { - if (t != null) + var track = current?.Track; + if (track != null) { - t.OnLoaded += loadedTrack => progressBar.EndTime = loadedTrack.Length; - if (t.IsLoaded) - { - progressBar.EndTime = t.Length; - t.OnLoaded = null; - } + // the track may not be loaded at this point + track.OnLoaded += loadedTrack => Schedule(() => progressBar.EndTime = loadedTrack.Length); + + if (track.IsLoaded) + // but it also may be. + progressBar.EndTime = track.Length; } + + updateDisplay(beatmap, direction); + + queuedDirection = null; } private ScheduledDelegate pendingBeatmapSwitch; From 4b4b03756a1a8ee0b40f4d647b108ae9bcd53cd2 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Tue, 18 Jul 2017 15:36:05 +0900 Subject: [PATCH 106/106] Don't use dodgy OnLoaded "event" --- osu.Game/Overlays/MusicController.cs | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/osu.Game/Overlays/MusicController.cs b/osu.Game/Overlays/MusicController.cs index 47d305aecd..0da425652a 100644 --- a/osu.Game/Overlays/MusicController.cs +++ b/osu.Game/Overlays/MusicController.cs @@ -229,7 +229,9 @@ namespace osu.Game.Overlays { var track = current.Track; + progressBar.EndTime = track.Length; progressBar.CurrentTime = track.CurrentTime; + playButton.Icon = track.IsRunning ? FontAwesome.fa_pause_circle_o : FontAwesome.fa_play_circle_o; if (track.HasCompleted && !track.Looping) next(); @@ -300,18 +302,9 @@ namespace osu.Game.Overlays current = beatmap; - var track = current?.Track; - if (track != null) - { - // the track may not be loaded at this point - track.OnLoaded += loadedTrack => Schedule(() => progressBar.EndTime = loadedTrack.Length); + progressBar.CurrentTime = 0; - if (track.IsLoaded) - // but it also may be. - progressBar.EndTime = track.Length; - } - - updateDisplay(beatmap, direction); + updateDisplay(current, direction); queuedDirection = null; }