From 59cb93321fbdffaf271021a8b6ede430e0eee10d Mon Sep 17 00:00:00 2001 From: Andrei Zavatski Date: Sat, 18 Jan 2020 01:36:14 +0300 Subject: [PATCH 01/12] Implement ProfileItemBackground component --- .../Historical/DrawableMostPlayedBeatmap.cs | 81 +++++++++---------- .../Profile/Sections/ProfileItemBackground.cs | 49 +++++++++++ 2 files changed, 85 insertions(+), 45 deletions(-) create mode 100644 osu.Game/Overlays/Profile/Sections/ProfileItemBackground.cs diff --git a/osu.Game/Overlays/Profile/Sections/Historical/DrawableMostPlayedBeatmap.cs b/osu.Game/Overlays/Profile/Sections/Historical/DrawableMostPlayedBeatmap.cs index 0206c4e13b..9040af3384 100644 --- a/osu.Game/Overlays/Profile/Sections/Historical/DrawableMostPlayedBeatmap.cs +++ b/osu.Game/Overlays/Profile/Sections/Historical/DrawableMostPlayedBeatmap.cs @@ -4,7 +4,6 @@ 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.Localisation; using osu.Game.Beatmaps; @@ -13,32 +12,25 @@ using osu.Game.Graphics; using osu.Game.Graphics.Containers; using osu.Game.Graphics.Sprites; using osuTK; -using System.Collections.Generic; using osu.Framework.Graphics.Cursor; namespace osu.Game.Overlays.Profile.Sections.Historical { - public class DrawableMostPlayedBeatmap : OsuHoverContainer + public class DrawableMostPlayedBeatmap : CompositeDrawable { private const int cover_width = 100; private const int corner_radius = 6; - private const int height = 50; private readonly BeatmapInfo beatmap; private readonly int playCount; - private Box background; - - protected override IEnumerable EffectTargets => new[] { background }; - public DrawableMostPlayedBeatmap(BeatmapInfo beatmap, int playCount) { this.beatmap = beatmap; this.playCount = playCount; - Enabled.Value = true; //manually enabled, because we have no action RelativeSizeAxes = Axes.X; - Height = height; + Height = 50; Masking = true; CornerRadius = corner_radius; @@ -47,10 +39,7 @@ namespace osu.Game.Overlays.Profile.Sections.Historical [BackgroundDependencyLoader] private void load(OsuColour colours) { - IdleColour = colours.GreySeafoam; - HoverColour = colours.GreySeafoamLight; - - Children = new Drawable[] + AddRangeInternal(new Drawable[] { new UpdateableBeatmapSetCover { @@ -72,46 +61,48 @@ namespace osu.Game.Overlays.Profile.Sections.Historical CornerRadius = corner_radius, Children = new Drawable[] { - background = new Box { RelativeSizeAxes = Axes.Both }, - new Container + new ProfileItemBackground { - RelativeSizeAxes = Axes.Both, - Padding = new MarginPadding(10), - Children = new Drawable[] + Child = new Container { - new FillFlowContainer + RelativeSizeAxes = Axes.Both, + Padding = new MarginPadding(10), + Children = new Drawable[] { - Anchor = Anchor.CentreLeft, - Origin = Anchor.CentreLeft, - AutoSizeAxes = Axes.Both, - Direction = FillDirection.Vertical, - Children = new Drawable[] + new FillFlowContainer { - new MostPlayedBeatmapMetadataContainer(beatmap), - new LinkFlowContainer(t => t.Font = OsuFont.GetFont(size: 12, weight: FontWeight.Regular)) + Anchor = Anchor.CentreLeft, + Origin = Anchor.CentreLeft, + AutoSizeAxes = Axes.Both, + Direction = FillDirection.Vertical, + Children = new Drawable[] { - AutoSizeAxes = Axes.Both, - Direction = FillDirection.Horizontal, - Colour = colours.GreySeafoamLighter - }.With(d => - { - d.AddText("mapped by "); - d.AddUserLink(beatmap.Metadata.Author); - }), - } - }, - new PlayCountText(playCount) - { - Anchor = Anchor.CentreRight, - Origin = Anchor.CentreRight - }, - } - }, + new MostPlayedBeatmapMetadataContainer(beatmap), + new LinkFlowContainer(t => t.Font = OsuFont.GetFont(size: 12, weight: FontWeight.Regular)) + { + AutoSizeAxes = Axes.Both, + Direction = FillDirection.Horizontal, + Colour = colours.GreySeafoamLighter + }.With(d => + { + d.AddText("mapped by "); + d.AddUserLink(beatmap.Metadata.Author); + }), + } + }, + new PlayCountText(playCount) + { + Anchor = Anchor.CentreRight, + Origin = Anchor.CentreRight + }, + } + }, + } } } } } - }; + }); } private class MostPlayedBeatmapMetadataContainer : BeatmapMetadataContainer diff --git a/osu.Game/Overlays/Profile/Sections/ProfileItemBackground.cs b/osu.Game/Overlays/Profile/Sections/ProfileItemBackground.cs new file mode 100644 index 0000000000..4f8630c92d --- /dev/null +++ b/osu.Game/Overlays/Profile/Sections/ProfileItemBackground.cs @@ -0,0 +1,49 @@ +// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. +// See the LICENCE file in the repository root for full licence text. + +using osu.Framework.Allocation; +using osu.Framework.Graphics; +using osu.Framework.Graphics.Containers; +using osu.Framework.Graphics.Shapes; +using osu.Game.Graphics; +using osu.Game.Graphics.Containers; +using System.Collections.Generic; + +namespace osu.Game.Overlays.Profile.Sections +{ + public class ProfileItemBackground : OsuHoverContainer + { + protected override IEnumerable EffectTargets => new[] { background }; + protected override Container Content => content; + + private readonly Box background; + private readonly Container content; + + public ProfileItemBackground() + { + RelativeSizeAxes = Axes.Both; + Enabled.Value = true; //manually enabled, because we have no action + Masking = true; + CornerRadius = 6; + + base.Content.AddRange(new Drawable[] + { + background = new Box + { + RelativeSizeAxes = Axes.Both, + }, + content = new Container + { + RelativeSizeAxes = Axes.Both, + } + }); + } + + [BackgroundDependencyLoader] + private void load(OsuColour colours) + { + IdleColour = colours.GreySeafoam; + HoverColour = colours.GreySeafoamLight; + } + } +} From 4cdaebb42bf681a04e2e4043fd18f204c928fa6e Mon Sep 17 00:00:00 2001 From: Andrei Zavatski Date: Sat, 18 Jan 2020 02:58:10 +0300 Subject: [PATCH 02/12] Implement ProfileScore component --- .../Online/TestSceneUserProfileScores.cs | 82 ++++++ osu.Game/Graphics/DrawableDate.cs | 4 +- .../Profile/Sections/Ranks/ProfileScore.cs | 242 ++++++++++++++++++ 3 files changed, 326 insertions(+), 2 deletions(-) create mode 100644 osu.Game.Tests/Visual/Online/TestSceneUserProfileScores.cs create mode 100644 osu.Game/Overlays/Profile/Sections/Ranks/ProfileScore.cs diff --git a/osu.Game.Tests/Visual/Online/TestSceneUserProfileScores.cs b/osu.Game.Tests/Visual/Online/TestSceneUserProfileScores.cs new file mode 100644 index 0000000000..f8e3da5241 --- /dev/null +++ b/osu.Game.Tests/Visual/Online/TestSceneUserProfileScores.cs @@ -0,0 +1,82 @@ +// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. +// See the LICENCE file in the repository root for full licence text. + +using System; +using System.Collections.Generic; +using osu.Game.Overlays.Profile.Sections; +using osu.Game.Overlays.Profile.Sections.Ranks; +using osu.Framework.Graphics; +using osu.Game.Scoring; +using osu.Framework.Graphics.Containers; +using osuTK; +using osu.Game.Beatmaps; +using osu.Game.Rulesets.Mods; +using osu.Game.Rulesets.Osu.Mods; + +namespace osu.Game.Tests.Visual.Online +{ + public class TestSceneUserProfileScores : OsuTestScene + { + public override IReadOnlyList RequiredTypes => new[] + { + typeof(ProfileScore), + typeof(ProfileItemBackground), + }; + + public TestSceneUserProfileScores() + { + var score = new ScoreInfo + { + PP = 134.32, + Rank = ScoreRank.A, + Beatmap = new BeatmapInfo + { + Metadata = new BeatmapMetadata + { + Title = "Triumph & Regret", + Artist = "typeMARS" + }, + Version = "[4K] Regret" + }, + Date = DateTimeOffset.Now, + Mods = new Mod[] + { + new OsuModHardRock(), + new OsuModDoubleTime(), + }, + Accuracy = 0.998546 + }; + + var noPPScore = new ScoreInfo + { + Rank = ScoreRank.B, + Beatmap = new BeatmapInfo + { + Metadata = new BeatmapMetadata + { + Title = "C18H27NO3(extend)", + Artist = "Team Grimoire" + }, + Version = "[4K] Cataclysmic Hypernova" + }, + Date = DateTimeOffset.Now, + Accuracy = 0.55879 + }; + + Add(new FillFlowContainer + { + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + RelativeSizeAxes = Axes.X, + AutoSizeAxes = Axes.Y, + Direction = FillDirection.Vertical, + Spacing = new Vector2(0, 10), + Children = new[] + { + new ProfileScore(score), + new ProfileScore(noPPScore), + } + }); + } + } +} diff --git a/osu.Game/Graphics/DrawableDate.cs b/osu.Game/Graphics/DrawableDate.cs index 533f02af7b..925c7981e0 100644 --- a/osu.Game/Graphics/DrawableDate.cs +++ b/osu.Game/Graphics/DrawableDate.cs @@ -29,9 +29,9 @@ namespace osu.Game.Graphics } } - public DrawableDate(DateTimeOffset date) + public DrawableDate(DateTimeOffset date, float textSize = OsuFont.DEFAULT_FONT_SIZE) { - Font = OsuFont.GetFont(weight: FontWeight.Regular, italics: true); + Font = OsuFont.GetFont(weight: FontWeight.Regular, size: textSize, italics: true); Date = date; } diff --git a/osu.Game/Overlays/Profile/Sections/Ranks/ProfileScore.cs b/osu.Game/Overlays/Profile/Sections/Ranks/ProfileScore.cs new file mode 100644 index 0000000000..c30c13d52e --- /dev/null +++ b/osu.Game/Overlays/Profile/Sections/Ranks/ProfileScore.cs @@ -0,0 +1,242 @@ +// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. +// See the LICENCE file in the repository root for full licence text. + +using System.Linq; +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.Localisation; +using osu.Game.Beatmaps; +using osu.Game.Graphics; +using osu.Game.Graphics.Sprites; +using osu.Game.Online.Leaderboards; +using osu.Game.Rulesets.UI; +using osu.Game.Scoring; +using osuTK; +using osuTK.Graphics; + +namespace osu.Game.Overlays.Profile.Sections.Ranks +{ + public class ProfileScore : CompositeDrawable + { + private const int performance_width = 80; + private const int content_padding = 10; + + protected readonly ScoreInfo Score; + + [Resolved] + private OsuColour colours { get; set; } + + public ProfileScore(ScoreInfo score) + { + Score = score; + + RelativeSizeAxes = Axes.X; + Height = 40; + } + + [BackgroundDependencyLoader] + private void load() + { + AddInternal(new ProfileItemBackground + { + Children = new Drawable[] + { + new Container + { + RelativeSizeAxes = Axes.Both, + Padding = new MarginPadding { Left = content_padding, Right = performance_width + content_padding }, + Children = new Drawable[] + { + new FillFlowContainer + { + Anchor = Anchor.CentreLeft, + Origin = Anchor.CentreLeft, + AutoSizeAxes = Axes.Both, + Direction = FillDirection.Horizontal, + Spacing = new Vector2(8, 0), + Children = new Drawable[] + { + new UpdateableRank(Score.Rank) + { + Anchor = Anchor.CentreLeft, + Origin = Anchor.CentreLeft, + Size = new Vector2(50, 20), + }, + new FillFlowContainer + { + Anchor = Anchor.CentreLeft, + Origin = Anchor.CentreLeft, + AutoSizeAxes = Axes.Both, + Direction = FillDirection.Vertical, + Spacing = new Vector2(0, 2), + Children = new Drawable[] + { + new ScoreBeatmapMetadataContainer(Score.Beatmap), + new FillFlowContainer + { + AutoSizeAxes = Axes.Both, + Direction = FillDirection.Horizontal, + Spacing = new Vector2(5, 0), + Children = new Drawable[] + { + new OsuSpriteText + { + Text = $"{Score.Beatmap.Version}", + Font = OsuFont.GetFont(size: 12, weight: FontWeight.Regular), + Colour = colours.Yellow + }, + new DrawableDate(Score.Date, 12) + { + Colour = colours.GreySeafoamLighter + } + } + } + } + } + } + }, + new FillFlowContainer + { + Anchor = Anchor.CentreRight, + Origin = Anchor.CentreRight, + AutoSizeAxes = Axes.Both, + Direction = FillDirection.Horizontal, + Spacing = new Vector2(10), + Children = new Drawable[] + { + CreateRightContent().With(c => + { + c.Anchor = Anchor.CentreRight; + c.Origin = Anchor.CentreRight; + }), + new FillFlowContainer + { + AutoSizeAxes = Axes.Both, + Anchor = Anchor.CentreRight, + Origin = Anchor.CentreRight, + Direction = FillDirection.Horizontal, + Spacing = new Vector2(2), + Children = Score.Mods.Select(mod => new ModIcon(mod) + { + Scale = new Vector2(0.35f) + }).ToList(), + } + } + } + } + }, + new Container + { + RelativeSizeAxes = Axes.Y, + Width = performance_width, + Anchor = Anchor.CentreRight, + Origin = Anchor.CentreRight, + Children = new[] + { + new Box + { + RelativeSizeAxes = Axes.Both, + Size = new Vector2(1, 0.5f), + Colour = Color4.Black.Opacity(0.5f), + Shear = new Vector2(-0.45f, 0), + EdgeSmoothness = new Vector2(2, 0), + }, + new Box + { + RelativeSizeAxes = Axes.Both, + RelativePositionAxes = Axes.Y, + Size = new Vector2(1, -0.5f), + Position = new Vector2(0, 1), + Colour = Color4.Black.Opacity(0.5f), + Shear = new Vector2(0.45f, 0), + EdgeSmoothness = new Vector2(2, 0), + }, + createDrawablePerformance().With(d => + { + d.Anchor = Anchor.Centre; + d.Origin = Anchor.Centre; + }) + } + } + } + }); + } + + protected virtual Drawable CreateRightContent() => CreateDrawableAccuracy(); + + protected OsuSpriteText CreateDrawableAccuracy(float textSize = 16) => new OsuSpriteText + { + Text = $"{Score.Accuracy:P2}", + Font = OsuFont.GetFont(size: textSize, weight: FontWeight.Bold, italics: true), + Colour = colours.Yellow, + }; + + private Drawable createDrawablePerformance() + { + if (Score.PP.HasValue) + { + return new FillFlowContainer + { + AutoSizeAxes = Axes.Both, + Children = new[] + { + new OsuSpriteText + { + Anchor = Anchor.BottomLeft, + Origin = Anchor.BottomLeft, + Font = OsuFont.GetFont(weight: FontWeight.Bold), + Text = $"{Score.PP:0}", + Colour = colours.GreenLight + }, + new OsuSpriteText + { + Anchor = Anchor.BottomLeft, + Origin = Anchor.BottomLeft, + Font = OsuFont.GetFont(size: 12, weight: FontWeight.Bold), + Text = "pp", + Colour = colours.Green + } + } + }; + } + + return new OsuSpriteText + { + Font = OsuFont.GetFont(weight: FontWeight.Bold), + Text = "-", + Colour = colours.GreenLight + }; + } + + private class ScoreBeatmapMetadataContainer : BeatmapMetadataContainer + { + public ScoreBeatmapMetadataContainer(BeatmapInfo beatmap) + : base(beatmap) + { + } + + protected override Drawable[] CreateText(BeatmapInfo beatmap) => new Drawable[] + { + new OsuSpriteText + { + Anchor = Anchor.BottomLeft, + Origin = Anchor.BottomLeft, + Text = new LocalisedString(( + $"{beatmap.Metadata.TitleUnicode ?? beatmap.Metadata.Title} ", + $"{beatmap.Metadata.Title ?? beatmap.Metadata.TitleUnicode} ")), + Font = OsuFont.GetFont(weight: FontWeight.SemiBold, italics: true) + }, + new OsuSpriteText + { + Anchor = Anchor.BottomLeft, + Origin = Anchor.BottomLeft, + Text = "by " + new LocalisedString((beatmap.Metadata.ArtistUnicode, beatmap.Metadata.Artist)), + Font = OsuFont.GetFont(size: 14, italics: true) + }, + }; + } + } +} From 4964505c3e3bbbf037dad273b6d1ee1cacd382f4 Mon Sep 17 00:00:00 2001 From: Andrei Zavatski Date: Sat, 18 Jan 2020 03:19:28 +0300 Subject: [PATCH 03/12] Implement ProfileWeightedScore component --- .../Online/TestSceneUserProfileScores.cs | 2 + .../Profile/Sections/Ranks/ProfileScore.cs | 9 ++- .../Sections/Ranks/ProfileWeightedScore.cs | 70 +++++++++++++++++++ 3 files changed, 78 insertions(+), 3 deletions(-) create mode 100644 osu.Game/Overlays/Profile/Sections/Ranks/ProfileWeightedScore.cs diff --git a/osu.Game.Tests/Visual/Online/TestSceneUserProfileScores.cs b/osu.Game.Tests/Visual/Online/TestSceneUserProfileScores.cs index f8e3da5241..4af024052e 100644 --- a/osu.Game.Tests/Visual/Online/TestSceneUserProfileScores.cs +++ b/osu.Game.Tests/Visual/Online/TestSceneUserProfileScores.cs @@ -20,6 +20,7 @@ namespace osu.Game.Tests.Visual.Online public override IReadOnlyList RequiredTypes => new[] { typeof(ProfileScore), + typeof(ProfileWeightedScore), typeof(ProfileItemBackground), }; @@ -75,6 +76,7 @@ namespace osu.Game.Tests.Visual.Online { new ProfileScore(score), new ProfileScore(noPPScore), + new ProfileWeightedScore(score, 0.85), } }); } diff --git a/osu.Game/Overlays/Profile/Sections/Ranks/ProfileScore.cs b/osu.Game/Overlays/Profile/Sections/Ranks/ProfileScore.cs index c30c13d52e..bd49c59523 100644 --- a/osu.Game/Overlays/Profile/Sections/Ranks/ProfileScore.cs +++ b/osu.Game/Overlays/Profile/Sections/Ranks/ProfileScore.cs @@ -2,6 +2,7 @@ // See the LICENCE file in the repository root for full licence text. using System.Linq; +using JetBrains.Annotations; using osu.Framework.Allocation; using osu.Framework.Extensions.Color4Extensions; using osu.Framework.Graphics; @@ -104,7 +105,7 @@ namespace osu.Game.Overlays.Profile.Sections.Ranks Origin = Anchor.CentreRight, AutoSizeAxes = Axes.Both, Direction = FillDirection.Horizontal, - Spacing = new Vector2(10), + Spacing = new Vector2(15), Children = new Drawable[] { CreateRightContent().With(c => @@ -165,12 +166,13 @@ namespace osu.Game.Overlays.Profile.Sections.Ranks }); } + [NotNull] protected virtual Drawable CreateRightContent() => CreateDrawableAccuracy(); - protected OsuSpriteText CreateDrawableAccuracy(float textSize = 16) => new OsuSpriteText + protected OsuSpriteText CreateDrawableAccuracy() => new OsuSpriteText { Text = $"{Score.Accuracy:P2}", - Font = OsuFont.GetFont(size: textSize, weight: FontWeight.Bold, italics: true), + Font = OsuFont.GetFont(weight: FontWeight.Bold, italics: true), Colour = colours.Yellow, }; @@ -181,6 +183,7 @@ namespace osu.Game.Overlays.Profile.Sections.Ranks return new FillFlowContainer { AutoSizeAxes = Axes.Both, + Direction = FillDirection.Horizontal, Children = new[] { new OsuSpriteText diff --git a/osu.Game/Overlays/Profile/Sections/Ranks/ProfileWeightedScore.cs b/osu.Game/Overlays/Profile/Sections/Ranks/ProfileWeightedScore.cs new file mode 100644 index 0000000000..aaf3664403 --- /dev/null +++ b/osu.Game/Overlays/Profile/Sections/Ranks/ProfileWeightedScore.cs @@ -0,0 +1,70 @@ +// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. +// See the LICENCE file in the repository root for full licence text. + +using osu.Framework.Graphics; +using osu.Framework.Graphics.Containers; +using osu.Game.Graphics; +using osu.Game.Graphics.Sprites; +using osu.Game.Scoring; +using osuTK; + +namespace osu.Game.Overlays.Profile.Sections.Ranks +{ + public class ProfileWeightedScore : ProfileScore + { + private readonly double weight; + + public ProfileWeightedScore(ScoreInfo score, double weight) + : base(score) + { + this.weight = weight; + } + + protected override Drawable CreateRightContent() => new FillFlowContainer + { + AutoSizeAxes = Axes.Both, + Direction = FillDirection.Vertical, + Spacing = new Vector2(0, 2), + Children = new Drawable[] + { + new FillFlowContainer + { + AutoSizeAxes = Axes.Both, + Direction = FillDirection.Horizontal, + Spacing = new Vector2(15, 0), + Children = new Drawable[] + { + CreateDrawableAccuracy(), + new FillFlowContainer + { + AutoSizeAxes = Axes.Both, + Direction = FillDirection.Horizontal, + Children = new[] + { + new OsuSpriteText + { + Anchor = Anchor.BottomLeft, + Origin = Anchor.BottomLeft, + Font = OsuFont.GetFont(weight: FontWeight.Bold, italics: true), + Text = $"{Score.PP * weight:0}", + }, + new OsuSpriteText + { + Anchor = Anchor.BottomLeft, + Origin = Anchor.BottomLeft, + Font = OsuFont.GetFont(size: 14, weight: FontWeight.Bold, italics: true), + Text = "pp", + } + } + } + } + }, + new OsuSpriteText + { + Font = OsuFont.GetFont(size: 12, weight: FontWeight.Bold), + Text = $@"weighted {weight:P0}" + } + } + }; + } +} From 6e776d02f817563ad9299dd204e03dcecb937e70 Mon Sep 17 00:00:00 2001 From: Andrei Zavatski Date: Sat, 18 Jan 2020 03:33:02 +0300 Subject: [PATCH 04/12] Refactor PaginatedScoreContainer to use new components --- .../Profile/Sections/Ranks/PaginatedScoreContainer.cs | 10 ++++------ .../Profile/Sections/Ranks/ProfileWeightedScore.cs | 7 ++++++- osu.Game/Overlays/Profile/Sections/RanksSection.cs | 2 +- 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/osu.Game/Overlays/Profile/Sections/Ranks/PaginatedScoreContainer.cs b/osu.Game/Overlays/Profile/Sections/Ranks/PaginatedScoreContainer.cs index e0f1c935da..ad6621696d 100644 --- a/osu.Game/Overlays/Profile/Sections/Ranks/PaginatedScoreContainer.cs +++ b/osu.Game/Overlays/Profile/Sections/Ranks/PaginatedScoreContainer.cs @@ -15,14 +15,12 @@ namespace osu.Game.Overlays.Profile.Sections.Ranks { public class PaginatedScoreContainer : PaginatedContainer { - private readonly bool includeWeight; private readonly ScoreType type; - public PaginatedScoreContainer(ScoreType type, Bindable user, string header, string missing, bool includeWeight = false) + public PaginatedScoreContainer(ScoreType type, Bindable user, string header, string missing) : base(user, header, missing) { this.type = type; - this.includeWeight = includeWeight; ItemsPerPage = 5; @@ -43,10 +41,10 @@ namespace osu.Game.Overlays.Profile.Sections.Ranks switch (type) { default: - return new DrawablePerformanceScore(model.CreateScoreInfo(Rulesets), includeWeight ? Math.Pow(0.95, ItemsContainer.Count) : (double?)null); + return new ProfileScore(model.CreateScoreInfo(Rulesets)); - case ScoreType.Recent: - return new DrawableTotalScore(model.CreateScoreInfo(Rulesets)); + case ScoreType.Best: + return new ProfileWeightedScore(model.CreateScoreInfo(Rulesets), Math.Pow(0.95, ItemsContainer.Count)); } } } diff --git a/osu.Game/Overlays/Profile/Sections/Ranks/ProfileWeightedScore.cs b/osu.Game/Overlays/Profile/Sections/Ranks/ProfileWeightedScore.cs index aaf3664403..5f080f2589 100644 --- a/osu.Game/Overlays/Profile/Sections/Ranks/ProfileWeightedScore.cs +++ b/osu.Game/Overlays/Profile/Sections/Ranks/ProfileWeightedScore.cs @@ -34,7 +34,12 @@ namespace osu.Game.Overlays.Profile.Sections.Ranks Spacing = new Vector2(15, 0), Children = new Drawable[] { - CreateDrawableAccuracy(), + new Container + { + AutoSizeAxes = Axes.Y, + Width = 60, + Child = CreateDrawableAccuracy() + }, new FillFlowContainer { AutoSizeAxes = Axes.Both, diff --git a/osu.Game/Overlays/Profile/Sections/RanksSection.cs b/osu.Game/Overlays/Profile/Sections/RanksSection.cs index c4b933593e..dbdff3a273 100644 --- a/osu.Game/Overlays/Profile/Sections/RanksSection.cs +++ b/osu.Game/Overlays/Profile/Sections/RanksSection.cs @@ -16,7 +16,7 @@ namespace osu.Game.Overlays.Profile.Sections { Children = new[] { - new PaginatedScoreContainer(ScoreType.Best, User, "Best Performance", "No performance records. :(", true), + new PaginatedScoreContainer(ScoreType.Best, User, "Best Performance", "No performance records. :("), new PaginatedScoreContainer(ScoreType.Firsts, User, "First Place Ranks", "No awesome performance records yet. :("), }; } From d5a3d8dbaa9f21d75a46150f55b048a0972c76cb Mon Sep 17 00:00:00 2001 From: Andrei Zavatski Date: Sat, 18 Jan 2020 03:35:47 +0300 Subject: [PATCH 05/12] Remove no longer used components --- .../Visual/Online/TestSceneUserRanks.cs | 7 +- .../Ranks/DrawablePerformanceScore.cs | 47 --------- .../Sections/Ranks/DrawableProfileScore.cs | 96 ------------------- .../Sections/Ranks/DrawableTotalScore.cs | 31 ------ 4 files changed, 6 insertions(+), 175 deletions(-) delete mode 100644 osu.Game/Overlays/Profile/Sections/Ranks/DrawablePerformanceScore.cs delete mode 100644 osu.Game/Overlays/Profile/Sections/Ranks/DrawableProfileScore.cs delete mode 100644 osu.Game/Overlays/Profile/Sections/Ranks/DrawableTotalScore.cs diff --git a/osu.Game.Tests/Visual/Online/TestSceneUserRanks.cs b/osu.Game.Tests/Visual/Online/TestSceneUserRanks.cs index 2951f6b63e..9779343c07 100644 --- a/osu.Game.Tests/Visual/Online/TestSceneUserRanks.cs +++ b/osu.Game.Tests/Visual/Online/TestSceneUserRanks.cs @@ -20,7 +20,12 @@ namespace osu.Game.Tests.Visual.Online { protected override bool UseOnlineAPI => true; - public override IReadOnlyList RequiredTypes => new[] { typeof(DrawableProfileScore), typeof(RanksSection) }; + public override IReadOnlyList RequiredTypes => new[] + { + typeof(ProfileScore), + typeof(ProfileWeightedScore), + typeof(RanksSection) + }; public TestSceneUserRanks() { diff --git a/osu.Game/Overlays/Profile/Sections/Ranks/DrawablePerformanceScore.cs b/osu.Game/Overlays/Profile/Sections/Ranks/DrawablePerformanceScore.cs deleted file mode 100644 index 843f9b7ef2..0000000000 --- a/osu.Game/Overlays/Profile/Sections/Ranks/DrawablePerformanceScore.cs +++ /dev/null @@ -1,47 +0,0 @@ -// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. -// See the LICENCE file in the repository root for full licence text. - -using osu.Framework.Allocation; -using osu.Framework.Graphics; -using osu.Game.Graphics; -using osu.Game.Graphics.Sprites; -using osu.Game.Scoring; - -namespace osu.Game.Overlays.Profile.Sections.Ranks -{ - public class DrawablePerformanceScore : DrawableProfileScore - { - private readonly double? weight; - - public DrawablePerformanceScore(ScoreInfo score, double? weight = null) - : base(score) - { - this.weight = weight; - } - - [BackgroundDependencyLoader] - private void load(OsuColour colour) - { - double pp = Score.PP ?? 0; - RightFlowContainer.Add(new OsuSpriteText - { - Text = $"{pp:0}pp", - Anchor = Anchor.TopRight, - Origin = Anchor.TopRight, - Font = OsuFont.GetFont(size: 18, weight: FontWeight.Bold, italics: true) - }); - - if (weight.HasValue) - { - RightFlowContainer.Add(new OsuSpriteText - { - Text = $"weighted: {pp * weight:0}pp ({weight:P0})", - Anchor = Anchor.TopRight, - Origin = Anchor.TopRight, - Colour = colour.GrayA, - Font = OsuFont.GetFont(size: 11, weight: FontWeight.Regular, italics: true) - }); - } - } - } -} diff --git a/osu.Game/Overlays/Profile/Sections/Ranks/DrawableProfileScore.cs b/osu.Game/Overlays/Profile/Sections/Ranks/DrawableProfileScore.cs deleted file mode 100644 index 6362d3dfb0..0000000000 --- a/osu.Game/Overlays/Profile/Sections/Ranks/DrawableProfileScore.cs +++ /dev/null @@ -1,96 +0,0 @@ -// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. -// See the LICENCE file in the repository root for full licence text. - -using osuTK; -using osu.Framework.Allocation; -using osu.Framework.Graphics; -using osu.Game.Graphics; -using osu.Game.Graphics.Sprites; -using osu.Game.Online.Leaderboards; -using osu.Game.Rulesets.Mods; -using osu.Game.Rulesets.UI; -using osu.Game.Scoring; -using osu.Game.Beatmaps; -using osu.Framework.Localisation; -using osu.Framework.Graphics.Containers; - -namespace osu.Game.Overlays.Profile.Sections.Ranks -{ - public abstract class DrawableProfileScore : DrawableProfileRow - { - private readonly FillFlowContainer modsContainer; - protected readonly ScoreInfo Score; - - protected DrawableProfileScore(ScoreInfo score) - { - Score = score; - - RelativeSizeAxes = Axes.X; - Height = 60; - Children = new Drawable[] - { - modsContainer = new FillFlowContainer - { - AutoSizeAxes = Axes.Both, - Anchor = Anchor.CentreRight, - Origin = Anchor.CentreRight, - Spacing = new Vector2(1), - Margin = new MarginPadding { Right = 160 } - } - }; - } - - [BackgroundDependencyLoader(true)] - private void load(OsuColour colour) - { - var text = new OsuSpriteText - { - Text = $"accuracy: {Score.Accuracy:P2}", - Anchor = Anchor.TopRight, - Origin = Anchor.TopRight, - Colour = colour.GrayA, - Font = OsuFont.GetFont(size: 11, weight: FontWeight.Regular, italics: true) - }; - - RightFlowContainer.Insert(1, text); - - LeftFlowContainer.Add(new ProfileScoreBeatmapMetadataContainer(Score.Beatmap)); - LeftFlowContainer.Add(new DrawableDate(Score.Date)); - - foreach (Mod mod in Score.Mods) - modsContainer.Add(new ModIcon(mod) { Scale = new Vector2(0.5f) }); - } - - protected override Drawable CreateLeftVisual() => new UpdateableRank(Score.Rank) - { - RelativeSizeAxes = Axes.Y, - Width = 60, - FillMode = FillMode.Fit, - }; - - private class ProfileScoreBeatmapMetadataContainer : BeatmapMetadataContainer - { - public ProfileScoreBeatmapMetadataContainer(BeatmapInfo beatmap) - : base(beatmap) - { - } - - protected override Drawable[] CreateText(BeatmapInfo beatmap) => new Drawable[] - { - new OsuSpriteText - { - Text = new LocalisedString(( - $"{beatmap.Metadata.TitleUnicode ?? beatmap.Metadata.Title} [{beatmap.Version}] ", - $"{beatmap.Metadata.Title ?? beatmap.Metadata.TitleUnicode} [{beatmap.Version}] ")), - Font = OsuFont.GetFont(size: 15, weight: FontWeight.SemiBold, italics: true) - }, - new OsuSpriteText - { - Text = new LocalisedString((beatmap.Metadata.ArtistUnicode, beatmap.Metadata.Artist)), - Padding = new MarginPadding { Top = 3 }, - Font = OsuFont.GetFont(size: 12, weight: FontWeight.Regular, italics: true) - }, - }; - } - } -} diff --git a/osu.Game/Overlays/Profile/Sections/Ranks/DrawableTotalScore.cs b/osu.Game/Overlays/Profile/Sections/Ranks/DrawableTotalScore.cs deleted file mode 100644 index 8bfca08fe7..0000000000 --- a/osu.Game/Overlays/Profile/Sections/Ranks/DrawableTotalScore.cs +++ /dev/null @@ -1,31 +0,0 @@ -// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. -// See the LICENCE file in the repository root for full licence text. - -using osu.Framework.Allocation; -using osu.Framework.Graphics; -using osu.Game.Graphics; -using osu.Game.Graphics.Sprites; -using osu.Game.Scoring; - -namespace osu.Game.Overlays.Profile.Sections.Ranks -{ - public class DrawableTotalScore : DrawableProfileScore - { - public DrawableTotalScore(ScoreInfo score) - : base(score) - { - } - - [BackgroundDependencyLoader] - private void load() - { - RightFlowContainer.Add(new OsuSpriteText - { - Text = Score.TotalScore.ToString("#,###"), - Anchor = Anchor.TopRight, - Origin = Anchor.TopRight, - Font = OsuFont.GetFont(size: 18, weight: FontWeight.Bold, italics: true) - }); - } - } -} From 16cfb9310b4edda6055eea3079d7a60cb94b3c04 Mon Sep 17 00:00:00 2001 From: Andrei Zavatski Date: Sat, 18 Jan 2020 03:40:31 +0300 Subject: [PATCH 06/12] Naming adjustments --- .../Visual/Online/TestSceneUserProfileScores.cs | 10 +++++----- osu.Game.Tests/Visual/Online/TestSceneUserRanks.cs | 4 ++-- .../Ranks/{ProfileScore.cs => DrawableProfileScore.cs} | 4 ++-- ...eightedScore.cs => DrawableProfileWeightedScore.cs} | 4 ++-- .../Profile/Sections/Ranks/PaginatedScoreContainer.cs | 4 ++-- 5 files changed, 13 insertions(+), 13 deletions(-) rename osu.Game/Overlays/Profile/Sections/Ranks/{ProfileScore.cs => DrawableProfileScore.cs} (98%) rename osu.Game/Overlays/Profile/Sections/Ranks/{ProfileWeightedScore.cs => DrawableProfileWeightedScore.cs} (94%) diff --git a/osu.Game.Tests/Visual/Online/TestSceneUserProfileScores.cs b/osu.Game.Tests/Visual/Online/TestSceneUserProfileScores.cs index 4af024052e..ff26611311 100644 --- a/osu.Game.Tests/Visual/Online/TestSceneUserProfileScores.cs +++ b/osu.Game.Tests/Visual/Online/TestSceneUserProfileScores.cs @@ -19,8 +19,8 @@ namespace osu.Game.Tests.Visual.Online { public override IReadOnlyList RequiredTypes => new[] { - typeof(ProfileScore), - typeof(ProfileWeightedScore), + typeof(DrawableProfileScore), + typeof(DrawableProfileWeightedScore), typeof(ProfileItemBackground), }; @@ -74,9 +74,9 @@ namespace osu.Game.Tests.Visual.Online Spacing = new Vector2(0, 10), Children = new[] { - new ProfileScore(score), - new ProfileScore(noPPScore), - new ProfileWeightedScore(score, 0.85), + new DrawableProfileScore(score), + new DrawableProfileScore(noPPScore), + new DrawableProfileWeightedScore(score, 0.85), } }); } diff --git a/osu.Game.Tests/Visual/Online/TestSceneUserRanks.cs b/osu.Game.Tests/Visual/Online/TestSceneUserRanks.cs index 9779343c07..5cbdfb561e 100644 --- a/osu.Game.Tests/Visual/Online/TestSceneUserRanks.cs +++ b/osu.Game.Tests/Visual/Online/TestSceneUserRanks.cs @@ -22,8 +22,8 @@ namespace osu.Game.Tests.Visual.Online public override IReadOnlyList RequiredTypes => new[] { - typeof(ProfileScore), - typeof(ProfileWeightedScore), + typeof(DrawableProfileScore), + typeof(DrawableProfileWeightedScore), typeof(RanksSection) }; diff --git a/osu.Game/Overlays/Profile/Sections/Ranks/ProfileScore.cs b/osu.Game/Overlays/Profile/Sections/Ranks/DrawableProfileScore.cs similarity index 98% rename from osu.Game/Overlays/Profile/Sections/Ranks/ProfileScore.cs rename to osu.Game/Overlays/Profile/Sections/Ranks/DrawableProfileScore.cs index bd49c59523..13bdb523d2 100644 --- a/osu.Game/Overlays/Profile/Sections/Ranks/ProfileScore.cs +++ b/osu.Game/Overlays/Profile/Sections/Ranks/DrawableProfileScore.cs @@ -20,7 +20,7 @@ using osuTK.Graphics; namespace osu.Game.Overlays.Profile.Sections.Ranks { - public class ProfileScore : CompositeDrawable + public class DrawableProfileScore : CompositeDrawable { private const int performance_width = 80; private const int content_padding = 10; @@ -30,7 +30,7 @@ namespace osu.Game.Overlays.Profile.Sections.Ranks [Resolved] private OsuColour colours { get; set; } - public ProfileScore(ScoreInfo score) + public DrawableProfileScore(ScoreInfo score) { Score = score; diff --git a/osu.Game/Overlays/Profile/Sections/Ranks/ProfileWeightedScore.cs b/osu.Game/Overlays/Profile/Sections/Ranks/DrawableProfileWeightedScore.cs similarity index 94% rename from osu.Game/Overlays/Profile/Sections/Ranks/ProfileWeightedScore.cs rename to osu.Game/Overlays/Profile/Sections/Ranks/DrawableProfileWeightedScore.cs index 5f080f2589..bacfc0fd83 100644 --- a/osu.Game/Overlays/Profile/Sections/Ranks/ProfileWeightedScore.cs +++ b/osu.Game/Overlays/Profile/Sections/Ranks/DrawableProfileWeightedScore.cs @@ -10,11 +10,11 @@ using osuTK; namespace osu.Game.Overlays.Profile.Sections.Ranks { - public class ProfileWeightedScore : ProfileScore + public class DrawableProfileWeightedScore : DrawableProfileScore { private readonly double weight; - public ProfileWeightedScore(ScoreInfo score, double weight) + public DrawableProfileWeightedScore(ScoreInfo score, double weight) : base(score) { this.weight = weight; diff --git a/osu.Game/Overlays/Profile/Sections/Ranks/PaginatedScoreContainer.cs b/osu.Game/Overlays/Profile/Sections/Ranks/PaginatedScoreContainer.cs index ad6621696d..64494f9814 100644 --- a/osu.Game/Overlays/Profile/Sections/Ranks/PaginatedScoreContainer.cs +++ b/osu.Game/Overlays/Profile/Sections/Ranks/PaginatedScoreContainer.cs @@ -41,10 +41,10 @@ namespace osu.Game.Overlays.Profile.Sections.Ranks switch (type) { default: - return new ProfileScore(model.CreateScoreInfo(Rulesets)); + return new DrawableProfileScore(model.CreateScoreInfo(Rulesets)); case ScoreType.Best: - return new ProfileWeightedScore(model.CreateScoreInfo(Rulesets), Math.Pow(0.95, ItemsContainer.Count)); + return new DrawableProfileWeightedScore(model.CreateScoreInfo(Rulesets), Math.Pow(0.95, ItemsContainer.Count)); } } } From bab67eb399149c5ed638fafff8118a971dd7f11e Mon Sep 17 00:00:00 2001 From: Andrei Zavatski Date: Sat, 18 Jan 2020 04:12:17 +0300 Subject: [PATCH 07/12] CI fix --- .../Overlays/Profile/Sections/Ranks/DrawableProfileScore.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Overlays/Profile/Sections/Ranks/DrawableProfileScore.cs b/osu.Game/Overlays/Profile/Sections/Ranks/DrawableProfileScore.cs index 13bdb523d2..4d2334df5e 100644 --- a/osu.Game/Overlays/Profile/Sections/Ranks/DrawableProfileScore.cs +++ b/osu.Game/Overlays/Profile/Sections/Ranks/DrawableProfileScore.cs @@ -106,7 +106,7 @@ namespace osu.Game.Overlays.Profile.Sections.Ranks AutoSizeAxes = Axes.Both, Direction = FillDirection.Horizontal, Spacing = new Vector2(15), - Children = new Drawable[] + Children = new[] { CreateRightContent().With(c => { From 8906416294b21aa72ac2a1c574ed165651a12de6 Mon Sep 17 00:00:00 2001 From: Andrei Zavatski Date: Sun, 19 Jan 2020 22:48:11 +0300 Subject: [PATCH 08/12] ProfileItemBackground -> ProfileItemContainer --- osu.Game.Tests/Visual/Online/TestSceneUserProfileScores.cs | 2 +- .../Profile/Sections/Historical/DrawableMostPlayedBeatmap.cs | 2 +- .../{ProfileItemBackground.cs => ProfileItemContainer.cs} | 4 ++-- .../Overlays/Profile/Sections/Ranks/DrawableProfileScore.cs | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) rename osu.Game/Overlays/Profile/Sections/{ProfileItemBackground.cs => ProfileItemContainer.cs} (93%) diff --git a/osu.Game.Tests/Visual/Online/TestSceneUserProfileScores.cs b/osu.Game.Tests/Visual/Online/TestSceneUserProfileScores.cs index ff26611311..a303d88037 100644 --- a/osu.Game.Tests/Visual/Online/TestSceneUserProfileScores.cs +++ b/osu.Game.Tests/Visual/Online/TestSceneUserProfileScores.cs @@ -21,7 +21,7 @@ namespace osu.Game.Tests.Visual.Online { typeof(DrawableProfileScore), typeof(DrawableProfileWeightedScore), - typeof(ProfileItemBackground), + typeof(ProfileItemContainer), }; public TestSceneUserProfileScores() diff --git a/osu.Game/Overlays/Profile/Sections/Historical/DrawableMostPlayedBeatmap.cs b/osu.Game/Overlays/Profile/Sections/Historical/DrawableMostPlayedBeatmap.cs index 9040af3384..e75ad2f161 100644 --- a/osu.Game/Overlays/Profile/Sections/Historical/DrawableMostPlayedBeatmap.cs +++ b/osu.Game/Overlays/Profile/Sections/Historical/DrawableMostPlayedBeatmap.cs @@ -61,7 +61,7 @@ namespace osu.Game.Overlays.Profile.Sections.Historical CornerRadius = corner_radius, Children = new Drawable[] { - new ProfileItemBackground + new ProfileItemContainer { Child = new Container { diff --git a/osu.Game/Overlays/Profile/Sections/ProfileItemBackground.cs b/osu.Game/Overlays/Profile/Sections/ProfileItemContainer.cs similarity index 93% rename from osu.Game/Overlays/Profile/Sections/ProfileItemBackground.cs rename to osu.Game/Overlays/Profile/Sections/ProfileItemContainer.cs index 4f8630c92d..8b6d4ea97d 100644 --- a/osu.Game/Overlays/Profile/Sections/ProfileItemBackground.cs +++ b/osu.Game/Overlays/Profile/Sections/ProfileItemContainer.cs @@ -11,7 +11,7 @@ using System.Collections.Generic; namespace osu.Game.Overlays.Profile.Sections { - public class ProfileItemBackground : OsuHoverContainer + public class ProfileItemContainer : OsuHoverContainer { protected override IEnumerable EffectTargets => new[] { background }; protected override Container Content => content; @@ -19,7 +19,7 @@ namespace osu.Game.Overlays.Profile.Sections private readonly Box background; private readonly Container content; - public ProfileItemBackground() + public ProfileItemContainer() { RelativeSizeAxes = Axes.Both; Enabled.Value = true; //manually enabled, because we have no action diff --git a/osu.Game/Overlays/Profile/Sections/Ranks/DrawableProfileScore.cs b/osu.Game/Overlays/Profile/Sections/Ranks/DrawableProfileScore.cs index 4d2334df5e..722b4d2dae 100644 --- a/osu.Game/Overlays/Profile/Sections/Ranks/DrawableProfileScore.cs +++ b/osu.Game/Overlays/Profile/Sections/Ranks/DrawableProfileScore.cs @@ -41,7 +41,7 @@ namespace osu.Game.Overlays.Profile.Sections.Ranks [BackgroundDependencyLoader] private void load() { - AddInternal(new ProfileItemBackground + AddInternal(new ProfileItemContainer { Children = new Drawable[] { From 5f11084aedc4a6896f50d0e5a32ca7cf8540e653 Mon Sep 17 00:00:00 2001 From: Andrei Zavatski Date: Sun, 19 Jan 2020 22:57:39 +0300 Subject: [PATCH 09/12] Refactor ProfileItemContainer to not use sounds --- .../Profile/Sections/ProfileItemContainer.cs | 31 ++++++++++++++----- 1 file changed, 23 insertions(+), 8 deletions(-) diff --git a/osu.Game/Overlays/Profile/Sections/ProfileItemContainer.cs b/osu.Game/Overlays/Profile/Sections/ProfileItemContainer.cs index 8b6d4ea97d..99cad26a64 100644 --- a/osu.Game/Overlays/Profile/Sections/ProfileItemContainer.cs +++ b/osu.Game/Overlays/Profile/Sections/ProfileItemContainer.cs @@ -5,28 +5,31 @@ using osu.Framework.Allocation; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Shapes; +using osu.Framework.Input.Events; using osu.Game.Graphics; -using osu.Game.Graphics.Containers; -using System.Collections.Generic; +using osuTK.Graphics; namespace osu.Game.Overlays.Profile.Sections { - public class ProfileItemContainer : OsuHoverContainer + public class ProfileItemContainer : Container { - protected override IEnumerable EffectTargets => new[] { background }; + private const int hover_duration = 200; + protected override Container Content => content; + private Color4 idleColour; + private Color4 hoverColour; + private readonly Box background; private readonly Container content; public ProfileItemContainer() { RelativeSizeAxes = Axes.Both; - Enabled.Value = true; //manually enabled, because we have no action Masking = true; CornerRadius = 6; - base.Content.AddRange(new Drawable[] + AddRangeInternal(new Drawable[] { background = new Box { @@ -42,8 +45,20 @@ namespace osu.Game.Overlays.Profile.Sections [BackgroundDependencyLoader] private void load(OsuColour colours) { - IdleColour = colours.GreySeafoam; - HoverColour = colours.GreySeafoamLight; + background.Colour = idleColour = colours.GreySeafoam; + hoverColour = colours.GreySeafoamLight; + } + + protected override bool OnHover(HoverEvent e) + { + background.FadeColour(hoverColour, hover_duration, Easing.OutQuint); + return base.OnHover(e); + } + + protected override void OnHoverLost(HoverLostEvent e) + { + base.OnHoverLost(e); + background.FadeColour(idleColour, hover_duration, Easing.OutQuint); } } } From 79cdfc6dc211ec3086843d8bfddb998df80db4ed Mon Sep 17 00:00:00 2001 From: Andrei Zavatski Date: Mon, 27 Jan 2020 12:55:19 +0300 Subject: [PATCH 10/12] Use OverlayColourProvider --- .../Online/TestSceneUserProfileScores.cs | 23 ++++++++++++++++--- .../Visual/Online/TestSceneUserRanks.cs | 5 ++++ .../Profile/Sections/ProfileItemContainer.cs | 7 +++--- .../Sections/Ranks/DrawableProfileScore.cs | 11 +++++---- 4 files changed, 35 insertions(+), 11 deletions(-) diff --git a/osu.Game.Tests/Visual/Online/TestSceneUserProfileScores.cs b/osu.Game.Tests/Visual/Online/TestSceneUserProfileScores.cs index a303d88037..19b72e7071 100644 --- a/osu.Game.Tests/Visual/Online/TestSceneUserProfileScores.cs +++ b/osu.Game.Tests/Visual/Online/TestSceneUserProfileScores.cs @@ -12,6 +12,8 @@ using osuTK; using osu.Game.Beatmaps; using osu.Game.Rulesets.Mods; using osu.Game.Rulesets.Osu.Mods; +using osu.Game.Overlays; +using osu.Framework.Allocation; namespace osu.Game.Tests.Visual.Online { @@ -74,11 +76,26 @@ namespace osu.Game.Tests.Visual.Online Spacing = new Vector2(0, 10), Children = new[] { - new DrawableProfileScore(score), - new DrawableProfileScore(noPPScore), - new DrawableProfileWeightedScore(score, 0.85), + new ColourProvidedContainer(OverlayColourScheme.Green, new DrawableProfileScore(score)), + new ColourProvidedContainer(OverlayColourScheme.Pink, new DrawableProfileScore(noPPScore)), + new ColourProvidedContainer(OverlayColourScheme.Pink, new DrawableProfileWeightedScore(score, 0.85)) } }); } + + private class ColourProvidedContainer : Container + { + [Cached] + private readonly OverlayColourProvider colourProvider; + + public ColourProvidedContainer(OverlayColourScheme colourScheme, DrawableProfileScore score) + { + colourProvider = new OverlayColourProvider(colourScheme); + + AutoSizeAxes = Axes.Y; + RelativeSizeAxes = Axes.X; + Add(score); + } + } } } diff --git a/osu.Game.Tests/Visual/Online/TestSceneUserRanks.cs b/osu.Game.Tests/Visual/Online/TestSceneUserRanks.cs index 5cbdfb561e..c8e94b2915 100644 --- a/osu.Game.Tests/Visual/Online/TestSceneUserRanks.cs +++ b/osu.Game.Tests/Visual/Online/TestSceneUserRanks.cs @@ -4,11 +4,13 @@ using System; using System.Collections.Generic; using NUnit.Framework; +using osu.Framework.Allocation; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Shapes; using osu.Game.Graphics; using osu.Game.Graphics.Containers; +using osu.Game.Overlays; using osu.Game.Overlays.Profile.Sections; using osu.Game.Overlays.Profile.Sections.Ranks; using osu.Game.Users; @@ -27,6 +29,9 @@ namespace osu.Game.Tests.Visual.Online typeof(RanksSection) }; + [Cached] + private readonly OverlayColourProvider colourProvider = new OverlayColourProvider(OverlayColourScheme.Green); + public TestSceneUserRanks() { RanksSection ranks; diff --git a/osu.Game/Overlays/Profile/Sections/ProfileItemContainer.cs b/osu.Game/Overlays/Profile/Sections/ProfileItemContainer.cs index 99cad26a64..717ec4fb1a 100644 --- a/osu.Game/Overlays/Profile/Sections/ProfileItemContainer.cs +++ b/osu.Game/Overlays/Profile/Sections/ProfileItemContainer.cs @@ -6,7 +6,6 @@ using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Shapes; using osu.Framework.Input.Events; -using osu.Game.Graphics; using osuTK.Graphics; namespace osu.Game.Overlays.Profile.Sections @@ -43,10 +42,10 @@ namespace osu.Game.Overlays.Profile.Sections } [BackgroundDependencyLoader] - private void load(OsuColour colours) + private void load(OverlayColourProvider colourProvider) { - background.Colour = idleColour = colours.GreySeafoam; - hoverColour = colours.GreySeafoamLight; + background.Colour = idleColour = colourProvider.Background4; + hoverColour = colourProvider.Background3; } protected override bool OnHover(HoverEvent e) diff --git a/osu.Game/Overlays/Profile/Sections/Ranks/DrawableProfileScore.cs b/osu.Game/Overlays/Profile/Sections/Ranks/DrawableProfileScore.cs index 722b4d2dae..9145ce6894 100644 --- a/osu.Game/Overlays/Profile/Sections/Ranks/DrawableProfileScore.cs +++ b/osu.Game/Overlays/Profile/Sections/Ranks/DrawableProfileScore.cs @@ -30,6 +30,9 @@ namespace osu.Game.Overlays.Profile.Sections.Ranks [Resolved] private OsuColour colours { get; set; } + [Resolved] + private OverlayColourProvider colourProvider { get; set; } + public DrawableProfileScore(ScoreInfo score) { Score = score; @@ -91,7 +94,7 @@ namespace osu.Game.Overlays.Profile.Sections.Ranks }, new DrawableDate(Score.Date, 12) { - Colour = colours.GreySeafoamLighter + Colour = colourProvider.Foreground1 } } } @@ -192,7 +195,7 @@ namespace osu.Game.Overlays.Profile.Sections.Ranks Origin = Anchor.BottomLeft, Font = OsuFont.GetFont(weight: FontWeight.Bold), Text = $"{Score.PP:0}", - Colour = colours.GreenLight + Colour = colourProvider.Highlight1 }, new OsuSpriteText { @@ -200,7 +203,7 @@ namespace osu.Game.Overlays.Profile.Sections.Ranks Origin = Anchor.BottomLeft, Font = OsuFont.GetFont(size: 12, weight: FontWeight.Bold), Text = "pp", - Colour = colours.Green + Colour = colourProvider.Light3 } } }; @@ -210,7 +213,7 @@ namespace osu.Game.Overlays.Profile.Sections.Ranks { Font = OsuFont.GetFont(weight: FontWeight.Bold), Text = "-", - Colour = colours.GreenLight + Colour = colourProvider.Highlight1 }; } From d908bc269345c13a7a1f282418faa29fb79204d6 Mon Sep 17 00:00:00 2001 From: smoogipoo Date: Wed, 29 Jan 2020 18:44:30 +0900 Subject: [PATCH 11/12] Remove unnecessary extra spritetext --- .../Ranks/DrawableProfileWeightedScore.cs | 27 +++++-------------- 1 file changed, 6 insertions(+), 21 deletions(-) diff --git a/osu.Game/Overlays/Profile/Sections/Ranks/DrawableProfileWeightedScore.cs b/osu.Game/Overlays/Profile/Sections/Ranks/DrawableProfileWeightedScore.cs index bacfc0fd83..1b77e8e4fb 100644 --- a/osu.Game/Overlays/Profile/Sections/Ranks/DrawableProfileWeightedScore.cs +++ b/osu.Game/Overlays/Profile/Sections/Ranks/DrawableProfileWeightedScore.cs @@ -40,28 +40,13 @@ namespace osu.Game.Overlays.Profile.Sections.Ranks Width = 60, Child = CreateDrawableAccuracy() }, - new FillFlowContainer + new OsuSpriteText { - AutoSizeAxes = Axes.Both, - Direction = FillDirection.Horizontal, - Children = new[] - { - new OsuSpriteText - { - Anchor = Anchor.BottomLeft, - Origin = Anchor.BottomLeft, - Font = OsuFont.GetFont(weight: FontWeight.Bold, italics: true), - Text = $"{Score.PP * weight:0}", - }, - new OsuSpriteText - { - Anchor = Anchor.BottomLeft, - Origin = Anchor.BottomLeft, - Font = OsuFont.GetFont(size: 14, weight: FontWeight.Bold, italics: true), - Text = "pp", - } - } - } + Anchor = Anchor.BottomLeft, + Origin = Anchor.BottomLeft, + Font = OsuFont.GetFont(weight: FontWeight.Bold, italics: true), + Text = $"{Score.PP * weight:0}pp", + }, } }, new OsuSpriteText From 7f946047f9ab1b064a27901eea7a171a864c06ee Mon Sep 17 00:00:00 2001 From: smoogipoo Date: Wed, 29 Jan 2020 18:51:20 +0900 Subject: [PATCH 12/12] Adjust styling to closer match osu-web --- .../Profile/Sections/Ranks/DrawableProfileScore.cs | 8 ++++---- .../Sections/Ranks/DrawableProfileWeightedScore.cs | 11 +++-------- 2 files changed, 7 insertions(+), 12 deletions(-) diff --git a/osu.Game/Overlays/Profile/Sections/Ranks/DrawableProfileScore.cs b/osu.Game/Overlays/Profile/Sections/Ranks/DrawableProfileScore.cs index 9145ce6894..5196bef48d 100644 --- a/osu.Game/Overlays/Profile/Sections/Ranks/DrawableProfileScore.cs +++ b/osu.Game/Overlays/Profile/Sections/Ranks/DrawableProfileScore.cs @@ -174,8 +174,8 @@ namespace osu.Game.Overlays.Profile.Sections.Ranks protected OsuSpriteText CreateDrawableAccuracy() => new OsuSpriteText { - Text = $"{Score.Accuracy:P2}", - Font = OsuFont.GetFont(weight: FontWeight.Bold, italics: true), + Text = $"{Score.Accuracy:0.00%}", + Font = OsuFont.GetFont(size: 14, weight: FontWeight.Bold, italics: true), Colour = colours.Yellow, }; @@ -233,14 +233,14 @@ namespace osu.Game.Overlays.Profile.Sections.Ranks Text = new LocalisedString(( $"{beatmap.Metadata.TitleUnicode ?? beatmap.Metadata.Title} ", $"{beatmap.Metadata.Title ?? beatmap.Metadata.TitleUnicode} ")), - Font = OsuFont.GetFont(weight: FontWeight.SemiBold, italics: true) + Font = OsuFont.GetFont(size: 14, weight: FontWeight.SemiBold, italics: true) }, new OsuSpriteText { Anchor = Anchor.BottomLeft, Origin = Anchor.BottomLeft, Text = "by " + new LocalisedString((beatmap.Metadata.ArtistUnicode, beatmap.Metadata.Artist)), - Font = OsuFont.GetFont(size: 14, italics: true) + Font = OsuFont.GetFont(size: 12, italics: true) }, }; } diff --git a/osu.Game/Overlays/Profile/Sections/Ranks/DrawableProfileWeightedScore.cs b/osu.Game/Overlays/Profile/Sections/Ranks/DrawableProfileWeightedScore.cs index 1b77e8e4fb..e741c88aeb 100644 --- a/osu.Game/Overlays/Profile/Sections/Ranks/DrawableProfileWeightedScore.cs +++ b/osu.Game/Overlays/Profile/Sections/Ranks/DrawableProfileWeightedScore.cs @@ -6,7 +6,6 @@ using osu.Framework.Graphics.Containers; using osu.Game.Graphics; using osu.Game.Graphics.Sprites; using osu.Game.Scoring; -using osuTK; namespace osu.Game.Overlays.Profile.Sections.Ranks { @@ -24,14 +23,12 @@ namespace osu.Game.Overlays.Profile.Sections.Ranks { AutoSizeAxes = Axes.Both, Direction = FillDirection.Vertical, - Spacing = new Vector2(0, 2), Children = new Drawable[] { new FillFlowContainer { AutoSizeAxes = Axes.Both, Direction = FillDirection.Horizontal, - Spacing = new Vector2(15, 0), Children = new Drawable[] { new Container @@ -42,17 +39,15 @@ namespace osu.Game.Overlays.Profile.Sections.Ranks }, new OsuSpriteText { - Anchor = Anchor.BottomLeft, - Origin = Anchor.BottomLeft, - Font = OsuFont.GetFont(weight: FontWeight.Bold, italics: true), + Font = OsuFont.GetFont(size: 14, weight: FontWeight.Bold, italics: true), Text = $"{Score.PP * weight:0}pp", }, } }, new OsuSpriteText { - Font = OsuFont.GetFont(size: 12, weight: FontWeight.Bold), - Text = $@"weighted {weight:P0}" + Font = OsuFont.GetFont(size: 12), + Text = $@"weighted {weight:0%}" } } };