From fe7f9cccaa0520791ff08064fd5a851b0eaf423d Mon Sep 17 00:00:00 2001 From: jorolf Date: Sun, 19 Nov 2017 14:16:00 +0100 Subject: [PATCH 01/19] BeatmapSetCover can display other types of covers now --- .../Beatmaps/Drawables/BeatmapSetCover.cs | 27 +++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/osu.Game/Beatmaps/Drawables/BeatmapSetCover.cs b/osu.Game/Beatmaps/Drawables/BeatmapSetCover.cs index 614ebc236b..ba79db3f48 100644 --- a/osu.Game/Beatmaps/Drawables/BeatmapSetCover.cs +++ b/osu.Game/Beatmaps/Drawables/BeatmapSetCover.cs @@ -11,21 +11,44 @@ namespace osu.Game.Beatmaps.Drawables public class BeatmapSetCover : Sprite { private readonly BeatmapSetInfo set; - public BeatmapSetCover(BeatmapSetInfo set) + private readonly BeatmapSetCoverType type; + + public BeatmapSetCover(BeatmapSetInfo set, BeatmapSetCoverType type = BeatmapSetCoverType.Cover) { if (set == null) throw new ArgumentNullException(nameof(set)); this.set = set; + this.type = type; } [BackgroundDependencyLoader] private void load(TextureStore textures) { - string resource = set.OnlineInfo.Covers.Cover; + string resource = null; + + switch (type) + { + case BeatmapSetCoverType.Cover: + resource = set.OnlineInfo.Covers.Cover; + break; + case BeatmapSetCoverType.Card: + resource = set.OnlineInfo.Covers.Card; + break; + case BeatmapSetCoverType.List: + resource = set.OnlineInfo.Covers.List; + break; + } if (resource != null) Texture = textures.Get(resource); } } + + public enum BeatmapSetCoverType + { + Cover, + Card, + List, + } } From 1f379cab8fcdaa8b1b5d1497e18b2bae313d2cc1 Mon Sep 17 00:00:00 2001 From: jorolf Date: Sun, 19 Nov 2017 14:17:14 +0100 Subject: [PATCH 02/19] move BeatmapMetadataContainer to a separate class --- .../Sections/BeatmapMetadataContainer.cs | 60 +++++++++++++++++++ .../Profile/Sections/Ranks/DrawableScore.cs | 44 +------------- osu.Game/osu.Game.csproj | 1 + 3 files changed, 62 insertions(+), 43 deletions(-) create mode 100644 osu.Game/Overlays/Profile/Sections/BeatmapMetadataContainer.cs diff --git a/osu.Game/Overlays/Profile/Sections/BeatmapMetadataContainer.cs b/osu.Game/Overlays/Profile/Sections/BeatmapMetadataContainer.cs new file mode 100644 index 0000000000..5104f98f9d --- /dev/null +++ b/osu.Game/Overlays/Profile/Sections/BeatmapMetadataContainer.cs @@ -0,0 +1,60 @@ +// 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; +using osu.Framework.Graphics.Containers; +using osu.Framework.Graphics.Cursor; +using osu.Framework.Localisation; +using osu.Game.Beatmaps; +using osu.Game.Graphics.Containers; +using osu.Game.Graphics.Sprites; +namespace osu.Game.Overlays.Profile.Sections +{ + public class BeatmapMetadataContainer : OsuHoverContainer, IHasTooltip + { + private readonly BeatmapInfo beatmap; + + public BeatmapMetadataContainer(BeatmapInfo beatmap) + { + this.beatmap = beatmap; + AutoSizeAxes = Axes.Both; + TooltipText = $"{beatmap.Metadata.Artist} - {beatmap.Metadata.Title}"; + } + + public string TooltipText { get; } + + [BackgroundDependencyLoader(true)] + private void load(LocalisationEngine locale, BeatmapSetOverlay beatmapSetOverlay) + { + Action = () => + { + if (beatmap.OnlineBeatmapSetID.HasValue) beatmapSetOverlay?.ShowBeatmapSet(beatmap.OnlineBeatmapSetID.Value); + }; + + Child = new FillFlowContainer + { + AutoSizeAxes = Axes.Both, + Children = new Drawable[] + { + new OsuSpriteText + { + Current = locale.GetUnicodePreference( + $"{beatmap.Metadata.TitleUnicode ?? beatmap.Metadata.Title} [{beatmap.Version}] ", + $"{beatmap.Metadata.Title ?? beatmap.Metadata.TitleUnicode} [{beatmap.Version}] " + ), + TextSize = 15, + Font = "Exo2.0-SemiBoldItalic", + }, + new OsuSpriteText + { + Current = locale.GetUnicodePreference(beatmap.Metadata.ArtistUnicode, beatmap.Metadata.Artist), + TextSize = 12, + Padding = new MarginPadding { Top = 3 }, + Font = "Exo2.0-RegularItalic", + }, + }, + }; + } + } +} diff --git a/osu.Game/Overlays/Profile/Sections/Ranks/DrawableScore.cs b/osu.Game/Overlays/Profile/Sections/Ranks/DrawableScore.cs index 35f4778047..6c475cbb26 100644 --- a/osu.Game/Overlays/Profile/Sections/Ranks/DrawableScore.cs +++ b/osu.Game/Overlays/Profile/Sections/Ranks/DrawableScore.cs @@ -14,10 +14,8 @@ using osu.Game.Rulesets.Scoring; using osu.Game.Rulesets.UI; using OpenTK.Graphics; using osu.Framework.Graphics.Shapes; -using osu.Framework.Graphics.Cursor; using osu.Framework.Input; using osu.Framework.Extensions.Color4Extensions; -using osu.Game.Graphics.Containers; namespace osu.Game.Overlays.Profile.Sections.Ranks { @@ -130,37 +128,7 @@ namespace osu.Game.Overlays.Profile.Sections.Ranks Depth = -1, }); - metadata.Add(new MetadataContainer(Score.Beatmap.Metadata.Title, Score.Beatmap.Metadata.Artist) - { - AutoSizeAxes = Axes.Both, - Action = () => - { - if (Score.Beatmap.OnlineBeatmapSetID.HasValue) beatmapSetOverlay?.ShowBeatmapSet(Score.Beatmap.OnlineBeatmapSetID.Value); - }, - Child = new FillFlowContainer - { - AutoSizeAxes = Axes.Both, - Children = new Drawable[] - { - new OsuSpriteText - { - Current = locale.GetUnicodePreference( - $"{Score.Beatmap.Metadata.TitleUnicode ?? Score.Beatmap.Metadata.Title} [{Score.Beatmap.Version}] ", - $"{Score.Beatmap.Metadata.Title ?? Score.Beatmap.Metadata.TitleUnicode} [{Score.Beatmap.Version}] " - ), - TextSize = 15, - Font = "Exo2.0-SemiBoldItalic", - }, - new OsuSpriteText - { - Current = locale.GetUnicodePreference(Score.Beatmap.Metadata.ArtistUnicode, Score.Beatmap.Metadata.Artist), - TextSize = 12, - Padding = new MarginPadding { Top = 3 }, - Font = "Exo2.0-RegularItalic", - }, - }, - }, - }); + metadata.Add(new BeatmapMetadataContainer(Score.Beatmap)); foreach (Mod mod in Score.Mods) modsContainer.Add(new ModIcon(mod) { Scale = new Vector2(0.5f) }); @@ -181,15 +149,5 @@ namespace osu.Game.Overlays.Profile.Sections.Ranks underscoreLine.FadeIn(fade_duration, Easing.OutQuint); base.OnHoverLost(state); } - - private class MetadataContainer : OsuHoverContainer, IHasTooltip - { - public string TooltipText { get; set; } - - public MetadataContainer(string title, string artist) - { - TooltipText = $"{artist} - {title}"; - } - } } } diff --git a/osu.Game/osu.Game.csproj b/osu.Game/osu.Game.csproj index 7b479bdba2..c5493ea59f 100644 --- a/osu.Game/osu.Game.csproj +++ b/osu.Game/osu.Game.csproj @@ -287,6 +287,7 @@ + From 48b44e8e4eb0f29c2430ca286438dd8b69ee9cc2 Mon Sep 17 00:00:00 2001 From: jorolf Date: Sun, 19 Nov 2017 14:18:14 +0100 Subject: [PATCH 03/19] add a user most played beatmaps request/response --- .../API/Requests/GetBeatmapSetsResponse.cs | 2 +- .../API/Requests/GetUserBeatmapsRequest.cs | 15 ++++- .../GetUserMostPlayedBeatmapsRequest.cs | 67 +++++++++++++++++++ osu.Game/osu.Game.csproj | 1 + 4 files changed, 82 insertions(+), 3 deletions(-) create mode 100644 osu.Game/Online/API/Requests/GetUserMostPlayedBeatmapsRequest.cs diff --git a/osu.Game/Online/API/Requests/GetBeatmapSetsResponse.cs b/osu.Game/Online/API/Requests/GetBeatmapSetsResponse.cs index 9e412a9b8b..d187cabf31 100644 --- a/osu.Game/Online/API/Requests/GetBeatmapSetsResponse.cs +++ b/osu.Game/Online/API/Requests/GetBeatmapSetsResponse.cs @@ -65,7 +65,7 @@ namespace osu.Game.Online.API.Requests Ranked = ranked, LastUpdated = lastUpdated, }, - Beatmaps = beatmaps.Select(b => b.ToBeatmap(rulesets)).ToList(), + Beatmaps = beatmaps?.Select(b => b.ToBeatmap(rulesets)).ToList(), }; } diff --git a/osu.Game/Online/API/Requests/GetUserBeatmapsRequest.cs b/osu.Game/Online/API/Requests/GetUserBeatmapsRequest.cs index a66799f404..9c3a32ec9e 100644 --- a/osu.Game/Online/API/Requests/GetUserBeatmapsRequest.cs +++ b/osu.Game/Online/API/Requests/GetUserBeatmapsRequest.cs @@ -1,18 +1,19 @@ // Copyright (c) 2007-2017 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE +using System; using Humanizer; using System.Collections.Generic; namespace osu.Game.Online.API.Requests { - public class GetUserBeatmapsRequest : APIRequest> + public class GetUserBeatmapsRequest : APIRequest> { private readonly long userId; private readonly int offset; private readonly BeatmapSetType type; - public GetUserBeatmapsRequest(long userId, BeatmapSetType type, int offset = 0) + protected GetUserBeatmapsRequest(long userId, BeatmapSetType type, int offset = 0) { this.userId = userId; this.offset = offset; @@ -22,6 +23,16 @@ namespace osu.Game.Online.API.Requests protected override string Target => $@"users/{userId}/beatmapsets/{type.ToString().Underscore()}?offset={offset}"; } + public class GetUserBeatmapsRequest : GetUserBeatmapsRequest + { + public GetUserBeatmapsRequest(long userID, BeatmapSetType type, int offset = 0) + : base(userID, type, offset) + { + if(type == BeatmapSetType.MostPlayed) + throw new ArgumentException("Please use " + nameof(GetUserMostPlayedBeatmapsRequest) + " instead"); + } + } + public enum BeatmapSetType { MostPlayed, diff --git a/osu.Game/Online/API/Requests/GetUserMostPlayedBeatmapsRequest.cs b/osu.Game/Online/API/Requests/GetUserMostPlayedBeatmapsRequest.cs new file mode 100644 index 0000000000..33b755450b --- /dev/null +++ b/osu.Game/Online/API/Requests/GetUserMostPlayedBeatmapsRequest.cs @@ -0,0 +1,67 @@ +// 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 Newtonsoft.Json; +using osu.Framework.Extensions; +using osu.Game.Beatmaps; +using osu.Game.Rulesets; + +namespace osu.Game.Online.API.Requests +{ + public class GetUserMostPlayedBeatmapsRequest : GetUserBeatmapsRequest + { + public GetUserMostPlayedBeatmapsRequest(long userID, BeatmapSetType type, int offset = 0) + : base(userID, type, offset) + { + if (type != BeatmapSetType.MostPlayed) + throw new ArgumentException("Please use " + nameof(GetUserBeatmapsRequest) + " instead"); + } + } + + public class UserMostPlayedBeatmapsResponse + { + [JsonProperty("beatmap_id")] + public int BeatmapID; + + [JsonProperty("count")] + public int PlayCount; + + [JsonProperty] + private BeatmapResponse beatmap; + + [JsonProperty] + private GetBeatmapSetsResponse beatmapSet; + + public BeatmapInfo GetBeatmapInfo(RulesetStore rulesets) + { + BeatmapSetInfo setInfo = beatmapSet.ToBeatmapSet(rulesets); + return new BeatmapInfo + { + OnlineBeatmapID = beatmap.Id, + OnlineBeatmapSetID = setInfo.OnlineBeatmapSetID, + Ruleset = rulesets.AvailableRulesets.FirstOrDefault(ruleset => ruleset.Name.Equals(beatmap.Mode)), + StarDifficulty = beatmap.DifficultyRating, + Version = beatmap.Version, + Metadata = setInfo.Metadata, + BeatmapSet = setInfo, + }; + } + + private class BeatmapResponse + { + [JsonProperty] + public int Id; + + [JsonProperty] + public string Mode; + + [JsonProperty("difficulty_rating")] + public double DifficultyRating; + + [JsonProperty] + public string Version; + } + } +} diff --git a/osu.Game/osu.Game.csproj b/osu.Game/osu.Game.csproj index c5493ea59f..9fc1674c45 100644 --- a/osu.Game/osu.Game.csproj +++ b/osu.Game/osu.Game.csproj @@ -282,6 +282,7 @@ + From 4281d76bcf8d8e0c7f56424f8faa863c7aa02dfd Mon Sep 17 00:00:00 2001 From: jorolf Date: Sun, 19 Nov 2017 14:19:05 +0100 Subject: [PATCH 04/19] historical section now shows the most played beatmaps --- .../Historical/MostPlayedBeatmapDrawable.cs | 160 ++++++++++++++++++ .../PaginatedMostPlayedBeatmapContainer.cs | 52 ++++++ .../Profile/Sections/HistoricalSection.cs | 8 +- osu.Game/osu.Game.csproj | 2 + 4 files changed, 221 insertions(+), 1 deletion(-) create mode 100644 osu.Game/Overlays/Profile/Sections/Historical/MostPlayedBeatmapDrawable.cs create mode 100644 osu.Game/Overlays/Profile/Sections/Historical/PaginatedMostPlayedBeatmapContainer.cs diff --git a/osu.Game/Overlays/Profile/Sections/Historical/MostPlayedBeatmapDrawable.cs b/osu.Game/Overlays/Profile/Sections/Historical/MostPlayedBeatmapDrawable.cs new file mode 100644 index 0000000000..0f419ad44e --- /dev/null +++ b/osu.Game/Overlays/Profile/Sections/Historical/MostPlayedBeatmapDrawable.cs @@ -0,0 +1,160 @@ +// 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.Color4Extensions; +using osu.Framework.Graphics; +using osu.Framework.Graphics.Containers; +using osu.Framework.Graphics.Shapes; +using osu.Framework.Input; +using osu.Game.Beatmaps; +using osu.Game.Beatmaps.Drawables; +using osu.Game.Graphics; +using osu.Game.Graphics.Containers; +using osu.Game.Graphics.Sprites; +using OpenTK; +using OpenTK.Graphics; + +namespace osu.Game.Overlays.Profile.Sections.Historical +{ + public class MostPlayedBeatmapDrawable : Container + { + private readonly BeatmapInfo beatmap; + private readonly OsuHoverContainer mapperContainer; + + private readonly EdgeEffectParameters edgeEffectNormal = new EdgeEffectParameters + { + Type = EdgeEffectType.Shadow, + Offset = new Vector2(0, 1f), + Radius = 2f, + Colour = Color4.Black.Opacity(0.25f), + }; + + private readonly EdgeEffectParameters edgeEffectHovered = new EdgeEffectParameters + { + Type = EdgeEffectType.Shadow, + Offset = new Vector2(0, 5f), + Radius = 10f, + Colour = Color4.Black.Opacity(0.25f), + }; + + public MostPlayedBeatmapDrawable(BeatmapInfo beatmap, int playCount) + { + this.beatmap = beatmap; + RelativeSizeAxes = Axes.X; + Height = 50; + Margin = new MarginPadding { Bottom = 10 }; + Masking = true; + EdgeEffect = edgeEffectNormal; + + Children = new Drawable[] + { + new Box //Background for this container, otherwise the shadow would be visible + { + RelativeSizeAxes = Axes.Both, + Colour = OsuColour.Gray(0.2f), + }, + new Box //Image Background while loading + { + Size = new Vector2(80, 50), + Colour = Color4.Black, + }, + new DelayedLoadWrapper(new BeatmapSetCover(beatmap.BeatmapSet, BeatmapSetCoverType.List) + { + RelativeSizeAxes = Axes.Both, + FillMode = FillMode.Fit, + }), + new FillFlowContainer + { + RelativeSizeAxes = Axes.Both, + Padding = new MarginPadding(10) { Left = 90 }, + Direction = FillDirection.Vertical, + Children = new Drawable[] + { + new Container + { + RelativeSizeAxes = Axes.X, + AutoSizeAxes = Axes.Y, + Children = new Drawable[] + { + new BeatmapMetadataContainer(beatmap), + new FillFlowContainer + { + Anchor = Anchor.TopRight, + Origin = Anchor.TopRight, + AutoSizeAxes = Axes.Both, + Direction = FillDirection.Horizontal, + Children = new [] + { + new OsuSpriteText + { + Anchor = Anchor.BottomRight, + Origin = Anchor.BottomRight, + Text = playCount.ToString(), + TextSize = 18, + Font = @"Exo2.0-SemiBoldItalic" + }, + new OsuSpriteText + { + Anchor = Anchor.BottomRight, + Origin = Anchor.BottomRight, + Text = @"times played ", + TextSize = 12, + Font = @"Exo2.0-RegularItalic" + }, + } + } + }, + }, + new FillFlowContainer + { + RelativeSizeAxes = Axes.X, + AutoSizeAxes = Axes.Y, + Direction = FillDirection.Horizontal, + Children = new Drawable[] + { + new OsuSpriteText + { + Text = @"mapped by ", + TextSize = 12, + }, + mapperContainer = new OsuHoverContainer + { + AutoSizeAxes = Axes.Both, + Children = new Drawable[] + { + new OsuSpriteText + { + Text = beatmap.Metadata.AuthorString, + TextSize = 12, + Font = @"Exo2.0-MediumItalic" + } + } + }, + } + }, + }, + } + }; + } + + [BackgroundDependencyLoader(true)] + private void load(UserProfileOverlay profileOverlay) + { + if(profileOverlay != null) + mapperContainer.Action = () => profileOverlay.ShowUser(beatmap.BeatmapSet.Metadata.Author); + } + + protected override bool OnHover(InputState state) + { + TweenEdgeEffectTo(edgeEffectHovered, 120, Easing.OutQuint); + return base.OnHover(state); + } + + protected override void OnHoverLost(InputState state) + { + TweenEdgeEffectTo(edgeEffectNormal, 120, Easing.OutQuint); + base.OnHoverLost(state); + } + } +} diff --git a/osu.Game/Overlays/Profile/Sections/Historical/PaginatedMostPlayedBeatmapContainer.cs b/osu.Game/Overlays/Profile/Sections/Historical/PaginatedMostPlayedBeatmapContainer.cs new file mode 100644 index 0000000000..d42e00b1a5 --- /dev/null +++ b/osu.Game/Overlays/Profile/Sections/Historical/PaginatedMostPlayedBeatmapContainer.cs @@ -0,0 +1,52 @@ +// Copyright (c) 2007-2017 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using System.Linq; +using osu.Framework.Configuration; +using osu.Framework.Graphics; +using osu.Framework.Graphics.Containers; +using osu.Game.Beatmaps; +using osu.Game.Online.API.Requests; +using osu.Game.Users; + +namespace osu.Game.Overlays.Profile.Sections.Historical +{ + public class PaginatedMostPlayedBeatmapContainer : PaginatedContainer + { + public PaginatedMostPlayedBeatmapContainer(Bindable user) + :base(user, "Most Played Beatmaps", "No performance records. :(") + { + ItemsPerPage = 5; + + ItemsContainer.Direction = FillDirection.Vertical; + } + + protected override void ShowMore() + { + base.ShowMore(); + + var req = new GetUserMostPlayedBeatmapsRequest(User.Value.Id, BeatmapSetType.MostPlayed, VisiblePages++ * ItemsPerPage); + + req.Success += beatmaps => + { + ShowMoreButton.FadeTo(beatmaps.Count == ItemsPerPage ? 1 : 0); + ShowMoreLoading.Hide(); + + if (!beatmaps.Any() && VisiblePages == 1) + { + MissingText.Show(); + return; + } + + MissingText.Hide(); + + foreach (var beatmap in beatmaps) + { + ItemsContainer.Add(new MostPlayedBeatmapDrawable(beatmap.GetBeatmapInfo(Rulesets), beatmap.PlayCount)); + } + }; + + Api.Queue(req); + } + } +} diff --git a/osu.Game/Overlays/Profile/Sections/HistoricalSection.cs b/osu.Game/Overlays/Profile/Sections/HistoricalSection.cs index a4d043d20a..ab99abdccd 100644 --- a/osu.Game/Overlays/Profile/Sections/HistoricalSection.cs +++ b/osu.Game/Overlays/Profile/Sections/HistoricalSection.cs @@ -1,7 +1,9 @@ // 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.Game.Online.API.Requests; +using osu.Game.Overlays.Profile.Sections.Historical; using osu.Game.Overlays.Profile.Sections.Ranks; namespace osu.Game.Overlays.Profile.Sections @@ -14,7 +16,11 @@ namespace osu.Game.Overlays.Profile.Sections public HistoricalSection() { - Child = new PaginatedScoreContainer(ScoreType.Recent, User, "Recent Plays (24h)", "No performance records. :("); + Children = new Drawable[] + { + new PaginatedMostPlayedBeatmapContainer(User), + new PaginatedScoreContainer(ScoreType.Recent, User, "Recent Plays (24h)", "No performance records. :("), + }; } } } diff --git a/osu.Game/osu.Game.csproj b/osu.Game/osu.Game.csproj index 9fc1674c45..fd8e03f623 100644 --- a/osu.Game/osu.Game.csproj +++ b/osu.Game/osu.Game.csproj @@ -290,6 +290,8 @@ + + From 66c51c7b44a1d3f99187decbb465a884606bc102 Mon Sep 17 00:00:00 2001 From: jorolf Date: Sun, 19 Nov 2017 14:33:50 +0100 Subject: [PATCH 05/19] cleanup --- osu.Game/Online/API/Requests/GetUserBeatmapsRequest.cs | 2 +- .../Online/API/Requests/GetUserMostPlayedBeatmapsRequest.cs | 1 - .../Sections/Historical/PaginatedMostPlayedBeatmapContainer.cs | 1 - osu.Game/Overlays/Profile/Sections/Ranks/DrawableScore.cs | 3 +-- 4 files changed, 2 insertions(+), 5 deletions(-) diff --git a/osu.Game/Online/API/Requests/GetUserBeatmapsRequest.cs b/osu.Game/Online/API/Requests/GetUserBeatmapsRequest.cs index 9c3a32ec9e..dca0395e3a 100644 --- a/osu.Game/Online/API/Requests/GetUserBeatmapsRequest.cs +++ b/osu.Game/Online/API/Requests/GetUserBeatmapsRequest.cs @@ -7,7 +7,7 @@ using System.Collections.Generic; namespace osu.Game.Online.API.Requests { - public class GetUserBeatmapsRequest : APIRequest> + public abstract class GetUserBeatmapsRequest : APIRequest> { private readonly long userId; private readonly int offset; diff --git a/osu.Game/Online/API/Requests/GetUserMostPlayedBeatmapsRequest.cs b/osu.Game/Online/API/Requests/GetUserMostPlayedBeatmapsRequest.cs index 33b755450b..cdc156be05 100644 --- a/osu.Game/Online/API/Requests/GetUserMostPlayedBeatmapsRequest.cs +++ b/osu.Game/Online/API/Requests/GetUserMostPlayedBeatmapsRequest.cs @@ -4,7 +4,6 @@ using System; using System.Linq; using Newtonsoft.Json; -using osu.Framework.Extensions; using osu.Game.Beatmaps; using osu.Game.Rulesets; diff --git a/osu.Game/Overlays/Profile/Sections/Historical/PaginatedMostPlayedBeatmapContainer.cs b/osu.Game/Overlays/Profile/Sections/Historical/PaginatedMostPlayedBeatmapContainer.cs index d42e00b1a5..916f1f437a 100644 --- a/osu.Game/Overlays/Profile/Sections/Historical/PaginatedMostPlayedBeatmapContainer.cs +++ b/osu.Game/Overlays/Profile/Sections/Historical/PaginatedMostPlayedBeatmapContainer.cs @@ -5,7 +5,6 @@ using System.Linq; using osu.Framework.Configuration; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; -using osu.Game.Beatmaps; using osu.Game.Online.API.Requests; using osu.Game.Users; diff --git a/osu.Game/Overlays/Profile/Sections/Ranks/DrawableScore.cs b/osu.Game/Overlays/Profile/Sections/Ranks/DrawableScore.cs index 6c475cbb26..4d210f399e 100644 --- a/osu.Game/Overlays/Profile/Sections/Ranks/DrawableScore.cs +++ b/osu.Game/Overlays/Profile/Sections/Ranks/DrawableScore.cs @@ -9,7 +9,6 @@ using osu.Game.Graphics; using osu.Game.Graphics.Sprites; using osu.Game.Rulesets.Mods; using osu.Game.Screens.Select.Leaderboards; -using osu.Framework.Localisation; using osu.Game.Rulesets.Scoring; using osu.Game.Rulesets.UI; using OpenTK.Graphics; @@ -113,7 +112,7 @@ namespace osu.Game.Overlays.Profile.Sections.Ranks } [BackgroundDependencyLoader(true)] - private void load(OsuColour colour, LocalisationEngine locale, BeatmapSetOverlay beatmapSetOverlay) + private void load(OsuColour colour) { coloredBackground.Colour = underscoreLine.Colour = colour.Gray4; From 57f2d8556bd9caacf2bc6616da73a64bf485ff64 Mon Sep 17 00:00:00 2001 From: jorolf Date: Wed, 22 Nov 2017 22:00:17 +0100 Subject: [PATCH 06/19] add a visual test --- .../Visual/TestCaseHistoricalSection.cs | 43 +++++++++++++++++++ osu.Game.Tests/osu.Game.Tests.csproj | 1 + 2 files changed, 44 insertions(+) create mode 100644 osu.Game.Tests/Visual/TestCaseHistoricalSection.cs diff --git a/osu.Game.Tests/Visual/TestCaseHistoricalSection.cs b/osu.Game.Tests/Visual/TestCaseHistoricalSection.cs new file mode 100644 index 0000000000..e67f389969 --- /dev/null +++ b/osu.Game.Tests/Visual/TestCaseHistoricalSection.cs @@ -0,0 +1,43 @@ +// 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 osu.Framework.Graphics; +using osu.Framework.Graphics.Containers; +using osu.Framework.Graphics.Shapes; +using osu.Game.Graphics; +using osu.Game.Overlays.Profile.Sections; +using osu.Game.Overlays.Profile.Sections.Historical; +using osu.Game.Users; + +namespace osu.Game.Tests.Visual +{ + internal class TestCaseHistoricalSection : OsuTestCase + { + public override string Description => "User's History"; + + public override IReadOnlyList RequiredTypes => new [] { typeof(HistoricalSection), typeof(MostPlayedBeatmapDrawable)}; + + + public TestCaseHistoricalSection() + { + HistoricalSection section; + + Add(new Box + { + RelativeSizeAxes = Axes.Both, + Colour = OsuColour.Gray(0.2f) + }); + + Add(new ScrollContainer + { + RelativeSizeAxes = Axes.Both, + Child = section = new HistoricalSection(), + }); + + AddStep("Show peppy", () => section.User.Value = new User { Id = 2 }); + AddStep("Show WubWoofWolf", () => section.User.Value = new User { Id = 39828 }); + } + } +} diff --git a/osu.Game.Tests/osu.Game.Tests.csproj b/osu.Game.Tests/osu.Game.Tests.csproj index 9bba09b1a7..b093989b45 100644 --- a/osu.Game.Tests/osu.Game.Tests.csproj +++ b/osu.Game.Tests/osu.Game.Tests.csproj @@ -110,6 +110,7 @@ + From 21d5d107381f28a8efb2642ba0cd88bf05459ce3 Mon Sep 17 00:00:00 2001 From: jorolf Date: Fri, 24 Nov 2017 22:48:56 +0100 Subject: [PATCH 07/19] replace BeatmapResponse with BeatmapInfo --- .../Visual/TestCaseHistoricalSection.cs | 2 +- osu.Game/Beatmaps/BeatmapInfo.cs | 1 + .../GetUserMostPlayedBeatmapsRequest.cs | 32 +++---------------- 3 files changed, 7 insertions(+), 28 deletions(-) diff --git a/osu.Game.Tests/Visual/TestCaseHistoricalSection.cs b/osu.Game.Tests/Visual/TestCaseHistoricalSection.cs index e67f389969..d75f9116ce 100644 --- a/osu.Game.Tests/Visual/TestCaseHistoricalSection.cs +++ b/osu.Game.Tests/Visual/TestCaseHistoricalSection.cs @@ -17,7 +17,7 @@ namespace osu.Game.Tests.Visual { public override string Description => "User's History"; - public override IReadOnlyList RequiredTypes => new [] { typeof(HistoricalSection), typeof(MostPlayedBeatmapDrawable)}; + public override IReadOnlyList RequiredTypes => new [] { typeof(HistoricalSection), typeof(PaginatedMostPlayedBeatmapContainer), typeof(MostPlayedBeatmapDrawable) }; public TestCaseHistoricalSection() diff --git a/osu.Game/Beatmaps/BeatmapInfo.cs b/osu.Game/Beatmaps/BeatmapInfo.cs index 022d64db03..f3a9694982 100644 --- a/osu.Game/Beatmaps/BeatmapInfo.cs +++ b/osu.Game/Beatmaps/BeatmapInfo.cs @@ -115,6 +115,7 @@ namespace osu.Game.Beatmaps // Metadata public string Version { get; set; } + [JsonProperty("difficulty_rating")] public double StarDifficulty { get; set; } public bool Equals(BeatmapInfo other) diff --git a/osu.Game/Online/API/Requests/GetUserMostPlayedBeatmapsRequest.cs b/osu.Game/Online/API/Requests/GetUserMostPlayedBeatmapsRequest.cs index cdc156be05..2d08f09d20 100644 --- a/osu.Game/Online/API/Requests/GetUserMostPlayedBeatmapsRequest.cs +++ b/osu.Game/Online/API/Requests/GetUserMostPlayedBeatmapsRequest.cs @@ -2,7 +2,6 @@ // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE using System; -using System.Linq; using Newtonsoft.Json; using osu.Game.Beatmaps; using osu.Game.Rulesets; @@ -28,7 +27,7 @@ namespace osu.Game.Online.API.Requests public int PlayCount; [JsonProperty] - private BeatmapResponse beatmap; + private BeatmapInfo beatmap; [JsonProperty] private GetBeatmapSetsResponse beatmapSet; @@ -36,31 +35,10 @@ namespace osu.Game.Online.API.Requests public BeatmapInfo GetBeatmapInfo(RulesetStore rulesets) { BeatmapSetInfo setInfo = beatmapSet.ToBeatmapSet(rulesets); - return new BeatmapInfo - { - OnlineBeatmapID = beatmap.Id, - OnlineBeatmapSetID = setInfo.OnlineBeatmapSetID, - Ruleset = rulesets.AvailableRulesets.FirstOrDefault(ruleset => ruleset.Name.Equals(beatmap.Mode)), - StarDifficulty = beatmap.DifficultyRating, - Version = beatmap.Version, - Metadata = setInfo.Metadata, - BeatmapSet = setInfo, - }; - } - - private class BeatmapResponse - { - [JsonProperty] - public int Id; - - [JsonProperty] - public string Mode; - - [JsonProperty("difficulty_rating")] - public double DifficultyRating; - - [JsonProperty] - public string Version; + beatmap.BeatmapSet = setInfo; + beatmap.OnlineBeatmapSetID = setInfo.OnlineBeatmapSetID; + beatmap.Metadata = setInfo.Metadata; + return beatmap; } } } From 6b3347d6acfabc2df1dd0444ca97a31637c8d214 Mon Sep 17 00:00:00 2001 From: jorolf Date: Fri, 24 Nov 2017 22:59:21 +0100 Subject: [PATCH 08/19] remove description --- osu.Game.Tests/Visual/TestCaseHistoricalSection.cs | 2 -- 1 file changed, 2 deletions(-) diff --git a/osu.Game.Tests/Visual/TestCaseHistoricalSection.cs b/osu.Game.Tests/Visual/TestCaseHistoricalSection.cs index d75f9116ce..37bb935787 100644 --- a/osu.Game.Tests/Visual/TestCaseHistoricalSection.cs +++ b/osu.Game.Tests/Visual/TestCaseHistoricalSection.cs @@ -15,8 +15,6 @@ namespace osu.Game.Tests.Visual { internal class TestCaseHistoricalSection : OsuTestCase { - public override string Description => "User's History"; - public override IReadOnlyList RequiredTypes => new [] { typeof(HistoricalSection), typeof(PaginatedMostPlayedBeatmapContainer), typeof(MostPlayedBeatmapDrawable) }; From 02fa1f9dd6c5418f68bccfd12d4015479855766b Mon Sep 17 00:00:00 2001 From: jorolf Date: Sun, 26 Nov 2017 21:52:35 +0100 Subject: [PATCH 09/19] move shared stuff between MostPlayedBeatmapDrawable and DrawableScore to DrawableBeatmapRow --- .../Profile/Sections/DrawableBeatmapRow.cs | 118 +++++++++++ .../Historical/MostPlayedBeatmapDrawable.cs | 188 +++++++----------- .../Ranks/DrawablePerformanceScore.cs | 4 +- .../Profile/Sections/Ranks/DrawableScore.cs | 119 ++--------- .../Sections/Ranks/DrawableTotalScore.cs | 2 +- osu.Game/osu.Game.csproj | 1 + 6 files changed, 213 insertions(+), 219 deletions(-) create mode 100644 osu.Game/Overlays/Profile/Sections/DrawableBeatmapRow.cs diff --git a/osu.Game/Overlays/Profile/Sections/DrawableBeatmapRow.cs b/osu.Game/Overlays/Profile/Sections/DrawableBeatmapRow.cs new file mode 100644 index 0000000000..f6800a5f32 --- /dev/null +++ b/osu.Game/Overlays/Profile/Sections/DrawableBeatmapRow.cs @@ -0,0 +1,118 @@ +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.Input; +using osu.Game.Graphics; +using OpenTK; +using OpenTK.Graphics; + +namespace osu.Game.Overlays.Profile.Sections +{ + public abstract class DrawableBeatmapRow : Container + { + private const int fade_duration = 200; + + private Box underscoreLine; + private readonly Box coloredBackground; + private readonly Container background; + + protected abstract Drawable CreatePicture(); + + protected FillFlowContainer LeftFlowContainer { get; private set; } + protected FillFlowContainer RightFlowContainer { get; private set; } + + protected override Container Content { get; } + + protected DrawableBeatmapRow() + { + RelativeSizeAxes = Axes.X; + Height = 60; + InternalChildren = new Drawable[] + { + background = new Container + { + RelativeSizeAxes = Axes.Both, + Masking = true, + CornerRadius = 3, + Alpha = 0, + EdgeEffect = new EdgeEffectParameters + { + Type = EdgeEffectType.Shadow, + Offset = new Vector2(0f, 1f), + Radius = 1f, + Colour = Color4.Black.Opacity(0.2f), + }, + Child = coloredBackground = new Box { RelativeSizeAxes = Axes.Both } + }, + Content = new Container + { + RelativeSizeAxes = Axes.Both, + Anchor = Anchor.TopCentre, + Origin = Anchor.TopCentre, + Width = 0.97f, + }, + }; + } + + [BackgroundDependencyLoader(true)] + private void load(OsuColour colour) + { + AddRange(new Drawable[] + { + underscoreLine = new Box + { + Anchor = Anchor.BottomCentre, + Origin = Anchor.BottomCentre, + RelativeSizeAxes = Axes.X, + Height = 1, + }, + new FillFlowContainer + { + RelativeSizeAxes = Axes.Both, + Direction = FillDirection.Horizontal, + Children = new[] + { + CreatePicture(), + LeftFlowContainer = new FillFlowContainer + { + RelativeSizeAxes = Axes.X, + AutoSizeAxes = Axes.Y, + Anchor = Anchor.CentreLeft, + Origin = Anchor.CentreLeft, + Margin = new MarginPadding { Left = 10 }, + Direction = FillDirection.Vertical, + }, + } + }, + RightFlowContainer = new FillFlowContainer + { + RelativeSizeAxes = Axes.X, + AutoSizeAxes = Axes.Y, + Anchor = Anchor.CentreRight, + Origin = Anchor.CentreRight, + Direction = FillDirection.Vertical, + }, + }); + + coloredBackground.Colour = underscoreLine.Colour = colour.Gray4; + } + + protected override bool OnClick(InputState state) => true; + + protected override bool OnHover(InputState state) + { + background.FadeIn(fade_duration, Easing.OutQuint); + underscoreLine.FadeOut(fade_duration, Easing.OutQuint); + return true; + } + + protected override void OnHoverLost(InputState state) + { + background.FadeOut(fade_duration, Easing.OutQuint); + underscoreLine.FadeIn(fade_duration, Easing.OutQuint); + base.OnHoverLost(state); + } + } +} diff --git a/osu.Game/Overlays/Profile/Sections/Historical/MostPlayedBeatmapDrawable.cs b/osu.Game/Overlays/Profile/Sections/Historical/MostPlayedBeatmapDrawable.cs index 0f419ad44e..446af667f2 100644 --- a/osu.Game/Overlays/Profile/Sections/Historical/MostPlayedBeatmapDrawable.cs +++ b/osu.Game/Overlays/Profile/Sections/Historical/MostPlayedBeatmapDrawable.cs @@ -2,14 +2,11 @@ // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE 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.Input; using osu.Game.Beatmaps; using osu.Game.Beatmaps.Drawables; -using osu.Game.Graphics; using osu.Game.Graphics.Containers; using osu.Game.Graphics.Sprites; using OpenTK; @@ -17,144 +14,99 @@ using OpenTK.Graphics; namespace osu.Game.Overlays.Profile.Sections.Historical { - public class MostPlayedBeatmapDrawable : Container + public class MostPlayedBeatmapDrawable : DrawableBeatmapRow { private readonly BeatmapInfo beatmap; - private readonly OsuHoverContainer mapperContainer; - - private readonly EdgeEffectParameters edgeEffectNormal = new EdgeEffectParameters - { - Type = EdgeEffectType.Shadow, - Offset = new Vector2(0, 1f), - Radius = 2f, - Colour = Color4.Black.Opacity(0.25f), - }; - - private readonly EdgeEffectParameters edgeEffectHovered = new EdgeEffectParameters - { - Type = EdgeEffectType.Shadow, - Offset = new Vector2(0, 5f), - Radius = 10f, - Colour = Color4.Black.Opacity(0.25f), - }; + private readonly int playCount; + private OsuHoverContainer mapperContainer; public MostPlayedBeatmapDrawable(BeatmapInfo beatmap, int playCount) { this.beatmap = beatmap; - RelativeSizeAxes = Axes.X; - Height = 50; - Margin = new MarginPadding { Bottom = 10 }; - Masking = true; - EdgeEffect = edgeEffectNormal; + this.playCount = playCount; + } + protected override Drawable CreatePicture() => new Container + { + Anchor = Anchor.CentreLeft, + Origin = Anchor.CentreLeft, + AutoSizeAxes = Axes.Both, Children = new Drawable[] { - new Box //Background for this container, otherwise the shadow would be visible - { - RelativeSizeAxes = Axes.Both, - Colour = OsuColour.Gray(0.2f), - }, new Box //Image Background while loading { - Size = new Vector2(80, 50), - Colour = Color4.Black, + Size = new Vector2(80, 50), + Colour = Color4.Black, }, new DelayedLoadWrapper(new BeatmapSetCover(beatmap.BeatmapSet, BeatmapSetCoverType.List) { RelativeSizeAxes = Axes.Both, FillMode = FillMode.Fit, }), - new FillFlowContainer - { - RelativeSizeAxes = Axes.Both, - Padding = new MarginPadding(10) { Left = 90 }, - Direction = FillDirection.Vertical, - Children = new Drawable[] - { - new Container - { - RelativeSizeAxes = Axes.X, - AutoSizeAxes = Axes.Y, - Children = new Drawable[] - { - new BeatmapMetadataContainer(beatmap), - new FillFlowContainer - { - Anchor = Anchor.TopRight, - Origin = Anchor.TopRight, - AutoSizeAxes = Axes.Both, - Direction = FillDirection.Horizontal, - Children = new [] - { - new OsuSpriteText - { - Anchor = Anchor.BottomRight, - Origin = Anchor.BottomRight, - Text = playCount.ToString(), - TextSize = 18, - Font = @"Exo2.0-SemiBoldItalic" - }, - new OsuSpriteText - { - Anchor = Anchor.BottomRight, - Origin = Anchor.BottomRight, - Text = @"times played ", - TextSize = 12, - Font = @"Exo2.0-RegularItalic" - }, - } - } - }, - }, - new FillFlowContainer - { - RelativeSizeAxes = Axes.X, - AutoSizeAxes = Axes.Y, - Direction = FillDirection.Horizontal, - Children = new Drawable[] - { - new OsuSpriteText - { - Text = @"mapped by ", - TextSize = 12, - }, - mapperContainer = new OsuHoverContainer - { - AutoSizeAxes = Axes.Both, - Children = new Drawable[] - { - new OsuSpriteText - { - Text = beatmap.Metadata.AuthorString, - TextSize = 12, - Font = @"Exo2.0-MediumItalic" - } - } - }, - } - }, - }, - } - }; - } + }, + }; [BackgroundDependencyLoader(true)] private void load(UserProfileOverlay profileOverlay) { + LeftFlowContainer.Add(new BeatmapMetadataContainer(beatmap)); + LeftFlowContainer.Add(new FillFlowContainer + { + RelativeSizeAxes = Axes.X, + AutoSizeAxes = Axes.Y, + Direction = FillDirection.Horizontal, + Children = new Drawable[] + { + new OsuSpriteText + { + Text = @"mapped by ", + TextSize = 12, + }, + mapperContainer = new OsuHoverContainer + { + AutoSizeAxes = Axes.Both, + Children = new Drawable[] + { + new OsuSpriteText + { + Text = beatmap.Metadata.AuthorString, + TextSize = 12, + Font = @"Exo2.0-MediumItalic" + } + } + }, + } + }); + + RightFlowContainer.Add(new FillFlowContainer + { + Anchor = Anchor.TopRight, + Origin = Anchor.TopRight, + AutoSizeAxes = Axes.Both, + Direction = FillDirection.Horizontal, + Children = new[] + { + new OsuSpriteText + { + Anchor = Anchor.BottomRight, + Origin = Anchor.BottomRight, + Text = playCount.ToString(), + TextSize = 18, + Font = @"Exo2.0-SemiBoldItalic" + }, + new OsuSpriteText + { + Anchor = Anchor.BottomRight, + Origin = Anchor.BottomRight, + Text = @"times played ", + TextSize = 12, + Font = @"Exo2.0-RegularItalic" + }, + } + }); + if(profileOverlay != null) mapperContainer.Action = () => profileOverlay.ShowUser(beatmap.BeatmapSet.Metadata.Author); } - - protected override bool OnHover(InputState state) - { - TweenEdgeEffectTo(edgeEffectHovered, 120, Easing.OutQuint); - return base.OnHover(state); - } - - protected override void OnHoverLost(InputState state) - { - TweenEdgeEffectTo(edgeEffectNormal, 120, Easing.OutQuint); - base.OnHoverLost(state); - } } } diff --git a/osu.Game/Overlays/Profile/Sections/Ranks/DrawablePerformanceScore.cs b/osu.Game/Overlays/Profile/Sections/Ranks/DrawablePerformanceScore.cs index e6ba5b26ac..cd13d14575 100644 --- a/osu.Game/Overlays/Profile/Sections/Ranks/DrawablePerformanceScore.cs +++ b/osu.Game/Overlays/Profile/Sections/Ranks/DrawablePerformanceScore.cs @@ -23,7 +23,7 @@ namespace osu.Game.Overlays.Profile.Sections.Ranks private void load(OsuColour colour) { double pp = Score.PP ?? 0; - Stats.Add(new OsuSpriteText + RightFlowContainer.Add(new OsuSpriteText { Text = $"{pp:0}pp", Anchor = Anchor.TopRight, @@ -34,7 +34,7 @@ namespace osu.Game.Overlays.Profile.Sections.Ranks if (weight.HasValue) { - Stats.Add(new OsuSpriteText + RightFlowContainer.Add(new OsuSpriteText { Text = $"weighted: {pp * weight:0}pp ({weight:P0})", Anchor = Anchor.TopRight, diff --git a/osu.Game/Overlays/Profile/Sections/Ranks/DrawableScore.cs b/osu.Game/Overlays/Profile/Sections/Ranks/DrawableScore.cs index 4d210f399e..db7647ce0e 100644 --- a/osu.Game/Overlays/Profile/Sections/Ranks/DrawableScore.cs +++ b/osu.Game/Overlays/Profile/Sections/Ranks/DrawableScore.cs @@ -11,24 +11,14 @@ using osu.Game.Rulesets.Mods; using osu.Game.Screens.Select.Leaderboards; using osu.Game.Rulesets.Scoring; using osu.Game.Rulesets.UI; -using OpenTK.Graphics; -using osu.Framework.Graphics.Shapes; -using osu.Framework.Input; -using osu.Framework.Extensions.Color4Extensions; namespace osu.Game.Overlays.Profile.Sections.Ranks { - public abstract class DrawableScore : Container + public abstract class DrawableScore : DrawableBeatmapRow { - private const int fade_duration = 200; - - protected readonly FillFlowContainer Stats; private readonly FillFlowContainer metadata; private readonly ScoreModsContainer modsContainer; protected readonly Score Score; - private readonly Box underscoreLine; - private readonly Box coloredBackground; - private readonly Container background; protected DrawableScore(Score score) { @@ -38,85 +28,21 @@ namespace osu.Game.Overlays.Profile.Sections.Ranks Height = 60; Children = new Drawable[] { - background = new Container + modsContainer = new ScoreModsContainer { - RelativeSizeAxes = Axes.Both, - Masking = true, - CornerRadius = 3, - Alpha = 0, - EdgeEffect = new EdgeEffectParameters - { - Type = EdgeEffectType.Shadow, - Offset = new Vector2(0f, 1f), - Radius = 1f, - Colour = Color4.Black.Opacity(0.2f), - }, - Child = coloredBackground = new Box { RelativeSizeAxes = Axes.Both } - }, - new Container - { - RelativeSizeAxes = Axes.Both, - Anchor = Anchor.TopCentre, - Origin = Anchor.TopCentre, - Width = 0.97f, - Children = new Drawable[] - { - underscoreLine = new Box - { - Anchor = Anchor.BottomCentre, - Origin = Anchor.BottomCentre, - RelativeSizeAxes = Axes.X, - Height = 1, - }, - new DrawableRank(score.Rank) - { - RelativeSizeAxes = Axes.Y, - Width = 60, - FillMode = FillMode.Fit, - }, - Stats = new FillFlowContainer - { - RelativeSizeAxes = Axes.X, - AutoSizeAxes = Axes.Y, - Anchor = Anchor.CentreRight, - Origin = Anchor.CentreRight, - Direction = FillDirection.Vertical, - }, - metadata = new FillFlowContainer - { - RelativeSizeAxes = Axes.X, - AutoSizeAxes = Axes.Y, - Anchor = Anchor.CentreLeft, - Origin = Anchor.CentreLeft, - Margin = new MarginPadding { Left = 70 }, - Direction = FillDirection.Vertical, - Child = new OsuSpriteText - { - Text = score.Date.LocalDateTime.ToShortDateString(), - TextSize = 11, - Colour = OsuColour.Gray(0xAA), - Depth = -1, - }, - }, - modsContainer = new ScoreModsContainer - { - AutoSizeAxes = Axes.Y, - Anchor = Anchor.CentreRight, - Origin = Anchor.CentreRight, - Width = 60, - Margin = new MarginPadding { Right = 160 } - } - } - }, + AutoSizeAxes = Axes.Y, + Anchor = Anchor.CentreRight, + Origin = Anchor.CentreRight, + Width = 60, + Margin = new MarginPadding { Right = 160 } + } }; } [BackgroundDependencyLoader(true)] private void load(OsuColour colour) { - coloredBackground.Colour = underscoreLine.Colour = colour.Gray4; - - Stats.Add(new OsuSpriteText + RightFlowContainer.Add(new OsuSpriteText { Text = $"accuracy: {Score.Accuracy:P2}", Anchor = Anchor.TopRight, @@ -127,26 +53,23 @@ namespace osu.Game.Overlays.Profile.Sections.Ranks Depth = -1, }); - metadata.Add(new BeatmapMetadataContainer(Score.Beatmap)); + LeftFlowContainer.Add(new BeatmapMetadataContainer(Score.Beatmap)); + LeftFlowContainer.Add(new OsuSpriteText + { + Text = Score.Date.LocalDateTime.ToShortDateString(), + TextSize = 11, + Colour = OsuColour.Gray(0xAA), + }); foreach (Mod mod in Score.Mods) modsContainer.Add(new ModIcon(mod) { Scale = new Vector2(0.5f) }); } - protected override bool OnClick(InputState state) => true; - - protected override bool OnHover(InputState state) + protected override Drawable CreatePicture() => new DrawableRank(Score.Rank) { - background.FadeIn(fade_duration, Easing.OutQuint); - underscoreLine.FadeOut(fade_duration, Easing.OutQuint); - return true; - } - - protected override void OnHoverLost(InputState state) - { - background.FadeOut(fade_duration, Easing.OutQuint); - underscoreLine.FadeIn(fade_duration, Easing.OutQuint); - base.OnHoverLost(state); - } + RelativeSizeAxes = Axes.Y, + Width = 60, + FillMode = FillMode.Fit, + }; } } diff --git a/osu.Game/Overlays/Profile/Sections/Ranks/DrawableTotalScore.cs b/osu.Game/Overlays/Profile/Sections/Ranks/DrawableTotalScore.cs index 537b208b39..1539142f1d 100644 --- a/osu.Game/Overlays/Profile/Sections/Ranks/DrawableTotalScore.cs +++ b/osu.Game/Overlays/Profile/Sections/Ranks/DrawableTotalScore.cs @@ -18,7 +18,7 @@ namespace osu.Game.Overlays.Profile.Sections.Ranks [BackgroundDependencyLoader] private void load() { - Stats.Add(new OsuSpriteText + RightFlowContainer.Add(new OsuSpriteText { Text = Score.TotalScore.ToString("#,###"), Anchor = Anchor.TopRight, diff --git a/osu.Game/osu.Game.csproj b/osu.Game/osu.Game.csproj index 4921c4ce05..b774602b76 100644 --- a/osu.Game/osu.Game.csproj +++ b/osu.Game/osu.Game.csproj @@ -294,6 +294,7 @@ + From 4c68090e59d2139c6bc53033c423b138c7963f3e Mon Sep 17 00:00:00 2001 From: jorolf Date: Sun, 26 Nov 2017 22:06:03 +0100 Subject: [PATCH 10/19] separate GetUserBeatmapsRequest and GetUserMostPlayedBeatmapsRequest --- .../API/Requests/GetUserBeatmapsRequest.cs | 16 ++-------------- .../Requests/GetUserMostPlayedBeatmapsRequest.cs | 16 ++++++++++------ .../PaginatedMostPlayedBeatmapContainer.cs | 2 +- 3 files changed, 13 insertions(+), 21 deletions(-) diff --git a/osu.Game/Online/API/Requests/GetUserBeatmapsRequest.cs b/osu.Game/Online/API/Requests/GetUserBeatmapsRequest.cs index dca0395e3a..691f8496d9 100644 --- a/osu.Game/Online/API/Requests/GetUserBeatmapsRequest.cs +++ b/osu.Game/Online/API/Requests/GetUserBeatmapsRequest.cs @@ -1,19 +1,18 @@ // Copyright (c) 2007-2017 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE -using System; using Humanizer; using System.Collections.Generic; namespace osu.Game.Online.API.Requests { - public abstract class GetUserBeatmapsRequest : APIRequest> + public class GetUserBeatmapsRequest : APIRequest> { private readonly long userId; private readonly int offset; private readonly BeatmapSetType type; - protected GetUserBeatmapsRequest(long userId, BeatmapSetType type, int offset = 0) + public GetUserBeatmapsRequest(long userId, BeatmapSetType type, int offset = 0) { this.userId = userId; this.offset = offset; @@ -23,19 +22,8 @@ namespace osu.Game.Online.API.Requests protected override string Target => $@"users/{userId}/beatmapsets/{type.ToString().Underscore()}?offset={offset}"; } - public class GetUserBeatmapsRequest : GetUserBeatmapsRequest - { - public GetUserBeatmapsRequest(long userID, BeatmapSetType type, int offset = 0) - : base(userID, type, offset) - { - if(type == BeatmapSetType.MostPlayed) - throw new ArgumentException("Please use " + nameof(GetUserMostPlayedBeatmapsRequest) + " instead"); - } - } - public enum BeatmapSetType { - MostPlayed, Favourite, RankedAndApproved, Unranked, diff --git a/osu.Game/Online/API/Requests/GetUserMostPlayedBeatmapsRequest.cs b/osu.Game/Online/API/Requests/GetUserMostPlayedBeatmapsRequest.cs index 2d08f09d20..c45ef734e6 100644 --- a/osu.Game/Online/API/Requests/GetUserMostPlayedBeatmapsRequest.cs +++ b/osu.Game/Online/API/Requests/GetUserMostPlayedBeatmapsRequest.cs @@ -1,21 +1,25 @@ // 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.Game.Beatmaps; using osu.Game.Rulesets; +using System.Collections.Generic; namespace osu.Game.Online.API.Requests { - public class GetUserMostPlayedBeatmapsRequest : GetUserBeatmapsRequest + public class GetUserMostPlayedBeatmapsRequest : APIRequest> { - public GetUserMostPlayedBeatmapsRequest(long userID, BeatmapSetType type, int offset = 0) - : base(userID, type, offset) + private readonly long userId; + private readonly int offset; + + public GetUserMostPlayedBeatmapsRequest(long userId, int offset = 0) { - if (type != BeatmapSetType.MostPlayed) - throw new ArgumentException("Please use " + nameof(GetUserBeatmapsRequest) + " instead"); + this.userId = userId; + this.offset = offset; } + + protected override string Target => $@"users/{userId}/beatmapsets/most_played?offset={offset}"; } public class UserMostPlayedBeatmapsResponse diff --git a/osu.Game/Overlays/Profile/Sections/Historical/PaginatedMostPlayedBeatmapContainer.cs b/osu.Game/Overlays/Profile/Sections/Historical/PaginatedMostPlayedBeatmapContainer.cs index 916f1f437a..b7df60a7a2 100644 --- a/osu.Game/Overlays/Profile/Sections/Historical/PaginatedMostPlayedBeatmapContainer.cs +++ b/osu.Game/Overlays/Profile/Sections/Historical/PaginatedMostPlayedBeatmapContainer.cs @@ -24,7 +24,7 @@ namespace osu.Game.Overlays.Profile.Sections.Historical { base.ShowMore(); - var req = new GetUserMostPlayedBeatmapsRequest(User.Value.Id, BeatmapSetType.MostPlayed, VisiblePages++ * ItemsPerPage); + var req = new GetUserMostPlayedBeatmapsRequest(User.Value.Id, VisiblePages++ * ItemsPerPage); req.Success += beatmaps => { From 70b6071898afa38590f00ca43accedb6b808e754 Mon Sep 17 00:00:00 2001 From: jorolf Date: Sun, 26 Nov 2017 22:13:52 +0100 Subject: [PATCH 11/19] add license header --- osu.Game/Overlays/Profile/Sections/DrawableBeatmapRow.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/osu.Game/Overlays/Profile/Sections/DrawableBeatmapRow.cs b/osu.Game/Overlays/Profile/Sections/DrawableBeatmapRow.cs index f6800a5f32..4d2affd77c 100644 --- a/osu.Game/Overlays/Profile/Sections/DrawableBeatmapRow.cs +++ b/osu.Game/Overlays/Profile/Sections/DrawableBeatmapRow.cs @@ -1,4 +1,7 @@ -using osu.Framework.Allocation; +// 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.Color4Extensions; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; From 7f068c0c683c297d4d1257ebe58eca6db26be55c Mon Sep 17 00:00:00 2001 From: jorolf Date: Mon, 27 Nov 2017 21:13:01 +0100 Subject: [PATCH 12/19] correct string mistake --- .../Sections/Historical/PaginatedMostPlayedBeatmapContainer.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Overlays/Profile/Sections/Historical/PaginatedMostPlayedBeatmapContainer.cs b/osu.Game/Overlays/Profile/Sections/Historical/PaginatedMostPlayedBeatmapContainer.cs index b7df60a7a2..cec0e9a775 100644 --- a/osu.Game/Overlays/Profile/Sections/Historical/PaginatedMostPlayedBeatmapContainer.cs +++ b/osu.Game/Overlays/Profile/Sections/Historical/PaginatedMostPlayedBeatmapContainer.cs @@ -13,7 +13,7 @@ namespace osu.Game.Overlays.Profile.Sections.Historical public class PaginatedMostPlayedBeatmapContainer : PaginatedContainer { public PaginatedMostPlayedBeatmapContainer(Bindable user) - :base(user, "Most Played Beatmaps", "No performance records. :(") + :base(user, "Most Played Beatmaps", "No records. :(") { ItemsPerPage = 5; From 14fdf98abc0aa6981ddf5d56c263c3b3a0446a7b Mon Sep 17 00:00:00 2001 From: jorolf Date: Wed, 29 Nov 2017 23:08:46 +0100 Subject: [PATCH 13/19] rename GetBeatmapSetsResponse --- .../{GetBeatmapSetsResponse.cs => APIResponseBeatmapSet.cs} | 6 +++--- osu.Game/Online/API/Requests/GetBeatmapSetRequest.cs | 2 +- osu.Game/Online/API/Requests/GetUserBeatmapsRequest.cs | 2 +- .../Online/API/Requests/GetUserMostPlayedBeatmapsRequest.cs | 2 +- osu.Game/Online/API/Requests/SearchBeatmapSetsRequest.cs | 2 +- osu.Game/osu.Game.csproj | 2 +- 6 files changed, 8 insertions(+), 8 deletions(-) rename osu.Game/Online/API/Requests/{GetBeatmapSetsResponse.cs => APIResponseBeatmapSet.cs} (91%) diff --git a/osu.Game/Online/API/Requests/GetBeatmapSetsResponse.cs b/osu.Game/Online/API/Requests/APIResponseBeatmapSet.cs similarity index 91% rename from osu.Game/Online/API/Requests/GetBeatmapSetsResponse.cs rename to osu.Game/Online/API/Requests/APIResponseBeatmapSet.cs index d187cabf31..90d99446c7 100644 --- a/osu.Game/Online/API/Requests/GetBeatmapSetsResponse.cs +++ b/osu.Game/Online/API/Requests/APIResponseBeatmapSet.cs @@ -10,7 +10,7 @@ using System; namespace osu.Game.Online.API.Requests { - public class GetBeatmapSetsResponse : BeatmapMetadata // todo: this is a bit wrong... + public class APIResponseBeatmapSet : BeatmapMetadata // todo: this is a bit wrong... { [JsonProperty(@"covers")] private BeatmapSetOnlineCovers covers { get; set; } @@ -45,7 +45,7 @@ namespace osu.Game.Online.API.Requests } [JsonProperty(@"beatmaps")] - private IEnumerable beatmaps { get; set; } + private IEnumerable beatmaps { get; set; } public BeatmapSetInfo ToBeatmapSet(RulesetStore rulesets) { @@ -69,7 +69,7 @@ namespace osu.Game.Online.API.Requests }; } - private class GetBeatmapSetsBeatmapResponse : BeatmapMetadata + private class APIResponseSetsBeatmap : BeatmapMetadata { [JsonProperty(@"id")] private int onlineBeatmapID { get; set; } diff --git a/osu.Game/Online/API/Requests/GetBeatmapSetRequest.cs b/osu.Game/Online/API/Requests/GetBeatmapSetRequest.cs index e0fdc9adf2..1e6ceaafc6 100644 --- a/osu.Game/Online/API/Requests/GetBeatmapSetRequest.cs +++ b/osu.Game/Online/API/Requests/GetBeatmapSetRequest.cs @@ -3,7 +3,7 @@ namespace osu.Game.Online.API.Requests { - public class GetBeatmapSetRequest : APIRequest + public class GetBeatmapSetRequest : APIRequest { private readonly int beatmapSetId; diff --git a/osu.Game/Online/API/Requests/GetUserBeatmapsRequest.cs b/osu.Game/Online/API/Requests/GetUserBeatmapsRequest.cs index 691f8496d9..173562e04d 100644 --- a/osu.Game/Online/API/Requests/GetUserBeatmapsRequest.cs +++ b/osu.Game/Online/API/Requests/GetUserBeatmapsRequest.cs @@ -6,7 +6,7 @@ using System.Collections.Generic; namespace osu.Game.Online.API.Requests { - public class GetUserBeatmapsRequest : APIRequest> + public class GetUserBeatmapsRequest : APIRequest> { private readonly long userId; private readonly int offset; diff --git a/osu.Game/Online/API/Requests/GetUserMostPlayedBeatmapsRequest.cs b/osu.Game/Online/API/Requests/GetUserMostPlayedBeatmapsRequest.cs index c45ef734e6..80409fc3b9 100644 --- a/osu.Game/Online/API/Requests/GetUserMostPlayedBeatmapsRequest.cs +++ b/osu.Game/Online/API/Requests/GetUserMostPlayedBeatmapsRequest.cs @@ -34,7 +34,7 @@ namespace osu.Game.Online.API.Requests private BeatmapInfo beatmap; [JsonProperty] - private GetBeatmapSetsResponse beatmapSet; + private APIResponseBeatmapSet beatmapSet; public BeatmapInfo GetBeatmapInfo(RulesetStore rulesets) { diff --git a/osu.Game/Online/API/Requests/SearchBeatmapSetsRequest.cs b/osu.Game/Online/API/Requests/SearchBeatmapSetsRequest.cs index 56858b3d56..4e6c70124f 100644 --- a/osu.Game/Online/API/Requests/SearchBeatmapSetsRequest.cs +++ b/osu.Game/Online/API/Requests/SearchBeatmapSetsRequest.cs @@ -9,7 +9,7 @@ using osu.Game.Rulesets; namespace osu.Game.Online.API.Requests { - public class SearchBeatmapSetsRequest : APIRequest> + public class SearchBeatmapSetsRequest : APIRequest> { private readonly string query; private readonly RulesetInfo ruleset; diff --git a/osu.Game/osu.Game.csproj b/osu.Game/osu.Game.csproj index b774602b76..947300cba0 100644 --- a/osu.Game/osu.Game.csproj +++ b/osu.Game/osu.Game.csproj @@ -285,7 +285,7 @@ - + From e629cebe31b02c5db828a8cfbce154a7b73af923 Mon Sep 17 00:00:00 2001 From: Aergwyn Date: Sun, 10 Dec 2017 13:22:46 +0100 Subject: [PATCH 14/19] fix MusicController ignoring Looping property of a Track my fix to prevent the MusicController from constantly trying to restart a track before accidentally removed this --- 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 b30ee8f6fc..b8f33c9a60 100644 --- a/osu.Game/Overlays/MusicController.cs +++ b/osu.Game/Overlays/MusicController.cs @@ -251,7 +251,7 @@ namespace osu.Game.Overlays playButton.Icon = track.IsRunning ? FontAwesome.fa_pause_circle_o : FontAwesome.fa_play_circle_o; - if (track.HasCompleted && !beatmapBacking.Disabled && playlist.BeatmapSets.Any()) + if (track.HasCompleted && !track.Looping && !beatmapBacking.Disabled && playlist.BeatmapSets.Any()) next(); } else From 91335a83ec5121a4434e1b5cc67d68a03f334869 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Mon, 11 Dec 2017 12:24:47 +0900 Subject: [PATCH 15/19] Remove unnecessary whitespace --- osu.Game.Tests/Visual/TestCaseHistoricalSection.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/osu.Game.Tests/Visual/TestCaseHistoricalSection.cs b/osu.Game.Tests/Visual/TestCaseHistoricalSection.cs index 37bb935787..7f991dc5a6 100644 --- a/osu.Game.Tests/Visual/TestCaseHistoricalSection.cs +++ b/osu.Game.Tests/Visual/TestCaseHistoricalSection.cs @@ -17,7 +17,6 @@ namespace osu.Game.Tests.Visual { public override IReadOnlyList RequiredTypes => new [] { typeof(HistoricalSection), typeof(PaginatedMostPlayedBeatmapContainer), typeof(MostPlayedBeatmapDrawable) }; - public TestCaseHistoricalSection() { HistoricalSection section; From 507d0e3252d66311f8f774df5b95c544f36b8755 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Mon, 11 Dec 2017 12:25:29 +0900 Subject: [PATCH 16/19] Use more sensible names for classes --- osu.Game/Online/API/Requests/APIResponseBeatmapSet.cs | 4 ++-- .../Online/API/Requests/GetUserMostPlayedBeatmapsRequest.cs | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/osu.Game/Online/API/Requests/APIResponseBeatmapSet.cs b/osu.Game/Online/API/Requests/APIResponseBeatmapSet.cs index 90d99446c7..1b30853421 100644 --- a/osu.Game/Online/API/Requests/APIResponseBeatmapSet.cs +++ b/osu.Game/Online/API/Requests/APIResponseBeatmapSet.cs @@ -45,7 +45,7 @@ namespace osu.Game.Online.API.Requests } [JsonProperty(@"beatmaps")] - private IEnumerable beatmaps { get; set; } + private IEnumerable beatmaps { get; set; } public BeatmapSetInfo ToBeatmapSet(RulesetStore rulesets) { @@ -69,7 +69,7 @@ namespace osu.Game.Online.API.Requests }; } - private class APIResponseSetsBeatmap : BeatmapMetadata + private class APIResponseBeatmap : BeatmapMetadata { [JsonProperty(@"id")] private int onlineBeatmapID { get; set; } diff --git a/osu.Game/Online/API/Requests/GetUserMostPlayedBeatmapsRequest.cs b/osu.Game/Online/API/Requests/GetUserMostPlayedBeatmapsRequest.cs index 80409fc3b9..431a14085f 100644 --- a/osu.Game/Online/API/Requests/GetUserMostPlayedBeatmapsRequest.cs +++ b/osu.Game/Online/API/Requests/GetUserMostPlayedBeatmapsRequest.cs @@ -8,7 +8,7 @@ using System.Collections.Generic; namespace osu.Game.Online.API.Requests { - public class GetUserMostPlayedBeatmapsRequest : APIRequest> + public class GetUserMostPlayedBeatmapsRequest : APIRequest> { private readonly long userId; private readonly int offset; @@ -22,7 +22,7 @@ namespace osu.Game.Online.API.Requests protected override string Target => $@"users/{userId}/beatmapsets/most_played?offset={offset}"; } - public class UserMostPlayedBeatmapsResponse + public class MostPlayedBeatmap { [JsonProperty("beatmap_id")] public int BeatmapID; From 98ce856de1d319318b0e33c5308643b2d35f3028 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Mon, 11 Dec 2017 12:31:35 +0900 Subject: [PATCH 17/19] Use more sensible names for classes and methods Adds xmldoc in places too. --- osu.Game.Tests/Visual/TestCaseHistoricalSection.cs | 2 +- .../Profile/Sections/BeatmapMetadataContainer.cs | 3 +++ .../{DrawableBeatmapRow.cs => DrawableProfileRow.cs} | 11 +++++++---- ...yedBeatmapDrawable.cs => DrawableMostPlayedRow.cs} | 6 +++--- .../Historical/PaginatedMostPlayedBeatmapContainer.cs | 2 +- .../Overlays/Profile/Sections/Ranks/DrawableScore.cs | 4 ++-- osu.Game/osu.Game.csproj | 4 ++-- 7 files changed, 19 insertions(+), 13 deletions(-) rename osu.Game/Overlays/Profile/Sections/{DrawableBeatmapRow.cs => DrawableProfileRow.cs} (89%) rename osu.Game/Overlays/Profile/Sections/Historical/{MostPlayedBeatmapDrawable.cs => DrawableMostPlayedRow.cs} (92%) diff --git a/osu.Game.Tests/Visual/TestCaseHistoricalSection.cs b/osu.Game.Tests/Visual/TestCaseHistoricalSection.cs index 7f991dc5a6..a1cb28bfef 100644 --- a/osu.Game.Tests/Visual/TestCaseHistoricalSection.cs +++ b/osu.Game.Tests/Visual/TestCaseHistoricalSection.cs @@ -15,7 +15,7 @@ namespace osu.Game.Tests.Visual { internal class TestCaseHistoricalSection : OsuTestCase { - public override IReadOnlyList RequiredTypes => new [] { typeof(HistoricalSection), typeof(PaginatedMostPlayedBeatmapContainer), typeof(MostPlayedBeatmapDrawable) }; + public override IReadOnlyList RequiredTypes => new [] { typeof(HistoricalSection), typeof(PaginatedMostPlayedBeatmapContainer), typeof(DrawableMostPlayedRow) }; public TestCaseHistoricalSection() { diff --git a/osu.Game/Overlays/Profile/Sections/BeatmapMetadataContainer.cs b/osu.Game/Overlays/Profile/Sections/BeatmapMetadataContainer.cs index 5104f98f9d..bfd8db5d9c 100644 --- a/osu.Game/Overlays/Profile/Sections/BeatmapMetadataContainer.cs +++ b/osu.Game/Overlays/Profile/Sections/BeatmapMetadataContainer.cs @@ -11,6 +11,9 @@ using osu.Game.Graphics.Containers; using osu.Game.Graphics.Sprites; namespace osu.Game.Overlays.Profile.Sections { + /// + /// Display artist/title/mapper information, commonly used as the left portion of a profile or score display row (see ). + /// public class BeatmapMetadataContainer : OsuHoverContainer, IHasTooltip { private readonly BeatmapInfo beatmap; diff --git a/osu.Game/Overlays/Profile/Sections/DrawableBeatmapRow.cs b/osu.Game/Overlays/Profile/Sections/DrawableProfileRow.cs similarity index 89% rename from osu.Game/Overlays/Profile/Sections/DrawableBeatmapRow.cs rename to osu.Game/Overlays/Profile/Sections/DrawableProfileRow.cs index 4d2affd77c..0607549f20 100644 --- a/osu.Game/Overlays/Profile/Sections/DrawableBeatmapRow.cs +++ b/osu.Game/Overlays/Profile/Sections/DrawableProfileRow.cs @@ -13,7 +13,7 @@ using OpenTK.Graphics; namespace osu.Game.Overlays.Profile.Sections { - public abstract class DrawableBeatmapRow : Container + public abstract class DrawableProfileRow : Container { private const int fade_duration = 200; @@ -21,14 +21,17 @@ namespace osu.Game.Overlays.Profile.Sections private readonly Box coloredBackground; private readonly Container background; - protected abstract Drawable CreatePicture(); + /// + /// A visual element displayed to the left of content. + /// + protected abstract Drawable CreateLeftVisual(); protected FillFlowContainer LeftFlowContainer { get; private set; } protected FillFlowContainer RightFlowContainer { get; private set; } protected override Container Content { get; } - protected DrawableBeatmapRow() + protected DrawableProfileRow() { RelativeSizeAxes = Axes.X; Height = 60; @@ -77,7 +80,7 @@ namespace osu.Game.Overlays.Profile.Sections Direction = FillDirection.Horizontal, Children = new[] { - CreatePicture(), + CreateLeftVisual(), LeftFlowContainer = new FillFlowContainer { RelativeSizeAxes = Axes.X, diff --git a/osu.Game/Overlays/Profile/Sections/Historical/MostPlayedBeatmapDrawable.cs b/osu.Game/Overlays/Profile/Sections/Historical/DrawableMostPlayedRow.cs similarity index 92% rename from osu.Game/Overlays/Profile/Sections/Historical/MostPlayedBeatmapDrawable.cs rename to osu.Game/Overlays/Profile/Sections/Historical/DrawableMostPlayedRow.cs index 446af667f2..0b5e376fd6 100644 --- a/osu.Game/Overlays/Profile/Sections/Historical/MostPlayedBeatmapDrawable.cs +++ b/osu.Game/Overlays/Profile/Sections/Historical/DrawableMostPlayedRow.cs @@ -14,19 +14,19 @@ using OpenTK.Graphics; namespace osu.Game.Overlays.Profile.Sections.Historical { - public class MostPlayedBeatmapDrawable : DrawableBeatmapRow + public class DrawableMostPlayedRow : DrawableProfileRow { private readonly BeatmapInfo beatmap; private readonly int playCount; private OsuHoverContainer mapperContainer; - public MostPlayedBeatmapDrawable(BeatmapInfo beatmap, int playCount) + public DrawableMostPlayedRow(BeatmapInfo beatmap, int playCount) { this.beatmap = beatmap; this.playCount = playCount; } - protected override Drawable CreatePicture() => new Container + protected override Drawable CreateLeftVisual() => new Container { Anchor = Anchor.CentreLeft, Origin = Anchor.CentreLeft, diff --git a/osu.Game/Overlays/Profile/Sections/Historical/PaginatedMostPlayedBeatmapContainer.cs b/osu.Game/Overlays/Profile/Sections/Historical/PaginatedMostPlayedBeatmapContainer.cs index cec0e9a775..e54f012faf 100644 --- a/osu.Game/Overlays/Profile/Sections/Historical/PaginatedMostPlayedBeatmapContainer.cs +++ b/osu.Game/Overlays/Profile/Sections/Historical/PaginatedMostPlayedBeatmapContainer.cs @@ -41,7 +41,7 @@ namespace osu.Game.Overlays.Profile.Sections.Historical foreach (var beatmap in beatmaps) { - ItemsContainer.Add(new MostPlayedBeatmapDrawable(beatmap.GetBeatmapInfo(Rulesets), beatmap.PlayCount)); + ItemsContainer.Add(new DrawableMostPlayedRow(beatmap.GetBeatmapInfo(Rulesets), beatmap.PlayCount)); } }; diff --git a/osu.Game/Overlays/Profile/Sections/Ranks/DrawableScore.cs b/osu.Game/Overlays/Profile/Sections/Ranks/DrawableScore.cs index db7647ce0e..9fa828802a 100644 --- a/osu.Game/Overlays/Profile/Sections/Ranks/DrawableScore.cs +++ b/osu.Game/Overlays/Profile/Sections/Ranks/DrawableScore.cs @@ -14,7 +14,7 @@ using osu.Game.Rulesets.UI; namespace osu.Game.Overlays.Profile.Sections.Ranks { - public abstract class DrawableScore : DrawableBeatmapRow + public abstract class DrawableScore : DrawableProfileRow { private readonly FillFlowContainer metadata; private readonly ScoreModsContainer modsContainer; @@ -65,7 +65,7 @@ namespace osu.Game.Overlays.Profile.Sections.Ranks modsContainer.Add(new ModIcon(mod) { Scale = new Vector2(0.5f) }); } - protected override Drawable CreatePicture() => new DrawableRank(Score.Rank) + protected override Drawable CreateLeftVisual() => new DrawableRank(Score.Rank) { RelativeSizeAxes = Axes.Y, Width = 60, diff --git a/osu.Game/osu.Game.csproj b/osu.Game/osu.Game.csproj index 934eeafc03..0e93844de6 100644 --- a/osu.Game/osu.Game.csproj +++ b/osu.Game/osu.Game.csproj @@ -296,8 +296,8 @@ - - + + From 0c2158ccbd17e7864488e61038ecefaebcda3b8e Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Mon, 11 Dec 2017 12:47:31 +0900 Subject: [PATCH 18/19] Improve display of beatmap thumbnails --- .../Visual/TestCaseHistoricalSection.cs | 9 +++++- .../Historical/DrawableMostPlayedRow.cs | 31 +++++++------------ 2 files changed, 20 insertions(+), 20 deletions(-) diff --git a/osu.Game.Tests/Visual/TestCaseHistoricalSection.cs b/osu.Game.Tests/Visual/TestCaseHistoricalSection.cs index a1cb28bfef..17d45748ff 100644 --- a/osu.Game.Tests/Visual/TestCaseHistoricalSection.cs +++ b/osu.Game.Tests/Visual/TestCaseHistoricalSection.cs @@ -15,7 +15,14 @@ namespace osu.Game.Tests.Visual { internal class TestCaseHistoricalSection : OsuTestCase { - public override IReadOnlyList RequiredTypes => new [] { typeof(HistoricalSection), typeof(PaginatedMostPlayedBeatmapContainer), typeof(DrawableMostPlayedRow) }; + public override IReadOnlyList RequiredTypes => + new[] + { + typeof(HistoricalSection), + typeof(PaginatedMostPlayedBeatmapContainer), + typeof(DrawableMostPlayedRow), + typeof(DrawableProfileRow) + }; public TestCaseHistoricalSection() { diff --git a/osu.Game/Overlays/Profile/Sections/Historical/DrawableMostPlayedRow.cs b/osu.Game/Overlays/Profile/Sections/Historical/DrawableMostPlayedRow.cs index 0b5e376fd6..14ab5d8279 100644 --- a/osu.Game/Overlays/Profile/Sections/Historical/DrawableMostPlayedRow.cs +++ b/osu.Game/Overlays/Profile/Sections/Historical/DrawableMostPlayedRow.cs @@ -4,13 +4,11 @@ using osu.Framework.Allocation; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; -using osu.Framework.Graphics.Shapes; using osu.Game.Beatmaps; using osu.Game.Beatmaps.Drawables; using osu.Game.Graphics.Containers; using osu.Game.Graphics.Sprites; using OpenTK; -using OpenTK.Graphics; namespace osu.Game.Overlays.Profile.Sections.Historical { @@ -26,24 +24,19 @@ namespace osu.Game.Overlays.Profile.Sections.Historical this.playCount = playCount; } - protected override Drawable CreateLeftVisual() => new Container + protected override Drawable CreateLeftVisual() => new DelayedLoadWrapper(new BeatmapSetCover(beatmap.BeatmapSet, BeatmapSetCoverType.List) + { + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + FillMode = FillMode.Fit, + RelativeSizeAxes = Axes.Both, + OnLoadComplete = d => d.FadeInFromZero(500, Easing.OutQuint) + }) { - Anchor = Anchor.CentreLeft, Origin = Anchor.CentreLeft, - AutoSizeAxes = Axes.Both, - Children = new Drawable[] - { - new Box //Image Background while loading - { - Size = new Vector2(80, 50), - Colour = Color4.Black, - }, - new DelayedLoadWrapper(new BeatmapSetCover(beatmap.BeatmapSet, BeatmapSetCoverType.List) - { - RelativeSizeAxes = Axes.Both, - FillMode = FillMode.Fit, - }), - }, + Anchor = Anchor.CentreLeft, + RelativeSizeAxes = Axes.None, + Size = new Vector2(80, 50), }; [BackgroundDependencyLoader(true)] @@ -105,7 +98,7 @@ namespace osu.Game.Overlays.Profile.Sections.Historical } }); - if(profileOverlay != null) + if (profileOverlay != null) mapperContainer.Action = () => profileOverlay.ShowUser(beatmap.BeatmapSet.Metadata.Author); } } From 7d8fb1233288f26278f7e0a78006897e1fe3bb13 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Mon, 11 Dec 2017 12:51:02 +0900 Subject: [PATCH 19/19] DrawableScore -> DrawableProfileScore Discern between the other class of the same name --- osu.Game.Tests/Visual/TestCaseUserRanks.cs | 2 +- .../Profile/Sections/Ranks/DrawablePerformanceScore.cs | 2 +- .../Ranks/{DrawableScore.cs => DrawableProfileScore.cs} | 4 ++-- .../Overlays/Profile/Sections/Ranks/DrawableTotalScore.cs | 2 +- .../Profile/Sections/Ranks/PaginatedScoreContainer.cs | 2 +- osu.Game/osu.Game.csproj | 2 +- 6 files changed, 7 insertions(+), 7 deletions(-) rename osu.Game/Overlays/Profile/Sections/Ranks/{DrawableScore.cs => DrawableProfileScore.cs} (92%) diff --git a/osu.Game.Tests/Visual/TestCaseUserRanks.cs b/osu.Game.Tests/Visual/TestCaseUserRanks.cs index eb0678203c..c0c488673b 100644 --- a/osu.Game.Tests/Visual/TestCaseUserRanks.cs +++ b/osu.Game.Tests/Visual/TestCaseUserRanks.cs @@ -15,7 +15,7 @@ namespace osu.Game.Tests.Visual { internal class TestCaseUserRanks : OsuTestCase { - public override IReadOnlyList RequiredTypes => new[] { typeof(DrawableScore), typeof(RanksSection) }; + public override IReadOnlyList RequiredTypes => new[] { typeof(DrawableProfileScore), typeof(RanksSection) }; public TestCaseUserRanks() { diff --git a/osu.Game/Overlays/Profile/Sections/Ranks/DrawablePerformanceScore.cs b/osu.Game/Overlays/Profile/Sections/Ranks/DrawablePerformanceScore.cs index cd13d14575..c3296dae4f 100644 --- a/osu.Game/Overlays/Profile/Sections/Ranks/DrawablePerformanceScore.cs +++ b/osu.Game/Overlays/Profile/Sections/Ranks/DrawablePerformanceScore.cs @@ -9,7 +9,7 @@ using osu.Game.Rulesets.Scoring; namespace osu.Game.Overlays.Profile.Sections.Ranks { - public class DrawablePerformanceScore : DrawableScore + public class DrawablePerformanceScore : DrawableProfileScore { private readonly double? weight; diff --git a/osu.Game/Overlays/Profile/Sections/Ranks/DrawableScore.cs b/osu.Game/Overlays/Profile/Sections/Ranks/DrawableProfileScore.cs similarity index 92% rename from osu.Game/Overlays/Profile/Sections/Ranks/DrawableScore.cs rename to osu.Game/Overlays/Profile/Sections/Ranks/DrawableProfileScore.cs index 9fa828802a..06e4684d4c 100644 --- a/osu.Game/Overlays/Profile/Sections/Ranks/DrawableScore.cs +++ b/osu.Game/Overlays/Profile/Sections/Ranks/DrawableProfileScore.cs @@ -14,13 +14,13 @@ using osu.Game.Rulesets.UI; namespace osu.Game.Overlays.Profile.Sections.Ranks { - public abstract class DrawableScore : DrawableProfileRow + public abstract class DrawableProfileScore : DrawableProfileRow { private readonly FillFlowContainer metadata; private readonly ScoreModsContainer modsContainer; protected readonly Score Score; - protected DrawableScore(Score score) + protected DrawableProfileScore(Score score) { Score = score; diff --git a/osu.Game/Overlays/Profile/Sections/Ranks/DrawableTotalScore.cs b/osu.Game/Overlays/Profile/Sections/Ranks/DrawableTotalScore.cs index 1539142f1d..56b2950f89 100644 --- a/osu.Game/Overlays/Profile/Sections/Ranks/DrawableTotalScore.cs +++ b/osu.Game/Overlays/Profile/Sections/Ranks/DrawableTotalScore.cs @@ -8,7 +8,7 @@ using osu.Game.Rulesets.Scoring; namespace osu.Game.Overlays.Profile.Sections.Ranks { - public class DrawableTotalScore : DrawableScore + public class DrawableTotalScore : DrawableProfileScore { public DrawableTotalScore(Score score) : base(score) diff --git a/osu.Game/Overlays/Profile/Sections/Ranks/PaginatedScoreContainer.cs b/osu.Game/Overlays/Profile/Sections/Ranks/PaginatedScoreContainer.cs index dc30934990..472800860c 100644 --- a/osu.Game/Overlays/Profile/Sections/Ranks/PaginatedScoreContainer.cs +++ b/osu.Game/Overlays/Profile/Sections/Ranks/PaginatedScoreContainer.cs @@ -51,7 +51,7 @@ namespace osu.Game.Overlays.Profile.Sections.Ranks foreach (OnlineScore score in scores) { - DrawableScore drawableScore; + DrawableProfileScore drawableScore; switch (type) { diff --git a/osu.Game/osu.Game.csproj b/osu.Game/osu.Game.csproj index 0e93844de6..f8041b8b5e 100644 --- a/osu.Game/osu.Game.csproj +++ b/osu.Game/osu.Game.csproj @@ -488,7 +488,7 @@ - +