From ccc804a9b2ac61e4f90448fd265dac4ec1db568f Mon Sep 17 00:00:00 2001 From: jorolf Date: Thu, 4 Apr 2019 00:24:42 +0200 Subject: [PATCH] get everything working again --- .../{ => Online}/TestCaseUserProfileHeader.cs | 4 +-- .../Graphics/UserInterface/ScreenTitle.cs | 6 +++-- .../Profile/Header/BottomHeaderContainer.cs | 18 ++++++------- .../Profile/Header/CenterHeaderContainer.cs | 6 ++--- .../Profile/Header/ProfileMessageButton.cs | 8 +++--- .../Overlays/Profile/Header/SupporterIcon.cs | 5 ++-- osu.Game/Overlays/Profile/ProfileHeader.cs | 27 +++++++++++++------ osu.Game/Screens/Multi/Header.cs | 2 +- osu.Game/Users/UserCoverBackground.cs | 7 ++--- osu.Game/Users/UserPanel.cs | 2 +- 10 files changed, 49 insertions(+), 36 deletions(-) rename osu.Game.Tests/Visual/{ => Online}/TestCaseUserProfileHeader.cs (96%) diff --git a/osu.Game.Tests/Visual/TestCaseUserProfileHeader.cs b/osu.Game.Tests/Visual/Online/TestCaseUserProfileHeader.cs similarity index 96% rename from osu.Game.Tests/Visual/TestCaseUserProfileHeader.cs rename to osu.Game.Tests/Visual/Online/TestCaseUserProfileHeader.cs index 8f36b4dda8..98bad9831f 100644 --- a/osu.Game.Tests/Visual/TestCaseUserProfileHeader.cs +++ b/osu.Game.Tests/Visual/Online/TestCaseUserProfileHeader.cs @@ -11,7 +11,7 @@ using osu.Game.Overlays.Profile; using osu.Game.Overlays.Profile.Header; using osu.Game.Users; -namespace osu.Game.Tests.Visual +namespace osu.Game.Tests.Visual.Online { public class TestCaseUserProfileHeader : OsuTestCase { @@ -24,7 +24,7 @@ namespace osu.Game.Tests.Visual }; [Resolved] - private APIAccess api { get; set; } + private IAPIProvider api { get; set; } private readonly ProfileHeader header; diff --git a/osu.Game/Graphics/UserInterface/ScreenTitle.cs b/osu.Game/Graphics/UserInterface/ScreenTitle.cs index 1574023068..b9d9b5427d 100644 --- a/osu.Game/Graphics/UserInterface/ScreenTitle.cs +++ b/osu.Game/Graphics/UserInterface/ScreenTitle.cs @@ -14,6 +14,8 @@ namespace osu.Game.Graphics.UserInterface { private readonly SpriteIcon iconSprite; private readonly OsuSpriteText titleText, pageText; + public const float ICON_WIDTH = icon_size + icon_spacing; + private const float icon_size = 25, icon_spacing = 10; protected IconUsage Icon { @@ -48,12 +50,12 @@ namespace osu.Game.Graphics.UserInterface new FillFlowContainer { AutoSizeAxes = Axes.Both, - Spacing = new Vector2(10, 0), + Spacing = new Vector2(icon_spacing, 0), Children = new Drawable[] { iconSprite = new SpriteIcon { - Size = new Vector2(25), + Size = new Vector2(icon_size), }, new FillFlowContainer { diff --git a/osu.Game/Overlays/Profile/Header/BottomHeaderContainer.cs b/osu.Game/Overlays/Profile/Header/BottomHeaderContainer.cs index 1f9d741b8d..04b70ea10f 100644 --- a/osu.Game/Overlays/Profile/Header/BottomHeaderContainer.cs +++ b/osu.Game/Overlays/Profile/Header/BottomHeaderContainer.cs @@ -107,7 +107,7 @@ namespace osu.Game.Overlays.Profile.Header bottomTopLinkContainer.AddText("Contributed "); bottomTopLinkContainer.AddLink($@"{user.PostCount:#,##0} forum posts", $"https://osu.ppy.sh/users/{user.Id}/posts", creationParameters: bold); - void tryAddInfo(FontAwesome icon, string content, string link = null) + void tryAddInfo(IconUsage icon, string content, string link = null) { if (string.IsNullOrEmpty(content)) return; @@ -138,16 +138,16 @@ namespace osu.Game.Overlays.Profile.Header websiteWithoutProtcol = websiteWithoutProtcol.Substring(protocolIndex + 2); } - tryAddInfo(FontAwesome.fa_map_marker, user.Location); - tryAddInfo(FontAwesome.fa_heart_o, user.Interests); - tryAddInfo(FontAwesome.fa_suitcase, user.Occupation); + tryAddInfo(FontAwesome.Solid.MapMarker, user.Location); + tryAddInfo(OsuIcon.Heart, user.Interests); + tryAddInfo(FontAwesome.Solid.Suitcase, user.Occupation); bottomLinkContainer.NewLine(); if (!string.IsNullOrEmpty(user.Twitter)) - tryAddInfo(FontAwesome.fa_twitter, "@" + user.Twitter, $@"https://twitter.com/{user.Twitter}"); - tryAddInfo(FontAwesome.fa_gamepad, user.Discord); //todo: update fontawesome to include discord logo - tryAddInfo(FontAwesome.fa_skype, user.Skype, @"skype:" + user.Skype + @"?chat"); - tryAddInfo(FontAwesome.fa_lastfm, user.Lastfm, $@"https://last.fm/users/{user.Lastfm}"); - tryAddInfo(FontAwesome.fa_link, websiteWithoutProtcol, user.Website); + tryAddInfo(FontAwesome.Brands.Twitter, "@" + user.Twitter, $@"https://twitter.com/{user.Twitter}"); + tryAddInfo(FontAwesome.Brands.Discord, user.Discord); + tryAddInfo(FontAwesome.Brands.Skype, user.Skype, @"skype:" + user.Skype + @"?chat"); + tryAddInfo(FontAwesome.Brands.Lastfm, user.Lastfm, $@"https://last.fm/users/{user.Lastfm}"); + tryAddInfo(FontAwesome.Solid.Link, websiteWithoutProtcol, user.Website); } } } diff --git a/osu.Game/Overlays/Profile/Header/CenterHeaderContainer.cs b/osu.Game/Overlays/Profile/Header/CenterHeaderContainer.cs index b5e04bee9e..3d0b9b9db4 100644 --- a/osu.Game/Overlays/Profile/Header/CenterHeaderContainer.cs +++ b/osu.Game/Overlays/Profile/Header/CenterHeaderContainer.cs @@ -77,7 +77,7 @@ namespace osu.Game.Overlays.Profile.Header { Anchor = Anchor.CentreLeft, Origin = Anchor.CentreLeft, - Icon = FontAwesome.fa_user, + Icon = FontAwesome.Solid.User, FillMode = FillMode.Fit, Size = new Vector2(50, 14) }, @@ -116,7 +116,7 @@ namespace osu.Game.Overlays.Profile.Header Anchor = Anchor.Centre, Origin = Anchor.Centre, Size = new Vector2(20), - Icon = FontAwesome.fa_chevron_up, + Icon = FontAwesome.Solid.ChevronUp, }, } }, @@ -212,7 +212,7 @@ namespace osu.Game.Overlays.Profile.Header detailsToggleButton.Action = () => { detailsVisible = !detailsVisible; - expandButtonIcon.Icon = detailsVisible ? FontAwesome.fa_chevron_down : FontAwesome.fa_chevron_up; + expandButtonIcon.Icon = detailsVisible ? FontAwesome.Solid.ChevronDown : FontAwesome.Solid.ChevronUp; hiddenDetailContainer.Alpha = detailsVisible ? 1 : 0; expandedDetailContainer.Alpha = detailsVisible ? 0 : 1; DetailsVisibilityAction(detailsVisible); diff --git a/osu.Game/Overlays/Profile/Header/ProfileMessageButton.cs b/osu.Game/Overlays/Profile/Header/ProfileMessageButton.cs index a14c0324d7..3121eae727 100644 --- a/osu.Game/Overlays/Profile/Header/ProfileMessageButton.cs +++ b/osu.Game/Overlays/Profile/Header/ProfileMessageButton.cs @@ -4,7 +4,7 @@ using osu.Framework.Allocation; using osu.Framework.Bindables; using osu.Framework.Graphics; -using osu.Game.Graphics; +using osu.Framework.Graphics.Sprites; using osu.Game.Online.API; using osu.Game.Online.Chat; using osu.Game.Users; @@ -26,7 +26,7 @@ namespace osu.Game.Overlays.Profile.Header private ChatOverlay chatOverlay { get; set; } [Resolved] - private APIAccess apiAccess { get; set; } + private IAPIProvider apiProvider { get; set; } public ProfileMessageButton() { @@ -37,7 +37,7 @@ namespace osu.Game.Overlays.Profile.Header { Anchor = Anchor.CentreLeft, Origin = Anchor.CentreLeft, - Icon = FontAwesome.fa_envelope, + Icon = FontAwesome.Solid.Envelope, FillMode = FillMode.Fit, Size = new Vector2(50, 14) }; @@ -51,7 +51,7 @@ namespace osu.Game.Overlays.Profile.Header chatOverlay?.Show(); }; - User.ValueChanged += e => Content.Alpha = !e.NewValue.PMFriendsOnly && apiAccess.LocalUser.Value.Id != e.NewValue.Id ? 1 : 0; + User.ValueChanged += e => Content.Alpha = !e.NewValue.PMFriendsOnly && apiProvider.LocalUser.Value.Id != e.NewValue.Id ? 1 : 0; } } } diff --git a/osu.Game/Overlays/Profile/Header/SupporterIcon.cs b/osu.Game/Overlays/Profile/Header/SupporterIcon.cs index 3cb30ab044..569ed252b7 100644 --- a/osu.Game/Overlays/Profile/Header/SupporterIcon.cs +++ b/osu.Game/Overlays/Profile/Header/SupporterIcon.cs @@ -37,7 +37,7 @@ namespace osu.Game.Overlays.Profile.Header { Width = 12, RelativeSizeAxes = Axes.Y, - Icon = FontAwesome.fa_heart, + Icon = FontAwesome.Solid.Heart, }); } @@ -66,8 +66,7 @@ namespace osu.Game.Overlays.Profile.Header AutoSizeAxes = Axes.X, Height = 0.6f, Anchor = Anchor.Centre, - Origin = Anchor.Centre, - Icon = FontAwesome.Solid.Heart, + Origin = Anchor.Centre } } }; diff --git a/osu.Game/Overlays/Profile/ProfileHeader.cs b/osu.Game/Overlays/Profile/ProfileHeader.cs index 988fa3afd9..b75de39c4b 100644 --- a/osu.Game/Overlays/Profile/ProfileHeader.cs +++ b/osu.Game/Overlays/Profile/ProfileHeader.cs @@ -5,11 +5,11 @@ using osu.Framework.Allocation; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Cursor; -using osu.Framework.Graphics.Textures; using osu.Game.Graphics; using osu.Game.Overlays.Profile.Header; using osu.Game.Users; using osu.Framework.Bindables; +using osu.Framework.Graphics.Sprites; using osu.Game.Graphics.UserInterface; namespace osu.Game.Overlays.Profile @@ -17,7 +17,6 @@ namespace osu.Game.Overlays.Profile public class ProfileHeader : Container { private readonly UserCoverBackground coverContainer; - private readonly ScreenTitle coverTitle; private readonly ProfileHeaderTabControl infoTabControl; private const float cover_height = 150; @@ -52,10 +51,9 @@ namespace osu.Game.Overlays.Profile Depth = -float.MaxValue, Children = new Drawable[] { - coverTitle = new ScreenTitle + new ProfileHeaderTitle { - Title = "Player ", - Page = "Info" + X = -ScreenTitle.ICON_WIDTH, }, infoTabControl = new ProfileHeaderTabControl { @@ -113,10 +111,8 @@ namespace osu.Game.Overlays.Profile } [BackgroundDependencyLoader] - private void load(OsuColour colours, TextureStore textures) + private void load(OsuColour colours) { - coverTitle.AccentColour = colours.CommunityUserGreen; - infoTabControl.AccentColour = colours.CommunityUserGreen; } @@ -131,5 +127,20 @@ namespace osu.Game.Overlays.Profile { public string TooltipText { get; set; } } + + private class ProfileHeaderTitle : ScreenTitle + { + public ProfileHeaderTitle() + { + Title = "Player "; + Section = "Info"; + } + + [BackgroundDependencyLoader] + private void load(OsuColour colours) + { + AccentColour = colours.CommunityUserGreen; + } + } } } diff --git a/osu.Game/Screens/Multi/Header.cs b/osu.Game/Screens/Multi/Header.cs index 7924086389..35edc5bac8 100644 --- a/osu.Game/Screens/Multi/Header.cs +++ b/osu.Game/Screens/Multi/Header.cs @@ -42,7 +42,7 @@ namespace osu.Game.Screens.Multi { Anchor = Anchor.CentreLeft, Origin = Anchor.BottomLeft, - X = -35, + X = -ScreenTitle.ICON_WIDTH, }, breadcrumbs = new HeaderBreadcrumbControl(stack) { diff --git a/osu.Game/Users/UserCoverBackground.cs b/osu.Game/Users/UserCoverBackground.cs index d037f809b4..dbc132995a 100644 --- a/osu.Game/Users/UserCoverBackground.cs +++ b/osu.Game/Users/UserCoverBackground.cs @@ -36,15 +36,16 @@ namespace osu.Game.Users } else { - return new Sprite + var sprite = new Sprite { RelativeSizeAxes = Axes.Both, Texture = textures.Get(user.CoverUrl), FillMode = FillMode.Fill, Anchor = Anchor.Centre, - Origin = Anchor.Centre, - OnLoadComplete = d => d.FadeInFromZero(400), + Origin = Anchor.Centre }; + sprite.OnLoadComplete += d => d.FadeInFromZero(400); + return sprite; } } } diff --git a/osu.Game/Users/UserPanel.cs b/osu.Game/Users/UserPanel.cs index 0e928e0aac..eb7f0941fb 100644 --- a/osu.Game/Users/UserPanel.cs +++ b/osu.Game/Users/UserPanel.cs @@ -76,7 +76,7 @@ namespace osu.Game.Users Children = new Drawable[] { - new DelayedLoadWrapper(coverBackground = new UserCoverBackground(user) + new DelayedLoadWrapper(coverBackground = new UserCoverBackground { RelativeSizeAxes = Axes.Both, Anchor = Anchor.Centre,