From 894b50f95572899305df5868236acdf8723d70ac Mon Sep 17 00:00:00 2001 From: Andrei Zavatski Date: Sat, 22 Feb 2020 03:24:50 +0300 Subject: [PATCH 1/3] Basic implementation of BeatmapSetCommentsContainer --- osu.Game/Overlays/BeatmapSet/Info.cs | 11 ---- osu.Game/Overlays/BeatmapSetOverlay.cs | 76 ++++++++++++++++++++++---- 2 files changed, 65 insertions(+), 22 deletions(-) diff --git a/osu.Game/Overlays/BeatmapSet/Info.cs b/osu.Game/Overlays/BeatmapSet/Info.cs index 0f2d6a9e35..bac658b76e 100644 --- a/osu.Game/Overlays/BeatmapSet/Info.cs +++ b/osu.Game/Overlays/BeatmapSet/Info.cs @@ -3,17 +3,14 @@ using osu.Framework.Allocation; using osu.Framework.Bindables; -using osu.Framework.Extensions.Color4Extensions; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; -using osu.Framework.Graphics.Effects; using osu.Framework.Graphics.Shapes; using osu.Game.Beatmaps; using osu.Game.Graphics; using osu.Game.Graphics.Containers; using osu.Game.Graphics.Sprites; using osuTK; -using osuTK.Graphics; namespace osu.Game.Overlays.BeatmapSet { @@ -43,14 +40,6 @@ namespace osu.Game.Overlays.BeatmapSet RelativeSizeAxes = Axes.X; Height = base_height; - Masking = true; - EdgeEffect = new EdgeEffectParameters - { - Colour = Color4.Black.Opacity(0.25f), - Type = EdgeEffectType.Shadow, - Radius = 3, - Offset = new Vector2(0f, 1f), - }; Children = new Drawable[] { diff --git a/osu.Game/Overlays/BeatmapSetOverlay.cs b/osu.Game/Overlays/BeatmapSetOverlay.cs index d29997f7e5..5b5580f286 100644 --- a/osu.Game/Overlays/BeatmapSetOverlay.cs +++ b/osu.Game/Overlays/BeatmapSetOverlay.cs @@ -4,8 +4,10 @@ using System.Linq; using osu.Framework.Allocation; using osu.Framework.Bindables; +using osu.Framework.Extensions.Color4Extensions; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; +using osu.Framework.Graphics.Effects; using osu.Framework.Graphics.Shapes; using osu.Framework.Input.Events; using osu.Game.Beatmaps; @@ -13,8 +15,10 @@ using osu.Game.Graphics.Containers; using osu.Game.Online.API.Requests; using osu.Game.Overlays.BeatmapSet; using osu.Game.Overlays.BeatmapSet.Scores; +using osu.Game.Overlays.Comments; using osu.Game.Rulesets; using osuTK; +using osuTK.Graphics; namespace osu.Game.Overlays { @@ -40,6 +44,7 @@ namespace osu.Game.Overlays { OsuScrollContainer scroll; Info info; + BeatmapSetCommentsContainer comments; Children = new Drawable[] { @@ -51,28 +56,38 @@ namespace osu.Game.Overlays { RelativeSizeAxes = Axes.Both, ScrollbarVisible = false, - Child = new ReverseChildIDFillFlowContainer + Child = new ReverseChildIDFillFlowContainer
{ RelativeSizeAxes = Axes.X, AutoSizeAxes = Axes.Y, Direction = FillDirection.Vertical, Spacing = new Vector2(0, 20), - Children = new Drawable[] + Children = new[] { - new ReverseChildIDFillFlowContainer + new Section { - AutoSizeAxes = Axes.Y, - RelativeSizeAxes = Axes.X, - Direction = FillDirection.Vertical, - Children = new Drawable[] + Child = new ReverseChildIDFillFlowContainer { - Header = new Header(), - info = new Info() + AutoSizeAxes = Axes.Y, + RelativeSizeAxes = Axes.X, + Direction = FillDirection.Vertical, + Children = new Drawable[] + { + Header = new Header(), + info = new Info() + } + }, + }, + new Section + { + Child = new ScoresContainer + { + Beatmap = { BindTarget = Header.Picker.Beatmap } } }, - new ScoresContainer + new Section { - Beatmap = { BindTarget = Header.Picker.Beatmap } + Child = comments = new BeatmapSetCommentsContainer() } }, }, @@ -81,6 +96,7 @@ namespace osu.Game.Overlays Header.BeatmapSet.BindTo(beatmapSet); info.BeatmapSet.BindTo(beatmapSet); + comments.BeatmapSet.BindTo(beatmapSet); Header.Picker.Beatmap.ValueChanged += b => { @@ -143,5 +159,43 @@ namespace osu.Game.Overlays beatmapSet.Value = set; Show(); } + + private class Section : Container + { + public Section() + { + RelativeSizeAxes = Axes.X; + AutoSizeAxes = Axes.Y; + Masking = true; + EdgeEffect = new EdgeEffectParameters + { + Colour = Color4.Black.Opacity(0.25f), + Type = EdgeEffectType.Shadow, + Radius = 3, + Offset = new Vector2(0f, 1f), + }; + } + } + + private class BeatmapSetCommentsContainer : CommentsContainer + { + public readonly Bindable BeatmapSet = new Bindable(); + + public BeatmapSetCommentsContainer() + { + BeatmapSet.BindValueChanged(beatmapSet => + { + if (beatmapSet.NewValue?.OnlineBeatmapSetID.HasValue != true) + { + Hide(); + } + else + { + Show(); + ShowComments(CommentableType.Beatmapset, beatmapSet.NewValue.OnlineBeatmapSetID.Value); + } + }, true); + } + } } } From 63006e8672276d44ccd85ae12a163087e6d84cb5 Mon Sep 17 00:00:00 2001 From: Andrei Zavatski Date: Sat, 22 Feb 2020 03:40:59 +0300 Subject: [PATCH 2/3] Refactor to avoid visual inconsistency for beatmaps with no leaderboard --- .../BeatmapSet/BeatmapSetLayoutSection.cs | 29 +++++++++++ .../BeatmapSet/Scores/ScoresContainer.cs | 17 +++---- osu.Game/Overlays/BeatmapSetOverlay.cs | 48 +++++-------------- 3 files changed, 49 insertions(+), 45 deletions(-) create mode 100644 osu.Game/Overlays/BeatmapSet/BeatmapSetLayoutSection.cs diff --git a/osu.Game/Overlays/BeatmapSet/BeatmapSetLayoutSection.cs b/osu.Game/Overlays/BeatmapSet/BeatmapSetLayoutSection.cs new file mode 100644 index 0000000000..e6d433f7bc --- /dev/null +++ b/osu.Game/Overlays/BeatmapSet/BeatmapSetLayoutSection.cs @@ -0,0 +1,29 @@ +// 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.Extensions.Color4Extensions; +using osu.Framework.Graphics; +using osu.Framework.Graphics.Containers; +using osu.Framework.Graphics.Effects; +using osuTK; +using osuTK.Graphics; + +namespace osu.Game.Overlays.BeatmapSet +{ + public class BeatmapSetLayoutSection : Container + { + public BeatmapSetLayoutSection() + { + RelativeSizeAxes = Axes.X; + AutoSizeAxes = Axes.Y; + Masking = true; + EdgeEffect = new EdgeEffectParameters + { + Colour = Color4.Black.Opacity(0.25f), + Type = EdgeEffectType.Shadow, + Radius = 3, + Offset = new Vector2(0f, 1f), + }; + } + } +} diff --git a/osu.Game/Overlays/BeatmapSet/Scores/ScoresContainer.cs b/osu.Game/Overlays/BeatmapSet/Scores/ScoresContainer.cs index e831c8ce42..7607eac1f8 100644 --- a/osu.Game/Overlays/BeatmapSet/Scores/ScoresContainer.cs +++ b/osu.Game/Overlays/BeatmapSet/Scores/ScoresContainer.cs @@ -19,7 +19,7 @@ using osu.Game.Users; namespace osu.Game.Overlays.BeatmapSet.Scores { - public class ScoresContainer : CompositeDrawable + public class ScoresContainer : BeatmapSetLayoutSection { private const int spacing = 15; @@ -34,7 +34,6 @@ namespace osu.Game.Overlays.BeatmapSet.Scores private readonly LoadingLayer loading; private readonly LeaderboardModSelector modSelector; private readonly NoScoresPlaceholder noScoresPlaceholder; - private readonly FillFlowContainer content; private readonly NotSupporterPlaceholder notSupporterPlaceholder; [Resolved] @@ -76,15 +75,13 @@ namespace osu.Game.Overlays.BeatmapSet.Scores public ScoresContainer() { - RelativeSizeAxes = Axes.X; - AutoSizeAxes = Axes.Y; - InternalChildren = new Drawable[] + AddRange(new Drawable[] { background = new Box { RelativeSizeAxes = Axes.Both, }, - content = new FillFlowContainer + new FillFlowContainer { Anchor = Anchor.TopCentre, Origin = Anchor.TopCentre, @@ -164,8 +161,8 @@ namespace osu.Game.Overlays.BeatmapSet.Scores } } } - }, - }; + } + }); } [BackgroundDependencyLoader] @@ -223,7 +220,7 @@ namespace osu.Game.Overlays.BeatmapSet.Scores if (Beatmap.Value?.OnlineBeatmapID.HasValue != true || Beatmap.Value.Status <= BeatmapSetOnlineStatus.Pending) { Scores = null; - content.Hide(); + Hide(); return; } @@ -237,7 +234,7 @@ namespace osu.Game.Overlays.BeatmapSet.Scores notSupporterPlaceholder.Hide(); - content.Show(); + Show(); loading.Show(); getScoresRequest = new GetScoresRequest(Beatmap.Value, Beatmap.Value.Ruleset, scope.Value, modSelector.SelectedMods); diff --git a/osu.Game/Overlays/BeatmapSetOverlay.cs b/osu.Game/Overlays/BeatmapSetOverlay.cs index 5b5580f286..efa9e27f5c 100644 --- a/osu.Game/Overlays/BeatmapSetOverlay.cs +++ b/osu.Game/Overlays/BeatmapSetOverlay.cs @@ -4,10 +4,8 @@ using System.Linq; using osu.Framework.Allocation; using osu.Framework.Bindables; -using osu.Framework.Extensions.Color4Extensions; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; -using osu.Framework.Graphics.Effects; using osu.Framework.Graphics.Shapes; using osu.Framework.Input.Events; using osu.Game.Beatmaps; @@ -18,7 +16,6 @@ using osu.Game.Overlays.BeatmapSet.Scores; using osu.Game.Overlays.Comments; using osu.Game.Rulesets; using osuTK; -using osuTK.Graphics; namespace osu.Game.Overlays { @@ -44,7 +41,7 @@ namespace osu.Game.Overlays { OsuScrollContainer scroll; Info info; - BeatmapSetCommentsContainer comments; + CommentsSection comments; Children = new Drawable[] { @@ -56,7 +53,7 @@ namespace osu.Game.Overlays { RelativeSizeAxes = Axes.Both, ScrollbarVisible = false, - Child = new ReverseChildIDFillFlowContainer
+ Child = new ReverseChildIDFillFlowContainer { RelativeSizeAxes = Axes.X, AutoSizeAxes = Axes.Y, @@ -64,7 +61,7 @@ namespace osu.Game.Overlays Spacing = new Vector2(0, 20), Children = new[] { - new Section + new BeatmapSetLayoutSection { Child = new ReverseChildIDFillFlowContainer { @@ -78,17 +75,11 @@ namespace osu.Game.Overlays } }, }, - new Section + new ScoresContainer { - Child = new ScoresContainer - { - Beatmap = { BindTarget = Header.Picker.Beatmap } - } + Beatmap = { BindTarget = Header.Picker.Beatmap } }, - new Section - { - Child = comments = new BeatmapSetCommentsContainer() - } + comments = new CommentsSection() }, }, }, @@ -160,29 +151,16 @@ namespace osu.Game.Overlays Show(); } - private class Section : Container - { - public Section() - { - RelativeSizeAxes = Axes.X; - AutoSizeAxes = Axes.Y; - Masking = true; - EdgeEffect = new EdgeEffectParameters - { - Colour = Color4.Black.Opacity(0.25f), - Type = EdgeEffectType.Shadow, - Radius = 3, - Offset = new Vector2(0f, 1f), - }; - } - } - - private class BeatmapSetCommentsContainer : CommentsContainer + private class CommentsSection : BeatmapSetLayoutSection { public readonly Bindable BeatmapSet = new Bindable(); - public BeatmapSetCommentsContainer() + public CommentsSection() { + CommentsContainer comments; + + Add(comments = new CommentsContainer()); + BeatmapSet.BindValueChanged(beatmapSet => { if (beatmapSet.NewValue?.OnlineBeatmapSetID.HasValue != true) @@ -192,7 +170,7 @@ namespace osu.Game.Overlays else { Show(); - ShowComments(CommentableType.Beatmapset, beatmapSet.NewValue.OnlineBeatmapSetID.Value); + comments.ShowComments(CommentableType.Beatmapset, beatmapSet.NewValue.OnlineBeatmapSetID.Value); } }, true); } From 71c34a36edd568f4140f71d21788df9fe4197905 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Dach?= Date: Sun, 23 Feb 2020 14:46:42 +0100 Subject: [PATCH 3/3] Use pattern matching instead of .(Has)?Value --- osu.Game/Overlays/BeatmapSetOverlay.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/osu.Game/Overlays/BeatmapSetOverlay.cs b/osu.Game/Overlays/BeatmapSetOverlay.cs index efa9e27f5c..0d16c4842d 100644 --- a/osu.Game/Overlays/BeatmapSetOverlay.cs +++ b/osu.Game/Overlays/BeatmapSetOverlay.cs @@ -163,14 +163,14 @@ namespace osu.Game.Overlays BeatmapSet.BindValueChanged(beatmapSet => { - if (beatmapSet.NewValue?.OnlineBeatmapSetID.HasValue != true) + if (beatmapSet.NewValue?.OnlineBeatmapSetID is int onlineBeatmapSetID) { - Hide(); + Show(); + comments.ShowComments(CommentableType.Beatmapset, onlineBeatmapSetID); } else { - Show(); - comments.ShowComments(CommentableType.Beatmapset, beatmapSet.NewValue.OnlineBeatmapSetID.Value); + Hide(); } }, true); }