From 1d3139d3c3b9c6f0da17e2ebf9b7f688c148b107 Mon Sep 17 00:00:00 2001 From: DrabWeb Date: Fri, 8 Sep 2017 18:32:07 -0300 Subject: [PATCH 01/30] Basic layout. --- .../Visual/TestCaseOnlineBeatmapSetOverlay.cs | 126 ++++++++++++++ osu.Desktop.Tests/osu.Desktop.Tests.csproj | 1 + osu.Game/Overlays/OnlineBeatmapSet/Header.cs | 139 ++++++++++++++++ osu.Game/Overlays/OnlineBeatmapSet/Info.cs | 155 ++++++++++++++++++ osu.Game/Overlays/OnlineBeatmapSetOverlay.cs | 80 +++++++++ osu.Game/osu.Game.csproj | 3 + 6 files changed, 504 insertions(+) create mode 100644 osu.Desktop.Tests/Visual/TestCaseOnlineBeatmapSetOverlay.cs create mode 100644 osu.Game/Overlays/OnlineBeatmapSet/Header.cs create mode 100644 osu.Game/Overlays/OnlineBeatmapSet/Info.cs create mode 100644 osu.Game/Overlays/OnlineBeatmapSetOverlay.cs diff --git a/osu.Desktop.Tests/Visual/TestCaseOnlineBeatmapSetOverlay.cs b/osu.Desktop.Tests/Visual/TestCaseOnlineBeatmapSetOverlay.cs new file mode 100644 index 0000000000..c939bc002c --- /dev/null +++ b/osu.Desktop.Tests/Visual/TestCaseOnlineBeatmapSetOverlay.cs @@ -0,0 +1,126 @@ +using System.Collections.Generic; +using osu.Framework.Allocation; +using osu.Framework.Testing; +using osu.Game.Beatmaps; +using osu.Game.Overlays; +using osu.Game.Rulesets; + +namespace osu.Desktop.VisualTests.Tests +{ + internal class TestCaseOnlineBeatmapSetOverlay : TestCase + { + public override string Description => @"view online beatmap sets"; + + private readonly OnlineBeatmapSetOverlay overlay; + + public TestCaseOnlineBeatmapSetOverlay() + { + Add(overlay = new OnlineBeatmapSetOverlay()); + } + + [BackgroundDependencyLoader] + private void load(RulesetStore rulesets) + { + var r = rulesets.GetRuleset(3); + + AddStep(@"show lachryma", () => + { + overlay.ShowBeatmapSet(new BeatmapSetInfo + { + OnlineBeatmapSetID = 415886, + Metadata = new BeatmapMetadata + { + Title = @"Lachryma ", + Artist = @"Kaneko Chiharu", + Author = @"Fresh Chicken", + Source = @"SOUND VOLTEX III GRAVITY WARS", + Tags = @"sdvx grace the 5th kac original song contest konami bemani", + }, + OnlineInfo = new BeatmapSetOnlineInfo + { + Preview = @"https://b.ppy.sh/preview/415886.mp3", + PlayCount = 681380, + FavouriteCount = 356, + Covers = new BeatmapSetOnlineCovers + { + Cover = @"https://assets.ppy.sh/beatmaps/415886/covers/cover.jpg?1465651778", + }, + }, + Beatmaps = new List + { + new BeatmapInfo + { + OnlineBeatmapID = 901048, + StarDifficulty = 1.36, + Version = @"BASIC", + Ruleset = r, + Difficulty = new BeatmapDifficulty + { + CircleSize = 4, + DrainRate = 6.5f, + OverallDifficulty = 6.5f, + ApproachRate = 5, + }, + }, + new BeatmapInfo + { + OnlineBeatmapID = 901051, + StarDifficulty = 2.22, + Version = @"NOVICE", + Ruleset = r, + Difficulty = new BeatmapDifficulty + { + CircleSize = 4, + DrainRate = 7, + OverallDifficulty = 7, + ApproachRate = 5, + }, + }, + new BeatmapInfo + { + OnlineBeatmapID = 901047, + StarDifficulty = 3.49, + Version = @"ADVANCED", + Ruleset = r, + Difficulty = new BeatmapDifficulty + { + CircleSize = 4, + DrainRate = 7.5f, + OverallDifficulty = 7.5f, + ApproachRate = 5, + }, + }, + new BeatmapInfo + { + OnlineBeatmapID = 901049, + StarDifficulty = 4.24, + Version = @"EXHAUST", + Ruleset = r, + Difficulty = new BeatmapDifficulty + { + CircleSize = 4, + DrainRate = 8, + OverallDifficulty = 8, + ApproachRate = 5, + }, + }, + new BeatmapInfo + { + OnlineBeatmapID = 901050, + StarDifficulty = 901050, + Version = @"GRAVITY", + Ruleset = r, + Difficulty = new BeatmapDifficulty + { + CircleSize = 4, + DrainRate = 8.5f, + OverallDifficulty = 8.5f, + ApproachRate = 5, + }, + }, + }, + }); + }); + } + } +} diff --git a/osu.Desktop.Tests/osu.Desktop.Tests.csproj b/osu.Desktop.Tests/osu.Desktop.Tests.csproj index 86268e6110..2c0ef1cbee 100644 --- a/osu.Desktop.Tests/osu.Desktop.Tests.csproj +++ b/osu.Desktop.Tests/osu.Desktop.Tests.csproj @@ -112,6 +112,7 @@ + diff --git a/osu.Game/Overlays/OnlineBeatmapSet/Header.cs b/osu.Game/Overlays/OnlineBeatmapSet/Header.cs new file mode 100644 index 0000000000..f4adbc2497 --- /dev/null +++ b/osu.Game/Overlays/OnlineBeatmapSet/Header.cs @@ -0,0 +1,139 @@ +// Copyright (c) 2007-2017 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using OpenTK; +using OpenTK.Graphics; +using osu.Framework.Extensions.Color4Extensions; +using osu.Framework.Graphics; +using osu.Framework.Graphics.Colour; +using osu.Framework.Graphics.Containers; +using osu.Framework.Graphics.Shapes; +using osu.Game.Beatmaps; +using osu.Game.Beatmaps.Drawables; + +namespace osu.Game.Overlays.OnlineBeatmapSet +{ + public class Header : Container + { + public Header(BeatmapSetInfo set) + { + RelativeSizeAxes = Axes.X; + Height = 400; + Masking = true; + EdgeEffect = new EdgeEffectParameters + { + Colour = Color4.Black.Opacity(0.25f), + Type = EdgeEffectType.Shadow, + Radius = 3, + Offset = new Vector2(0f, 1f), + }; + + Children = new Drawable[] + { + new Container + { + RelativeSizeAxes = Axes.Both, + Children = new Drawable[] + { + new Box + { + RelativeSizeAxes = Axes.Both, + Colour = Color4.Black, + }, + new DelayedLoadWrapper(new BeatmapSetCover(set) + { + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + RelativeSizeAxes = Axes.Both, + FillMode = FillMode.Fill, + OnLoadComplete = d => + { + d.FadeInFromZero(400, Easing.Out); + }, + }) + { + RelativeSizeAxes = Axes.Both, + TimeBeforeLoad = 300 + }, + new Box + { + RelativeSizeAxes = Axes.Both, + Colour = ColourInfo.GradientVertical(Color4.Black.Opacity(0.3f), Color4.Black.Opacity(0.8f)), + }, + }, + }, + new FillFlowContainer + { + Anchor = Anchor.BottomRight, + Origin = Anchor.BottomRight, + Width = OnlineBeatmapSetOverlay.RIGHT_WIDTH, + AutoSizeAxes = Axes.Y, + Margin = new MarginPadding { Right = OnlineBeatmapSetOverlay.X_PADDING }, + Spacing = new Vector2(1f), + Children = new Drawable[] + { + new DetailBox + { + Child = new Container + { + RelativeSizeAxes = Axes.X, + Height = 42, + }, + }, + new DetailBox + { + Child = new Container + { + RelativeSizeAxes = Axes.X, + Height = 35, + }, + }, + new DetailBox + { + Child = new Container + { + RelativeSizeAxes = Axes.X, + Height = 110, + }, + }, + new DetailBox + { + Child = new Container + { + RelativeSizeAxes = Axes.X, + Height = 115, + }, + }, + }, + }, + }; + } + + private class DetailBox : Container + { + private Container content; + protected override Container Content => content; + + public DetailBox() + { + RelativeSizeAxes = Axes.X; + AutoSizeAxes = Axes.Y; + + InternalChildren = new Drawable[] + { + new Box + { + RelativeSizeAxes = Axes.Both, + Colour = Color4.Black.Opacity(0.5f), + }, + content = new Container + { + RelativeSizeAxes = Axes.X, + AutoSizeAxes = Axes.Y, + Padding = new MarginPadding { Horizontal = 15 }, + }, + }; + } + } + } +} diff --git a/osu.Game/Overlays/OnlineBeatmapSet/Info.cs b/osu.Game/Overlays/OnlineBeatmapSet/Info.cs new file mode 100644 index 0000000000..948d20b0ac --- /dev/null +++ b/osu.Game/Overlays/OnlineBeatmapSet/Info.cs @@ -0,0 +1,155 @@ +// Copyright (c) 2007-2017 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using OpenTK; +using OpenTK.Graphics; +using osu.Framework.Allocation; +using osu.Framework.Extensions.Color4Extensions; +using osu.Framework.Graphics; +using osu.Framework.Graphics.Containers; +using osu.Framework.Graphics.Shapes; +using osu.Game.Beatmaps; +using osu.Game.Graphics; +using osu.Game.Graphics.Sprites; + +namespace osu.Game.Overlays.OnlineBeatmapSet +{ + public class Info : Container + { + private const float metadata_width = 225; + private const float spacing = 20; + + private readonly BeatmapSetInfo set; + + private readonly Box successRateBackground; + private readonly FillFlowContainer metadataFlow; + private readonly ScrollContainer descriptionScroll; + + public Info(BeatmapSetInfo set) + { + this.set = set; + + RelativeSizeAxes = Axes.X; + Height = 220; + Masking = true; + EdgeEffect = new EdgeEffectParameters + { + Colour = Color4.Black.Opacity(0.25f), + Type = EdgeEffectType.Shadow, + Radius = 3, + Offset = new Vector2(0f, 1f), + }; + + Children = new Drawable[] + { + new Box + { + RelativeSizeAxes = Axes.Both, + Colour = Color4.White, + }, + new Container + { + RelativeSizeAxes = Axes.Both, + Padding = new MarginPadding { Top = 15, Horizontal = OnlineBeatmapSetOverlay.X_PADDING }, + Children = new Drawable[] + { + new Container + { + RelativeSizeAxes = Axes.Both, + Padding = new MarginPadding { Right = metadata_width + OnlineBeatmapSetOverlay.RIGHT_WIDTH + spacing * 2 }, + Child = descriptionScroll = new ScrollContainer + { + RelativeSizeAxes = Axes.Both, + ScrollbarVisible = false, + }, + }, + new ScrollContainer + { + Anchor = Anchor.TopRight, + Origin = Anchor.TopRight, + RelativeSizeAxes = Axes.Y, + Width = metadata_width, + ScrollbarVisible = false, + Padding = new MarginPadding { Horizontal = 10 }, + Margin = new MarginPadding { Right = OnlineBeatmapSetOverlay.RIGHT_WIDTH + spacing }, + Child = metadataFlow = new FillFlowContainer + { + RelativeSizeAxes = Axes.X, + AutoSizeAxes = Axes.Y, + Direction = FillDirection.Vertical, + }, + }, + new Container + { + Anchor = Anchor.TopRight, + Origin = Anchor.TopRight, + RelativeSizeAxes = Axes.Y, + Width = OnlineBeatmapSetOverlay.RIGHT_WIDTH, + Children = new[] + { + successRateBackground = new Box + { + RelativeSizeAxes = Axes.Both, + }, + }, + }, + }, + }, + }; + } + + [BackgroundDependencyLoader] + private void load(OsuColour colours) + { + successRateBackground.Colour = colours.GrayE; + descriptionScroll.Child = new MetadataSection("Description", "", colours.Gray5); + metadataFlow.Children = new[] + { + new MetadataSection("Source", set.Metadata.Source, colours.Gray5), + new MetadataSection("Tags", set.Metadata.Tags, colours.BlueDark), + }; + } + + private class MetadataSection : FillFlowContainer + { + private readonly OsuSpriteText header; + + public MetadataSection(string title, string body, Color4 textColour) + { + RelativeSizeAxes = Axes.X; + AutoSizeAxes = Axes.Y; + Direction = FillDirection.Vertical; + Spacing = new Vector2(5f); + + TextFlowContainer content; + Children = new Drawable[] + { + header = new OsuSpriteText + { + Font = @"Exo2.0-Bold", + TextSize = 14, + Text = title, + Margin = new MarginPadding { Top = 20 }, + }, + content = new TextFlowContainer + { + RelativeSizeAxes = Axes.X, + AutoSizeAxes = Axes.Y, + }, + }; + + content.AddText(body, t => + { + t.TextSize = 14; + t.Colour = textColour; + }); + } + + [BackgroundDependencyLoader] + private void load(OsuColour colours) + { + header.Colour = colours.Gray5; + } + } + } +} diff --git a/osu.Game/Overlays/OnlineBeatmapSetOverlay.cs b/osu.Game/Overlays/OnlineBeatmapSetOverlay.cs new file mode 100644 index 0000000000..4fae3cac35 --- /dev/null +++ b/osu.Game/Overlays/OnlineBeatmapSetOverlay.cs @@ -0,0 +1,80 @@ +// Copyright (c) 2007-2017 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using OpenTK; +using OpenTK.Graphics; +using osu.Framework.Extensions.Color4Extensions; +using osu.Framework.Graphics; +using osu.Framework.Graphics.Containers; +using osu.Game.Beatmaps; +using osu.Game.Graphics; +using osu.Game.Graphics.Containers; +using osu.Game.Overlays.OnlineBeatmapSet; + +namespace osu.Game.Overlays +{ + public class OnlineBeatmapSetOverlay : WaveOverlayContainer + { + public const float X_PADDING = 40; + public const float RIGHT_WIDTH = 275; + + private readonly ReverseChildIDFillFlowContainer scrollContent; + + public OnlineBeatmapSetOverlay() + { + FirstWaveColour = OsuColour.Gray(0.4f); + SecondWaveColour = OsuColour.Gray(0.3f); + ThirdWaveColour = OsuColour.Gray(0.2f); + FourthWaveColour = OsuColour.Gray(0.1f); + + Anchor = Anchor.TopCentre; + Origin = Anchor.TopCentre; + RelativeSizeAxes = Axes.Both; + Width = 0.85f; + + Masking = true; + EdgeEffect = new EdgeEffectParameters + { + Colour = Color4.Black.Opacity(0), + Type = EdgeEffectType.Shadow, + Radius = 3, + Offset = new Vector2(0f, 1f), + }; + + Child = new ScrollContainer + { + RelativeSizeAxes = Axes.Both, + ScrollbarVisible = false, + Child = scrollContent = new ReverseChildIDFillFlowContainer + { + RelativeSizeAxes = Axes.X, + AutoSizeAxes = Axes.Y, + Direction = FillDirection.Vertical, + }, + }; + } + + protected override void PopIn() + { + base.PopIn(); + FadeEdgeEffectTo(0.25f, APPEAR_DURATION, Easing.In); + } + + protected override void PopOut() + { + base.PopOut(); + FadeEdgeEffectTo(0, DISAPPEAR_DURATION, Easing.Out); + } + + public void ShowBeatmapSet(BeatmapSetInfo set) + { + scrollContent.Children = new Drawable[] + { + new Header(set), + new Info(set), + }; + + Show(); + } + } +} diff --git a/osu.Game/osu.Game.csproj b/osu.Game/osu.Game.csproj index 05ba3e25ab..f3f67149fa 100644 --- a/osu.Game/osu.Game.csproj +++ b/osu.Game/osu.Game.csproj @@ -538,6 +538,9 @@ + + + From ecd6994d743eb718cc23d1ef0d62ab15878b0244 Mon Sep 17 00:00:00 2001 From: DrabWeb Date: Fri, 8 Sep 2017 19:17:39 -0300 Subject: [PATCH 02/30] Added favourite/download buttons and author info. --- osu.Game/Beatmaps/BeatmapSetOnlineInfo.cs | 22 ++ .../Overlays/OnlineBeatmapSet/AuthorInfo.cs | 83 +++++ osu.Game/Overlays/OnlineBeatmapSet/Header.cs | 329 +++++++++++++++--- osu.Game/Overlays/OnlineBeatmapSet/Info.cs | 1 + 4 files changed, 384 insertions(+), 51 deletions(-) create mode 100644 osu.Game/Overlays/OnlineBeatmapSet/AuthorInfo.cs diff --git a/osu.Game/Beatmaps/BeatmapSetOnlineInfo.cs b/osu.Game/Beatmaps/BeatmapSetOnlineInfo.cs index e5a1984f50..40755b468f 100644 --- a/osu.Game/Beatmaps/BeatmapSetOnlineInfo.cs +++ b/osu.Game/Beatmaps/BeatmapSetOnlineInfo.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 System; using Newtonsoft.Json; +using osu.Game.Users; namespace osu.Game.Beatmaps { @@ -10,6 +12,26 @@ namespace osu.Game.Beatmaps /// public class BeatmapSetOnlineInfo { + /// + /// The author of the beatmaps in this set. + /// + public User Author; + + /// + /// The date this beatmap set was submitted to the online listing. + /// + public DateTimeOffset Submitted { get; set; } + + /// + /// The date this beatmap set was ranked. + /// + public DateTimeOffset Ranked { get; set; } + + /// + /// The date this beatmap set was last updated. + /// + public DateTimeOffset LastUpdated { get; set; } + /// /// The different sizes of cover art for this beatmap set. /// diff --git a/osu.Game/Overlays/OnlineBeatmapSet/AuthorInfo.cs b/osu.Game/Overlays/OnlineBeatmapSet/AuthorInfo.cs new file mode 100644 index 0000000000..af4566a3f8 --- /dev/null +++ b/osu.Game/Overlays/OnlineBeatmapSet/AuthorInfo.cs @@ -0,0 +1,83 @@ +// Copyright (c) 2007-2017 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using System; +using OpenTK; +using OpenTK.Graphics; +using osu.Framework.Extensions.Color4Extensions; +using osu.Framework.Graphics; +using osu.Framework.Graphics.Containers; +using osu.Game.Beatmaps; +using osu.Game.Graphics.Sprites; +using osu.Game.Users; + +namespace osu.Game.Overlays.OnlineBeatmapSet +{ + public class AuthorInfo : Container + { + private const float height = 50; + + public AuthorInfo(BeatmapSetOnlineInfo info) + { + RelativeSizeAxes = Axes.X; + Height = height; + + Children = new Drawable[] + { + new UpdateableAvatar + { + Size = new Vector2(height), + CornerRadius = 3, + Masking = true, + User = info.Author, + EdgeEffect = new EdgeEffectParameters + { + Colour = Color4.Black.Opacity(0.25f), + Type = EdgeEffectType.Shadow, + Radius = 3, + Offset = new Vector2(0f, 1f), + }, + }, + new FillFlowContainer + { + RelativeSizeAxes = Axes.Both, + Direction = FillDirection.Vertical, + Padding = new MarginPadding { Left = height + 5 }, + Children = new Drawable[] + { + new Field("made by", info.Author.Username, @"Exo2.0-RegularItalic"), + new Field("submitted on", info.Submitted.ToString(@"MMM d, yyyy"), @"Exo2.0-Bold") + { + Margin = new MarginPadding { Top = 5 }, + }, + new Field(info.Ranked == null ? "last updated on " : "ranked on ", (info.Ranked == null ? info.Submitted : info.Ranked).ToString(@"MMM d, yyyy"), @"Exo2.0-Bold"), + }, + }, + }; + } + + private class Field : FillFlowContainer + { + public Field(string first, string second, string secondFont) + { + AutoSizeAxes = Axes.Both; + Direction = FillDirection.Horizontal; + + Children = new[] + { + new OsuSpriteText + { + Text = $"{first} ", + TextSize = 13, + }, + new OsuSpriteText + { + Text = second, + TextSize = 13, + Font = secondFont, + }, + }; + } + } + } +} diff --git a/osu.Game/Overlays/OnlineBeatmapSet/Header.cs b/osu.Game/Overlays/OnlineBeatmapSet/Header.cs index f4adbc2497..35bd3bebdc 100644 --- a/osu.Game/Overlays/OnlineBeatmapSet/Header.cs +++ b/osu.Game/Overlays/OnlineBeatmapSet/Header.cs @@ -3,6 +3,8 @@ using OpenTK; using OpenTK.Graphics; +using osu.Framework.Allocation; +using osu.Framework.Configuration; using osu.Framework.Extensions.Color4Extensions; using osu.Framework.Graphics; using osu.Framework.Graphics.Colour; @@ -10,11 +12,19 @@ using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Shapes; using osu.Game.Beatmaps; using osu.Game.Beatmaps.Drawables; +using osu.Game.Graphics; +using osu.Game.Graphics.Backgrounds; +using osu.Game.Graphics.Containers; +using osu.Game.Graphics.Sprites; namespace osu.Game.Overlays.OnlineBeatmapSet { public class Header : Container { + private const float tabs_height = 50; + + private readonly Box tabsBg; + public Header(BeatmapSetInfo set) { RelativeSizeAxes = Axes.X; @@ -32,76 +42,148 @@ namespace osu.Game.Overlays.OnlineBeatmapSet { new Container { - RelativeSizeAxes = Axes.Both, - Children = new Drawable[] + RelativeSizeAxes = Axes.X, + Height = tabs_height, + Children = new[] { - new Box + tabsBg = new Box { RelativeSizeAxes = Axes.Both, - Colour = Color4.Black, - }, - new DelayedLoadWrapper(new BeatmapSetCover(set) - { - Anchor = Anchor.Centre, - Origin = Anchor.Centre, - RelativeSizeAxes = Axes.Both, - FillMode = FillMode.Fill, - OnLoadComplete = d => - { - d.FadeInFromZero(400, Easing.Out); - }, - }) - { - RelativeSizeAxes = Axes.Both, - TimeBeforeLoad = 300 - }, - new Box - { - RelativeSizeAxes = Axes.Both, - Colour = ColourInfo.GradientVertical(Color4.Black.Opacity(0.3f), Color4.Black.Opacity(0.8f)), }, }, }, - new FillFlowContainer + new Container { - Anchor = Anchor.BottomRight, - Origin = Anchor.BottomRight, - Width = OnlineBeatmapSetOverlay.RIGHT_WIDTH, - AutoSizeAxes = Axes.Y, - Margin = new MarginPadding { Right = OnlineBeatmapSetOverlay.X_PADDING }, - Spacing = new Vector2(1f), + RelativeSizeAxes = Axes.Both, + Padding = new MarginPadding { Top = tabs_height }, Children = new Drawable[] { - new DetailBox + new Container { - Child = new Container + RelativeSizeAxes = Axes.Both, + Children = new Drawable[] { - RelativeSizeAxes = Axes.X, - Height = 42, + new Box + { + RelativeSizeAxes = Axes.Both, + Colour = Color4.Black, + }, + new DelayedLoadWrapper(new BeatmapSetCover(set) + { + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + RelativeSizeAxes = Axes.Both, + FillMode = FillMode.Fill, + OnLoadComplete = d => + { + d.FadeInFromZero(400, Easing.Out); + }, + }) + { + RelativeSizeAxes = Axes.Both, + TimeBeforeLoad = 300 + }, + new Box + { + RelativeSizeAxes = Axes.Both, + Colour = ColourInfo.GradientVertical(Color4.Black.Opacity(0.3f), Color4.Black.Opacity(0.8f)), + }, }, }, - new DetailBox + new Container { - Child = new Container + RelativeSizeAxes = Axes.Both, + Padding = new MarginPadding { Top = 20, Bottom = 30, Horizontal = OnlineBeatmapSetOverlay.X_PADDING }, + Child = new FillFlowContainer { - RelativeSizeAxes = Axes.X, - Height = 35, + RelativeSizeAxes = Axes.Both, + Direction = FillDirection.Vertical, + Children = new Drawable[] + { + new Container + { + Name = @"beatmap picker", + RelativeSizeAxes = Axes.X, + Height = 113, + }, + new OsuSpriteText + { + Text = set.Metadata.Title, + Font = @"Exo2.0-BoldItalic", + TextSize = 37, + }, + new OsuSpriteText + { + Text = set.Metadata.Artist, + Font = @"Exo2.0-SemiBoldItalic", + TextSize = 25, + }, + new Container + { + Name = "mapper", + RelativeSizeAxes = Axes.X, + AutoSizeAxes = Axes.Y, + Margin = new MarginPadding { Top = 20 }, + Child = new AuthorInfo(set.OnlineInfo), + }, + new FillFlowContainer + { + RelativeSizeAxes = Axes.X, + Height = 45, + Spacing = new Vector2(5f), + Margin = new MarginPadding { Top = 10 }, + Children = new Button[] + { + new FavouriteButton(), + new DownloadButton("Download", ""), + new DownloadButton("osu!direct", ""), + }, + }, + }, }, }, - new DetailBox + new FillFlowContainer { - Child = new Container + Anchor = Anchor.BottomRight, + Origin = Anchor.BottomRight, + Width = OnlineBeatmapSetOverlay.RIGHT_WIDTH, + AutoSizeAxes = Axes.Y, + Margin = new MarginPadding { Right = OnlineBeatmapSetOverlay.X_PADDING }, + Spacing = new Vector2(1f), + Children = new Drawable[] { - RelativeSizeAxes = Axes.X, - Height = 110, - }, - }, - new DetailBox - { - Child = new Container - { - RelativeSizeAxes = Axes.X, - Height = 115, + new DetailBox + { + Child = new Container + { + RelativeSizeAxes = Axes.X, + Height = 42, + }, + }, + new DetailBox + { + Child = new Container + { + RelativeSizeAxes = Axes.X, + Height = 35, + }, + }, + new DetailBox + { + Child = new Container + { + RelativeSizeAxes = Axes.X, + Height = 110, + }, + }, + new DetailBox + { + Child = new Container + { + RelativeSizeAxes = Axes.X, + Height = 115, + }, + }, }, }, }, @@ -109,6 +191,151 @@ namespace osu.Game.Overlays.OnlineBeatmapSet }; } + [BackgroundDependencyLoader] + private void load(OsuColour colours) + { + tabsBg.Colour = colours.Gray3; + } + + private class Button : OsuClickableContainer + { + private readonly Container content; + + protected override Container Content => content; + + public Button() + { + CornerRadius = 3; + Masking = true; + + InternalChildren = new Drawable[] + { + new Box + { + RelativeSizeAxes = Axes.Both, + Colour = OsuColour.FromHex(@"094c5f"), + }, + new Triangles + { + RelativeSizeAxes = Axes.Both, + ColourLight = OsuColour.FromHex(@"0f7c9b"), + ColourDark = OsuColour.FromHex(@"094c5f"), + TriangleScale = 1.5f, + }, + content = new Container + { + RelativeSizeAxes = Axes.Both, + }, + }; + } + } + + private class DownloadButton : Button + { + public DownloadButton(string title, string subtitle) + { + Width = 120; + RelativeSizeAxes = Axes.Y; + + Child = new Container + { + RelativeSizeAxes = Axes.Both, + Padding = new MarginPadding { Horizontal = 10 }, + Children = new Drawable[] + { + new FillFlowContainer + { + Anchor = Anchor.CentreLeft, + Origin = Anchor.CentreLeft, + AutoSizeAxes = Axes.Both, + Direction = FillDirection.Vertical, + Children = new[] + { + new OsuSpriteText + { + Text = title, + TextSize = 13, + Font = @"Exo2.0-Bold", + }, + new OsuSpriteText + { + Text = subtitle, + TextSize = 11, + Font = @"Exo2.0-Bold", + }, + }, + }, + new SpriteIcon + { + Anchor = Anchor.CentreRight, + Origin = Anchor.CentreRight, + Icon = FontAwesome.fa_download, + Size = new Vector2(16), + Margin = new MarginPadding { Right = 5 }, + }, + }, + }; + } + } + + private class FavouriteButton : Button + { + public readonly Bindable Favourited = new Bindable(); + + public FavouriteButton() + { + RelativeSizeAxes = Axes.Y; + + Container pink; + SpriteIcon icon; + Children = new Drawable[] + { + pink = new Container + { + RelativeSizeAxes = Axes.Both, + Alpha = 0f, + Children = new Drawable[] + { + new Box + { + RelativeSizeAxes = Axes.Both, + Colour = OsuColour.FromHex(@"9f015f"), + }, + new Triangles + { + RelativeSizeAxes = Axes.Both, + ColourLight = OsuColour.FromHex(@"cb2187"), + ColourDark = OsuColour.FromHex(@"9f015f"), + TriangleScale = 1.5f, + }, + }, + }, + icon = new SpriteIcon + { + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + Icon = FontAwesome.fa_heart_o, + Size = new Vector2(18), + Shadow = false, + }, + }; + + Favourited.ValueChanged += value => + { + pink.FadeTo(value ? 1 : 0, 200); + icon.Icon = value ? FontAwesome.fa_heart : FontAwesome.fa_heart_o; + }; + Action = () => Favourited.Value = !Favourited.Value; + } + + protected override void UpdateAfterChildren() + { + base.UpdateAfterChildren(); + + Width = DrawHeight; + } + } + private class DetailBox : Container { private Container content; diff --git a/osu.Game/Overlays/OnlineBeatmapSet/Info.cs b/osu.Game/Overlays/OnlineBeatmapSet/Info.cs index 948d20b0ac..b4c505b136 100644 --- a/osu.Game/Overlays/OnlineBeatmapSet/Info.cs +++ b/osu.Game/Overlays/OnlineBeatmapSet/Info.cs @@ -129,6 +129,7 @@ namespace osu.Game.Overlays.OnlineBeatmapSet Font = @"Exo2.0-Bold", TextSize = 14, Text = title, + Shadow = false, Margin = new MarginPadding { Top = 20 }, }, content = new TextFlowContainer From cbd9c07aed87953ef07a5432179c5b05ca2853d9 Mon Sep 17 00:00:00 2001 From: DrabWeb Date: Sat, 9 Sep 2017 18:19:43 -0300 Subject: [PATCH 03/30] BeatmapPicker design. --- .../OnlineBeatmapSet/BeatmapPicker.cs | 218 ++++++++++++++++++ osu.Game/Overlays/OnlineBeatmapSet/Header.cs | 3 +- 2 files changed, 219 insertions(+), 2 deletions(-) create mode 100644 osu.Game/Overlays/OnlineBeatmapSet/BeatmapPicker.cs diff --git a/osu.Game/Overlays/OnlineBeatmapSet/BeatmapPicker.cs b/osu.Game/Overlays/OnlineBeatmapSet/BeatmapPicker.cs new file mode 100644 index 0000000000..fa02754d80 --- /dev/null +++ b/osu.Game/Overlays/OnlineBeatmapSet/BeatmapPicker.cs @@ -0,0 +1,218 @@ +// 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 OpenTK; +using OpenTK.Graphics; +using osu.Framework.Allocation; +using osu.Framework.Extensions.Color4Extensions; +using osu.Framework.Graphics; +using osu.Framework.Graphics.Containers; +using osu.Framework.Graphics.Shapes; +using osu.Framework.Input; +using osu.Game.Beatmaps; +using osu.Game.Beatmaps.Drawables; +using osu.Game.Graphics; +using osu.Game.Graphics.Containers; +using osu.Game.Graphics.Sprites; + +namespace osu.Game.Overlays.OnlineBeatmapSet +{ + public class BeatmapPicker : Container + { + private const float tile_icon_padding = 7; + private const float tile_spacing = 2; + + private readonly OsuSpriteText version, starRating; + + public BeatmapPicker(BeatmapSetInfo set) + { + RelativeSizeAxes = Axes.X; + AutoSizeAxes = Axes.Y; + + FillFlowContainer tileContainer; + Children = new Drawable[] + { + new FillFlowContainer + { + AutoSizeAxes = Axes.Y, + RelativeSizeAxes = Axes.X, + Direction = FillDirection.Vertical, + Children = new Drawable[] + { + tileContainer = new FillFlowContainer + { + RelativeSizeAxes = Axes.X, + AutoSizeAxes = Axes.Y, + Margin = new MarginPadding { Left = -(tile_icon_padding + tile_spacing / 2) }, + }, + new FillFlowContainer + { + AutoSizeAxes = Axes.Both, + Margin = new MarginPadding { Top = 10 }, + Spacing = new Vector2(5f), + Children = new[] + { + version = new OsuSpriteText + { + Anchor = Anchor.BottomLeft, + Origin = Anchor.BottomLeft, + TextSize = 20, + Font = @"Exo2.0-Bold", + Text = "BASIC", + }, + starRating = new OsuSpriteText + { + Anchor = Anchor.BottomLeft, + Origin = Anchor.BottomLeft, + TextSize = 13, + Font = @"Exo2.0-Bold", + Text = "Star Difficulty 1.36", + Margin = new MarginPadding { Bottom = 1 }, + }, + }, + }, + new FillFlowContainer + { + RelativeSizeAxes = Axes.X, + AutoSizeAxes = Axes.Y, + Spacing = new Vector2(10f), + Margin = new MarginPadding { Top = 5 }, + Children = new[] + { + new Statistic(FontAwesome.fa_play_circle, 682712), + new Statistic(FontAwesome.fa_heart, 357), + }, + }, + }, + }, + }; + + tileContainer.ChildrenEnumerable = set.Beatmaps.Select(b => new BeatmapTile(b) + { + OnHovered = beatmap => + { + }, + }); + } + + [BackgroundDependencyLoader] + private void load(OsuColour colours) + { + starRating.Colour = colours.Yellow; + } + + private class BeatmapTile : OsuClickableContainer + { + private const float transition_duration = 100; + private const float size = 52; + + private readonly BeatmapInfo beatmap; + + private readonly Container bg; + private readonly DifficultyIcon icon; + + public Action OnHovered; + + public BeatmapTile(BeatmapInfo beatmap) + { + this.beatmap = beatmap; + Size = new Vector2(size); + Margin = new MarginPadding { Horizontal = tile_spacing / 2 }; + + Children = new Drawable[] + { + bg = new Container + { + RelativeSizeAxes = Axes.Both, + Masking = true, + CornerRadius = 4, + Child = new Box + { + RelativeSizeAxes = Axes.Both, + Colour = Color4.Black.Opacity(0.5f), + }, + }, + icon = new DifficultyIcon(beatmap) + { + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + Size = new Vector2(size - tile_icon_padding * 2), + Margin = new MarginPadding { Bottom = 1 }, + }, + }; + + fadeOut(); + } + + protected override bool OnHover(InputState state) + { + fadeIn(); + OnHovered?.Invoke(beatmap); + return base.OnHover(state); + } + + protected override void OnHoverLost(InputState state) + { + fadeOut(); + } + + private void fadeIn() + { + bg.FadeIn(transition_duration); + icon.FadeIn(transition_duration); + } + + private void fadeOut() + { + bg.FadeOut(); + icon.FadeTo(0.7f, transition_duration); + } + } + + private class Statistic : FillFlowContainer + { + private readonly OsuSpriteText text; + + private int value; + public int Value + { + get { return value; } + set + { + this.value = value; + text.Text = Value.ToString(@"N0"); + } + } + + public Statistic(FontAwesome icon, int value = 0) + { + AutoSizeAxes = Axes.Both; + Direction = FillDirection.Horizontal; + Spacing = new Vector2(2f); + + Children = new Drawable[] + { + new SpriteIcon + { + Anchor = Anchor.CentreLeft, + Origin = Anchor.CentreLeft, + Icon = icon, + Shadow = true, + Size = new Vector2(13), + }, + text = new OsuSpriteText + { + Anchor = Anchor.CentreLeft, + Origin = Anchor.CentreLeft, + Font = @"Exo2.0-SemiBoldItalic", + TextSize = 14, + }, + }; + + Value = value; + } + } + } +} diff --git a/osu.Game/Overlays/OnlineBeatmapSet/Header.cs b/osu.Game/Overlays/OnlineBeatmapSet/Header.cs index 35bd3bebdc..1e6b81ae1f 100644 --- a/osu.Game/Overlays/OnlineBeatmapSet/Header.cs +++ b/osu.Game/Overlays/OnlineBeatmapSet/Header.cs @@ -102,9 +102,9 @@ namespace osu.Game.Overlays.OnlineBeatmapSet { new Container { - Name = @"beatmap picker", RelativeSizeAxes = Axes.X, Height = 113, + Child = new BeatmapPicker(set), }, new OsuSpriteText { @@ -120,7 +120,6 @@ namespace osu.Game.Overlays.OnlineBeatmapSet }, new Container { - Name = "mapper", RelativeSizeAxes = Axes.X, AutoSizeAxes = Axes.Y, Margin = new MarginPadding { Top = 20 }, From aa9dfcc082da5c372dd093b7055ff5fca6786ef0 Mon Sep 17 00:00:00 2001 From: DrabWeb Date: Sat, 9 Sep 2017 19:05:22 -0300 Subject: [PATCH 04/30] BeatmapPicker logic. --- .../Visual/TestCaseOnlineBeatmapSetOverlay.cs | 13 +++- .../OnlineBeatmapSet/BeatmapPicker.cs | 59 +++++++++++++++---- 2 files changed, 60 insertions(+), 12 deletions(-) diff --git a/osu.Desktop.Tests/Visual/TestCaseOnlineBeatmapSetOverlay.cs b/osu.Desktop.Tests/Visual/TestCaseOnlineBeatmapSetOverlay.cs index c939bc002c..2bbe6ea952 100644 --- a/osu.Desktop.Tests/Visual/TestCaseOnlineBeatmapSetOverlay.cs +++ b/osu.Desktop.Tests/Visual/TestCaseOnlineBeatmapSetOverlay.cs @@ -1,9 +1,11 @@ -using System.Collections.Generic; +using System; +using System.Collections.Generic; using osu.Framework.Allocation; using osu.Framework.Testing; using osu.Game.Beatmaps; using osu.Game.Overlays; using osu.Game.Rulesets; +using osu.Game.Users; namespace osu.Desktop.VisualTests.Tests { @@ -41,6 +43,13 @@ namespace osu.Desktop.VisualTests.Tests Preview = @"https://b.ppy.sh/preview/415886.mp3", PlayCount = 681380, FavouriteCount = 356, + Submitted = new DateTime(2016, 2, 10), + Ranked = new DateTime(2016, 6, 19), + Author = new User + { + Username = @"Fresh Chicken", + Id = 3984370, + }, Covers = new BeatmapSetOnlineCovers { Cover = @"https://assets.ppy.sh/beatmaps/415886/covers/cover.jpg?1465651778", @@ -107,7 +116,7 @@ namespace osu.Desktop.VisualTests.Tests new BeatmapInfo { OnlineBeatmapID = 901050, - StarDifficulty = 901050, + StarDifficulty = 5.26, Version = @"GRAVITY", Ruleset = r, Difficulty = new BeatmapDifficulty diff --git a/osu.Game/Overlays/OnlineBeatmapSet/BeatmapPicker.cs b/osu.Game/Overlays/OnlineBeatmapSet/BeatmapPicker.cs index fa02754d80..2a0e137a4e 100644 --- a/osu.Game/Overlays/OnlineBeatmapSet/BeatmapPicker.cs +++ b/osu.Game/Overlays/OnlineBeatmapSet/BeatmapPicker.cs @@ -6,6 +6,7 @@ using System.Linq; using OpenTK; using OpenTK.Graphics; using osu.Framework.Allocation; +using osu.Framework.Configuration; using osu.Framework.Extensions.Color4Extensions; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; @@ -26,12 +27,14 @@ namespace osu.Game.Overlays.OnlineBeatmapSet private readonly OsuSpriteText version, starRating; + public readonly Bindable Beatmap = new Bindable(); + public BeatmapPicker(BeatmapSetInfo set) { RelativeSizeAxes = Axes.X; AutoSizeAxes = Axes.Y; - FillFlowContainer tileContainer; + TilesFillFlowContainer tileContainer; Children = new Drawable[] { new FillFlowContainer @@ -41,11 +44,15 @@ namespace osu.Game.Overlays.OnlineBeatmapSet Direction = FillDirection.Vertical, Children = new Drawable[] { - tileContainer = new FillFlowContainer + tileContainer = new TilesFillFlowContainer { - RelativeSizeAxes = Axes.X, - AutoSizeAxes = Axes.Y, + AutoSizeAxes = Axes.Both, Margin = new MarginPadding { Left = -(tile_icon_padding + tile_spacing / 2) }, + OnLostHover = () => + { + showBeatmap(Beatmap.Value); + starRating.FadeOut(100); + }, }, new FillFlowContainer { @@ -60,7 +67,6 @@ namespace osu.Game.Overlays.OnlineBeatmapSet Origin = Anchor.BottomLeft, TextSize = 20, Font = @"Exo2.0-Bold", - Text = "BASIC", }, starRating = new OsuSpriteText { @@ -68,7 +74,8 @@ namespace osu.Game.Overlays.OnlineBeatmapSet Origin = Anchor.BottomLeft, TextSize = 13, Font = @"Exo2.0-Bold", - Text = "Star Difficulty 1.36", + Text = "Star Difficulty", + Alpha = 0, Margin = new MarginPadding { Bottom = 1 }, }, }, @@ -89,12 +96,19 @@ namespace osu.Game.Overlays.OnlineBeatmapSet }, }; - tileContainer.ChildrenEnumerable = set.Beatmaps.Select(b => new BeatmapTile(b) + Beatmap.Value = set.Beatmaps.First(); + Beatmap.ValueChanged += showBeatmap; + tileContainer.ChildrenEnumerable = set.Beatmaps.Select(b => new BeatmapTile(b, Beatmap) { OnHovered = beatmap => { + showBeatmap(beatmap); + starRating.Text = string.Format("Star Difficulty {0:N2}", beatmap.StarDifficulty); + starRating.FadeIn(100); }, }); + + Beatmap.TriggerChange(); } [BackgroundDependencyLoader] @@ -103,21 +117,36 @@ namespace osu.Game.Overlays.OnlineBeatmapSet starRating.Colour = colours.Yellow; } + private void showBeatmap(BeatmapInfo beatmap) => version.Text = beatmap.Version; + + private class TilesFillFlowContainer : FillFlowContainer + { + public Action OnLostHover; + + protected override void OnHoverLost(InputState state) + { + base.OnHoverLost(state); + OnLostHover?.Invoke(); + } + } + private class BeatmapTile : OsuClickableContainer { private const float transition_duration = 100; private const float size = 52; private readonly BeatmapInfo beatmap; + private readonly Bindable bindable = new Bindable(); private readonly Container bg; private readonly DifficultyIcon icon; public Action OnHovered; - public BeatmapTile(BeatmapInfo beatmap) + public BeatmapTile(BeatmapInfo beatmap, Bindable bindable) { this.beatmap = beatmap; + this.bindable.BindTo(bindable); Size = new Vector2(size); Margin = new MarginPadding { Horizontal = tile_spacing / 2 }; @@ -143,7 +172,8 @@ namespace osu.Game.Overlays.OnlineBeatmapSet }, }; - fadeOut(); + Action = () => this.bindable.Value = beatmap; + this.bindable.ValueChanged += bindable_ValueChanged; } protected override bool OnHover(InputState state) @@ -155,7 +185,16 @@ namespace osu.Game.Overlays.OnlineBeatmapSet protected override void OnHoverLost(InputState state) { - fadeOut(); + if (bindable.Value != beatmap) + fadeOut(); + } + + private void bindable_ValueChanged(BeatmapInfo value) + { + if (value == beatmap) + fadeIn(); + else + fadeOut(); } private void fadeIn() From 54172ac6adc4450c7abffbc444ed86800616d4e6 Mon Sep 17 00:00:00 2001 From: DrabWeb Date: Mon, 11 Sep 2017 01:21:53 -0300 Subject: [PATCH 05/30] Move header button and details components to own files. --- osu.Game/Overlays/OnlineBeatmapSet/Details.cs | 85 +++++++ .../OnlineBeatmapSet/DownloadButton.cs | 59 +++++ .../OnlineBeatmapSet/FavouriteButton.cs | 71 ++++++ osu.Game/Overlays/OnlineBeatmapSet/Header.cs | 211 +----------------- .../Overlays/OnlineBeatmapSet/HeaderButton.cs | 45 ++++ 5 files changed, 262 insertions(+), 209 deletions(-) create mode 100644 osu.Game/Overlays/OnlineBeatmapSet/Details.cs create mode 100644 osu.Game/Overlays/OnlineBeatmapSet/DownloadButton.cs create mode 100644 osu.Game/Overlays/OnlineBeatmapSet/FavouriteButton.cs create mode 100644 osu.Game/Overlays/OnlineBeatmapSet/HeaderButton.cs diff --git a/osu.Game/Overlays/OnlineBeatmapSet/Details.cs b/osu.Game/Overlays/OnlineBeatmapSet/Details.cs new file mode 100644 index 0000000000..69a489d05a --- /dev/null +++ b/osu.Game/Overlays/OnlineBeatmapSet/Details.cs @@ -0,0 +1,85 @@ +// Copyright (c) 2007-2017 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using OpenTK; +using OpenTK.Graphics; +using osu.Framework.Extensions.Color4Extensions; +using osu.Framework.Graphics; +using osu.Framework.Graphics.Containers; +using osu.Framework.Graphics.Shapes; + +namespace osu.Game.Overlays.OnlineBeatmapSet +{ + public class Details : FillFlowContainer + { + public Details() + { + Width = OnlineBeatmapSetOverlay.RIGHT_WIDTH; + AutoSizeAxes = Axes.Y; + Spacing = new Vector2(1f); + + Children = new Drawable[] + { + new DetailBox + { + Child = new Container + { + RelativeSizeAxes = Axes.X, + Height = 42, + }, + }, + new DetailBox + { + Child = new Container + { + RelativeSizeAxes = Axes.X, + Height = 35, + }, + }, + new DetailBox + { + Child = new Container + { + RelativeSizeAxes = Axes.X, + Height = 110, + }, + }, + new DetailBox + { + Child = new Container + { + RelativeSizeAxes = Axes.X, + Height = 115, + }, + }, + }; + } + + private class DetailBox : Container + { + private Container content; + protected override Container Content => content; + + public DetailBox() + { + RelativeSizeAxes = Axes.X; + AutoSizeAxes = Axes.Y; + + InternalChildren = new Drawable[] + { + new Box + { + RelativeSizeAxes = Axes.Both, + Colour = Color4.Black.Opacity(0.5f), + }, + content = new Container + { + RelativeSizeAxes = Axes.X, + AutoSizeAxes = Axes.Y, + Padding = new MarginPadding { Horizontal = 15 }, + }, + }; + } + } + } +} diff --git a/osu.Game/Overlays/OnlineBeatmapSet/DownloadButton.cs b/osu.Game/Overlays/OnlineBeatmapSet/DownloadButton.cs new file mode 100644 index 0000000000..96f811ca55 --- /dev/null +++ b/osu.Game/Overlays/OnlineBeatmapSet/DownloadButton.cs @@ -0,0 +1,59 @@ +// Copyright (c) 2007-2017 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using OpenTK; +using osu.Framework.Graphics; +using osu.Framework.Graphics.Containers; +using osu.Game.Graphics; +using osu.Game.Graphics.Sprites; + +namespace osu.Game.Overlays.OnlineBeatmapSet +{ + public class DownloadButton : HeaderButton + { + public DownloadButton(string title, string subtitle) + { + Width = 120; + RelativeSizeAxes = Axes.Y; + + Child = new Container + { + RelativeSizeAxes = Axes.Both, + Padding = new MarginPadding { Horizontal = 10 }, + Children = new Drawable[] + { + new FillFlowContainer + { + Anchor = Anchor.CentreLeft, + Origin = Anchor.CentreLeft, + AutoSizeAxes = Axes.Both, + Direction = FillDirection.Vertical, + Children = new[] + { + new OsuSpriteText + { + Text = title, + TextSize = 13, + Font = @"Exo2.0-Bold", + }, + new OsuSpriteText + { + Text = subtitle, + TextSize = 11, + Font = @"Exo2.0-Bold", + }, + }, + }, + new SpriteIcon + { + Anchor = Anchor.CentreRight, + Origin = Anchor.CentreRight, + Icon = FontAwesome.fa_download, + Size = new Vector2(16), + Margin = new MarginPadding { Right = 5 }, + }, + }, + }; + } + } +} diff --git a/osu.Game/Overlays/OnlineBeatmapSet/FavouriteButton.cs b/osu.Game/Overlays/OnlineBeatmapSet/FavouriteButton.cs new file mode 100644 index 0000000000..140e2cd120 --- /dev/null +++ b/osu.Game/Overlays/OnlineBeatmapSet/FavouriteButton.cs @@ -0,0 +1,71 @@ +// Copyright (c) 2007-2017 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE] + +using OpenTK; +using osu.Framework.Configuration; +using osu.Framework.Graphics; +using osu.Framework.Graphics.Containers; +using osu.Framework.Graphics.Shapes; +using osu.Game.Graphics; +using osu.Game.Graphics.Backgrounds; + +namespace osu.Game.Overlays.OnlineBeatmapSet +{ + public class FavouriteButton : HeaderButton + { + public readonly Bindable Favourited = new Bindable(); + + public FavouriteButton() + { + RelativeSizeAxes = Axes.Y; + + Container pink; + SpriteIcon icon; + Children = new Drawable[] + { + pink = new Container + { + RelativeSizeAxes = Axes.Both, + Alpha = 0f, + Children = new Drawable[] + { + new Box + { + RelativeSizeAxes = Axes.Both, + Colour = OsuColour.FromHex(@"9f015f"), + }, + new Triangles + { + RelativeSizeAxes = Axes.Both, + ColourLight = OsuColour.FromHex(@"cb2187"), + ColourDark = OsuColour.FromHex(@"9f015f"), + TriangleScale = 1.5f, + }, + }, + }, + icon = new SpriteIcon + { + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + Icon = FontAwesome.fa_heart_o, + Size = new Vector2(18), + Shadow = false, + }, + }; + + Favourited.ValueChanged += value => + { + pink.FadeTo(value ? 1 : 0, 200); + icon.Icon = value ? FontAwesome.fa_heart : FontAwesome.fa_heart_o; + }; + Action = () => Favourited.Value = !Favourited.Value; + } + + protected override void UpdateAfterChildren() + { + base.UpdateAfterChildren(); + + Width = DrawHeight; + } + } +} diff --git a/osu.Game/Overlays/OnlineBeatmapSet/Header.cs b/osu.Game/Overlays/OnlineBeatmapSet/Header.cs index 1e6b81ae1f..cea497af8c 100644 --- a/osu.Game/Overlays/OnlineBeatmapSet/Header.cs +++ b/osu.Game/Overlays/OnlineBeatmapSet/Header.cs @@ -4,7 +4,6 @@ using OpenTK; using OpenTK.Graphics; using osu.Framework.Allocation; -using osu.Framework.Configuration; using osu.Framework.Extensions.Color4Extensions; using osu.Framework.Graphics; using osu.Framework.Graphics.Colour; @@ -13,8 +12,6 @@ using osu.Framework.Graphics.Shapes; using osu.Game.Beatmaps; using osu.Game.Beatmaps.Drawables; using osu.Game.Graphics; -using osu.Game.Graphics.Backgrounds; -using osu.Game.Graphics.Containers; using osu.Game.Graphics.Sprites; namespace osu.Game.Overlays.OnlineBeatmapSet @@ -131,7 +128,7 @@ namespace osu.Game.Overlays.OnlineBeatmapSet Height = 45, Spacing = new Vector2(5f), Margin = new MarginPadding { Top = 10 }, - Children = new Button[] + Children = new HeaderButton[] { new FavouriteButton(), new DownloadButton("Download", ""), @@ -141,49 +138,11 @@ namespace osu.Game.Overlays.OnlineBeatmapSet }, }, }, - new FillFlowContainer + new Details { Anchor = Anchor.BottomRight, Origin = Anchor.BottomRight, - Width = OnlineBeatmapSetOverlay.RIGHT_WIDTH, - AutoSizeAxes = Axes.Y, Margin = new MarginPadding { Right = OnlineBeatmapSetOverlay.X_PADDING }, - Spacing = new Vector2(1f), - Children = new Drawable[] - { - new DetailBox - { - Child = new Container - { - RelativeSizeAxes = Axes.X, - Height = 42, - }, - }, - new DetailBox - { - Child = new Container - { - RelativeSizeAxes = Axes.X, - Height = 35, - }, - }, - new DetailBox - { - Child = new Container - { - RelativeSizeAxes = Axes.X, - Height = 110, - }, - }, - new DetailBox - { - Child = new Container - { - RelativeSizeAxes = Axes.X, - Height = 115, - }, - }, - }, }, }, }, @@ -195,171 +154,5 @@ namespace osu.Game.Overlays.OnlineBeatmapSet { tabsBg.Colour = colours.Gray3; } - - private class Button : OsuClickableContainer - { - private readonly Container content; - - protected override Container Content => content; - - public Button() - { - CornerRadius = 3; - Masking = true; - - InternalChildren = new Drawable[] - { - new Box - { - RelativeSizeAxes = Axes.Both, - Colour = OsuColour.FromHex(@"094c5f"), - }, - new Triangles - { - RelativeSizeAxes = Axes.Both, - ColourLight = OsuColour.FromHex(@"0f7c9b"), - ColourDark = OsuColour.FromHex(@"094c5f"), - TriangleScale = 1.5f, - }, - content = new Container - { - RelativeSizeAxes = Axes.Both, - }, - }; - } - } - - private class DownloadButton : Button - { - public DownloadButton(string title, string subtitle) - { - Width = 120; - RelativeSizeAxes = Axes.Y; - - Child = new Container - { - RelativeSizeAxes = Axes.Both, - Padding = new MarginPadding { Horizontal = 10 }, - Children = new Drawable[] - { - new FillFlowContainer - { - Anchor = Anchor.CentreLeft, - Origin = Anchor.CentreLeft, - AutoSizeAxes = Axes.Both, - Direction = FillDirection.Vertical, - Children = new[] - { - new OsuSpriteText - { - Text = title, - TextSize = 13, - Font = @"Exo2.0-Bold", - }, - new OsuSpriteText - { - Text = subtitle, - TextSize = 11, - Font = @"Exo2.0-Bold", - }, - }, - }, - new SpriteIcon - { - Anchor = Anchor.CentreRight, - Origin = Anchor.CentreRight, - Icon = FontAwesome.fa_download, - Size = new Vector2(16), - Margin = new MarginPadding { Right = 5 }, - }, - }, - }; - } - } - - private class FavouriteButton : Button - { - public readonly Bindable Favourited = new Bindable(); - - public FavouriteButton() - { - RelativeSizeAxes = Axes.Y; - - Container pink; - SpriteIcon icon; - Children = new Drawable[] - { - pink = new Container - { - RelativeSizeAxes = Axes.Both, - Alpha = 0f, - Children = new Drawable[] - { - new Box - { - RelativeSizeAxes = Axes.Both, - Colour = OsuColour.FromHex(@"9f015f"), - }, - new Triangles - { - RelativeSizeAxes = Axes.Both, - ColourLight = OsuColour.FromHex(@"cb2187"), - ColourDark = OsuColour.FromHex(@"9f015f"), - TriangleScale = 1.5f, - }, - }, - }, - icon = new SpriteIcon - { - Anchor = Anchor.Centre, - Origin = Anchor.Centre, - Icon = FontAwesome.fa_heart_o, - Size = new Vector2(18), - Shadow = false, - }, - }; - - Favourited.ValueChanged += value => - { - pink.FadeTo(value ? 1 : 0, 200); - icon.Icon = value ? FontAwesome.fa_heart : FontAwesome.fa_heart_o; - }; - Action = () => Favourited.Value = !Favourited.Value; - } - - protected override void UpdateAfterChildren() - { - base.UpdateAfterChildren(); - - Width = DrawHeight; - } - } - - private class DetailBox : Container - { - private Container content; - protected override Container Content => content; - - public DetailBox() - { - RelativeSizeAxes = Axes.X; - AutoSizeAxes = Axes.Y; - - InternalChildren = new Drawable[] - { - new Box - { - RelativeSizeAxes = Axes.Both, - Colour = Color4.Black.Opacity(0.5f), - }, - content = new Container - { - RelativeSizeAxes = Axes.X, - AutoSizeAxes = Axes.Y, - Padding = new MarginPadding { Horizontal = 15 }, - }, - }; - } - } } } diff --git a/osu.Game/Overlays/OnlineBeatmapSet/HeaderButton.cs b/osu.Game/Overlays/OnlineBeatmapSet/HeaderButton.cs new file mode 100644 index 0000000000..4c46b9e56f --- /dev/null +++ b/osu.Game/Overlays/OnlineBeatmapSet/HeaderButton.cs @@ -0,0 +1,45 @@ +// Copyright (c) 2007-2017 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using osu.Framework.Graphics; +using osu.Framework.Graphics.Containers; +using osu.Framework.Graphics.Shapes; +using osu.Game.Graphics; +using osu.Game.Graphics.Backgrounds; +using osu.Game.Graphics.Containers; + +namespace osu.Game.Overlays.OnlineBeatmapSet +{ + public class HeaderButton : OsuClickableContainer + { + private readonly Container content; + + protected override Container Content => content; + + public HeaderButton() + { + CornerRadius = 3; + Masking = true; + + InternalChildren = new Drawable[] + { + new Box + { + RelativeSizeAxes = Axes.Both, + Colour = OsuColour.FromHex(@"094c5f"), + }, + new Triangles + { + RelativeSizeAxes = Axes.Both, + ColourLight = OsuColour.FromHex(@"0f7c9b"), + ColourDark = OsuColour.FromHex(@"094c5f"), + TriangleScale = 1.5f, + }, + content = new Container + { + RelativeSizeAxes = Axes.Both, + }, + }; + } + } +} From 43fa314fe085179af36bc5823e123c9d7f3f2310 Mon Sep 17 00:00:00 2001 From: DrabWeb Date: Mon, 11 Sep 2017 02:48:48 -0300 Subject: [PATCH 06/30] Details and more data displaying. --- .../Visual/TestCaseOnlineBeatmapSetOverlay.cs | 73 ++++++++++ osu.Game/Beatmaps/BeatmapOnlineInfo.cs | 17 +++ osu.Game/Beatmaps/BeatmapSetOnlineInfo.cs | 10 ++ .../Overlays/OnlineBeatmapSet/BasicStats.cs | 124 ++++++++++++++++ .../OnlineBeatmapSet/BeatmapPicker.cs | 10 +- osu.Game/Overlays/OnlineBeatmapSet/Details.cs | 54 +++++-- osu.Game/Overlays/OnlineBeatmapSet/Header.cs | 31 +++- osu.Game/Overlays/OnlineBeatmapSet/Info.cs | 14 +- .../OnlineBeatmapSet/PreviewButton.cs | 137 ++++++++++++++++++ .../Overlays/OnlineBeatmapSet/SuccessRate.cs | 117 +++++++++++++++ osu.Game/Overlays/OnlineBeatmapSetOverlay.cs | 9 +- osu.Game/osu.Game.csproj | 11 +- 12 files changed, 581 insertions(+), 26 deletions(-) create mode 100644 osu.Game/Overlays/OnlineBeatmapSet/BasicStats.cs create mode 100644 osu.Game/Overlays/OnlineBeatmapSet/PreviewButton.cs create mode 100644 osu.Game/Overlays/OnlineBeatmapSet/SuccessRate.cs diff --git a/osu.Desktop.Tests/Visual/TestCaseOnlineBeatmapSetOverlay.cs b/osu.Desktop.Tests/Visual/TestCaseOnlineBeatmapSetOverlay.cs index 2bbe6ea952..2d26c6c518 100644 --- a/osu.Desktop.Tests/Visual/TestCaseOnlineBeatmapSetOverlay.cs +++ b/osu.Desktop.Tests/Visual/TestCaseOnlineBeatmapSetOverlay.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Linq; using osu.Framework.Allocation; using osu.Framework.Testing; using osu.Game.Beatmaps; @@ -45,6 +46,8 @@ namespace osu.Desktop.VisualTests.Tests FavouriteCount = 356, Submitted = new DateTime(2016, 2, 10), Ranked = new DateTime(2016, 6, 19), + Length = 118000, + BPM = 236, Author = new User { Username = @"Fresh Chicken", @@ -70,6 +73,20 @@ namespace osu.Desktop.VisualTests.Tests OverallDifficulty = 6.5f, ApproachRate = 5, }, + OnlineInfo = new BeatmapOnlineInfo + { + HasVideo = false, + CircleCount = 265, + SliderCount = 71, + PlayCount = 47906, + PassCount = 19899, + }, + Metrics = new BeatmapMetrics + { + Ratings = Enumerable.Range(0, 10), + Fails = Enumerable.Range(1, 100).Select(i => i % 12 - 6), + Retries = Enumerable.Range(-2, 100).Select(i => i % 12 - 6), + }, }, new BeatmapInfo { @@ -84,6 +101,20 @@ namespace osu.Desktop.VisualTests.Tests OverallDifficulty = 7, ApproachRate = 5, }, + OnlineInfo = new BeatmapOnlineInfo + { + HasVideo = false, + CircleCount = 592, + SliderCount = 62, + PlayCount = 162021, + PassCount = 72116, + }, + Metrics = new BeatmapMetrics + { + Ratings = Enumerable.Range(0, 10), + Fails = Enumerable.Range(1, 100).Select(i => i % 12 - 6), + Retries = Enumerable.Range(-2, 100).Select(i => i % 12 - 6), + }, }, new BeatmapInfo { @@ -98,6 +129,20 @@ namespace osu.Desktop.VisualTests.Tests OverallDifficulty = 7.5f, ApproachRate = 5, }, + OnlineInfo = new BeatmapOnlineInfo + { + HasVideo = false, + CircleCount = 1042, + SliderCount = 79, + PlayCount = 225178, + PassCount = 73001, + }, + Metrics = new BeatmapMetrics + { + Ratings = Enumerable.Range(0, 10), + Fails = Enumerable.Range(1, 100).Select(i => i % 12 - 6), + Retries = Enumerable.Range(-2, 100).Select(i => i % 12 - 6), + }, }, new BeatmapInfo { @@ -112,6 +157,20 @@ namespace osu.Desktop.VisualTests.Tests OverallDifficulty = 8, ApproachRate = 5, }, + OnlineInfo = new BeatmapOnlineInfo + { + HasVideo = false, + CircleCount = 1352, + SliderCount = 69, + PlayCount = 131545, + PassCount = 42703, + }, + Metrics = new BeatmapMetrics + { + Ratings = Enumerable.Range(0, 10), + Fails = Enumerable.Range(1, 100).Select(i => i % 12 - 6), + Retries = Enumerable.Range(-2, 100).Select(i => i % 12 - 6), + }, }, new BeatmapInfo { @@ -126,6 +185,20 @@ namespace osu.Desktop.VisualTests.Tests OverallDifficulty = 8.5f, ApproachRate = 5, }, + OnlineInfo = new BeatmapOnlineInfo + { + HasVideo = false, + CircleCount = 1730, + SliderCount = 115, + PlayCount = 117673, + PassCount = 24241, + }, + Metrics = new BeatmapMetrics + { + Ratings = Enumerable.Range(0, 10), + Fails = Enumerable.Range(1, 100).Select(i => i % 12 - 6), + Retries = Enumerable.Range(-2, 100).Select(i => i % 12 - 6), + }, }, }, }); diff --git a/osu.Game/Beatmaps/BeatmapOnlineInfo.cs b/osu.Game/Beatmaps/BeatmapOnlineInfo.cs index e8f40a7e07..c9794107ce 100644 --- a/osu.Game/Beatmaps/BeatmapOnlineInfo.cs +++ b/osu.Game/Beatmaps/BeatmapOnlineInfo.cs @@ -10,6 +10,23 @@ namespace osu.Game.Beatmaps /// public class BeatmapOnlineInfo { + /// + /// Whether or not this beatmap has a background video. + /// + public bool HasVideo { get; set; } + + /// + /// The amount of circles in this beatmap. + /// + [JsonProperty(@"count_circles")] + public int CircleCount { get; set; } + + /// + /// The amount of sliders in this beatmap. + /// + [JsonProperty(@"count_sliders")] + public int SliderCount { get; set; } + /// /// The amount of plays this beatmap has. /// diff --git a/osu.Game/Beatmaps/BeatmapSetOnlineInfo.cs b/osu.Game/Beatmaps/BeatmapSetOnlineInfo.cs index 40755b468f..8009ea5b9e 100644 --- a/osu.Game/Beatmaps/BeatmapSetOnlineInfo.cs +++ b/osu.Game/Beatmaps/BeatmapSetOnlineInfo.cs @@ -44,6 +44,16 @@ namespace osu.Game.Beatmaps [JsonProperty(@"previewUrl")] public string Preview { get; set; } + /// + /// The length in milliseconds of this beatmap's song. + /// + public double Length { get; set; } + + /// + /// The beats per minute of this beatmap set's song. + /// + public double BPM { get; set; } + /// /// The amount of plays this beatmap set has. /// diff --git a/osu.Game/Overlays/OnlineBeatmapSet/BasicStats.cs b/osu.Game/Overlays/OnlineBeatmapSet/BasicStats.cs new file mode 100644 index 0000000000..fa45a04b40 --- /dev/null +++ b/osu.Game/Overlays/OnlineBeatmapSet/BasicStats.cs @@ -0,0 +1,124 @@ +// Copyright (c) 2007-2017 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using System; +using OpenTK; +using osu.Framework.Allocation; +using osu.Framework.Graphics; +using osu.Framework.Graphics.Containers; +using osu.Framework.Graphics.Cursor; +using osu.Game.Beatmaps; +using osu.Game.Graphics; +using osu.Game.Graphics.Sprites; + +namespace osu.Game.Overlays.OnlineBeatmapSet +{ + public class BasicStats : Container + { + private readonly Statistic length, bpm, circleCount, sliderCount; + + private BeatmapInfo beatmap; + public BeatmapInfo Beatmap + { + get { return beatmap; } + set + { + if (value == beatmap) return; + beatmap = value; + circleCount.Value = string.Format(@"{0:n0}", beatmap.OnlineInfo.CircleCount); + sliderCount.Value = string.Format(@"{0:n0}", beatmap.OnlineInfo.SliderCount); + } + } + + public BasicStats(BeatmapSetInfo set) + { + var statWidth = 0.25f; + Child = new FillFlowContainer + { + RelativeSizeAxes = Axes.X, + AutoSizeAxes = Axes.Y, + Direction = FillDirection.Horizontal, + Children = new[] + { + length = new Statistic(FontAwesome.fa_clock_o, "Length") + { + Width = statWidth, + Value = TimeSpan.FromMilliseconds(set.OnlineInfo.Length).ToString(@"m\:ss"), + }, + bpm = new Statistic(FontAwesome.fa_circle, "BPM") + { + Width = statWidth, + Value = set.OnlineInfo.BPM.ToString(@"0.##"), + }, + circleCount = new Statistic(FontAwesome.fa_circle_o, "Circle Count") { Width = statWidth }, + sliderCount = new Statistic(FontAwesome.fa_circle, "Slider Count") { Width = statWidth }, + }, + }; + } + + private class Statistic : Container, IHasTooltip + { + private readonly string name; + private readonly OsuSpriteText value; + + public string TooltipText => name; + public string Value + { + get { return value.Text; } + set { this.value.Text = value; } + } + + public Statistic(FontAwesome icon, string name) + { + this.name = name; + RelativeSizeAxes = Axes.X; + AutoSizeAxes = Axes.Y; + + Children = new Drawable[] + { + new Container + { + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + AutoSizeAxes = Axes.Both, + Children = new Drawable[] + { + new SpriteIcon + { + Anchor = Anchor.CentreLeft, + Origin = Anchor.Centre, + Icon = FontAwesome.fa_square, + Size = new Vector2(13), + Rotation = 45, + Colour = OsuColour.FromHex(@"441288"), + }, + new SpriteIcon + { + Anchor = Anchor.CentreLeft, + Origin = Anchor.Centre, + Icon = icon, + Size = new Vector2(13), + Colour = OsuColour.FromHex(@"f7dd55"), + Scale = new Vector2(0.8f), + }, + value = new OsuSpriteText + { + Anchor = Anchor.CentreLeft, + Origin = Anchor.CentreLeft, + TextSize = 13, + Font = @"Exo2.0-Bold", + Margin = new MarginPadding { Left = 10 }, + }, + }, + }, + }; + } + + [BackgroundDependencyLoader] + private void load(OsuColour colour) + { + value.Colour = colour.Yellow; + } + } + } +} diff --git a/osu.Game/Overlays/OnlineBeatmapSet/BeatmapPicker.cs b/osu.Game/Overlays/OnlineBeatmapSet/BeatmapPicker.cs index 2a0e137a4e..3a1fe9bd07 100644 --- a/osu.Game/Overlays/OnlineBeatmapSet/BeatmapPicker.cs +++ b/osu.Game/Overlays/OnlineBeatmapSet/BeatmapPicker.cs @@ -107,8 +107,6 @@ namespace osu.Game.Overlays.OnlineBeatmapSet starRating.FadeIn(100); }, }); - - Beatmap.TriggerChange(); } [BackgroundDependencyLoader] @@ -117,6 +115,14 @@ namespace osu.Game.Overlays.OnlineBeatmapSet starRating.Colour = colours.Yellow; } + protected override void LoadComplete() + { + base.LoadComplete(); + + // done here so everything can bind in intialization and get the first trigger + Beatmap.TriggerChange(); + } + private void showBeatmap(BeatmapInfo beatmap) => version.Text = beatmap.Version; private class TilesFillFlowContainer : FillFlowContainer diff --git a/osu.Game/Overlays/OnlineBeatmapSet/Details.cs b/osu.Game/Overlays/OnlineBeatmapSet/Details.cs index 69a489d05a..300eb3a8e1 100644 --- a/osu.Game/Overlays/OnlineBeatmapSet/Details.cs +++ b/osu.Game/Overlays/OnlineBeatmapSet/Details.cs @@ -7,12 +7,32 @@ using osu.Framework.Extensions.Color4Extensions; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Shapes; +using osu.Game.Beatmaps; +using osu.Game.Screens.Select.Details; namespace osu.Game.Overlays.OnlineBeatmapSet { public class Details : FillFlowContainer { - public Details() + private readonly BasicStats basic; + private readonly AdvancedStats advanced; + private readonly UserRatings ratings; + + private BeatmapInfo beatmap; + public BeatmapInfo Beatmap + { + get { return beatmap; } + set + { + if (value == beatmap) return; + beatmap = value; + + basic.Beatmap = advanced.Beatmap = Beatmap; + ratings.Metrics = Beatmap.Metrics; + } + } + + public Details(BeatmapSetInfo set) { Width = OnlineBeatmapSetOverlay.RIGHT_WIDTH; AutoSizeAxes = Axes.Y; @@ -20,36 +40,40 @@ namespace osu.Game.Overlays.OnlineBeatmapSet Children = new Drawable[] { + new AsyncLoadWrapper(new PreviewButton(set) + { + RelativeSizeAxes = Axes.X, + }) + { + RelativeSizeAxes = Axes.X, + AutoSizeAxes = Axes.Y, + }, new DetailBox { - Child = new Container + Child = basic = new BasicStats(set) { RelativeSizeAxes = Axes.X, - Height = 42, + AutoSizeAxes = Axes.Y, + Margin = new MarginPadding { Vertical = 10 }, + Padding = new MarginPadding { Horizontal = 15 }, }, }, new DetailBox { - Child = new Container + Child = advanced = new AdvancedStats { RelativeSizeAxes = Axes.X, - Height = 35, + AutoSizeAxes = Axes.Y, + Margin = new MarginPadding { Vertical = 7.5f }, }, }, new DetailBox { - Child = new Container + Child = ratings = new UserRatings { RelativeSizeAxes = Axes.X, - Height = 110, - }, - }, - new DetailBox - { - Child = new Container - { - RelativeSizeAxes = Axes.X, - Height = 115, + Height = 95, + Margin = new MarginPadding { Top = 10 }, }, }, }; diff --git a/osu.Game/Overlays/OnlineBeatmapSet/Header.cs b/osu.Game/Overlays/OnlineBeatmapSet/Header.cs index cea497af8c..8200a9a373 100644 --- a/osu.Game/Overlays/OnlineBeatmapSet/Header.cs +++ b/osu.Game/Overlays/OnlineBeatmapSet/Header.cs @@ -22,6 +22,8 @@ namespace osu.Game.Overlays.OnlineBeatmapSet private readonly Box tabsBg; + public readonly BeatmapPicker Picker; + public Header(BeatmapSetInfo set) { RelativeSizeAxes = Axes.X; @@ -35,6 +37,8 @@ namespace osu.Game.Overlays.OnlineBeatmapSet Offset = new Vector2(0f, 1f), }; + FillFlowContainer buttons; + Details details; Children = new Drawable[] { new Container @@ -101,7 +105,7 @@ namespace osu.Game.Overlays.OnlineBeatmapSet { RelativeSizeAxes = Axes.X, Height = 113, - Child = new BeatmapPicker(set), + Child = Picker = new BeatmapPicker(set), }, new OsuSpriteText { @@ -122,7 +126,7 @@ namespace osu.Game.Overlays.OnlineBeatmapSet Margin = new MarginPadding { Top = 20 }, Child = new AuthorInfo(set.OnlineInfo), }, - new FillFlowContainer + buttons = new FillFlowContainer { RelativeSizeAxes = Axes.X, Height = 45, @@ -131,14 +135,12 @@ namespace osu.Game.Overlays.OnlineBeatmapSet Children = new HeaderButton[] { new FavouriteButton(), - new DownloadButton("Download", ""), - new DownloadButton("osu!direct", ""), }, }, }, }, }, - new Details + details = new Details(set) { Anchor = Anchor.BottomRight, Origin = Anchor.BottomRight, @@ -147,6 +149,25 @@ namespace osu.Game.Overlays.OnlineBeatmapSet }, }, }; + + Picker.Beatmap.ValueChanged += b => + { + details.Beatmap = b; + + buttons.Child = new FavouriteButton(); + if (b.OnlineInfo.HasVideo) + { + buttons.AddRange(new[] + { + new DownloadButton("Download", "with Video"), + new DownloadButton("Download", "without Video"), + }); + } + else + { + buttons.Add(new DownloadButton("Download", @"")); + } + }; } [BackgroundDependencyLoader] diff --git a/osu.Game/Overlays/OnlineBeatmapSet/Info.cs b/osu.Game/Overlays/OnlineBeatmapSet/Info.cs index b4c505b136..e311b6e886 100644 --- a/osu.Game/Overlays/OnlineBeatmapSet/Info.cs +++ b/osu.Game/Overlays/OnlineBeatmapSet/Info.cs @@ -22,9 +22,16 @@ namespace osu.Game.Overlays.OnlineBeatmapSet private readonly BeatmapSetInfo set; private readonly Box successRateBackground; + private readonly SuccessRate successRate; private readonly FillFlowContainer metadataFlow; private readonly ScrollContainer descriptionScroll; + public BeatmapInfo Beatmap + { + get { return successRate.Beatmap; } + set { successRate.Beatmap = value; } + } + public Info(BeatmapSetInfo set) { this.set = set; @@ -85,12 +92,17 @@ namespace osu.Game.Overlays.OnlineBeatmapSet Origin = Anchor.TopRight, RelativeSizeAxes = Axes.Y, Width = OnlineBeatmapSetOverlay.RIGHT_WIDTH, - Children = new[] + Children = new Drawable[] { successRateBackground = new Box { RelativeSizeAxes = Axes.Both, }, + successRate = new SuccessRate + { + RelativeSizeAxes = Axes.Both, + Padding = new MarginPadding { Top = 20, Horizontal = 15 }, + }, }, }, }, diff --git a/osu.Game/Overlays/OnlineBeatmapSet/PreviewButton.cs b/osu.Game/Overlays/OnlineBeatmapSet/PreviewButton.cs new file mode 100644 index 0000000000..a86623048a --- /dev/null +++ b/osu.Game/Overlays/OnlineBeatmapSet/PreviewButton.cs @@ -0,0 +1,137 @@ +// Copyright (c) 2007-2017 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using OpenTK; +using OpenTK.Graphics; +using osu.Framework.Allocation; +using osu.Framework.Audio; +using osu.Framework.Audio.Track; +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.Graphics; +using osu.Game.Graphics.Containers; + +namespace osu.Game.Overlays.OnlineBeatmapSet +{ + public class PreviewButton : OsuClickableContainer + { + private readonly BeatmapSetInfo set; + private readonly Box bg, progress; + private readonly SpriteIcon icon; + + private AudioManager audio; + private Track preview; + + private bool playing = false; + public bool Playing + { + get { return playing; } + set + { + if (value == playing) return; + playing = value; + + if (Playing) + { + icon.Icon = FontAwesome.fa_stop; + progress.FadeIn(100); + + loadPreview(); + preview.Start(); + } + else + { + icon.Icon = FontAwesome.fa_play; + progress.FadeOut(100); + preview.Stop(); + } + } + } + + public PreviewButton(BeatmapSetInfo set) + { + this.set = set; + Height = 42; + + Children = new Drawable[] + { + bg = new Box + { + RelativeSizeAxes = Axes.Both, + Colour = Color4.Black.Opacity(0.25f), + }, + new Container + { + Anchor = Anchor.BottomLeft, + Origin = Anchor.BottomLeft, + RelativeSizeAxes = Axes.X, + Height = 3, + Child = progress = new Box + { + RelativeSizeAxes = Axes.Both, + Width = 0f, + Alpha = 0f, + }, + }, + icon = new SpriteIcon + { + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + Icon = FontAwesome.fa_play, + Size = new Vector2(18), + Shadow = false, + }, + }; + + Action = () => Playing = !Playing; + } + + [BackgroundDependencyLoader] + private void load(OsuColour colours, AudioManager audio) + { + this.audio = audio; + progress.Colour = colours.Yellow; + + loadPreview(); + } + + protected override void Update() + { + base.Update(); + + if (Playing) + { + progress.Width = (float)(preview.CurrentTime / preview.Length); + if (preview.HasCompleted) Playing = false; + } + } + + protected override bool OnHover(InputState state) + { + bg.FadeColour(Color4.Black.Opacity(0.5f), 100); + return base.OnHover(state); + } + + protected override void OnHoverLost(InputState state) + { + bg.FadeColour(Color4.Black.Opacity(0.25f), 100); + } + + private void loadPreview() + { + if (preview?.HasCompleted ?? true) + { + preview = audio.Track.Get(set.OnlineInfo.Preview); + preview.Volume.Value = 0.5; + } + else + { + preview.Seek(0); + } + } + } +} diff --git a/osu.Game/Overlays/OnlineBeatmapSet/SuccessRate.cs b/osu.Game/Overlays/OnlineBeatmapSet/SuccessRate.cs new file mode 100644 index 0000000000..88aef753ff --- /dev/null +++ b/osu.Game/Overlays/OnlineBeatmapSet/SuccessRate.cs @@ -0,0 +1,117 @@ +// 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.Game.Graphics; +using osu.Game.Graphics.Sprites; +using osu.Game.Graphics.UserInterface; +using osu.Game.Beatmaps; +using osu.Game.Screens.Select.Details; +using System; + +namespace osu.Game.Overlays.OnlineBeatmapSet +{ + public class SuccessRate : Container + { + private readonly FillFlowContainer header; + private readonly OsuSpriteText successRateLabel, successPercent, graphLabel; + private readonly Bar successRate; + private readonly Container percentContainer; + private readonly FailRetryGraph graph; + + private BeatmapInfo beatmap; + public BeatmapInfo Beatmap + { + get { return beatmap; } + set + { + if (value == beatmap) return; + beatmap = value; + + var rate = (float)beatmap.OnlineInfo.PassCount / beatmap.OnlineInfo.PlayCount; + successPercent.Text = $"{Math.Round(rate * 100)}%"; + successRate.Length = rate; + + graph.Metrics = Beatmap.Metrics; + } + } + + public SuccessRate() + { + Children = new Drawable[] + { + header = new FillFlowContainer + { + RelativeSizeAxes = Axes.X, + AutoSizeAxes = Axes.Y, + Direction = FillDirection.Vertical, + Children = new Drawable[] + { + successRateLabel = new OsuSpriteText + { + Anchor = Anchor.TopCentre, + Origin = Anchor.TopCentre, + Text = "Success Rate", + TextSize = 13, + }, + successRate = new Bar + { + RelativeSizeAxes = Axes.X, + Height = 5, + Margin = new MarginPadding { Top = 5 }, + }, + percentContainer = new Container + { + RelativeSizeAxes = Axes.X, + AutoSizeAxes = Axes.Y, + Child = successPercent = new OsuSpriteText + { + Anchor = Anchor.TopRight, + Origin = Anchor.TopCentre, + TextSize = 13, + }, + }, + graphLabel = new OsuSpriteText + { + Anchor = Anchor.TopCentre, + Origin = Anchor.TopCentre, + Text = "Points of Failure", + TextSize = 13, + Margin = new MarginPadding { Vertical = 20 }, + }, + }, + }, + graph = new FailRetryGraph + { + Anchor = Anchor.BottomLeft, + Origin = Anchor.BottomLeft, + RelativeSizeAxes = Axes.Both, + }, + }; + } + + [BackgroundDependencyLoader] + private void load(OsuColour colours) + { + successRateLabel.Colour = successPercent.Colour = graphLabel.Colour = colours.Gray5; + successRate.AccentColour = colours.Green; + successRate.BackgroundColour = colours.GrayD; + } + + protected override void UpdateAfterChildren() + { + base.UpdateAfterChildren(); + + graph.Padding = new MarginPadding { Top = header.DrawHeight }; + } + + protected override void Update() + { + base.Update(); + + percentContainer.Width = successRate.Length; + } + } +} diff --git a/osu.Game/Overlays/OnlineBeatmapSetOverlay.cs b/osu.Game/Overlays/OnlineBeatmapSetOverlay.cs index 4fae3cac35..6e3a2019d0 100644 --- a/osu.Game/Overlays/OnlineBeatmapSetOverlay.cs +++ b/osu.Game/Overlays/OnlineBeatmapSetOverlay.cs @@ -1,6 +1,7 @@ // Copyright (c) 2007-2017 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE +using System.Linq; using OpenTK; using OpenTK.Graphics; using osu.Framework.Extensions.Color4Extensions; @@ -68,12 +69,16 @@ namespace osu.Game.Overlays public void ShowBeatmapSet(BeatmapSetInfo set) { + Header header; + Info info; scrollContent.Children = new Drawable[] { - new Header(set), - new Info(set), + header = new Header(set), + info = new Info(set), }; + header.Picker.Beatmap.ValueChanged += b => info.Beatmap = b; + Show(); } } diff --git a/osu.Game/osu.Game.csproj b/osu.Game/osu.Game.csproj index 7db65a0b4c..42dd1ad032 100644 --- a/osu.Game/osu.Game.csproj +++ b/osu.Game/osu.Game.csproj @@ -545,6 +545,15 @@ + + + + + + + + + @@ -570,4 +579,4 @@ --> - + \ No newline at end of file From 4be8899fb29b70ed7edace67c731d699cc3ebd2f Mon Sep 17 00:00:00 2001 From: DrabWeb Date: Mon, 11 Sep 2017 02:55:32 -0300 Subject: [PATCH 07/30] Move Length to BeatmapOnlineInfo. --- .../Visual/TestCaseOnlineBeatmapSetOverlay.cs | 6 +++++- osu.Game/Beatmaps/BeatmapOnlineInfo.cs | 5 +++++ osu.Game/Beatmaps/BeatmapSetOnlineInfo.cs | 5 ----- osu.Game/Overlays/OnlineBeatmapSet/BasicStats.cs | 8 +++----- 4 files changed, 13 insertions(+), 11 deletions(-) diff --git a/osu.Desktop.Tests/Visual/TestCaseOnlineBeatmapSetOverlay.cs b/osu.Desktop.Tests/Visual/TestCaseOnlineBeatmapSetOverlay.cs index 2d26c6c518..5bec99e5a5 100644 --- a/osu.Desktop.Tests/Visual/TestCaseOnlineBeatmapSetOverlay.cs +++ b/osu.Desktop.Tests/Visual/TestCaseOnlineBeatmapSetOverlay.cs @@ -46,7 +46,6 @@ namespace osu.Desktop.VisualTests.Tests FavouriteCount = 356, Submitted = new DateTime(2016, 2, 10), Ranked = new DateTime(2016, 6, 19), - Length = 118000, BPM = 236, Author = new User { @@ -75,6 +74,7 @@ namespace osu.Desktop.VisualTests.Tests }, OnlineInfo = new BeatmapOnlineInfo { + Length = 115000, HasVideo = false, CircleCount = 265, SliderCount = 71, @@ -103,6 +103,7 @@ namespace osu.Desktop.VisualTests.Tests }, OnlineInfo = new BeatmapOnlineInfo { + Length = 118000, HasVideo = false, CircleCount = 592, SliderCount = 62, @@ -131,6 +132,7 @@ namespace osu.Desktop.VisualTests.Tests }, OnlineInfo = new BeatmapOnlineInfo { + Length = 118000, HasVideo = false, CircleCount = 1042, SliderCount = 79, @@ -159,6 +161,7 @@ namespace osu.Desktop.VisualTests.Tests }, OnlineInfo = new BeatmapOnlineInfo { + Length = 118000, HasVideo = false, CircleCount = 1352, SliderCount = 69, @@ -187,6 +190,7 @@ namespace osu.Desktop.VisualTests.Tests }, OnlineInfo = new BeatmapOnlineInfo { + Length = 118000, HasVideo = false, CircleCount = 1730, SliderCount = 115, diff --git a/osu.Game/Beatmaps/BeatmapOnlineInfo.cs b/osu.Game/Beatmaps/BeatmapOnlineInfo.cs index c9794107ce..399cabda99 100644 --- a/osu.Game/Beatmaps/BeatmapOnlineInfo.cs +++ b/osu.Game/Beatmaps/BeatmapOnlineInfo.cs @@ -10,6 +10,11 @@ namespace osu.Game.Beatmaps /// public class BeatmapOnlineInfo { + /// + /// The length in milliseconds of this beatmap's song. + /// + public double Length { get; set; } + /// /// Whether or not this beatmap has a background video. /// diff --git a/osu.Game/Beatmaps/BeatmapSetOnlineInfo.cs b/osu.Game/Beatmaps/BeatmapSetOnlineInfo.cs index 8009ea5b9e..b53aee9661 100644 --- a/osu.Game/Beatmaps/BeatmapSetOnlineInfo.cs +++ b/osu.Game/Beatmaps/BeatmapSetOnlineInfo.cs @@ -44,11 +44,6 @@ namespace osu.Game.Beatmaps [JsonProperty(@"previewUrl")] public string Preview { get; set; } - /// - /// The length in milliseconds of this beatmap's song. - /// - public double Length { get; set; } - /// /// The beats per minute of this beatmap set's song. /// diff --git a/osu.Game/Overlays/OnlineBeatmapSet/BasicStats.cs b/osu.Game/Overlays/OnlineBeatmapSet/BasicStats.cs index fa45a04b40..d5acfd2e43 100644 --- a/osu.Game/Overlays/OnlineBeatmapSet/BasicStats.cs +++ b/osu.Game/Overlays/OnlineBeatmapSet/BasicStats.cs @@ -25,6 +25,8 @@ namespace osu.Game.Overlays.OnlineBeatmapSet { if (value == beatmap) return; beatmap = value; + + length.Value = TimeSpan.FromMilliseconds(beatmap.OnlineInfo.Length).ToString(@"m\:ss"); circleCount.Value = string.Format(@"{0:n0}", beatmap.OnlineInfo.CircleCount); sliderCount.Value = string.Format(@"{0:n0}", beatmap.OnlineInfo.SliderCount); } @@ -40,11 +42,7 @@ namespace osu.Game.Overlays.OnlineBeatmapSet Direction = FillDirection.Horizontal, Children = new[] { - length = new Statistic(FontAwesome.fa_clock_o, "Length") - { - Width = statWidth, - Value = TimeSpan.FromMilliseconds(set.OnlineInfo.Length).ToString(@"m\:ss"), - }, + length = new Statistic(FontAwesome.fa_clock_o, "Length") { Width = statWidth }, bpm = new Statistic(FontAwesome.fa_circle, "BPM") { Width = statWidth, From 169bfe134bfe9e8e047c8104e1dd8c3271de108a Mon Sep 17 00:00:00 2001 From: DrabWeb Date: Tue, 12 Sep 2017 20:24:24 -0300 Subject: [PATCH 08/30] Fix incorrect BasicStats padding. --- osu.Game/Overlays/OnlineBeatmapSet/Details.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/osu.Game/Overlays/OnlineBeatmapSet/Details.cs b/osu.Game/Overlays/OnlineBeatmapSet/Details.cs index 300eb3a8e1..9aed59272d 100644 --- a/osu.Game/Overlays/OnlineBeatmapSet/Details.cs +++ b/osu.Game/Overlays/OnlineBeatmapSet/Details.cs @@ -55,7 +55,6 @@ namespace osu.Game.Overlays.OnlineBeatmapSet RelativeSizeAxes = Axes.X, AutoSizeAxes = Axes.Y, Margin = new MarginPadding { Vertical = 10 }, - Padding = new MarginPadding { Horizontal = 15 }, }, }, new DetailBox From a291bd30204b83f155f40c156c90f8217673f724 Mon Sep 17 00:00:00 2001 From: DrabWeb Date: Tue, 12 Sep 2017 20:55:17 -0300 Subject: [PATCH 09/30] Add second beatmap set to test, fix some visual issues. --- .../Visual/TestCaseOnlineBeatmapSetOverlay.cs | 201 ++++++++++++++++-- .../Overlays/OnlineBeatmapSet/AuthorInfo.cs | 1 - .../OnlineBeatmapSet/BeatmapPicker.cs | 4 +- osu.Game/Overlays/OnlineBeatmapSet/Info.cs | 15 +- .../OnlineBeatmapSet/PreviewButton.cs | 6 + .../Overlays/OnlineBeatmapSet/SuccessRate.cs | 1 + osu.Game/Overlays/OnlineBeatmapSetOverlay.cs | 1 - 7 files changed, 206 insertions(+), 23 deletions(-) diff --git a/osu.Desktop.Tests/Visual/TestCaseOnlineBeatmapSetOverlay.cs b/osu.Desktop.Tests/Visual/TestCaseOnlineBeatmapSetOverlay.cs index 5bec99e5a5..be7127eaaf 100644 --- a/osu.Desktop.Tests/Visual/TestCaseOnlineBeatmapSetOverlay.cs +++ b/osu.Desktop.Tests/Visual/TestCaseOnlineBeatmapSetOverlay.cs @@ -1,4 +1,7 @@ -using System; +// Copyright (c) 2007-2017 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using System; using System.Collections.Generic; using System.Linq; using osu.Framework.Allocation; @@ -24,18 +27,17 @@ namespace osu.Desktop.VisualTests.Tests [BackgroundDependencyLoader] private void load(RulesetStore rulesets) { - var r = rulesets.GetRuleset(3); + var mania = rulesets.GetRuleset(3); + var taiko = rulesets.GetRuleset(1); - AddStep(@"show lachryma", () => + AddStep(@"show first", () => { overlay.ShowBeatmapSet(new BeatmapSetInfo { - OnlineBeatmapSetID = 415886, Metadata = new BeatmapMetadata { Title = @"Lachryma ", Artist = @"Kaneko Chiharu", - Author = @"Fresh Chicken", Source = @"SOUND VOLTEX III GRAVITY WARS", Tags = @"sdvx grace the 5th kac original song contest konami bemani", }, @@ -61,10 +63,9 @@ namespace osu.Desktop.VisualTests.Tests { new BeatmapInfo { - OnlineBeatmapID = 901048, StarDifficulty = 1.36, Version = @"BASIC", - Ruleset = r, + Ruleset = mania, Difficulty = new BeatmapDifficulty { CircleSize = 4, @@ -90,10 +91,9 @@ namespace osu.Desktop.VisualTests.Tests }, new BeatmapInfo { - OnlineBeatmapID = 901051, StarDifficulty = 2.22, Version = @"NOVICE", - Ruleset = r, + Ruleset = mania, Difficulty = new BeatmapDifficulty { CircleSize = 4, @@ -119,10 +119,9 @@ namespace osu.Desktop.VisualTests.Tests }, new BeatmapInfo { - OnlineBeatmapID = 901047, StarDifficulty = 3.49, Version = @"ADVANCED", - Ruleset = r, + Ruleset = mania, Difficulty = new BeatmapDifficulty { CircleSize = 4, @@ -148,10 +147,9 @@ namespace osu.Desktop.VisualTests.Tests }, new BeatmapInfo { - OnlineBeatmapID = 901049, StarDifficulty = 4.24, Version = @"EXHAUST", - Ruleset = r, + Ruleset = mania, Difficulty = new BeatmapDifficulty { CircleSize = 4, @@ -177,10 +175,9 @@ namespace osu.Desktop.VisualTests.Tests }, new BeatmapInfo { - OnlineBeatmapID = 901050, StarDifficulty = 5.26, Version = @"GRAVITY", - Ruleset = r, + Ruleset = mania, Difficulty = new BeatmapDifficulty { CircleSize = 4, @@ -207,6 +204,180 @@ namespace osu.Desktop.VisualTests.Tests }, }); }); + + AddStep(@"show second", () => + { + overlay.ShowBeatmapSet(new BeatmapSetInfo + { + Metadata = new BeatmapMetadata + { + Title = @"Soumatou Labyrinth", + Artist = @"Yunomi with Momobako&miko", + Tags = @"mmbk.com yuzu__rinrin charlotte", + }, + OnlineInfo = new BeatmapSetOnlineInfo + { + Preview = @"https://b.ppy.sh/preview/625493.mp3", + PlayCount = 22996, + FavouriteCount = 58, + Submitted = new DateTime(2016, 6, 11), + Ranked = new DateTime(2016, 7, 12), + BPM = 160, + Author = new User + { + Username = @"komasy", + Id = 1980256, + }, + Covers = new BeatmapSetOnlineCovers + { + Cover = @"https://assets.ppy.sh/beatmaps/625493/covers/cover.jpg?1499167472", + }, + }, + Beatmaps = new List + { + new BeatmapInfo + { + StarDifficulty = 1.40, + Version = @"yzrin's Kantan", + Ruleset = taiko, + Difficulty = new BeatmapDifficulty + { + CircleSize = 2, + DrainRate = 7, + OverallDifficulty = 3, + ApproachRate = 10, + }, + OnlineInfo = new BeatmapOnlineInfo + { + Length = 193000, + HasVideo = false, + CircleCount = 262, + SliderCount = 0, + PlayCount = 3952, + PassCount = 1373, + }, + Metrics = new BeatmapMetrics + { + Ratings = Enumerable.Range(0, 10), + Fails = Enumerable.Range(1, 100).Select(i => i % 12 - 6), + Retries = Enumerable.Range(-2, 100).Select(i => i % 12 - 6), + }, + }, + new BeatmapInfo + { + StarDifficulty = 2.23, + Version = @"Futsuu", + Ruleset = taiko, + Difficulty = new BeatmapDifficulty + { + CircleSize = 2, + DrainRate = 6, + OverallDifficulty = 4, + ApproachRate = 10, + }, + OnlineInfo = new BeatmapOnlineInfo + { + Length = 193000, + HasVideo = false, + CircleCount = 464, + SliderCount = 0, + PlayCount = 4833, + PassCount = 920, + }, + Metrics = new BeatmapMetrics + { + Ratings = Enumerable.Range(0, 10), + Fails = Enumerable.Range(1, 100).Select(i => i % 12 - 6), + Retries = Enumerable.Range(-2, 100).Select(i => i % 12 - 6), + }, + }, + new BeatmapInfo + { + StarDifficulty = 3.19, + Version = @"Muzukashii", + Ruleset = taiko, + Difficulty = new BeatmapDifficulty + { + CircleSize = 2, + DrainRate = 6, + OverallDifficulty = 5, + ApproachRate = 10, + }, + OnlineInfo = new BeatmapOnlineInfo + { + Length = 193000, + HasVideo = false, + CircleCount = 712, + SliderCount = 0, + PlayCount = 4405, + PassCount = 854, + }, + Metrics = new BeatmapMetrics + { + Ratings = Enumerable.Range(0, 10), + Fails = Enumerable.Range(1, 100).Select(i => i % 12 - 6), + Retries = Enumerable.Range(-2, 100).Select(i => i % 12 - 6), + }, + }, + new BeatmapInfo + { + StarDifficulty = 3.97, + Version = @"Charlotte's Oni", + Ruleset = taiko, + Difficulty = new BeatmapDifficulty + { + CircleSize = 5, + DrainRate = 6, + OverallDifficulty = 5.5f, + ApproachRate = 10, + }, + OnlineInfo = new BeatmapOnlineInfo + { + Length = 193000, + HasVideo = false, + CircleCount = 943, + SliderCount = 0, + PlayCount = 3950, + PassCount = 693, + }, + Metrics = new BeatmapMetrics + { + Ratings = Enumerable.Range(0, 10), + Fails = Enumerable.Range(1, 100).Select(i => i % 12 - 6), + Retries = Enumerable.Range(-2, 100).Select(i => i % 12 - 6), + }, + }, + new BeatmapInfo + { + StarDifficulty = 5.08, + Version = @"Labyrinth Oni", + Ruleset = taiko, + Difficulty = new BeatmapDifficulty + { + CircleSize = 5, + DrainRate = 5, + OverallDifficulty = 6, + ApproachRate = 10, + }, + OnlineInfo = new BeatmapOnlineInfo + { + Length = 193000, + HasVideo = false, + CircleCount = 1068, + SliderCount = 0, + PlayCount = 5856, + PassCount = 1207, + }, + Metrics = new BeatmapMetrics + { + Ratings = Enumerable.Range(0, 10), + Fails = Enumerable.Range(1, 100).Select(i => i % 12 - 6), + Retries = Enumerable.Range(-2, 100).Select(i => i % 12 - 6), + }, + }, + }, + }); + }); } } } diff --git a/osu.Game/Overlays/OnlineBeatmapSet/AuthorInfo.cs b/osu.Game/Overlays/OnlineBeatmapSet/AuthorInfo.cs index af4566a3f8..a3df59d866 100644 --- a/osu.Game/Overlays/OnlineBeatmapSet/AuthorInfo.cs +++ b/osu.Game/Overlays/OnlineBeatmapSet/AuthorInfo.cs @@ -1,7 +1,6 @@ // Copyright (c) 2007-2017 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE -using System; using OpenTK; using OpenTK.Graphics; using osu.Framework.Extensions.Color4Extensions; diff --git a/osu.Game/Overlays/OnlineBeatmapSet/BeatmapPicker.cs b/osu.Game/Overlays/OnlineBeatmapSet/BeatmapPicker.cs index 3a1fe9bd07..2bdffc687a 100644 --- a/osu.Game/Overlays/OnlineBeatmapSet/BeatmapPicker.cs +++ b/osu.Game/Overlays/OnlineBeatmapSet/BeatmapPicker.cs @@ -88,8 +88,8 @@ namespace osu.Game.Overlays.OnlineBeatmapSet Margin = new MarginPadding { Top = 5 }, Children = new[] { - new Statistic(FontAwesome.fa_play_circle, 682712), - new Statistic(FontAwesome.fa_heart, 357), + new Statistic(FontAwesome.fa_play_circle, set.OnlineInfo.PlayCount), + new Statistic(FontAwesome.fa_heart, set.OnlineInfo.FavouriteCount), }, }, }, diff --git a/osu.Game/Overlays/OnlineBeatmapSet/Info.cs b/osu.Game/Overlays/OnlineBeatmapSet/Info.cs index e311b6e886..b820345839 100644 --- a/osu.Game/Overlays/OnlineBeatmapSet/Info.cs +++ b/osu.Game/Overlays/OnlineBeatmapSet/Info.cs @@ -151,11 +151,18 @@ namespace osu.Game.Overlays.OnlineBeatmapSet }, }; - content.AddText(body, t => + if (!string.IsNullOrEmpty(body)) { - t.TextSize = 14; - t.Colour = textColour; - }); + content.AddText(body, t => + { + t.TextSize = 14; + t.Colour = textColour; + }); + } + else + { + Hide(); + } } [BackgroundDependencyLoader] diff --git a/osu.Game/Overlays/OnlineBeatmapSet/PreviewButton.cs b/osu.Game/Overlays/OnlineBeatmapSet/PreviewButton.cs index a86623048a..fa64348902 100644 --- a/osu.Game/Overlays/OnlineBeatmapSet/PreviewButton.cs +++ b/osu.Game/Overlays/OnlineBeatmapSet/PreviewButton.cs @@ -110,6 +110,12 @@ namespace osu.Game.Overlays.OnlineBeatmapSet } } + protected override void Dispose(bool isDisposing) + { + Playing = false; + base.Dispose(isDisposing); + } + protected override bool OnHover(InputState state) { bg.FadeColour(Color4.Black.Opacity(0.5f), 100); diff --git a/osu.Game/Overlays/OnlineBeatmapSet/SuccessRate.cs b/osu.Game/Overlays/OnlineBeatmapSet/SuccessRate.cs index 88aef753ff..c9326faf7f 100644 --- a/osu.Game/Overlays/OnlineBeatmapSet/SuccessRate.cs +++ b/osu.Game/Overlays/OnlineBeatmapSet/SuccessRate.cs @@ -70,6 +70,7 @@ namespace osu.Game.Overlays.OnlineBeatmapSet { Anchor = Anchor.TopRight, Origin = Anchor.TopCentre, + Text = @"0%", TextSize = 13, }, }, diff --git a/osu.Game/Overlays/OnlineBeatmapSetOverlay.cs b/osu.Game/Overlays/OnlineBeatmapSetOverlay.cs index 6e3a2019d0..0e215f059f 100644 --- a/osu.Game/Overlays/OnlineBeatmapSetOverlay.cs +++ b/osu.Game/Overlays/OnlineBeatmapSetOverlay.cs @@ -1,7 +1,6 @@ // Copyright (c) 2007-2017 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE -using System.Linq; using OpenTK; using OpenTK.Graphics; using osu.Framework.Extensions.Color4Extensions; From d09bcabc8f90f36ae16c7bec076ea28011f6df1f Mon Sep 17 00:00:00 2001 From: DrabWeb Date: Tue, 12 Sep 2017 21:00:20 -0300 Subject: [PATCH 10/30] Add a background to the overlay. --- .../Visual/TestCaseOnlineBeatmapSetOverlay.cs | 3 +++ osu.Game/Overlays/OnlineBeatmapSetOverlay.cs | 23 +++++++++++++------ 2 files changed, 19 insertions(+), 7 deletions(-) diff --git a/osu.Desktop.Tests/Visual/TestCaseOnlineBeatmapSetOverlay.cs b/osu.Desktop.Tests/Visual/TestCaseOnlineBeatmapSetOverlay.cs index be7127eaaf..832d5a1cb3 100644 --- a/osu.Desktop.Tests/Visual/TestCaseOnlineBeatmapSetOverlay.cs +++ b/osu.Desktop.Tests/Visual/TestCaseOnlineBeatmapSetOverlay.cs @@ -378,6 +378,9 @@ namespace osu.Desktop.VisualTests.Tests }, }); }); + + AddStep(@"hide", overlay.Hide); + AddStep(@"show without reload", overlay.Show); } } } diff --git a/osu.Game/Overlays/OnlineBeatmapSetOverlay.cs b/osu.Game/Overlays/OnlineBeatmapSetOverlay.cs index 0e215f059f..ab6d308af9 100644 --- a/osu.Game/Overlays/OnlineBeatmapSetOverlay.cs +++ b/osu.Game/Overlays/OnlineBeatmapSetOverlay.cs @@ -6,6 +6,7 @@ using OpenTK.Graphics; using osu.Framework.Extensions.Color4Extensions; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; +using osu.Framework.Graphics.Shapes; using osu.Game.Beatmaps; using osu.Game.Graphics; using osu.Game.Graphics.Containers; @@ -41,15 +42,23 @@ namespace osu.Game.Overlays Offset = new Vector2(0f, 1f), }; - Child = new ScrollContainer + Children = new Drawable[] { - RelativeSizeAxes = Axes.Both, - ScrollbarVisible = false, - Child = scrollContent = new ReverseChildIDFillFlowContainer + new Box { - RelativeSizeAxes = Axes.X, - AutoSizeAxes = Axes.Y, - Direction = FillDirection.Vertical, + RelativeSizeAxes = Axes.Both, + Colour = OsuColour.Gray(0.2f) + }, + new ScrollContainer + { + RelativeSizeAxes = Axes.Both, + ScrollbarVisible = false, + Child = scrollContent = new ReverseChildIDFillFlowContainer + { + RelativeSizeAxes = Axes.X, + AutoSizeAxes = Axes.Y, + Direction = FillDirection.Vertical, + }, }, }; } From 680f2e232ca2e155dc118425322232cb4efe1046 Mon Sep 17 00:00:00 2001 From: DrabWeb Date: Tue, 12 Sep 2017 21:24:43 -0300 Subject: [PATCH 11/30] Cleanup. --- .../Overlays/OnlineBeatmapSet/BasicStats.cs | 4 +- .../OnlineBeatmapSet/BeatmapPicker.cs | 7 +- .../OnlineBeatmapSet/FavouriteButton.cs | 13 +- .../Overlays/OnlineBeatmapSet/HeaderButton.cs | 48 +-- .../OnlineBeatmapSet/PreviewButton.cs | 287 +++++++++--------- .../Overlays/OnlineBeatmapSet/SuccessRate.cs | 6 - 6 files changed, 185 insertions(+), 180 deletions(-) diff --git a/osu.Game/Overlays/OnlineBeatmapSet/BasicStats.cs b/osu.Game/Overlays/OnlineBeatmapSet/BasicStats.cs index d5acfd2e43..05d13ebcda 100644 --- a/osu.Game/Overlays/OnlineBeatmapSet/BasicStats.cs +++ b/osu.Game/Overlays/OnlineBeatmapSet/BasicStats.cs @@ -15,7 +15,7 @@ namespace osu.Game.Overlays.OnlineBeatmapSet { public class BasicStats : Container { - private readonly Statistic length, bpm, circleCount, sliderCount; + private readonly Statistic length, circleCount, sliderCount; private BeatmapInfo beatmap; public BeatmapInfo Beatmap @@ -43,7 +43,7 @@ namespace osu.Game.Overlays.OnlineBeatmapSet Children = new[] { length = new Statistic(FontAwesome.fa_clock_o, "Length") { Width = statWidth }, - bpm = new Statistic(FontAwesome.fa_circle, "BPM") + new Statistic(FontAwesome.fa_circle, "BPM") { Width = statWidth, Value = set.OnlineInfo.BPM.ToString(@"0.##"), diff --git a/osu.Game/Overlays/OnlineBeatmapSet/BeatmapPicker.cs b/osu.Game/Overlays/OnlineBeatmapSet/BeatmapPicker.cs index 2bdffc687a..9f2dae5979 100644 --- a/osu.Game/Overlays/OnlineBeatmapSet/BeatmapPicker.cs +++ b/osu.Game/Overlays/OnlineBeatmapSet/BeatmapPicker.cs @@ -152,7 +152,6 @@ namespace osu.Game.Overlays.OnlineBeatmapSet public BeatmapTile(BeatmapInfo beatmap, Bindable bindable) { this.beatmap = beatmap; - this.bindable.BindTo(bindable); Size = new Vector2(size); Margin = new MarginPadding { Horizontal = tile_spacing / 2 }; @@ -179,7 +178,8 @@ namespace osu.Game.Overlays.OnlineBeatmapSet }; Action = () => this.bindable.Value = beatmap; - this.bindable.ValueChanged += bindable_ValueChanged; + this.bindable.ValueChanged += beatmapChanged; + this.bindable.BindTo(bindable); } protected override bool OnHover(InputState state) @@ -193,9 +193,10 @@ namespace osu.Game.Overlays.OnlineBeatmapSet { if (bindable.Value != beatmap) fadeOut(); + base.OnHoverLost(state); } - private void bindable_ValueChanged(BeatmapInfo value) + private void beatmapChanged(BeatmapInfo value) { if (value == beatmap) fadeIn(); diff --git a/osu.Game/Overlays/OnlineBeatmapSet/FavouriteButton.cs b/osu.Game/Overlays/OnlineBeatmapSet/FavouriteButton.cs index 140e2cd120..cef77dc43c 100644 --- a/osu.Game/Overlays/OnlineBeatmapSet/FavouriteButton.cs +++ b/osu.Game/Overlays/OnlineBeatmapSet/FavouriteButton.cs @@ -55,9 +55,18 @@ namespace osu.Game.Overlays.OnlineBeatmapSet Favourited.ValueChanged += value => { - pink.FadeTo(value ? 1 : 0, 200); - icon.Icon = value ? FontAwesome.fa_heart : FontAwesome.fa_heart_o; + if (value) + { + pink.FadeIn(200); + icon.Icon = FontAwesome.fa_heart; + } + else + { + pink.FadeOut(200); + icon.Icon = FontAwesome.fa_heart_o; + } }; + Action = () => Favourited.Value = !Favourited.Value; } diff --git a/osu.Game/Overlays/OnlineBeatmapSet/HeaderButton.cs b/osu.Game/Overlays/OnlineBeatmapSet/HeaderButton.cs index 4c46b9e56f..d4f611c194 100644 --- a/osu.Game/Overlays/OnlineBeatmapSet/HeaderButton.cs +++ b/osu.Game/Overlays/OnlineBeatmapSet/HeaderButton.cs @@ -14,32 +14,32 @@ namespace osu.Game.Overlays.OnlineBeatmapSet { private readonly Container content; - protected override Container Content => content; + protected override Container Content => content; - public HeaderButton() + public HeaderButton() + { + CornerRadius = 3; + Masking = true; + + InternalChildren = new Drawable[] { - CornerRadius = 3; - Masking = true; - - InternalChildren = new Drawable[] + new Box { - new Box - { - RelativeSizeAxes = Axes.Both, - Colour = OsuColour.FromHex(@"094c5f"), - }, - new Triangles - { - RelativeSizeAxes = Axes.Both, - ColourLight = OsuColour.FromHex(@"0f7c9b"), - ColourDark = OsuColour.FromHex(@"094c5f"), - TriangleScale = 1.5f, - }, - content = new Container - { - RelativeSizeAxes = Axes.Both, - }, - }; - } + RelativeSizeAxes = Axes.Both, + Colour = OsuColour.FromHex(@"094c5f"), + }, + new Triangles + { + RelativeSizeAxes = Axes.Both, + ColourLight = OsuColour.FromHex(@"0f7c9b"), + ColourDark = OsuColour.FromHex(@"094c5f"), + TriangleScale = 1.5f, + }, + content = new Container + { + RelativeSizeAxes = Axes.Both, + }, + }; + } } } diff --git a/osu.Game/Overlays/OnlineBeatmapSet/PreviewButton.cs b/osu.Game/Overlays/OnlineBeatmapSet/PreviewButton.cs index fa64348902..6fd131c720 100644 --- a/osu.Game/Overlays/OnlineBeatmapSet/PreviewButton.cs +++ b/osu.Game/Overlays/OnlineBeatmapSet/PreviewButton.cs @@ -1,143 +1,144 @@ -// Copyright (c) 2007-2017 ppy Pty Ltd . -// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE - -using OpenTK; -using OpenTK.Graphics; -using osu.Framework.Allocation; -using osu.Framework.Audio; -using osu.Framework.Audio.Track; -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.Graphics; -using osu.Game.Graphics.Containers; - -namespace osu.Game.Overlays.OnlineBeatmapSet -{ - public class PreviewButton : OsuClickableContainer - { - private readonly BeatmapSetInfo set; - private readonly Box bg, progress; - private readonly SpriteIcon icon; - - private AudioManager audio; - private Track preview; - - private bool playing = false; - public bool Playing - { - get { return playing; } - set - { - if (value == playing) return; - playing = value; - - if (Playing) - { - icon.Icon = FontAwesome.fa_stop; - progress.FadeIn(100); - - loadPreview(); - preview.Start(); - } - else - { - icon.Icon = FontAwesome.fa_play; - progress.FadeOut(100); - preview.Stop(); - } - } - } - - public PreviewButton(BeatmapSetInfo set) - { - this.set = set; - Height = 42; - - Children = new Drawable[] - { - bg = new Box - { - RelativeSizeAxes = Axes.Both, - Colour = Color4.Black.Opacity(0.25f), - }, - new Container - { - Anchor = Anchor.BottomLeft, - Origin = Anchor.BottomLeft, - RelativeSizeAxes = Axes.X, - Height = 3, - Child = progress = new Box - { - RelativeSizeAxes = Axes.Both, - Width = 0f, - Alpha = 0f, - }, - }, - icon = new SpriteIcon - { - Anchor = Anchor.Centre, - Origin = Anchor.Centre, - Icon = FontAwesome.fa_play, - Size = new Vector2(18), - Shadow = false, - }, - }; - - Action = () => Playing = !Playing; - } - - [BackgroundDependencyLoader] - private void load(OsuColour colours, AudioManager audio) - { - this.audio = audio; - progress.Colour = colours.Yellow; - - loadPreview(); - } - - protected override void Update() - { - base.Update(); - - if (Playing) - { - progress.Width = (float)(preview.CurrentTime / preview.Length); - if (preview.HasCompleted) Playing = false; - } - } - - protected override void Dispose(bool isDisposing) - { - Playing = false; - base.Dispose(isDisposing); - } - - protected override bool OnHover(InputState state) - { - bg.FadeColour(Color4.Black.Opacity(0.5f), 100); - return base.OnHover(state); - } - - protected override void OnHoverLost(InputState state) - { - bg.FadeColour(Color4.Black.Opacity(0.25f), 100); - } - - private void loadPreview() - { - if (preview?.HasCompleted ?? true) - { - preview = audio.Track.Get(set.OnlineInfo.Preview); - preview.Volume.Value = 0.5; - } - else - { - preview.Seek(0); - } - } - } -} +// Copyright (c) 2007-2017 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using OpenTK; +using OpenTK.Graphics; +using osu.Framework.Allocation; +using osu.Framework.Audio; +using osu.Framework.Audio.Track; +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.Graphics; +using osu.Game.Graphics.Containers; + +namespace osu.Game.Overlays.OnlineBeatmapSet +{ + public class PreviewButton : OsuClickableContainer + { + private readonly BeatmapSetInfo set; + private readonly Box bg, progress; + private readonly SpriteIcon icon; + + private AudioManager audio; + private Track preview; + + private bool playing; + public bool Playing + { + get { return playing; } + set + { + if (value == playing) return; + playing = value; + + if (Playing) + { + icon.Icon = FontAwesome.fa_stop; + progress.FadeIn(100); + + loadPreview(); + preview.Start(); + } + else + { + icon.Icon = FontAwesome.fa_play; + progress.FadeOut(100); + preview.Stop(); + } + } + } + + public PreviewButton(BeatmapSetInfo set) + { + this.set = set; + Height = 42; + + Children = new Drawable[] + { + bg = new Box + { + RelativeSizeAxes = Axes.Both, + Colour = Color4.Black.Opacity(0.25f), + }, + new Container + { + Anchor = Anchor.BottomLeft, + Origin = Anchor.BottomLeft, + RelativeSizeAxes = Axes.X, + Height = 3, + Child = progress = new Box + { + RelativeSizeAxes = Axes.Both, + Width = 0f, + Alpha = 0f, + }, + }, + icon = new SpriteIcon + { + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + Icon = FontAwesome.fa_play, + Size = new Vector2(18), + Shadow = false, + }, + }; + + Action = () => Playing = !Playing; + } + + [BackgroundDependencyLoader] + private void load(OsuColour colours, AudioManager audio) + { + this.audio = audio; + progress.Colour = colours.Yellow; + + loadPreview(); + } + + protected override void Update() + { + base.Update(); + + if (Playing) + { + progress.Width = (float)(preview.CurrentTime / preview.Length); + if (preview.HasCompleted) Playing = false; + } + } + + protected override void Dispose(bool isDisposing) + { + Playing = false; + base.Dispose(isDisposing); + } + + protected override bool OnHover(InputState state) + { + bg.FadeColour(Color4.Black.Opacity(0.5f), 100); + return base.OnHover(state); + } + + protected override void OnHoverLost(InputState state) + { + bg.FadeColour(Color4.Black.Opacity(0.25f), 100); + base.OnHoverLost(state); + } + + private void loadPreview() + { + if (preview?.HasCompleted ?? true) + { + preview = audio.Track.Get(set.OnlineInfo.Preview); + preview.Volume.Value = 0.5; + } + else + { + preview.Seek(0); + } + } + } +} diff --git a/osu.Game/Overlays/OnlineBeatmapSet/SuccessRate.cs b/osu.Game/Overlays/OnlineBeatmapSet/SuccessRate.cs index c9326faf7f..330ebedaca 100644 --- a/osu.Game/Overlays/OnlineBeatmapSet/SuccessRate.cs +++ b/osu.Game/Overlays/OnlineBeatmapSet/SuccessRate.cs @@ -106,12 +106,6 @@ namespace osu.Game.Overlays.OnlineBeatmapSet base.UpdateAfterChildren(); graph.Padding = new MarginPadding { Top = header.DrawHeight }; - } - - protected override void Update() - { - base.Update(); - percentContainer.Width = successRate.Length; } } From 97e5a0d4a311f69a10a47a464d9106f8bf352ea3 Mon Sep 17 00:00:00 2001 From: DrabWeb Date: Tue, 12 Sep 2017 23:41:10 -0300 Subject: [PATCH 12/30] CI fixes. --- .../Visual/TestCaseOnlineBeatmapSetOverlay.cs | 771 +++++++++--------- osu.Game/Beatmaps/BeatmapSetOnlineInfo.cs | 4 +- .../Overlays/OnlineBeatmapSet/AuthorInfo.cs | 173 ++-- .../Overlays/OnlineBeatmapSet/BasicStats.cs | 13 +- .../OnlineBeatmapSet/BeatmapPicker.cs | 528 ++++++------ osu.Game/Overlays/OnlineBeatmapSet/Details.cs | 216 ++--- .../OnlineBeatmapSet/DownloadButton.cs | 118 +-- .../OnlineBeatmapSet/FavouriteButton.cs | 160 ++-- .../Overlays/OnlineBeatmapSet/HeaderButton.cs | 90 +- 9 files changed, 1040 insertions(+), 1033 deletions(-) diff --git a/osu.Desktop.Tests/Visual/TestCaseOnlineBeatmapSetOverlay.cs b/osu.Desktop.Tests/Visual/TestCaseOnlineBeatmapSetOverlay.cs index 832d5a1cb3..b3421591f1 100644 --- a/osu.Desktop.Tests/Visual/TestCaseOnlineBeatmapSetOverlay.cs +++ b/osu.Desktop.Tests/Visual/TestCaseOnlineBeatmapSetOverlay.cs @@ -1,386 +1,385 @@ -// Copyright (c) 2007-2017 ppy Pty Ltd . -// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE - -using System; -using System.Collections.Generic; -using System.Linq; -using osu.Framework.Allocation; -using osu.Framework.Testing; -using osu.Game.Beatmaps; -using osu.Game.Overlays; -using osu.Game.Rulesets; -using osu.Game.Users; - -namespace osu.Desktop.VisualTests.Tests -{ - internal class TestCaseOnlineBeatmapSetOverlay : TestCase - { - public override string Description => @"view online beatmap sets"; - - private readonly OnlineBeatmapSetOverlay overlay; - - public TestCaseOnlineBeatmapSetOverlay() - { - Add(overlay = new OnlineBeatmapSetOverlay()); - } - - [BackgroundDependencyLoader] - private void load(RulesetStore rulesets) - { - var mania = rulesets.GetRuleset(3); - var taiko = rulesets.GetRuleset(1); - - AddStep(@"show first", () => - { - overlay.ShowBeatmapSet(new BeatmapSetInfo - { - Metadata = new BeatmapMetadata - { - Title = @"Lachryma ", - Artist = @"Kaneko Chiharu", - Source = @"SOUND VOLTEX III GRAVITY WARS", - Tags = @"sdvx grace the 5th kac original song contest konami bemani", - }, - OnlineInfo = new BeatmapSetOnlineInfo - { - Preview = @"https://b.ppy.sh/preview/415886.mp3", - PlayCount = 681380, - FavouriteCount = 356, - Submitted = new DateTime(2016, 2, 10), - Ranked = new DateTime(2016, 6, 19), - BPM = 236, - Author = new User - { - Username = @"Fresh Chicken", - Id = 3984370, - }, - Covers = new BeatmapSetOnlineCovers - { - Cover = @"https://assets.ppy.sh/beatmaps/415886/covers/cover.jpg?1465651778", - }, - }, - Beatmaps = new List - { - new BeatmapInfo - { - StarDifficulty = 1.36, - Version = @"BASIC", - Ruleset = mania, - Difficulty = new BeatmapDifficulty - { - CircleSize = 4, - DrainRate = 6.5f, - OverallDifficulty = 6.5f, - ApproachRate = 5, - }, - OnlineInfo = new BeatmapOnlineInfo - { - Length = 115000, - HasVideo = false, - CircleCount = 265, - SliderCount = 71, - PlayCount = 47906, - PassCount = 19899, - }, - Metrics = new BeatmapMetrics - { - Ratings = Enumerable.Range(0, 10), - Fails = Enumerable.Range(1, 100).Select(i => i % 12 - 6), - Retries = Enumerable.Range(-2, 100).Select(i => i % 12 - 6), - }, - }, - new BeatmapInfo - { - StarDifficulty = 2.22, - Version = @"NOVICE", - Ruleset = mania, - Difficulty = new BeatmapDifficulty - { - CircleSize = 4, - DrainRate = 7, - OverallDifficulty = 7, - ApproachRate = 5, - }, - OnlineInfo = new BeatmapOnlineInfo - { - Length = 118000, - HasVideo = false, - CircleCount = 592, - SliderCount = 62, - PlayCount = 162021, - PassCount = 72116, - }, - Metrics = new BeatmapMetrics - { - Ratings = Enumerable.Range(0, 10), - Fails = Enumerable.Range(1, 100).Select(i => i % 12 - 6), - Retries = Enumerable.Range(-2, 100).Select(i => i % 12 - 6), - }, - }, - new BeatmapInfo - { - StarDifficulty = 3.49, - Version = @"ADVANCED", - Ruleset = mania, - Difficulty = new BeatmapDifficulty - { - CircleSize = 4, - DrainRate = 7.5f, - OverallDifficulty = 7.5f, - ApproachRate = 5, - }, - OnlineInfo = new BeatmapOnlineInfo - { - Length = 118000, - HasVideo = false, - CircleCount = 1042, - SliderCount = 79, - PlayCount = 225178, - PassCount = 73001, - }, - Metrics = new BeatmapMetrics - { - Ratings = Enumerable.Range(0, 10), - Fails = Enumerable.Range(1, 100).Select(i => i % 12 - 6), - Retries = Enumerable.Range(-2, 100).Select(i => i % 12 - 6), - }, - }, - new BeatmapInfo - { - StarDifficulty = 4.24, - Version = @"EXHAUST", - Ruleset = mania, - Difficulty = new BeatmapDifficulty - { - CircleSize = 4, - DrainRate = 8, - OverallDifficulty = 8, - ApproachRate = 5, - }, - OnlineInfo = new BeatmapOnlineInfo - { - Length = 118000, - HasVideo = false, - CircleCount = 1352, - SliderCount = 69, - PlayCount = 131545, - PassCount = 42703, - }, - Metrics = new BeatmapMetrics - { - Ratings = Enumerable.Range(0, 10), - Fails = Enumerable.Range(1, 100).Select(i => i % 12 - 6), - Retries = Enumerable.Range(-2, 100).Select(i => i % 12 - 6), - }, - }, - new BeatmapInfo - { - StarDifficulty = 5.26, - Version = @"GRAVITY", - Ruleset = mania, - Difficulty = new BeatmapDifficulty - { - CircleSize = 4, - DrainRate = 8.5f, - OverallDifficulty = 8.5f, - ApproachRate = 5, - }, - OnlineInfo = new BeatmapOnlineInfo - { - Length = 118000, - HasVideo = false, - CircleCount = 1730, - SliderCount = 115, - PlayCount = 117673, - PassCount = 24241, - }, - Metrics = new BeatmapMetrics - { - Ratings = Enumerable.Range(0, 10), - Fails = Enumerable.Range(1, 100).Select(i => i % 12 - 6), - Retries = Enumerable.Range(-2, 100).Select(i => i % 12 - 6), - }, - }, - }, - }); - }); - - AddStep(@"show second", () => - { - overlay.ShowBeatmapSet(new BeatmapSetInfo - { - Metadata = new BeatmapMetadata - { - Title = @"Soumatou Labyrinth", - Artist = @"Yunomi with Momobako&miko", - Tags = @"mmbk.com yuzu__rinrin charlotte", - }, - OnlineInfo = new BeatmapSetOnlineInfo - { - Preview = @"https://b.ppy.sh/preview/625493.mp3", - PlayCount = 22996, - FavouriteCount = 58, - Submitted = new DateTime(2016, 6, 11), - Ranked = new DateTime(2016, 7, 12), - BPM = 160, - Author = new User - { - Username = @"komasy", - Id = 1980256, - }, - Covers = new BeatmapSetOnlineCovers - { - Cover = @"https://assets.ppy.sh/beatmaps/625493/covers/cover.jpg?1499167472", - }, - }, - Beatmaps = new List - { - new BeatmapInfo - { - StarDifficulty = 1.40, - Version = @"yzrin's Kantan", - Ruleset = taiko, - Difficulty = new BeatmapDifficulty - { - CircleSize = 2, - DrainRate = 7, - OverallDifficulty = 3, - ApproachRate = 10, - }, - OnlineInfo = new BeatmapOnlineInfo - { - Length = 193000, - HasVideo = false, - CircleCount = 262, - SliderCount = 0, - PlayCount = 3952, - PassCount = 1373, - }, - Metrics = new BeatmapMetrics - { - Ratings = Enumerable.Range(0, 10), - Fails = Enumerable.Range(1, 100).Select(i => i % 12 - 6), - Retries = Enumerable.Range(-2, 100).Select(i => i % 12 - 6), - }, - }, - new BeatmapInfo - { - StarDifficulty = 2.23, - Version = @"Futsuu", - Ruleset = taiko, - Difficulty = new BeatmapDifficulty - { - CircleSize = 2, - DrainRate = 6, - OverallDifficulty = 4, - ApproachRate = 10, - }, - OnlineInfo = new BeatmapOnlineInfo - { - Length = 193000, - HasVideo = false, - CircleCount = 464, - SliderCount = 0, - PlayCount = 4833, - PassCount = 920, - }, - Metrics = new BeatmapMetrics - { - Ratings = Enumerable.Range(0, 10), - Fails = Enumerable.Range(1, 100).Select(i => i % 12 - 6), - Retries = Enumerable.Range(-2, 100).Select(i => i % 12 - 6), - }, - }, - new BeatmapInfo - { - StarDifficulty = 3.19, - Version = @"Muzukashii", - Ruleset = taiko, - Difficulty = new BeatmapDifficulty - { - CircleSize = 2, - DrainRate = 6, - OverallDifficulty = 5, - ApproachRate = 10, - }, - OnlineInfo = new BeatmapOnlineInfo - { - Length = 193000, - HasVideo = false, - CircleCount = 712, - SliderCount = 0, - PlayCount = 4405, - PassCount = 854, - }, - Metrics = new BeatmapMetrics - { - Ratings = Enumerable.Range(0, 10), - Fails = Enumerable.Range(1, 100).Select(i => i % 12 - 6), - Retries = Enumerable.Range(-2, 100).Select(i => i % 12 - 6), - }, - }, - new BeatmapInfo - { - StarDifficulty = 3.97, - Version = @"Charlotte's Oni", - Ruleset = taiko, - Difficulty = new BeatmapDifficulty - { - CircleSize = 5, - DrainRate = 6, - OverallDifficulty = 5.5f, - ApproachRate = 10, - }, - OnlineInfo = new BeatmapOnlineInfo - { - Length = 193000, - HasVideo = false, - CircleCount = 943, - SliderCount = 0, - PlayCount = 3950, - PassCount = 693, - }, - Metrics = new BeatmapMetrics - { - Ratings = Enumerable.Range(0, 10), - Fails = Enumerable.Range(1, 100).Select(i => i % 12 - 6), - Retries = Enumerable.Range(-2, 100).Select(i => i % 12 - 6), - }, - }, - new BeatmapInfo - { - StarDifficulty = 5.08, - Version = @"Labyrinth Oni", - Ruleset = taiko, - Difficulty = new BeatmapDifficulty - { - CircleSize = 5, - DrainRate = 5, - OverallDifficulty = 6, - ApproachRate = 10, - }, - OnlineInfo = new BeatmapOnlineInfo - { - Length = 193000, - HasVideo = false, - CircleCount = 1068, - SliderCount = 0, - PlayCount = 5856, - PassCount = 1207, - }, - Metrics = new BeatmapMetrics - { - Ratings = Enumerable.Range(0, 10), - Fails = Enumerable.Range(1, 100).Select(i => i % 12 - 6), - Retries = Enumerable.Range(-2, 100).Select(i => i % 12 - 6), - }, - }, - }, - }); - }); - - AddStep(@"hide", overlay.Hide); - AddStep(@"show without reload", overlay.Show); - } - } -} +// Copyright (c) 2007-2017 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using System; +using System.Collections.Generic; +using System.Linq; +using osu.Framework.Allocation; +using osu.Game.Beatmaps; +using osu.Game.Overlays; +using osu.Game.Rulesets; +using osu.Game.Users; + +namespace osu.Desktop.Tests.Visual +{ + internal class TestCaseOnlineBeatmapSetOverlay : OsuTestCase + { + public override string Description => @"view online beatmap sets"; + + private readonly OnlineBeatmapSetOverlay overlay; + + public TestCaseOnlineBeatmapSetOverlay() + { + Add(overlay = new OnlineBeatmapSetOverlay()); + } + + [BackgroundDependencyLoader] + private void load(RulesetStore rulesets) + { + var mania = rulesets.GetRuleset(3); + var taiko = rulesets.GetRuleset(1); + + AddStep(@"show first", () => + { + overlay.ShowBeatmapSet(new BeatmapSetInfo + { + Metadata = new BeatmapMetadata + { + Title = @"Lachryma ", + Artist = @"Kaneko Chiharu", + Source = @"SOUND VOLTEX III GRAVITY WARS", + Tags = @"sdvx grace the 5th kac original song contest konami bemani", + }, + OnlineInfo = new BeatmapSetOnlineInfo + { + Preview = @"https://b.ppy.sh/preview/415886.mp3", + PlayCount = 681380, + FavouriteCount = 356, + Submitted = new DateTime(2016, 2, 10), + Ranked = new DateTime(2016, 6, 19), + BPM = 236, + Author = new User + { + Username = @"Fresh Chicken", + Id = 3984370, + }, + Covers = new BeatmapSetOnlineCovers + { + Cover = @"https://assets.ppy.sh/beatmaps/415886/covers/cover.jpg?1465651778", + }, + }, + Beatmaps = new List + { + new BeatmapInfo + { + StarDifficulty = 1.36, + Version = @"BASIC", + Ruleset = mania, + Difficulty = new BeatmapDifficulty + { + CircleSize = 4, + DrainRate = 6.5f, + OverallDifficulty = 6.5f, + ApproachRate = 5, + }, + OnlineInfo = new BeatmapOnlineInfo + { + Length = 115000, + HasVideo = false, + CircleCount = 265, + SliderCount = 71, + PlayCount = 47906, + PassCount = 19899, + }, + Metrics = new BeatmapMetrics + { + Ratings = Enumerable.Range(0, 10), + Fails = Enumerable.Range(1, 100).Select(i => i % 12 - 6), + Retries = Enumerable.Range(-2, 100).Select(i => i % 12 - 6), + }, + }, + new BeatmapInfo + { + StarDifficulty = 2.22, + Version = @"NOVICE", + Ruleset = mania, + Difficulty = new BeatmapDifficulty + { + CircleSize = 4, + DrainRate = 7, + OverallDifficulty = 7, + ApproachRate = 5, + }, + OnlineInfo = new BeatmapOnlineInfo + { + Length = 118000, + HasVideo = false, + CircleCount = 592, + SliderCount = 62, + PlayCount = 162021, + PassCount = 72116, + }, + Metrics = new BeatmapMetrics + { + Ratings = Enumerable.Range(0, 10), + Fails = Enumerable.Range(1, 100).Select(i => i % 12 - 6), + Retries = Enumerable.Range(-2, 100).Select(i => i % 12 - 6), + }, + }, + new BeatmapInfo + { + StarDifficulty = 3.49, + Version = @"ADVANCED", + Ruleset = mania, + Difficulty = new BeatmapDifficulty + { + CircleSize = 4, + DrainRate = 7.5f, + OverallDifficulty = 7.5f, + ApproachRate = 5, + }, + OnlineInfo = new BeatmapOnlineInfo + { + Length = 118000, + HasVideo = false, + CircleCount = 1042, + SliderCount = 79, + PlayCount = 225178, + PassCount = 73001, + }, + Metrics = new BeatmapMetrics + { + Ratings = Enumerable.Range(0, 10), + Fails = Enumerable.Range(1, 100).Select(i => i % 12 - 6), + Retries = Enumerable.Range(-2, 100).Select(i => i % 12 - 6), + }, + }, + new BeatmapInfo + { + StarDifficulty = 4.24, + Version = @"EXHAUST", + Ruleset = mania, + Difficulty = new BeatmapDifficulty + { + CircleSize = 4, + DrainRate = 8, + OverallDifficulty = 8, + ApproachRate = 5, + }, + OnlineInfo = new BeatmapOnlineInfo + { + Length = 118000, + HasVideo = false, + CircleCount = 1352, + SliderCount = 69, + PlayCount = 131545, + PassCount = 42703, + }, + Metrics = new BeatmapMetrics + { + Ratings = Enumerable.Range(0, 10), + Fails = Enumerable.Range(1, 100).Select(i => i % 12 - 6), + Retries = Enumerable.Range(-2, 100).Select(i => i % 12 - 6), + }, + }, + new BeatmapInfo + { + StarDifficulty = 5.26, + Version = @"GRAVITY", + Ruleset = mania, + Difficulty = new BeatmapDifficulty + { + CircleSize = 4, + DrainRate = 8.5f, + OverallDifficulty = 8.5f, + ApproachRate = 5, + }, + OnlineInfo = new BeatmapOnlineInfo + { + Length = 118000, + HasVideo = false, + CircleCount = 1730, + SliderCount = 115, + PlayCount = 117673, + PassCount = 24241, + }, + Metrics = new BeatmapMetrics + { + Ratings = Enumerable.Range(0, 10), + Fails = Enumerable.Range(1, 100).Select(i => i % 12 - 6), + Retries = Enumerable.Range(-2, 100).Select(i => i % 12 - 6), + }, + }, + }, + }); + }); + + AddStep(@"show second", () => + { + overlay.ShowBeatmapSet(new BeatmapSetInfo + { + Metadata = new BeatmapMetadata + { + Title = @"Soumatou Labyrinth", + Artist = @"Yunomi with Momobako&miko", + Tags = @"mmbk.com yuzu__rinrin charlotte", + }, + OnlineInfo = new BeatmapSetOnlineInfo + { + Preview = @"https://b.ppy.sh/preview/625493.mp3", + PlayCount = 22996, + FavouriteCount = 58, + Submitted = new DateTime(2016, 6, 11), + Ranked = new DateTime(2016, 7, 12), + BPM = 160, + Author = new User + { + Username = @"komasy", + Id = 1980256, + }, + Covers = new BeatmapSetOnlineCovers + { + Cover = @"https://assets.ppy.sh/beatmaps/625493/covers/cover.jpg?1499167472", + }, + }, + Beatmaps = new List + { + new BeatmapInfo + { + StarDifficulty = 1.40, + Version = @"yzrin's Kantan", + Ruleset = taiko, + Difficulty = new BeatmapDifficulty + { + CircleSize = 2, + DrainRate = 7, + OverallDifficulty = 3, + ApproachRate = 10, + }, + OnlineInfo = new BeatmapOnlineInfo + { + Length = 193000, + HasVideo = false, + CircleCount = 262, + SliderCount = 0, + PlayCount = 3952, + PassCount = 1373, + }, + Metrics = new BeatmapMetrics + { + Ratings = Enumerable.Range(0, 10), + Fails = Enumerable.Range(1, 100).Select(i => i % 12 - 6), + Retries = Enumerable.Range(-2, 100).Select(i => i % 12 - 6), + }, + }, + new BeatmapInfo + { + StarDifficulty = 2.23, + Version = @"Futsuu", + Ruleset = taiko, + Difficulty = new BeatmapDifficulty + { + CircleSize = 2, + DrainRate = 6, + OverallDifficulty = 4, + ApproachRate = 10, + }, + OnlineInfo = new BeatmapOnlineInfo + { + Length = 193000, + HasVideo = false, + CircleCount = 464, + SliderCount = 0, + PlayCount = 4833, + PassCount = 920, + }, + Metrics = new BeatmapMetrics + { + Ratings = Enumerable.Range(0, 10), + Fails = Enumerable.Range(1, 100).Select(i => i % 12 - 6), + Retries = Enumerable.Range(-2, 100).Select(i => i % 12 - 6), + }, + }, + new BeatmapInfo + { + StarDifficulty = 3.19, + Version = @"Muzukashii", + Ruleset = taiko, + Difficulty = new BeatmapDifficulty + { + CircleSize = 2, + DrainRate = 6, + OverallDifficulty = 5, + ApproachRate = 10, + }, + OnlineInfo = new BeatmapOnlineInfo + { + Length = 193000, + HasVideo = false, + CircleCount = 712, + SliderCount = 0, + PlayCount = 4405, + PassCount = 854, + }, + Metrics = new BeatmapMetrics + { + Ratings = Enumerable.Range(0, 10), + Fails = Enumerable.Range(1, 100).Select(i => i % 12 - 6), + Retries = Enumerable.Range(-2, 100).Select(i => i % 12 - 6), + }, + }, + new BeatmapInfo + { + StarDifficulty = 3.97, + Version = @"Charlotte's Oni", + Ruleset = taiko, + Difficulty = new BeatmapDifficulty + { + CircleSize = 5, + DrainRate = 6, + OverallDifficulty = 5.5f, + ApproachRate = 10, + }, + OnlineInfo = new BeatmapOnlineInfo + { + Length = 193000, + HasVideo = false, + CircleCount = 943, + SliderCount = 0, + PlayCount = 3950, + PassCount = 693, + }, + Metrics = new BeatmapMetrics + { + Ratings = Enumerable.Range(0, 10), + Fails = Enumerable.Range(1, 100).Select(i => i % 12 - 6), + Retries = Enumerable.Range(-2, 100).Select(i => i % 12 - 6), + }, + }, + new BeatmapInfo + { + StarDifficulty = 5.08, + Version = @"Labyrinth Oni", + Ruleset = taiko, + Difficulty = new BeatmapDifficulty + { + CircleSize = 5, + DrainRate = 5, + OverallDifficulty = 6, + ApproachRate = 10, + }, + OnlineInfo = new BeatmapOnlineInfo + { + Length = 193000, + HasVideo = false, + CircleCount = 1068, + SliderCount = 0, + PlayCount = 5856, + PassCount = 1207, + }, + Metrics = new BeatmapMetrics + { + Ratings = Enumerable.Range(0, 10), + Fails = Enumerable.Range(1, 100).Select(i => i % 12 - 6), + Retries = Enumerable.Range(-2, 100).Select(i => i % 12 - 6), + }, + }, + }, + }); + }); + + AddStep(@"hide", overlay.Hide); + AddStep(@"show without reload", overlay.Show); + } + } +} diff --git a/osu.Game/Beatmaps/BeatmapSetOnlineInfo.cs b/osu.Game/Beatmaps/BeatmapSetOnlineInfo.cs index b53aee9661..6b59f0f298 100644 --- a/osu.Game/Beatmaps/BeatmapSetOnlineInfo.cs +++ b/osu.Game/Beatmaps/BeatmapSetOnlineInfo.cs @@ -25,12 +25,12 @@ namespace osu.Game.Beatmaps /// /// The date this beatmap set was ranked. /// - public DateTimeOffset Ranked { get; set; } + public DateTimeOffset? Ranked { get; set; } /// /// The date this beatmap set was last updated. /// - public DateTimeOffset LastUpdated { get; set; } + public DateTimeOffset? LastUpdated { get; set; } /// /// The different sizes of cover art for this beatmap set. diff --git a/osu.Game/Overlays/OnlineBeatmapSet/AuthorInfo.cs b/osu.Game/Overlays/OnlineBeatmapSet/AuthorInfo.cs index a3df59d866..90d97f75c7 100644 --- a/osu.Game/Overlays/OnlineBeatmapSet/AuthorInfo.cs +++ b/osu.Game/Overlays/OnlineBeatmapSet/AuthorInfo.cs @@ -1,82 +1,91 @@ -// Copyright (c) 2007-2017 ppy Pty Ltd . -// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE - -using OpenTK; -using OpenTK.Graphics; -using osu.Framework.Extensions.Color4Extensions; -using osu.Framework.Graphics; -using osu.Framework.Graphics.Containers; -using osu.Game.Beatmaps; -using osu.Game.Graphics.Sprites; -using osu.Game.Users; - -namespace osu.Game.Overlays.OnlineBeatmapSet -{ - public class AuthorInfo : Container - { - private const float height = 50; - - public AuthorInfo(BeatmapSetOnlineInfo info) - { - RelativeSizeAxes = Axes.X; - Height = height; - - Children = new Drawable[] - { - new UpdateableAvatar - { - Size = new Vector2(height), - CornerRadius = 3, - Masking = true, - User = info.Author, - EdgeEffect = new EdgeEffectParameters - { - Colour = Color4.Black.Opacity(0.25f), - Type = EdgeEffectType.Shadow, - Radius = 3, - Offset = new Vector2(0f, 1f), - }, - }, - new FillFlowContainer - { - RelativeSizeAxes = Axes.Both, - Direction = FillDirection.Vertical, - Padding = new MarginPadding { Left = height + 5 }, - Children = new Drawable[] - { - new Field("made by", info.Author.Username, @"Exo2.0-RegularItalic"), - new Field("submitted on", info.Submitted.ToString(@"MMM d, yyyy"), @"Exo2.0-Bold") - { - Margin = new MarginPadding { Top = 5 }, - }, - new Field(info.Ranked == null ? "last updated on " : "ranked on ", (info.Ranked == null ? info.Submitted : info.Ranked).ToString(@"MMM d, yyyy"), @"Exo2.0-Bold"), - }, - }, - }; - } - - private class Field : FillFlowContainer - { - public Field(string first, string second, string secondFont) - { - AutoSizeAxes = Axes.Both; - Direction = FillDirection.Horizontal; - - Children = new[] - { - new OsuSpriteText - { - Text = $"{first} ", - TextSize = 13, - }, - new OsuSpriteText - { - Text = second, - TextSize = 13, - Font = secondFont, - }, - }; - } - } - } -} +// Copyright (c) 2007-2017 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using OpenTK; +using OpenTK.Graphics; +using osu.Framework.Extensions.Color4Extensions; +using osu.Framework.Graphics; +using osu.Framework.Graphics.Containers; +using osu.Game.Beatmaps; +using osu.Game.Graphics.Sprites; +using osu.Game.Users; + +namespace osu.Game.Overlays.OnlineBeatmapSet +{ + public class AuthorInfo : Container + { + private const float height = 50; + + public AuthorInfo(BeatmapSetOnlineInfo info) + { + RelativeSizeAxes = Axes.X; + Height = height; + + FillFlowContainer fields; + Children = new Drawable[] + { + new UpdateableAvatar + { + Size = new Vector2(height), + CornerRadius = 3, + Masking = true, + User = info.Author, + EdgeEffect = new EdgeEffectParameters + { + Colour = Color4.Black.Opacity(0.25f), + Type = EdgeEffectType.Shadow, + Radius = 3, + Offset = new Vector2(0f, 1f), + }, + }, + fields = new FillFlowContainer + { + RelativeSizeAxes = Axes.Both, + Direction = FillDirection.Vertical, + Padding = new MarginPadding { Left = height + 5 }, + Children = new Drawable[] + { + new Field("made by", info.Author.Username, @"Exo2.0-RegularItalic"), + new Field("submitted on", info.Submitted.ToString(@"MMM d, yyyy"), @"Exo2.0-Bold") + { + Margin = new MarginPadding { Top = 5 }, + }, + }, + }, + }; + + if (info.Ranked.HasValue) + { + fields.Add(new Field("ranked on ", info.Ranked.Value.ToString(@"MMM d, yyyy"), @"Exo2.0-Bold")); + } + else if (info.LastUpdated.HasValue) + { + fields.Add(new Field("last updated on ", info.LastUpdated.Value.ToString(@"MMM d, yyyy"), @"Exo2.0-Bold")); + } + } + + private class Field : FillFlowContainer + { + public Field(string first, string second, string secondFont) + { + AutoSizeAxes = Axes.Both; + Direction = FillDirection.Horizontal; + + Children = new[] + { + new OsuSpriteText + { + Text = $"{first} ", + TextSize = 13, + }, + new OsuSpriteText + { + Text = second, + TextSize = 13, + Font = secondFont, + }, + }; + } + } + } +} diff --git a/osu.Game/Overlays/OnlineBeatmapSet/BasicStats.cs b/osu.Game/Overlays/OnlineBeatmapSet/BasicStats.cs index 05d13ebcda..7772f34466 100644 --- a/osu.Game/Overlays/OnlineBeatmapSet/BasicStats.cs +++ b/osu.Game/Overlays/OnlineBeatmapSet/BasicStats.cs @@ -27,14 +27,13 @@ namespace osu.Game.Overlays.OnlineBeatmapSet beatmap = value; length.Value = TimeSpan.FromMilliseconds(beatmap.OnlineInfo.Length).ToString(@"m\:ss"); - circleCount.Value = string.Format(@"{0:n0}", beatmap.OnlineInfo.CircleCount); - sliderCount.Value = string.Format(@"{0:n0}", beatmap.OnlineInfo.SliderCount); + circleCount.Value = beatmap.OnlineInfo.CircleCount.ToString("N0"); + sliderCount.Value = beatmap.OnlineInfo.SliderCount.ToString("N0"); } } public BasicStats(BeatmapSetInfo set) { - var statWidth = 0.25f; Child = new FillFlowContainer { RelativeSizeAxes = Axes.X, @@ -42,14 +41,14 @@ namespace osu.Game.Overlays.OnlineBeatmapSet Direction = FillDirection.Horizontal, Children = new[] { - length = new Statistic(FontAwesome.fa_clock_o, "Length") { Width = statWidth }, + length = new Statistic(FontAwesome.fa_clock_o, "Length") { Width = 0.25f }, new Statistic(FontAwesome.fa_circle, "BPM") { - Width = statWidth, + Width = 0.25f, Value = set.OnlineInfo.BPM.ToString(@"0.##"), }, - circleCount = new Statistic(FontAwesome.fa_circle_o, "Circle Count") { Width = statWidth }, - sliderCount = new Statistic(FontAwesome.fa_circle, "Slider Count") { Width = statWidth }, + circleCount = new Statistic(FontAwesome.fa_circle_o, "Circle Count") { Width = 0.25f }, + sliderCount = new Statistic(FontAwesome.fa_circle, "Slider Count") { Width = 0.25f }, }, }; } diff --git a/osu.Game/Overlays/OnlineBeatmapSet/BeatmapPicker.cs b/osu.Game/Overlays/OnlineBeatmapSet/BeatmapPicker.cs index 9f2dae5979..92b9644263 100644 --- a/osu.Game/Overlays/OnlineBeatmapSet/BeatmapPicker.cs +++ b/osu.Game/Overlays/OnlineBeatmapSet/BeatmapPicker.cs @@ -1,264 +1,264 @@ -// 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 OpenTK; -using OpenTK.Graphics; -using osu.Framework.Allocation; -using osu.Framework.Configuration; -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; - -namespace osu.Game.Overlays.OnlineBeatmapSet -{ - public class BeatmapPicker : Container - { - private const float tile_icon_padding = 7; - private const float tile_spacing = 2; - - private readonly OsuSpriteText version, starRating; - - public readonly Bindable Beatmap = new Bindable(); - - public BeatmapPicker(BeatmapSetInfo set) - { - RelativeSizeAxes = Axes.X; - AutoSizeAxes = Axes.Y; - - TilesFillFlowContainer tileContainer; - Children = new Drawable[] - { - new FillFlowContainer - { - AutoSizeAxes = Axes.Y, - RelativeSizeAxes = Axes.X, - Direction = FillDirection.Vertical, - Children = new Drawable[] - { - tileContainer = new TilesFillFlowContainer - { - AutoSizeAxes = Axes.Both, - Margin = new MarginPadding { Left = -(tile_icon_padding + tile_spacing / 2) }, - OnLostHover = () => - { - showBeatmap(Beatmap.Value); - starRating.FadeOut(100); - }, - }, - new FillFlowContainer - { - AutoSizeAxes = Axes.Both, - Margin = new MarginPadding { Top = 10 }, - Spacing = new Vector2(5f), - Children = new[] - { - version = new OsuSpriteText - { - Anchor = Anchor.BottomLeft, - Origin = Anchor.BottomLeft, - TextSize = 20, - Font = @"Exo2.0-Bold", - }, - starRating = new OsuSpriteText - { - Anchor = Anchor.BottomLeft, - Origin = Anchor.BottomLeft, - TextSize = 13, - Font = @"Exo2.0-Bold", - Text = "Star Difficulty", - Alpha = 0, - Margin = new MarginPadding { Bottom = 1 }, - }, - }, - }, - new FillFlowContainer - { - RelativeSizeAxes = Axes.X, - AutoSizeAxes = Axes.Y, - Spacing = new Vector2(10f), - Margin = new MarginPadding { Top = 5 }, - Children = new[] - { - new Statistic(FontAwesome.fa_play_circle, set.OnlineInfo.PlayCount), - new Statistic(FontAwesome.fa_heart, set.OnlineInfo.FavouriteCount), - }, - }, - }, - }, - }; - - Beatmap.Value = set.Beatmaps.First(); - Beatmap.ValueChanged += showBeatmap; - tileContainer.ChildrenEnumerable = set.Beatmaps.Select(b => new BeatmapTile(b, Beatmap) - { - OnHovered = beatmap => - { - showBeatmap(beatmap); - starRating.Text = string.Format("Star Difficulty {0:N2}", beatmap.StarDifficulty); - starRating.FadeIn(100); - }, - }); - } - - [BackgroundDependencyLoader] - private void load(OsuColour colours) - { - starRating.Colour = colours.Yellow; - } - - protected override void LoadComplete() - { - base.LoadComplete(); - - // done here so everything can bind in intialization and get the first trigger - Beatmap.TriggerChange(); - } - - private void showBeatmap(BeatmapInfo beatmap) => version.Text = beatmap.Version; - - private class TilesFillFlowContainer : FillFlowContainer - { - public Action OnLostHover; - - protected override void OnHoverLost(InputState state) - { - base.OnHoverLost(state); - OnLostHover?.Invoke(); - } - } - - private class BeatmapTile : OsuClickableContainer - { - private const float transition_duration = 100; - private const float size = 52; - - private readonly BeatmapInfo beatmap; - private readonly Bindable bindable = new Bindable(); - - private readonly Container bg; - private readonly DifficultyIcon icon; - - public Action OnHovered; - - public BeatmapTile(BeatmapInfo beatmap, Bindable bindable) - { - this.beatmap = beatmap; - Size = new Vector2(size); - Margin = new MarginPadding { Horizontal = tile_spacing / 2 }; - - Children = new Drawable[] - { - bg = new Container - { - RelativeSizeAxes = Axes.Both, - Masking = true, - CornerRadius = 4, - Child = new Box - { - RelativeSizeAxes = Axes.Both, - Colour = Color4.Black.Opacity(0.5f), - }, - }, - icon = new DifficultyIcon(beatmap) - { - Anchor = Anchor.Centre, - Origin = Anchor.Centre, - Size = new Vector2(size - tile_icon_padding * 2), - Margin = new MarginPadding { Bottom = 1 }, - }, - }; - - Action = () => this.bindable.Value = beatmap; - this.bindable.ValueChanged += beatmapChanged; - this.bindable.BindTo(bindable); - } - - protected override bool OnHover(InputState state) - { - fadeIn(); - OnHovered?.Invoke(beatmap); - return base.OnHover(state); - } - - protected override void OnHoverLost(InputState state) - { - if (bindable.Value != beatmap) - fadeOut(); - base.OnHoverLost(state); - } - - private void beatmapChanged(BeatmapInfo value) - { - if (value == beatmap) - fadeIn(); - else - fadeOut(); - } - - private void fadeIn() - { - bg.FadeIn(transition_duration); - icon.FadeIn(transition_duration); - } - - private void fadeOut() - { - bg.FadeOut(); - icon.FadeTo(0.7f, transition_duration); - } - } - - private class Statistic : FillFlowContainer - { - private readonly OsuSpriteText text; - - private int value; - public int Value - { - get { return value; } - set - { - this.value = value; - text.Text = Value.ToString(@"N0"); - } - } - - public Statistic(FontAwesome icon, int value = 0) - { - AutoSizeAxes = Axes.Both; - Direction = FillDirection.Horizontal; - Spacing = new Vector2(2f); - - Children = new Drawable[] - { - new SpriteIcon - { - Anchor = Anchor.CentreLeft, - Origin = Anchor.CentreLeft, - Icon = icon, - Shadow = true, - Size = new Vector2(13), - }, - text = new OsuSpriteText - { - Anchor = Anchor.CentreLeft, - Origin = Anchor.CentreLeft, - Font = @"Exo2.0-SemiBoldItalic", - TextSize = 14, - }, - }; - - Value = value; - } - } - } -} +// 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 OpenTK; +using OpenTK.Graphics; +using osu.Framework.Allocation; +using osu.Framework.Configuration; +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; + +namespace osu.Game.Overlays.OnlineBeatmapSet +{ + public class BeatmapPicker : Container + { + private const float tile_icon_padding = 7; + private const float tile_spacing = 2; + + private readonly OsuSpriteText version, starRating; + + public readonly Bindable Beatmap = new Bindable(); + + public BeatmapPicker(BeatmapSetInfo set) + { + RelativeSizeAxes = Axes.X; + AutoSizeAxes = Axes.Y; + + TilesFillFlowContainer tileContainer; + Children = new Drawable[] + { + new FillFlowContainer + { + AutoSizeAxes = Axes.Y, + RelativeSizeAxes = Axes.X, + Direction = FillDirection.Vertical, + Children = new Drawable[] + { + tileContainer = new TilesFillFlowContainer + { + AutoSizeAxes = Axes.Both, + Margin = new MarginPadding { Left = -(tile_icon_padding + tile_spacing / 2) }, + OnLostHover = () => + { + showBeatmap(Beatmap.Value); + starRating.FadeOut(100); + }, + }, + new FillFlowContainer + { + AutoSizeAxes = Axes.Both, + Margin = new MarginPadding { Top = 10 }, + Spacing = new Vector2(5f), + Children = new[] + { + version = new OsuSpriteText + { + Anchor = Anchor.BottomLeft, + Origin = Anchor.BottomLeft, + TextSize = 20, + Font = @"Exo2.0-Bold", + }, + starRating = new OsuSpriteText + { + Anchor = Anchor.BottomLeft, + Origin = Anchor.BottomLeft, + TextSize = 13, + Font = @"Exo2.0-Bold", + Text = "Star Difficulty", + Alpha = 0, + Margin = new MarginPadding { Bottom = 1 }, + }, + }, + }, + new FillFlowContainer + { + RelativeSizeAxes = Axes.X, + AutoSizeAxes = Axes.Y, + Spacing = new Vector2(10f), + Margin = new MarginPadding { Top = 5 }, + Children = new[] + { + new Statistic(FontAwesome.fa_play_circle, set.OnlineInfo.PlayCount), + new Statistic(FontAwesome.fa_heart, set.OnlineInfo.FavouriteCount), + }, + }, + }, + }, + }; + + Beatmap.Value = set.Beatmaps.First(); + Beatmap.ValueChanged += showBeatmap; + tileContainer.ChildrenEnumerable = set.Beatmaps.Select(b => new BeatmapTile(b, Beatmap) + { + OnHovered = beatmap => + { + showBeatmap(beatmap); + starRating.Text = beatmap.StarDifficulty.ToString("Star Difficulty 0.##"); + starRating.FadeIn(100); + }, + }); + } + + [BackgroundDependencyLoader] + private void load(OsuColour colours) + { + starRating.Colour = colours.Yellow; + } + + protected override void LoadComplete() + { + base.LoadComplete(); + + // done here so everything can bind in intialization and get the first trigger + Beatmap.TriggerChange(); + } + + private void showBeatmap(BeatmapInfo beatmap) => version.Text = beatmap.Version; + + private class TilesFillFlowContainer : FillFlowContainer + { + public Action OnLostHover; + + protected override void OnHoverLost(InputState state) + { + base.OnHoverLost(state); + OnLostHover?.Invoke(); + } + } + + private class BeatmapTile : OsuClickableContainer + { + private const float transition_duration = 100; + private const float size = 52; + + private readonly BeatmapInfo beatmap; + private readonly Bindable bindable = new Bindable(); + + private readonly Container bg; + private readonly DifficultyIcon icon; + + public Action OnHovered; + + public BeatmapTile(BeatmapInfo beatmap, Bindable bindable) + { + this.beatmap = beatmap; + Size = new Vector2(size); + Margin = new MarginPadding { Horizontal = tile_spacing / 2 }; + + Children = new Drawable[] + { + bg = new Container + { + RelativeSizeAxes = Axes.Both, + Masking = true, + CornerRadius = 4, + Child = new Box + { + RelativeSizeAxes = Axes.Both, + Colour = Color4.Black.Opacity(0.5f), + }, + }, + icon = new DifficultyIcon(beatmap) + { + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + Size = new Vector2(size - tile_icon_padding * 2), + Margin = new MarginPadding { Bottom = 1 }, + }, + }; + + Action = () => this.bindable.Value = beatmap; + this.bindable.ValueChanged += beatmapChanged; + this.bindable.BindTo(bindable); + } + + protected override bool OnHover(InputState state) + { + fadeIn(); + OnHovered?.Invoke(beatmap); + return base.OnHover(state); + } + + protected override void OnHoverLost(InputState state) + { + if (bindable.Value != beatmap) + fadeOut(); + base.OnHoverLost(state); + } + + private void beatmapChanged(BeatmapInfo value) + { + if (value == beatmap) + fadeIn(); + else + fadeOut(); + } + + private void fadeIn() + { + bg.FadeIn(transition_duration); + icon.FadeIn(transition_duration); + } + + private void fadeOut() + { + bg.FadeOut(); + icon.FadeTo(0.7f, transition_duration); + } + } + + private class Statistic : FillFlowContainer + { + private readonly OsuSpriteText text; + + private int value; + public int Value + { + get { return value; } + set + { + this.value = value; + text.Text = Value.ToString(@"N0"); + } + } + + public Statistic(FontAwesome icon, int value = 0) + { + AutoSizeAxes = Axes.Both; + Direction = FillDirection.Horizontal; + Spacing = new Vector2(2f); + + Children = new Drawable[] + { + new SpriteIcon + { + Anchor = Anchor.CentreLeft, + Origin = Anchor.CentreLeft, + Icon = icon, + Shadow = true, + Size = new Vector2(13), + }, + text = new OsuSpriteText + { + Anchor = Anchor.CentreLeft, + Origin = Anchor.CentreLeft, + Font = @"Exo2.0-SemiBoldItalic", + TextSize = 14, + }, + }; + + Value = value; + } + } + } +} diff --git a/osu.Game/Overlays/OnlineBeatmapSet/Details.cs b/osu.Game/Overlays/OnlineBeatmapSet/Details.cs index 9aed59272d..05ae8f64a8 100644 --- a/osu.Game/Overlays/OnlineBeatmapSet/Details.cs +++ b/osu.Game/Overlays/OnlineBeatmapSet/Details.cs @@ -1,108 +1,108 @@ -// Copyright (c) 2007-2017 ppy Pty Ltd . -// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE - -using OpenTK; -using OpenTK.Graphics; -using osu.Framework.Extensions.Color4Extensions; -using osu.Framework.Graphics; -using osu.Framework.Graphics.Containers; -using osu.Framework.Graphics.Shapes; -using osu.Game.Beatmaps; -using osu.Game.Screens.Select.Details; - -namespace osu.Game.Overlays.OnlineBeatmapSet -{ - public class Details : FillFlowContainer - { - private readonly BasicStats basic; - private readonly AdvancedStats advanced; - private readonly UserRatings ratings; - - private BeatmapInfo beatmap; - public BeatmapInfo Beatmap - { - get { return beatmap; } - set - { - if (value == beatmap) return; - beatmap = value; - - basic.Beatmap = advanced.Beatmap = Beatmap; - ratings.Metrics = Beatmap.Metrics; - } - } - - public Details(BeatmapSetInfo set) - { - Width = OnlineBeatmapSetOverlay.RIGHT_WIDTH; - AutoSizeAxes = Axes.Y; - Spacing = new Vector2(1f); - - Children = new Drawable[] - { - new AsyncLoadWrapper(new PreviewButton(set) - { - RelativeSizeAxes = Axes.X, - }) - { - RelativeSizeAxes = Axes.X, - AutoSizeAxes = Axes.Y, - }, - new DetailBox - { - Child = basic = new BasicStats(set) - { - RelativeSizeAxes = Axes.X, - AutoSizeAxes = Axes.Y, - Margin = new MarginPadding { Vertical = 10 }, - }, - }, - new DetailBox - { - Child = advanced = new AdvancedStats - { - RelativeSizeAxes = Axes.X, - AutoSizeAxes = Axes.Y, - Margin = new MarginPadding { Vertical = 7.5f }, - }, - }, - new DetailBox - { - Child = ratings = new UserRatings - { - RelativeSizeAxes = Axes.X, - Height = 95, - Margin = new MarginPadding { Top = 10 }, - }, - }, - }; - } - - private class DetailBox : Container - { - private Container content; - protected override Container Content => content; - - public DetailBox() - { - RelativeSizeAxes = Axes.X; - AutoSizeAxes = Axes.Y; - - InternalChildren = new Drawable[] - { - new Box - { - RelativeSizeAxes = Axes.Both, - Colour = Color4.Black.Opacity(0.5f), - }, - content = new Container - { - RelativeSizeAxes = Axes.X, - AutoSizeAxes = Axes.Y, - Padding = new MarginPadding { Horizontal = 15 }, - }, - }; - } - } - } -} +// Copyright (c) 2007-2017 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using OpenTK; +using OpenTK.Graphics; +using osu.Framework.Extensions.Color4Extensions; +using osu.Framework.Graphics; +using osu.Framework.Graphics.Containers; +using osu.Framework.Graphics.Shapes; +using osu.Game.Beatmaps; +using osu.Game.Screens.Select.Details; + +namespace osu.Game.Overlays.OnlineBeatmapSet +{ + public class Details : FillFlowContainer + { + private readonly BasicStats basic; + private readonly AdvancedStats advanced; + private readonly UserRatings ratings; + + private BeatmapInfo beatmap; + public BeatmapInfo Beatmap + { + get { return beatmap; } + set + { + if (value == beatmap) return; + beatmap = value; + + basic.Beatmap = advanced.Beatmap = Beatmap; + ratings.Metrics = Beatmap.Metrics; + } + } + + public Details(BeatmapSetInfo set) + { + Width = OnlineBeatmapSetOverlay.RIGHT_WIDTH; + AutoSizeAxes = Axes.Y; + Spacing = new Vector2(1f); + + Children = new Drawable[] + { + new AsyncLoadWrapper(new PreviewButton(set) + { + RelativeSizeAxes = Axes.X, + }) + { + RelativeSizeAxes = Axes.X, + AutoSizeAxes = Axes.Y, + }, + new DetailBox + { + Child = basic = new BasicStats(set) + { + RelativeSizeAxes = Axes.X, + AutoSizeAxes = Axes.Y, + Margin = new MarginPadding { Vertical = 10 }, + }, + }, + new DetailBox + { + Child = advanced = new AdvancedStats + { + RelativeSizeAxes = Axes.X, + AutoSizeAxes = Axes.Y, + Margin = new MarginPadding { Vertical = 7.5f }, + }, + }, + new DetailBox + { + Child = ratings = new UserRatings + { + RelativeSizeAxes = Axes.X, + Height = 95, + Margin = new MarginPadding { Top = 10 }, + }, + }, + }; + } + + private class DetailBox : Container + { + private readonly Container content; + protected override Container Content => content; + + public DetailBox() + { + RelativeSizeAxes = Axes.X; + AutoSizeAxes = Axes.Y; + + InternalChildren = new Drawable[] + { + new Box + { + RelativeSizeAxes = Axes.Both, + Colour = Color4.Black.Opacity(0.5f), + }, + content = new Container + { + RelativeSizeAxes = Axes.X, + AutoSizeAxes = Axes.Y, + Padding = new MarginPadding { Horizontal = 15 }, + }, + }; + } + } + } +} diff --git a/osu.Game/Overlays/OnlineBeatmapSet/DownloadButton.cs b/osu.Game/Overlays/OnlineBeatmapSet/DownloadButton.cs index 96f811ca55..855aa3de93 100644 --- a/osu.Game/Overlays/OnlineBeatmapSet/DownloadButton.cs +++ b/osu.Game/Overlays/OnlineBeatmapSet/DownloadButton.cs @@ -1,59 +1,59 @@ -// Copyright (c) 2007-2017 ppy Pty Ltd . -// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE - -using OpenTK; -using osu.Framework.Graphics; -using osu.Framework.Graphics.Containers; -using osu.Game.Graphics; -using osu.Game.Graphics.Sprites; - -namespace osu.Game.Overlays.OnlineBeatmapSet -{ - public class DownloadButton : HeaderButton - { - public DownloadButton(string title, string subtitle) - { - Width = 120; - RelativeSizeAxes = Axes.Y; - - Child = new Container - { - RelativeSizeAxes = Axes.Both, - Padding = new MarginPadding { Horizontal = 10 }, - Children = new Drawable[] - { - new FillFlowContainer - { - Anchor = Anchor.CentreLeft, - Origin = Anchor.CentreLeft, - AutoSizeAxes = Axes.Both, - Direction = FillDirection.Vertical, - Children = new[] - { - new OsuSpriteText - { - Text = title, - TextSize = 13, - Font = @"Exo2.0-Bold", - }, - new OsuSpriteText - { - Text = subtitle, - TextSize = 11, - Font = @"Exo2.0-Bold", - }, - }, - }, - new SpriteIcon - { - Anchor = Anchor.CentreRight, - Origin = Anchor.CentreRight, - Icon = FontAwesome.fa_download, - Size = new Vector2(16), - Margin = new MarginPadding { Right = 5 }, - }, - }, - }; - } - } -} +// Copyright (c) 2007-2017 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using OpenTK; +using osu.Framework.Graphics; +using osu.Framework.Graphics.Containers; +using osu.Game.Graphics; +using osu.Game.Graphics.Sprites; + +namespace osu.Game.Overlays.OnlineBeatmapSet +{ + public class DownloadButton : HeaderButton + { + public DownloadButton(string title, string subtitle) + { + Width = 120; + RelativeSizeAxes = Axes.Y; + + Child = new Container + { + RelativeSizeAxes = Axes.Both, + Padding = new MarginPadding { Horizontal = 10 }, + Children = new Drawable[] + { + new FillFlowContainer + { + Anchor = Anchor.CentreLeft, + Origin = Anchor.CentreLeft, + AutoSizeAxes = Axes.Both, + Direction = FillDirection.Vertical, + Children = new[] + { + new OsuSpriteText + { + Text = title, + TextSize = 13, + Font = @"Exo2.0-Bold", + }, + new OsuSpriteText + { + Text = subtitle, + TextSize = 11, + Font = @"Exo2.0-Bold", + }, + }, + }, + new SpriteIcon + { + Anchor = Anchor.CentreRight, + Origin = Anchor.CentreRight, + Icon = FontAwesome.fa_download, + Size = new Vector2(16), + Margin = new MarginPadding { Right = 5 }, + }, + }, + }; + } + } +} diff --git a/osu.Game/Overlays/OnlineBeatmapSet/FavouriteButton.cs b/osu.Game/Overlays/OnlineBeatmapSet/FavouriteButton.cs index cef77dc43c..4998ea1c19 100644 --- a/osu.Game/Overlays/OnlineBeatmapSet/FavouriteButton.cs +++ b/osu.Game/Overlays/OnlineBeatmapSet/FavouriteButton.cs @@ -1,80 +1,80 @@ -// Copyright (c) 2007-2017 ppy Pty Ltd . -// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE] - -using OpenTK; -using osu.Framework.Configuration; -using osu.Framework.Graphics; -using osu.Framework.Graphics.Containers; -using osu.Framework.Graphics.Shapes; -using osu.Game.Graphics; -using osu.Game.Graphics.Backgrounds; - -namespace osu.Game.Overlays.OnlineBeatmapSet -{ - public class FavouriteButton : HeaderButton - { - public readonly Bindable Favourited = new Bindable(); - - public FavouriteButton() - { - RelativeSizeAxes = Axes.Y; - - Container pink; - SpriteIcon icon; - Children = new Drawable[] - { - pink = new Container - { - RelativeSizeAxes = Axes.Both, - Alpha = 0f, - Children = new Drawable[] - { - new Box - { - RelativeSizeAxes = Axes.Both, - Colour = OsuColour.FromHex(@"9f015f"), - }, - new Triangles - { - RelativeSizeAxes = Axes.Both, - ColourLight = OsuColour.FromHex(@"cb2187"), - ColourDark = OsuColour.FromHex(@"9f015f"), - TriangleScale = 1.5f, - }, - }, - }, - icon = new SpriteIcon - { - Anchor = Anchor.Centre, - Origin = Anchor.Centre, - Icon = FontAwesome.fa_heart_o, - Size = new Vector2(18), - Shadow = false, - }, - }; - - Favourited.ValueChanged += value => - { - if (value) - { - pink.FadeIn(200); - icon.Icon = FontAwesome.fa_heart; - } - else - { - pink.FadeOut(200); - icon.Icon = FontAwesome.fa_heart_o; - } - }; - - Action = () => Favourited.Value = !Favourited.Value; - } - - protected override void UpdateAfterChildren() - { - base.UpdateAfterChildren(); - - Width = DrawHeight; - } - } -} +// Copyright (c) 2007-2017 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using OpenTK; +using osu.Framework.Configuration; +using osu.Framework.Graphics; +using osu.Framework.Graphics.Containers; +using osu.Framework.Graphics.Shapes; +using osu.Game.Graphics; +using osu.Game.Graphics.Backgrounds; + +namespace osu.Game.Overlays.OnlineBeatmapSet +{ + public class FavouriteButton : HeaderButton + { + public readonly Bindable Favourited = new Bindable(); + + public FavouriteButton() + { + RelativeSizeAxes = Axes.Y; + + Container pink; + SpriteIcon icon; + Children = new Drawable[] + { + pink = new Container + { + RelativeSizeAxes = Axes.Both, + Alpha = 0f, + Children = new Drawable[] + { + new Box + { + RelativeSizeAxes = Axes.Both, + Colour = OsuColour.FromHex(@"9f015f"), + }, + new Triangles + { + RelativeSizeAxes = Axes.Both, + ColourLight = OsuColour.FromHex(@"cb2187"), + ColourDark = OsuColour.FromHex(@"9f015f"), + TriangleScale = 1.5f, + }, + }, + }, + icon = new SpriteIcon + { + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + Icon = FontAwesome.fa_heart_o, + Size = new Vector2(18), + Shadow = false, + }, + }; + + Favourited.ValueChanged += value => + { + if (value) + { + pink.FadeIn(200); + icon.Icon = FontAwesome.fa_heart; + } + else + { + pink.FadeOut(200); + icon.Icon = FontAwesome.fa_heart_o; + } + }; + + Action = () => Favourited.Value = !Favourited.Value; + } + + protected override void UpdateAfterChildren() + { + base.UpdateAfterChildren(); + + Width = DrawHeight; + } + } +} diff --git a/osu.Game/Overlays/OnlineBeatmapSet/HeaderButton.cs b/osu.Game/Overlays/OnlineBeatmapSet/HeaderButton.cs index d4f611c194..fe852ec83a 100644 --- a/osu.Game/Overlays/OnlineBeatmapSet/HeaderButton.cs +++ b/osu.Game/Overlays/OnlineBeatmapSet/HeaderButton.cs @@ -1,45 +1,45 @@ -// Copyright (c) 2007-2017 ppy Pty Ltd . -// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE - -using osu.Framework.Graphics; -using osu.Framework.Graphics.Containers; -using osu.Framework.Graphics.Shapes; -using osu.Game.Graphics; -using osu.Game.Graphics.Backgrounds; -using osu.Game.Graphics.Containers; - -namespace osu.Game.Overlays.OnlineBeatmapSet -{ - public class HeaderButton : OsuClickableContainer - { - private readonly Container content; - - protected override Container Content => content; - - public HeaderButton() - { - CornerRadius = 3; - Masking = true; - - InternalChildren = new Drawable[] - { - new Box - { - RelativeSizeAxes = Axes.Both, - Colour = OsuColour.FromHex(@"094c5f"), - }, - new Triangles - { - RelativeSizeAxes = Axes.Both, - ColourLight = OsuColour.FromHex(@"0f7c9b"), - ColourDark = OsuColour.FromHex(@"094c5f"), - TriangleScale = 1.5f, - }, - content = new Container - { - RelativeSizeAxes = Axes.Both, - }, - }; - } - } -} +// Copyright (c) 2007-2017 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using osu.Framework.Graphics; +using osu.Framework.Graphics.Containers; +using osu.Framework.Graphics.Shapes; +using osu.Game.Graphics; +using osu.Game.Graphics.Backgrounds; +using osu.Game.Graphics.Containers; + +namespace osu.Game.Overlays.OnlineBeatmapSet +{ + public class HeaderButton : OsuClickableContainer + { + private readonly Container content; + + protected override Container Content => content; + + public HeaderButton() + { + CornerRadius = 3; + Masking = true; + + InternalChildren = new Drawable[] + { + new Box + { + RelativeSizeAxes = Axes.Both, + Colour = OsuColour.FromHex(@"094c5f"), + }, + new Triangles + { + RelativeSizeAxes = Axes.Both, + ColourLight = OsuColour.FromHex(@"0f7c9b"), + ColourDark = OsuColour.FromHex(@"094c5f"), + TriangleScale = 1.5f, + }, + content = new Container + { + RelativeSizeAxes = Axes.Both, + }, + }; + } + } +} From d36fc134878d7e86c3bb50121f34a04958dc416d Mon Sep 17 00:00:00 2001 From: DrabWeb Date: Tue, 12 Sep 2017 23:46:21 -0300 Subject: [PATCH 13/30] Make success rate percent move with the bar. --- osu.Game/Overlays/OnlineBeatmapSet/SuccessRate.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Overlays/OnlineBeatmapSet/SuccessRate.cs b/osu.Game/Overlays/OnlineBeatmapSet/SuccessRate.cs index 330ebedaca..4641bf8c32 100644 --- a/osu.Game/Overlays/OnlineBeatmapSet/SuccessRate.cs +++ b/osu.Game/Overlays/OnlineBeatmapSet/SuccessRate.cs @@ -33,6 +33,7 @@ namespace osu.Game.Overlays.OnlineBeatmapSet var rate = (float)beatmap.OnlineInfo.PassCount / beatmap.OnlineInfo.PlayCount; successPercent.Text = $"{Math.Round(rate * 100)}%"; successRate.Length = rate; + percentContainer.ResizeWidthTo(successRate.Length, 250, Easing.InOutCubic); graph.Metrics = Beatmap.Metrics; } @@ -106,7 +107,6 @@ namespace osu.Game.Overlays.OnlineBeatmapSet base.UpdateAfterChildren(); graph.Padding = new MarginPadding { Top = header.DrawHeight }; - percentContainer.Width = successRate.Length; } } } From 0e9dc6fb85ba9dcad7632ff07d77a4d5f57e28ba Mon Sep 17 00:00:00 2001 From: DrabWeb Date: Tue, 12 Sep 2017 23:55:48 -0300 Subject: [PATCH 14/30] Don't recreate header buttons on beatmap change. --- .../Visual/TestCaseOnlineBeatmapSetOverlay.cs | 2 +- osu.Game/Overlays/OnlineBeatmapSet/Header.cs | 23 +++++++++++-------- 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/osu.Desktop.Tests/Visual/TestCaseOnlineBeatmapSetOverlay.cs b/osu.Desktop.Tests/Visual/TestCaseOnlineBeatmapSetOverlay.cs index b3421591f1..5d17cd6b8f 100644 --- a/osu.Desktop.Tests/Visual/TestCaseOnlineBeatmapSetOverlay.cs +++ b/osu.Desktop.Tests/Visual/TestCaseOnlineBeatmapSetOverlay.cs @@ -103,7 +103,7 @@ namespace osu.Desktop.Tests.Visual OnlineInfo = new BeatmapOnlineInfo { Length = 118000, - HasVideo = false, + HasVideo = true, CircleCount = 592, SliderCount = 62, PlayCount = 162021, diff --git a/osu.Game/Overlays/OnlineBeatmapSet/Header.cs b/osu.Game/Overlays/OnlineBeatmapSet/Header.cs index 8200a9a373..14cb4b653c 100644 --- a/osu.Game/Overlays/OnlineBeatmapSet/Header.cs +++ b/osu.Game/Overlays/OnlineBeatmapSet/Header.cs @@ -18,6 +18,7 @@ namespace osu.Game.Overlays.OnlineBeatmapSet { public class Header : Container { + private const float transition_duration = 250; private const float tabs_height = 50; private readonly Box tabsBg; @@ -37,7 +38,7 @@ namespace osu.Game.Overlays.OnlineBeatmapSet Offset = new Vector2(0f, 1f), }; - FillFlowContainer buttons; + DownloadButton noVideo, withVideo, withoutVideo; Details details; Children = new Drawable[] { @@ -126,15 +127,20 @@ namespace osu.Game.Overlays.OnlineBeatmapSet Margin = new MarginPadding { Top = 20 }, Child = new AuthorInfo(set.OnlineInfo), }, - buttons = new FillFlowContainer + new FillFlowContainer { RelativeSizeAxes = Axes.X, Height = 45, Spacing = new Vector2(5f), Margin = new MarginPadding { Top = 10 }, + LayoutDuration = transition_duration, + LayoutEasing = Easing.Out, Children = new HeaderButton[] { new FavouriteButton(), + noVideo = new DownloadButton("Download", @""), + withVideo = new DownloadButton("Download", "with Video"), + withoutVideo = new DownloadButton("Download", "without Video"), }, }, }, @@ -154,18 +160,17 @@ namespace osu.Game.Overlays.OnlineBeatmapSet { details.Beatmap = b; - buttons.Child = new FavouriteButton(); if (b.OnlineInfo.HasVideo) { - buttons.AddRange(new[] - { - new DownloadButton("Download", "with Video"), - new DownloadButton("Download", "without Video"), - }); + noVideo.FadeOut(transition_duration); + withVideo.FadeIn(transition_duration); + withoutVideo.FadeIn(transition_duration); } else { - buttons.Add(new DownloadButton("Download", @"")); + noVideo.FadeIn(transition_duration); + withVideo.FadeOut(transition_duration); + withoutVideo.FadeOut(transition_duration); } }; } From 9e6f94b81842f8a70f1a1089a43b8d571bacddbd Mon Sep 17 00:00:00 2001 From: DrabWeb Date: Wed, 13 Sep 2017 00:13:45 -0300 Subject: [PATCH 15/30] Make BeatmapPicker buttons more independent. --- .../OnlineBeatmapSet/BeatmapPicker.cs | 81 +++++++++++++------ 1 file changed, 58 insertions(+), 23 deletions(-) diff --git a/osu.Game/Overlays/OnlineBeatmapSet/BeatmapPicker.cs b/osu.Game/Overlays/OnlineBeatmapSet/BeatmapPicker.cs index 92b9644263..303c874d94 100644 --- a/osu.Game/Overlays/OnlineBeatmapSet/BeatmapPicker.cs +++ b/osu.Game/Overlays/OnlineBeatmapSet/BeatmapPicker.cs @@ -5,6 +5,7 @@ using System; using System.Linq; using OpenTK; using OpenTK.Graphics; +using osu.Framework; using osu.Framework.Allocation; using osu.Framework.Configuration; using osu.Framework.Extensions.Color4Extensions; @@ -25,6 +26,7 @@ namespace osu.Game.Overlays.OnlineBeatmapSet private const float tile_icon_padding = 7; private const float tile_spacing = 2; + private readonly DifficultiesContainer difficulties; private readonly OsuSpriteText version, starRating; public readonly Bindable Beatmap = new Bindable(); @@ -34,7 +36,6 @@ namespace osu.Game.Overlays.OnlineBeatmapSet RelativeSizeAxes = Axes.X; AutoSizeAxes = Axes.Y; - TilesFillFlowContainer tileContainer; Children = new Drawable[] { new FillFlowContainer @@ -44,7 +45,7 @@ namespace osu.Game.Overlays.OnlineBeatmapSet Direction = FillDirection.Vertical, Children = new Drawable[] { - tileContainer = new TilesFillFlowContainer + difficulties = new DifficultiesContainer { AutoSizeAxes = Axes.Both, Margin = new MarginPadding { Left = -(tile_icon_padding + tile_spacing / 2) }, @@ -97,15 +98,26 @@ namespace osu.Game.Overlays.OnlineBeatmapSet }; Beatmap.Value = set.Beatmaps.First(); - Beatmap.ValueChanged += showBeatmap; - tileContainer.ChildrenEnumerable = set.Beatmaps.Select(b => new BeatmapTile(b, Beatmap) + + Beatmap.ValueChanged += b => { + showBeatmap(b); + updateDifficultyButtons(); + }; + + difficulties.ChildrenEnumerable = set.Beatmaps.Select(b => new DifficultySelectorButton(b) + { + State = DifficultySelectorState.NotSelected, OnHovered = beatmap => { showBeatmap(beatmap); starRating.Text = beatmap.StarDifficulty.ToString("Star Difficulty 0.##"); starRating.FadeIn(100); }, + OnClicked = beatmap => + { + Beatmap.Value = beatmap; + }, }); } @@ -125,7 +137,12 @@ namespace osu.Game.Overlays.OnlineBeatmapSet private void showBeatmap(BeatmapInfo beatmap) => version.Text = beatmap.Version; - private class TilesFillFlowContainer : FillFlowContainer + private void updateDifficultyButtons() + { + difficulties.Children.ToList().ForEach(diff => diff.State = diff.Beatmap == Beatmap.Value ? DifficultySelectorState.Selected : DifficultySelectorState.NotSelected); + } + + private class DifficultiesContainer : FillFlowContainer { public Action OnLostHover; @@ -136,22 +153,40 @@ namespace osu.Game.Overlays.OnlineBeatmapSet } } - private class BeatmapTile : OsuClickableContainer + private class DifficultySelectorButton : OsuClickableContainer, IStateful { private const float transition_duration = 100; private const float size = 52; - private readonly BeatmapInfo beatmap; - private readonly Bindable bindable = new Bindable(); - private readonly Container bg; private readonly DifficultyIcon icon; - public Action OnHovered; + public readonly BeatmapInfo Beatmap; - public BeatmapTile(BeatmapInfo beatmap, Bindable bindable) + public Action OnHovered; + public Action OnClicked; + public event Action StateChanged; + + private DifficultySelectorState state; + public DifficultySelectorState State { - this.beatmap = beatmap; + get { return state; } + set + { + if (value == state) return; + state = value; + + StateChanged?.Invoke(State); + if (value == DifficultySelectorState.Selected) + fadeIn(); + else + fadeOut(); + } + } + + public DifficultySelectorButton(BeatmapInfo beatmap) + { + this.Beatmap = beatmap; Size = new Vector2(size); Margin = new MarginPadding { Horizontal = tile_spacing / 2 }; @@ -176,32 +211,26 @@ namespace osu.Game.Overlays.OnlineBeatmapSet Margin = new MarginPadding { Bottom = 1 }, }, }; - - Action = () => this.bindable.Value = beatmap; - this.bindable.ValueChanged += beatmapChanged; - this.bindable.BindTo(bindable); } protected override bool OnHover(InputState state) { fadeIn(); - OnHovered?.Invoke(beatmap); + OnHovered?.Invoke(Beatmap); return base.OnHover(state); } protected override void OnHoverLost(InputState state) { - if (bindable.Value != beatmap) + if (State == DifficultySelectorState.NotSelected) fadeOut(); base.OnHoverLost(state); } - private void beatmapChanged(BeatmapInfo value) + protected override bool OnClick(InputState state) { - if (value == beatmap) - fadeIn(); - else - fadeOut(); + OnClicked?.Invoke(Beatmap); + return base.OnClick(state); } private void fadeIn() @@ -260,5 +289,11 @@ namespace osu.Game.Overlays.OnlineBeatmapSet Value = value; } } + + private enum DifficultySelectorState + { + Selected, + NotSelected, + } } } From 0a5c963c4b1790fc9be1a09c86569836ec080ae7 Mon Sep 17 00:00:00 2001 From: DrabWeb Date: Wed, 13 Sep 2017 00:18:00 -0300 Subject: [PATCH 16/30] Remove redundant .this --- osu.Game/Overlays/OnlineBeatmapSet/BeatmapPicker.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Overlays/OnlineBeatmapSet/BeatmapPicker.cs b/osu.Game/Overlays/OnlineBeatmapSet/BeatmapPicker.cs index 303c874d94..bea6f98382 100644 --- a/osu.Game/Overlays/OnlineBeatmapSet/BeatmapPicker.cs +++ b/osu.Game/Overlays/OnlineBeatmapSet/BeatmapPicker.cs @@ -186,7 +186,7 @@ namespace osu.Game.Overlays.OnlineBeatmapSet public DifficultySelectorButton(BeatmapInfo beatmap) { - this.Beatmap = beatmap; + Beatmap = beatmap; Size = new Vector2(size); Margin = new MarginPadding { Horizontal = tile_spacing / 2 }; From 574d7b24ff82bf20ea86766d7f3c12187635cc53 Mon Sep 17 00:00:00 2001 From: DrabWeb Date: Wed, 13 Sep 2017 12:07:31 -0300 Subject: [PATCH 17/30] Fix some visual issues. --- osu.Game/Overlays/OnlineBeatmapSet/Header.cs | 52 +++++++++++++------ .../Overlays/OnlineBeatmapSet/SuccessRate.cs | 1 + 2 files changed, 37 insertions(+), 16 deletions(-) diff --git a/osu.Game/Overlays/OnlineBeatmapSet/Header.cs b/osu.Game/Overlays/OnlineBeatmapSet/Header.cs index 14cb4b653c..0525b32b36 100644 --- a/osu.Game/Overlays/OnlineBeatmapSet/Header.cs +++ b/osu.Game/Overlays/OnlineBeatmapSet/Header.cs @@ -20,6 +20,8 @@ namespace osu.Game.Overlays.OnlineBeatmapSet { private const float transition_duration = 250; private const float tabs_height = 50; + private const float buttons_height = 45; + private const float buttons_spacing = 5; private readonly Box tabsBg; @@ -38,7 +40,8 @@ namespace osu.Game.Overlays.OnlineBeatmapSet Offset = new Vector2(0f, 1f), }; - DownloadButton noVideo, withVideo, withoutVideo; + Container noVideoButtons; + FillFlowContainer videoButtons; Details details; Children = new Drawable[] { @@ -127,20 +130,39 @@ namespace osu.Game.Overlays.OnlineBeatmapSet Margin = new MarginPadding { Top = 20 }, Child = new AuthorInfo(set.OnlineInfo), }, - new FillFlowContainer + new Container { RelativeSizeAxes = Axes.X, - Height = 45, - Spacing = new Vector2(5f), + Height = buttons_height, Margin = new MarginPadding { Top = 10 }, - LayoutDuration = transition_duration, - LayoutEasing = Easing.Out, - Children = new HeaderButton[] + Children = new Drawable[] { new FavouriteButton(), - noVideo = new DownloadButton("Download", @""), - withVideo = new DownloadButton("Download", "with Video"), - withoutVideo = new DownloadButton("Download", "without Video"), + new Container + { + RelativeSizeAxes = Axes.Both, + Padding = new MarginPadding { Left = buttons_height + buttons_spacing }, + Children = new Drawable[] + { + noVideoButtons = new Container + { + RelativeSizeAxes = Axes.Both, + Alpha = 0f, + Child = new DownloadButton("Download", @""), + }, + videoButtons = new FillFlowContainer + { + RelativeSizeAxes = Axes.Both, + Spacing = new Vector2(buttons_spacing), + Alpha = 0f, + Children = new[] + { + new DownloadButton("Download", "with Video"), + new DownloadButton("Download", "without Video"), + }, + }, + }, + }, }, }, }, @@ -162,15 +184,13 @@ namespace osu.Game.Overlays.OnlineBeatmapSet if (b.OnlineInfo.HasVideo) { - noVideo.FadeOut(transition_duration); - withVideo.FadeIn(transition_duration); - withoutVideo.FadeIn(transition_duration); + noVideoButtons.FadeOut(transition_duration); + videoButtons.FadeIn(transition_duration); } else { - noVideo.FadeIn(transition_duration); - withVideo.FadeOut(transition_duration); - withoutVideo.FadeOut(transition_duration); + noVideoButtons.FadeIn(transition_duration); + videoButtons.FadeOut(transition_duration); } }; } diff --git a/osu.Game/Overlays/OnlineBeatmapSet/SuccessRate.cs b/osu.Game/Overlays/OnlineBeatmapSet/SuccessRate.cs index 4641bf8c32..3389542e64 100644 --- a/osu.Game/Overlays/OnlineBeatmapSet/SuccessRate.cs +++ b/osu.Game/Overlays/OnlineBeatmapSet/SuccessRate.cs @@ -67,6 +67,7 @@ namespace osu.Game.Overlays.OnlineBeatmapSet { RelativeSizeAxes = Axes.X, AutoSizeAxes = Axes.Y, + Width = 0f, Child = successPercent = new OsuSpriteText { Anchor = Anchor.TopRight, From 63c50f82eb3540253664969e08fe7275bc3272db Mon Sep 17 00:00:00 2001 From: DrabWeb Date: Wed, 13 Sep 2017 12:37:18 -0300 Subject: [PATCH 18/30] Make Info updateable. --- osu.Game/Overlays/OnlineBeatmapSet/Info.cs | 89 ++++++++++++-------- osu.Game/Overlays/OnlineBeatmapSetOverlay.cs | 24 +++--- 2 files changed, 68 insertions(+), 45 deletions(-) diff --git a/osu.Game/Overlays/OnlineBeatmapSet/Info.cs b/osu.Game/Overlays/OnlineBeatmapSet/Info.cs index b820345839..7782e8b7ab 100644 --- a/osu.Game/Overlays/OnlineBeatmapSet/Info.cs +++ b/osu.Game/Overlays/OnlineBeatmapSet/Info.cs @@ -16,15 +16,27 @@ namespace osu.Game.Overlays.OnlineBeatmapSet { public class Info : Container { + private const float transition_duration = 250; private const float metadata_width = 225; private const float spacing = 20; - private readonly BeatmapSetInfo set; - + private readonly MetadataSection description, source, tags; private readonly Box successRateBackground; private readonly SuccessRate successRate; - private readonly FillFlowContainer metadataFlow; - private readonly ScrollContainer descriptionScroll; + + private BeatmapSetInfo beatmapSet; + public BeatmapSetInfo BeatmapSet + { + get { return beatmapSet; } + set + { + if (value == beatmapSet) return; + beatmapSet = value; + + source.Text = BeatmapSet.Metadata.Source; + tags.Text = BeatmapSet.Metadata.Tags; + } + } public BeatmapInfo Beatmap { @@ -32,10 +44,8 @@ namespace osu.Game.Overlays.OnlineBeatmapSet set { successRate.Beatmap = value; } } - public Info(BeatmapSetInfo set) + public Info() { - this.set = set; - RelativeSizeAxes = Axes.X; Height = 220; Masking = true; @@ -64,10 +74,11 @@ namespace osu.Game.Overlays.OnlineBeatmapSet { RelativeSizeAxes = Axes.Both, Padding = new MarginPadding { Right = metadata_width + OnlineBeatmapSetOverlay.RIGHT_WIDTH + spacing * 2 }, - Child = descriptionScroll = new ScrollContainer + Child = new ScrollContainer { RelativeSizeAxes = Axes.Both, ScrollbarVisible = false, + Child = description = new MetadataSection("Description"), }, }, new ScrollContainer @@ -79,11 +90,17 @@ namespace osu.Game.Overlays.OnlineBeatmapSet ScrollbarVisible = false, Padding = new MarginPadding { Horizontal = 10 }, Margin = new MarginPadding { Right = OnlineBeatmapSetOverlay.RIGHT_WIDTH + spacing }, - Child = metadataFlow = new FillFlowContainer + Child = new FillFlowContainer { RelativeSizeAxes = Axes.X, AutoSizeAxes = Axes.Y, Direction = FillDirection.Vertical, + LayoutDuration = transition_duration, + Children = new[] + { + source = new MetadataSection("Source"), + tags = new MetadataSection("Tags"), + }, }, }, new Container @@ -114,55 +131,59 @@ namespace osu.Game.Overlays.OnlineBeatmapSet private void load(OsuColour colours) { successRateBackground.Colour = colours.GrayE; - descriptionScroll.Child = new MetadataSection("Description", "", colours.Gray5); - metadataFlow.Children = new[] - { - new MetadataSection("Source", set.Metadata.Source, colours.Gray5), - new MetadataSection("Tags", set.Metadata.Tags, colours.BlueDark), - }; + source.TextColour = description.TextColour = colours.Gray5; + tags.TextColour = colours.BlueDark; } private class MetadataSection : FillFlowContainer { private readonly OsuSpriteText header; + private readonly TextFlowContainer textFlow; - public MetadataSection(string title, string body, Color4 textColour) + public string Text + { + set + { + if (string.IsNullOrEmpty(value)) + { + this.FadeOut(transition_duration); + return; + } + + this.FadeIn(transition_duration); + textFlow.Clear(); + textFlow.AddText(value, s => s.TextSize = 14); + } + } + + public Color4 TextColour + { + get { return textFlow.Colour; } + set { textFlow.Colour = value; } + } + + public MetadataSection(string title) { RelativeSizeAxes = Axes.X; AutoSizeAxes = Axes.Y; - Direction = FillDirection.Vertical; Spacing = new Vector2(5f); - TextFlowContainer content; - Children = new Drawable[] + InternalChildren = new Drawable[] { header = new OsuSpriteText { + Text = title, Font = @"Exo2.0-Bold", TextSize = 14, - Text = title, Shadow = false, Margin = new MarginPadding { Top = 20 }, }, - content = new TextFlowContainer + textFlow = new TextFlowContainer { RelativeSizeAxes = Axes.X, AutoSizeAxes = Axes.Y, }, }; - - if (!string.IsNullOrEmpty(body)) - { - content.AddText(body, t => - { - t.TextSize = 14; - t.Colour = textColour; - }); - } - else - { - Hide(); - } } [BackgroundDependencyLoader] diff --git a/osu.Game/Overlays/OnlineBeatmapSetOverlay.cs b/osu.Game/Overlays/OnlineBeatmapSetOverlay.cs index ab6d308af9..9dea34e06b 100644 --- a/osu.Game/Overlays/OnlineBeatmapSetOverlay.cs +++ b/osu.Game/Overlays/OnlineBeatmapSetOverlay.cs @@ -1,6 +1,7 @@ // Copyright (c) 2007-2017 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE +using System.Linq; using OpenTK; using OpenTK.Graphics; using osu.Framework.Extensions.Color4Extensions; @@ -19,7 +20,8 @@ namespace osu.Game.Overlays public const float X_PADDING = 40; public const float RIGHT_WIDTH = 275; - private readonly ReverseChildIDFillFlowContainer scrollContent; + private readonly Header header; + private readonly Info info; public OnlineBeatmapSetOverlay() { @@ -53,14 +55,21 @@ namespace osu.Game.Overlays { RelativeSizeAxes = Axes.Both, ScrollbarVisible = false, - Child = scrollContent = new ReverseChildIDFillFlowContainer + Child = new ReverseChildIDFillFlowContainer { RelativeSizeAxes = Axes.X, AutoSizeAxes = Axes.Y, Direction = FillDirection.Vertical, + Children = new Drawable[] + { + // header = new Header(), + info = new Info(), + }, }, }, }; + + // header.Picker.Beatmap.ValueChanged += b => info.Beatmap = b; } protected override void PopIn() @@ -77,15 +86,8 @@ namespace osu.Game.Overlays public void ShowBeatmapSet(BeatmapSetInfo set) { - Header header; - Info info; - scrollContent.Children = new Drawable[] - { - header = new Header(set), - info = new Info(set), - }; - - header.Picker.Beatmap.ValueChanged += b => info.Beatmap = b; + /*header.BeatmapSet = */info.BeatmapSet = set; + info.Beatmap = set.Beatmaps.Last(); Show(); } From d83cd3ecf9eeadbf6e673c74294ff2ade10be342 Mon Sep 17 00:00:00 2001 From: DrabWeb Date: Wed, 13 Sep 2017 18:25:23 -0300 Subject: [PATCH 19/30] Make Header and it's components updateable. --- .../Overlays/OnlineBeatmapSet/AuthorInfo.cs | 58 ++++++++++------ .../Overlays/OnlineBeatmapSet/BasicStats.cs | 23 +++++-- .../OnlineBeatmapSet/BeatmapPicker.cs | 59 +++++++++------- osu.Game/Overlays/OnlineBeatmapSet/Details.cs | 24 +++++-- osu.Game/Overlays/OnlineBeatmapSet/Header.cs | 68 +++++++++++++------ .../OnlineBeatmapSet/PreviewButton.cs | 27 ++++++-- osu.Game/Overlays/OnlineBeatmapSetOverlay.cs | 8 +-- 7 files changed, 176 insertions(+), 91 deletions(-) diff --git a/osu.Game/Overlays/OnlineBeatmapSet/AuthorInfo.cs b/osu.Game/Overlays/OnlineBeatmapSet/AuthorInfo.cs index 90d97f75c7..ce46e96380 100644 --- a/osu.Game/Overlays/OnlineBeatmapSet/AuthorInfo.cs +++ b/osu.Game/Overlays/OnlineBeatmapSet/AuthorInfo.cs @@ -16,20 +16,53 @@ namespace osu.Game.Overlays.OnlineBeatmapSet { private const float height = 50; - public AuthorInfo(BeatmapSetOnlineInfo info) + private readonly UpdateableAvatar avatar; + private readonly FillFlowContainer fields; + + private BeatmapSetInfo beatmapSet; + public BeatmapSetInfo BeatmapSet + { + get { return beatmapSet; } + set + { + if (value == beatmapSet) return; + beatmapSet = value; + + var i = BeatmapSet.OnlineInfo; + + avatar.User = i.Author; + fields.Children = new Drawable[] + { + new Field("made by", i.Author.Username, @"Exo2.0-RegularItalic"), + new Field("submitted on", i.Submitted.ToString(@"MMM d, yyyy"), @"Exo2.0-Bold") + { + Margin = new MarginPadding { Top = 5 }, + }, + }; + + if (i.Ranked.HasValue) + { + fields.Add(new Field("ranked on ", i.Ranked.Value.ToString(@"MMM d, yyyy"), @"Exo2.0-Bold")); + } + else if (i.LastUpdated.HasValue) + { + fields.Add(new Field("last updated on ", i.LastUpdated.Value.ToString(@"MMM d, yyyy"), @"Exo2.0-Bold")); + } + } + } + + public AuthorInfo() { RelativeSizeAxes = Axes.X; Height = height; - FillFlowContainer fields; Children = new Drawable[] { - new UpdateableAvatar + avatar = new UpdateableAvatar { Size = new Vector2(height), CornerRadius = 3, Masking = true, - User = info.Author, EdgeEffect = new EdgeEffectParameters { Colour = Color4.Black.Opacity(0.25f), @@ -43,25 +76,8 @@ namespace osu.Game.Overlays.OnlineBeatmapSet RelativeSizeAxes = Axes.Both, Direction = FillDirection.Vertical, Padding = new MarginPadding { Left = height + 5 }, - Children = new Drawable[] - { - new Field("made by", info.Author.Username, @"Exo2.0-RegularItalic"), - new Field("submitted on", info.Submitted.ToString(@"MMM d, yyyy"), @"Exo2.0-Bold") - { - Margin = new MarginPadding { Top = 5 }, - }, - }, }, }; - - if (info.Ranked.HasValue) - { - fields.Add(new Field("ranked on ", info.Ranked.Value.ToString(@"MMM d, yyyy"), @"Exo2.0-Bold")); - } - else if (info.LastUpdated.HasValue) - { - fields.Add(new Field("last updated on ", info.LastUpdated.Value.ToString(@"MMM d, yyyy"), @"Exo2.0-Bold")); - } } private class Field : FillFlowContainer diff --git a/osu.Game/Overlays/OnlineBeatmapSet/BasicStats.cs b/osu.Game/Overlays/OnlineBeatmapSet/BasicStats.cs index 7772f34466..947bc111e0 100644 --- a/osu.Game/Overlays/OnlineBeatmapSet/BasicStats.cs +++ b/osu.Game/Overlays/OnlineBeatmapSet/BasicStats.cs @@ -15,7 +15,20 @@ namespace osu.Game.Overlays.OnlineBeatmapSet { public class BasicStats : Container { - private readonly Statistic length, circleCount, sliderCount; + private readonly Statistic length, bpm, circleCount, sliderCount; + + private BeatmapSetInfo beatmapSet; + public BeatmapSetInfo BeatmapSet + { + get { return beatmapSet; } + set + { + if (value == beatmapSet) return; + beatmapSet = value; + + bpm.Value = BeatmapSet.OnlineInfo.BPM.ToString(@"0.##"); + } + } private BeatmapInfo beatmap; public BeatmapInfo Beatmap @@ -32,7 +45,7 @@ namespace osu.Game.Overlays.OnlineBeatmapSet } } - public BasicStats(BeatmapSetInfo set) + public BasicStats() { Child = new FillFlowContainer { @@ -42,11 +55,7 @@ namespace osu.Game.Overlays.OnlineBeatmapSet Children = new[] { length = new Statistic(FontAwesome.fa_clock_o, "Length") { Width = 0.25f }, - new Statistic(FontAwesome.fa_circle, "BPM") - { - Width = 0.25f, - Value = set.OnlineInfo.BPM.ToString(@"0.##"), - }, + bpm = new Statistic(FontAwesome.fa_circle, "BPM") { Width = 0.25f }, circleCount = new Statistic(FontAwesome.fa_circle_o, "Circle Count") { Width = 0.25f }, sliderCount = new Statistic(FontAwesome.fa_circle, "Slider Count") { Width = 0.25f }, }, diff --git a/osu.Game/Overlays/OnlineBeatmapSet/BeatmapPicker.cs b/osu.Game/Overlays/OnlineBeatmapSet/BeatmapPicker.cs index bea6f98382..d7b9fa49bd 100644 --- a/osu.Game/Overlays/OnlineBeatmapSet/BeatmapPicker.cs +++ b/osu.Game/Overlays/OnlineBeatmapSet/BeatmapPicker.cs @@ -28,10 +28,42 @@ namespace osu.Game.Overlays.OnlineBeatmapSet private readonly DifficultiesContainer difficulties; private readonly OsuSpriteText version, starRating; + private readonly Statistic plays, favourites; public readonly Bindable Beatmap = new Bindable(); - public BeatmapPicker(BeatmapSetInfo set) + private BeatmapSetInfo beatmapSet; + public BeatmapSetInfo BeatmapSet + { + get { return beatmapSet; } + set + { + if (value == beatmapSet) return; + beatmapSet = value; + + Beatmap.Value = BeatmapSet.Beatmaps.First(); + plays.Value = BeatmapSet.OnlineInfo.PlayCount; + favourites.Value = BeatmapSet.OnlineInfo.FavouriteCount; + difficulties.ChildrenEnumerable = BeatmapSet.Beatmaps.Select(b => new DifficultySelectorButton(b) + { + State = DifficultySelectorState.NotSelected, + OnHovered = beatmap => + { + showBeatmap(beatmap); + starRating.Text = beatmap.StarDifficulty.ToString("Star Difficulty 0.##"); + starRating.FadeIn(100); + }, + OnClicked = beatmap => + { + Beatmap.Value = beatmap; + }, + }); + + updateDifficultyButtons(); + } + } + + public BeatmapPicker() { RelativeSizeAxes = Axes.X; AutoSizeAxes = Axes.Y; @@ -89,36 +121,19 @@ namespace osu.Game.Overlays.OnlineBeatmapSet Margin = new MarginPadding { Top = 5 }, Children = new[] { - new Statistic(FontAwesome.fa_play_circle, set.OnlineInfo.PlayCount), - new Statistic(FontAwesome.fa_heart, set.OnlineInfo.FavouriteCount), + plays = new Statistic(FontAwesome.fa_play_circle), + favourites = new Statistic(FontAwesome.fa_heart), }, }, }, }, }; - Beatmap.Value = set.Beatmaps.First(); - Beatmap.ValueChanged += b => { showBeatmap(b); updateDifficultyButtons(); }; - - difficulties.ChildrenEnumerable = set.Beatmaps.Select(b => new DifficultySelectorButton(b) - { - State = DifficultySelectorState.NotSelected, - OnHovered = beatmap => - { - showBeatmap(beatmap); - starRating.Text = beatmap.StarDifficulty.ToString("Star Difficulty 0.##"); - starRating.FadeIn(100); - }, - OnClicked = beatmap => - { - Beatmap.Value = beatmap; - }, - }); } [BackgroundDependencyLoader] @@ -261,7 +276,7 @@ namespace osu.Game.Overlays.OnlineBeatmapSet } } - public Statistic(FontAwesome icon, int value = 0) + public Statistic(FontAwesome icon) { AutoSizeAxes = Axes.Both; Direction = FillDirection.Horizontal; @@ -285,8 +300,6 @@ namespace osu.Game.Overlays.OnlineBeatmapSet TextSize = 14, }, }; - - Value = value; } } diff --git a/osu.Game/Overlays/OnlineBeatmapSet/Details.cs b/osu.Game/Overlays/OnlineBeatmapSet/Details.cs index 05ae8f64a8..e507ba8e5c 100644 --- a/osu.Game/Overlays/OnlineBeatmapSet/Details.cs +++ b/osu.Game/Overlays/OnlineBeatmapSet/Details.cs @@ -14,10 +14,24 @@ namespace osu.Game.Overlays.OnlineBeatmapSet { public class Details : FillFlowContainer { + private readonly PreviewButton preview; private readonly BasicStats basic; private readonly AdvancedStats advanced; private readonly UserRatings ratings; + private BeatmapSetInfo beatmapSet; + public BeatmapSetInfo BeatmapSet + { + get { return beatmapSet; } + set + { + if (value == beatmapSet) return; + beatmapSet = value; + + basic.BeatmapSet = preview.BeatmapSet = BeatmapSet; + } + } + private BeatmapInfo beatmap; public BeatmapInfo Beatmap { @@ -32,7 +46,7 @@ namespace osu.Game.Overlays.OnlineBeatmapSet } } - public Details(BeatmapSetInfo set) + public Details() { Width = OnlineBeatmapSetOverlay.RIGHT_WIDTH; AutoSizeAxes = Axes.Y; @@ -40,17 +54,13 @@ namespace osu.Game.Overlays.OnlineBeatmapSet Children = new Drawable[] { - new AsyncLoadWrapper(new PreviewButton(set) + preview = new PreviewButton { RelativeSizeAxes = Axes.X, - }) - { - RelativeSizeAxes = Axes.X, - AutoSizeAxes = Axes.Y, }, new DetailBox { - Child = basic = new BasicStats(set) + Child = basic = new BasicStats() { RelativeSizeAxes = Axes.X, AutoSizeAxes = Axes.Y, diff --git a/osu.Game/Overlays/OnlineBeatmapSet/Header.cs b/osu.Game/Overlays/OnlineBeatmapSet/Header.cs index 0525b32b36..0561bac702 100644 --- a/osu.Game/Overlays/OnlineBeatmapSet/Header.cs +++ b/osu.Game/Overlays/OnlineBeatmapSet/Header.cs @@ -24,10 +24,50 @@ namespace osu.Game.Overlays.OnlineBeatmapSet private const float buttons_spacing = 5; private readonly Box tabsBg; + private readonly Container coverContainer; + private readonly OsuSpriteText title, artist; + private readonly AuthorInfo author; + private readonly Details details; + + private DelayedLoadWrapper cover; public readonly BeatmapPicker Picker; - public Header(BeatmapSetInfo set) + private BeatmapSetInfo beatmapSet; + public BeatmapSetInfo BeatmapSet + { + get { return beatmapSet; } + set + { + if (value == beatmapSet) return; + beatmapSet = value; + + Picker.BeatmapSet = author.BeatmapSet = details.BeatmapSet = BeatmapSet; + title.Text = BeatmapSet.Metadata.Title; + artist.Text = BeatmapSet.Metadata.Artist; + + if (cover != null) + cover.FadeOut(400, Easing.Out); + + coverContainer.Add(cover = new DelayedLoadWrapper(new BeatmapSetCover(BeatmapSet) + { + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + RelativeSizeAxes = Axes.Both, + FillMode = FillMode.Fill, + OnLoadComplete = d => + { + d.FadeInFromZero(400, Easing.Out); + }, + }) + { + RelativeSizeAxes = Axes.Both, + TimeBeforeLoad = 300 + }); + } + } + + public Header() { RelativeSizeAxes = Axes.X; Height = 400; @@ -42,7 +82,6 @@ namespace osu.Game.Overlays.OnlineBeatmapSet Container noVideoButtons; FillFlowContainer videoButtons; - Details details; Children = new Drawable[] { new Container @@ -73,20 +112,9 @@ namespace osu.Game.Overlays.OnlineBeatmapSet RelativeSizeAxes = Axes.Both, Colour = Color4.Black, }, - new DelayedLoadWrapper(new BeatmapSetCover(set) - { - Anchor = Anchor.Centre, - Origin = Anchor.Centre, - RelativeSizeAxes = Axes.Both, - FillMode = FillMode.Fill, - OnLoadComplete = d => - { - d.FadeInFromZero(400, Easing.Out); - }, - }) + coverContainer = new Container { RelativeSizeAxes = Axes.Both, - TimeBeforeLoad = 300 }, new Box { @@ -109,17 +137,15 @@ namespace osu.Game.Overlays.OnlineBeatmapSet { RelativeSizeAxes = Axes.X, Height = 113, - Child = Picker = new BeatmapPicker(set), + Child = Picker = new BeatmapPicker(), }, - new OsuSpriteText + title = new OsuSpriteText { - Text = set.Metadata.Title, Font = @"Exo2.0-BoldItalic", TextSize = 37, }, - new OsuSpriteText + artist = new OsuSpriteText { - Text = set.Metadata.Artist, Font = @"Exo2.0-SemiBoldItalic", TextSize = 25, }, @@ -128,7 +154,7 @@ namespace osu.Game.Overlays.OnlineBeatmapSet RelativeSizeAxes = Axes.X, AutoSizeAxes = Axes.Y, Margin = new MarginPadding { Top = 20 }, - Child = new AuthorInfo(set.OnlineInfo), + Child = author = new AuthorInfo(), }, new Container { @@ -168,7 +194,7 @@ namespace osu.Game.Overlays.OnlineBeatmapSet }, }, }, - details = new Details(set) + details = new Details { Anchor = Anchor.BottomRight, Origin = Anchor.BottomRight, diff --git a/osu.Game/Overlays/OnlineBeatmapSet/PreviewButton.cs b/osu.Game/Overlays/OnlineBeatmapSet/PreviewButton.cs index 6fd131c720..e3fa7ccb17 100644 --- a/osu.Game/Overlays/OnlineBeatmapSet/PreviewButton.cs +++ b/osu.Game/Overlays/OnlineBeatmapSet/PreviewButton.cs @@ -19,13 +19,27 @@ namespace osu.Game.Overlays.OnlineBeatmapSet { public class PreviewButton : OsuClickableContainer { - private readonly BeatmapSetInfo set; private readonly Box bg, progress; private readonly SpriteIcon icon; private AudioManager audio; private Track preview; + private BeatmapSetInfo beatmapSet; + public BeatmapSetInfo BeatmapSet + { + get { return beatmapSet; } + set + { + if (value == beatmapSet) return; + beatmapSet = value; + + Playing = false; + preview = null; + loadPreview(); + } + } + private bool playing; public bool Playing { @@ -35,6 +49,8 @@ namespace osu.Game.Overlays.OnlineBeatmapSet if (value == playing) return; playing = value; + if (progress == null) return; + if (Playing) { icon.Icon = FontAwesome.fa_stop; @@ -52,9 +68,8 @@ namespace osu.Game.Overlays.OnlineBeatmapSet } } - public PreviewButton(BeatmapSetInfo set) + public PreviewButton() { - this.set = set; Height = 42; Children = new Drawable[] @@ -95,8 +110,6 @@ namespace osu.Game.Overlays.OnlineBeatmapSet { this.audio = audio; progress.Colour = colours.Yellow; - - loadPreview(); } protected override void Update() @@ -130,9 +143,9 @@ namespace osu.Game.Overlays.OnlineBeatmapSet private void loadPreview() { - if (preview?.HasCompleted ?? true) + if (preview == null || (preview?.HasCompleted ?? true) && BeatmapSet != null) { - preview = audio.Track.Get(set.OnlineInfo.Preview); + preview = audio.Track.Get(BeatmapSet.OnlineInfo.Preview); preview.Volume.Value = 0.5; } else diff --git a/osu.Game/Overlays/OnlineBeatmapSetOverlay.cs b/osu.Game/Overlays/OnlineBeatmapSetOverlay.cs index 9dea34e06b..8db211e352 100644 --- a/osu.Game/Overlays/OnlineBeatmapSetOverlay.cs +++ b/osu.Game/Overlays/OnlineBeatmapSetOverlay.cs @@ -1,7 +1,6 @@ // Copyright (c) 2007-2017 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE -using System.Linq; using OpenTK; using OpenTK.Graphics; using osu.Framework.Extensions.Color4Extensions; @@ -62,14 +61,14 @@ namespace osu.Game.Overlays Direction = FillDirection.Vertical, Children = new Drawable[] { - // header = new Header(), + header = new Header(), info = new Info(), }, }, }, }; - // header.Picker.Beatmap.ValueChanged += b => info.Beatmap = b; + header.Picker.Beatmap.ValueChanged += b => info.Beatmap = b; } protected override void PopIn() @@ -86,8 +85,7 @@ namespace osu.Game.Overlays public void ShowBeatmapSet(BeatmapSetInfo set) { - /*header.BeatmapSet = */info.BeatmapSet = set; - info.Beatmap = set.Beatmaps.Last(); + header.BeatmapSet = info.BeatmapSet = set; Show(); } From 022e39b8431de8643d073719cccf5b94d6050c83 Mon Sep 17 00:00:00 2001 From: DrabWeb Date: Wed, 13 Sep 2017 18:31:53 -0300 Subject: [PATCH 20/30] CI fixes. --- osu.Game/Overlays/OnlineBeatmapSet/Details.cs | 2 +- osu.Game/Overlays/OnlineBeatmapSet/Header.cs | 4 +--- osu.Game/Overlays/OnlineBeatmapSet/PreviewButton.cs | 2 +- 3 files changed, 3 insertions(+), 5 deletions(-) diff --git a/osu.Game/Overlays/OnlineBeatmapSet/Details.cs b/osu.Game/Overlays/OnlineBeatmapSet/Details.cs index e507ba8e5c..958cc2cd18 100644 --- a/osu.Game/Overlays/OnlineBeatmapSet/Details.cs +++ b/osu.Game/Overlays/OnlineBeatmapSet/Details.cs @@ -60,7 +60,7 @@ namespace osu.Game.Overlays.OnlineBeatmapSet }, new DetailBox { - Child = basic = new BasicStats() + Child = basic = new BasicStats { RelativeSizeAxes = Axes.X, AutoSizeAxes = Axes.Y, diff --git a/osu.Game/Overlays/OnlineBeatmapSet/Header.cs b/osu.Game/Overlays/OnlineBeatmapSet/Header.cs index 0561bac702..2cd07b2212 100644 --- a/osu.Game/Overlays/OnlineBeatmapSet/Header.cs +++ b/osu.Game/Overlays/OnlineBeatmapSet/Header.cs @@ -46,9 +46,7 @@ namespace osu.Game.Overlays.OnlineBeatmapSet title.Text = BeatmapSet.Metadata.Title; artist.Text = BeatmapSet.Metadata.Artist; - if (cover != null) - cover.FadeOut(400, Easing.Out); - + cover?.FadeOut(400, Easing.Out); coverContainer.Add(cover = new DelayedLoadWrapper(new BeatmapSetCover(BeatmapSet) { Anchor = Anchor.Centre, diff --git a/osu.Game/Overlays/OnlineBeatmapSet/PreviewButton.cs b/osu.Game/Overlays/OnlineBeatmapSet/PreviewButton.cs index e3fa7ccb17..1dddf4a4a3 100644 --- a/osu.Game/Overlays/OnlineBeatmapSet/PreviewButton.cs +++ b/osu.Game/Overlays/OnlineBeatmapSet/PreviewButton.cs @@ -143,7 +143,7 @@ namespace osu.Game.Overlays.OnlineBeatmapSet private void loadPreview() { - if (preview == null || (preview?.HasCompleted ?? true) && BeatmapSet != null) + if (preview == null || preview.HasCompleted && BeatmapSet != null) { preview = audio.Track.Get(BeatmapSet.OnlineInfo.Preview); preview.Volume.Value = 0.5; From 1bac1e2c0e48d5678a92ce6c2152924a01b5b4ce Mon Sep 17 00:00:00 2001 From: DrabWeb Date: Fri, 15 Sep 2017 13:47:03 -0300 Subject: [PATCH 21/30] Make PreviewButton async. --- .../OnlineBeatmapSet/PreviewButton.cs | 112 ++++++++++++++---- 1 file changed, 88 insertions(+), 24 deletions(-) diff --git a/osu.Game/Overlays/OnlineBeatmapSet/PreviewButton.cs b/osu.Game/Overlays/OnlineBeatmapSet/PreviewButton.cs index 1dddf4a4a3..b12ec9c7ae 100644 --- a/osu.Game/Overlays/OnlineBeatmapSet/PreviewButton.cs +++ b/osu.Game/Overlays/OnlineBeatmapSet/PreviewButton.cs @@ -14,17 +14,38 @@ using osu.Framework.Input; using osu.Game.Beatmaps; using osu.Game.Graphics; using osu.Game.Graphics.Containers; +using osu.Game.Graphics.UserInterface; namespace osu.Game.Overlays.OnlineBeatmapSet { public class PreviewButton : OsuClickableContainer { + private const float transition_duration = 500; + + private readonly Container audioWrapper; private readonly Box bg, progress; private readonly SpriteIcon icon; + private readonly LoadingAnimation loadingAnimation; - private AudioManager audio; private Track preview; + private bool loading + { + set + { + if (value) + { + loadingAnimation.Show(); + icon.FadeOut(transition_duration * 5, Easing.OutQuint); + } + else + { + loadingAnimation.Hide(); + icon.FadeIn(transition_duration, Easing.OutQuint); + } + } + } + private BeatmapSetInfo beatmapSet; public BeatmapSetInfo BeatmapSet { @@ -36,7 +57,6 @@ namespace osu.Game.Overlays.OnlineBeatmapSet Playing = false; preview = null; - loadPreview(); } } @@ -49,22 +69,28 @@ namespace osu.Game.Overlays.OnlineBeatmapSet if (value == playing) return; playing = value; - if (progress == null) return; - - if (Playing) + if (preview == null) { - icon.Icon = FontAwesome.fa_stop; - progress.FadeIn(100); + loading = true; + audioWrapper.Child = new AsyncLoadWrapper(new AudioLoadWrapper(BeatmapSet) + { + OnLoadComplete = d => + { + loading = false; - loadPreview(); - preview.Start(); - } - else - { - icon.Icon = FontAwesome.fa_play; - progress.FadeOut(100); - preview.Stop(); + if (d is AudioLoadWrapper) + { + preview = (d as AudioLoadWrapper).Preview; + Playing = Playing; + updatePlayingState(); + } + }, + }); + + return; } + + updatePlayingState(); } } @@ -74,6 +100,7 @@ namespace osu.Game.Overlays.OnlineBeatmapSet Children = new Drawable[] { + audioWrapper = new Container(), bg = new Box { RelativeSizeAxes = Axes.Both, @@ -100,15 +127,19 @@ namespace osu.Game.Overlays.OnlineBeatmapSet Size = new Vector2(18), Shadow = false, }, + loadingAnimation = new LoadingAnimation + { + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + }, }; Action = () => Playing = !Playing; } [BackgroundDependencyLoader] - private void load(OsuColour colours, AudioManager audio) + private void load(OsuColour colours) { - this.audio = audio; progress.Colour = colours.Yellow; } @@ -116,10 +147,14 @@ namespace osu.Game.Overlays.OnlineBeatmapSet { base.Update(); - if (Playing) + if (Playing && preview != null) { progress.Width = (float)(preview.CurrentTime / preview.Length); - if (preview.HasCompleted) Playing = false; + if (preview.HasCompleted) + { + Playing = false; + preview = null; + } } } @@ -141,16 +176,45 @@ namespace osu.Game.Overlays.OnlineBeatmapSet base.OnHoverLost(state); } - private void loadPreview() + private void updatePlayingState() { - if (preview == null || preview.HasCompleted && BeatmapSet != null) + if (preview == null) return; + + if (Playing) { - preview = audio.Track.Get(BeatmapSet.OnlineInfo.Preview); - preview.Volume.Value = 0.5; + icon.Icon = FontAwesome.fa_stop; + progress.FadeIn(100); + + preview.Seek(0); + preview.Start(); } else { - preview.Seek(0); + icon.Icon = FontAwesome.fa_play; + progress.FadeOut(100); + preview.Stop(); + } + } + + private class AudioLoadWrapper : Drawable + { + private readonly string preview; + + public Track Preview; + + public AudioLoadWrapper(BeatmapSetInfo set) + { + preview = set.OnlineInfo.Preview; + } + + [BackgroundDependencyLoader] + private void load(AudioManager audio) + { + if (!string.IsNullOrEmpty(preview)) + { + Preview = audio.Track.Get(preview); + Preview.Volume.Value = 0.5; + } } } } From 7e30c55bf40865f75d7468c03e3e963f51862fd2 Mon Sep 17 00:00:00 2001 From: DrabWeb Date: Fri, 15 Sep 2017 13:54:16 -0300 Subject: [PATCH 22/30] CI fix. --- osu.Game/Overlays/OnlineBeatmapSet/PreviewButton.cs | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/osu.Game/Overlays/OnlineBeatmapSet/PreviewButton.cs b/osu.Game/Overlays/OnlineBeatmapSet/PreviewButton.cs index b12ec9c7ae..8e93db8d19 100644 --- a/osu.Game/Overlays/OnlineBeatmapSet/PreviewButton.cs +++ b/osu.Game/Overlays/OnlineBeatmapSet/PreviewButton.cs @@ -78,12 +78,9 @@ namespace osu.Game.Overlays.OnlineBeatmapSet { loading = false; - if (d is AudioLoadWrapper) - { - preview = (d as AudioLoadWrapper).Preview; - Playing = Playing; - updatePlayingState(); - } + preview = (d as AudioLoadWrapper).Preview; + Playing = Playing; + updatePlayingState(); }, }); From 46af17f00c4b98b66ba0efaa647085c132abf9a4 Mon Sep 17 00:00:00 2001 From: DrabWeb Date: Thu, 21 Sep 2017 14:46:51 -0300 Subject: [PATCH 23/30] Fix preview button potential null ref. --- osu.Game/Overlays/OnlineBeatmapSet/PreviewButton.cs | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/osu.Game/Overlays/OnlineBeatmapSet/PreviewButton.cs b/osu.Game/Overlays/OnlineBeatmapSet/PreviewButton.cs index 8e93db8d19..dacb1c3743 100644 --- a/osu.Game/Overlays/OnlineBeatmapSet/PreviewButton.cs +++ b/osu.Game/Overlays/OnlineBeatmapSet/PreviewButton.cs @@ -76,11 +76,14 @@ namespace osu.Game.Overlays.OnlineBeatmapSet { OnLoadComplete = d => { - loading = false; + if (d is AudioLoadWrapper) + { + loading = false; - preview = (d as AudioLoadWrapper).Preview; - Playing = Playing; - updatePlayingState(); + preview = ((AudioLoadWrapper)d).Preview; + Playing = Playing; + updatePlayingState(); + } }, }); From 01e70f9bef9efc6d5d49ba68429f0ce3ac212a12 Mon Sep 17 00:00:00 2001 From: DrabWeb Date: Thu, 21 Sep 2017 14:53:42 -0300 Subject: [PATCH 24/30] Change type check to safe cast. --- osu.Game/Overlays/OnlineBeatmapSet/PreviewButton.cs | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/osu.Game/Overlays/OnlineBeatmapSet/PreviewButton.cs b/osu.Game/Overlays/OnlineBeatmapSet/PreviewButton.cs index dacb1c3743..b8673e2a77 100644 --- a/osu.Game/Overlays/OnlineBeatmapSet/PreviewButton.cs +++ b/osu.Game/Overlays/OnlineBeatmapSet/PreviewButton.cs @@ -76,14 +76,11 @@ namespace osu.Game.Overlays.OnlineBeatmapSet { OnLoadComplete = d => { - if (d is AudioLoadWrapper) - { - loading = false; + loading = false; - preview = ((AudioLoadWrapper)d).Preview; - Playing = Playing; - updatePlayingState(); - } + preview = (d as AudioLoadWrapper)?.Preview; + Playing = Playing; + updatePlayingState(); }, }); From 5be11f539bbe56c53a6b451ffbb0f32931b35383 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Mon, 25 Sep 2017 17:26:27 +0800 Subject: [PATCH 25/30] Rename to BeatmapSetOverlay --- .../AuthorInfo.cs | 6 ++--- .../BasicStats.cs | 4 +-- .../BeatmapPicker.cs | 6 ++--- .../Details.cs | 8 +++--- .../DownloadButton.cs | 4 +-- .../FavouriteButton.cs | 4 +-- .../Header.cs | 10 +++---- .../HeaderButton.cs | 2 +- .../{OnlineBeatmapSet => BeatmapSet}/Info.cs | 14 +++++----- .../PreviewButton.cs | 6 ++--- .../SuccessRate.cs | 6 ++--- ...tmapSetOverlay.cs => BeatmapSetOverlay.cs} | 6 ++--- ...verlay.cs => TestCaseBeatmapSetOverlay.cs} | 8 +++--- osu.Game/osu.Game.csproj | 26 +++++++++---------- 14 files changed, 55 insertions(+), 55 deletions(-) rename osu.Game/Overlays/{OnlineBeatmapSet => BeatmapSet}/AuthorInfo.cs (95%) rename osu.Game/Overlays/{OnlineBeatmapSet => BeatmapSet}/BasicStats.cs (96%) rename osu.Game/Overlays/{OnlineBeatmapSet => BeatmapSet}/BeatmapPicker.cs (96%) rename osu.Game/Overlays/{OnlineBeatmapSet => BeatmapSet}/Details.cs (94%) rename osu.Game/Overlays/{OnlineBeatmapSet => BeatmapSet}/DownloadButton.cs (95%) rename osu.Game/Overlays/{OnlineBeatmapSet => BeatmapSet}/FavouriteButton.cs (95%) rename osu.Game/Overlays/{OnlineBeatmapSet => BeatmapSet}/Header.cs (96%) rename osu.Game/Overlays/{OnlineBeatmapSet => BeatmapSet}/HeaderButton.cs (93%) rename osu.Game/Overlays/{OnlineBeatmapSet => BeatmapSet}/Info.cs (93%) rename osu.Game/Overlays/{OnlineBeatmapSet => BeatmapSet}/PreviewButton.cs (95%) rename osu.Game/Overlays/{OnlineBeatmapSet => BeatmapSet}/SuccessRate.cs (96%) rename osu.Game/Overlays/{OnlineBeatmapSetOverlay.cs => BeatmapSetOverlay.cs} (91%) rename osu.Game/Tests/Visual/{TestCaseOnlineBeatmapSetOverlay.cs => TestCaseBeatmapSetOverlay.cs} (96%) diff --git a/osu.Game/Overlays/OnlineBeatmapSet/AuthorInfo.cs b/osu.Game/Overlays/BeatmapSet/AuthorInfo.cs similarity index 95% rename from osu.Game/Overlays/OnlineBeatmapSet/AuthorInfo.cs rename to osu.Game/Overlays/BeatmapSet/AuthorInfo.cs index ce46e96380..b0e4e49e31 100644 --- a/osu.Game/Overlays/OnlineBeatmapSet/AuthorInfo.cs +++ b/osu.Game/Overlays/BeatmapSet/AuthorInfo.cs @@ -1,16 +1,16 @@ // Copyright (c) 2007-2017 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE -using OpenTK; -using OpenTK.Graphics; using osu.Framework.Extensions.Color4Extensions; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Game.Beatmaps; using osu.Game.Graphics.Sprites; using osu.Game.Users; +using OpenTK; +using OpenTK.Graphics; -namespace osu.Game.Overlays.OnlineBeatmapSet +namespace osu.Game.Overlays.BeatmapSet { public class AuthorInfo : Container { diff --git a/osu.Game/Overlays/OnlineBeatmapSet/BasicStats.cs b/osu.Game/Overlays/BeatmapSet/BasicStats.cs similarity index 96% rename from osu.Game/Overlays/OnlineBeatmapSet/BasicStats.cs rename to osu.Game/Overlays/BeatmapSet/BasicStats.cs index 947bc111e0..885f9cc219 100644 --- a/osu.Game/Overlays/OnlineBeatmapSet/BasicStats.cs +++ b/osu.Game/Overlays/BeatmapSet/BasicStats.cs @@ -2,7 +2,6 @@ // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE using System; -using OpenTK; using osu.Framework.Allocation; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; @@ -10,8 +9,9 @@ using osu.Framework.Graphics.Cursor; using osu.Game.Beatmaps; using osu.Game.Graphics; using osu.Game.Graphics.Sprites; +using OpenTK; -namespace osu.Game.Overlays.OnlineBeatmapSet +namespace osu.Game.Overlays.BeatmapSet { public class BasicStats : Container { diff --git a/osu.Game/Overlays/OnlineBeatmapSet/BeatmapPicker.cs b/osu.Game/Overlays/BeatmapSet/BeatmapPicker.cs similarity index 96% rename from osu.Game/Overlays/OnlineBeatmapSet/BeatmapPicker.cs rename to osu.Game/Overlays/BeatmapSet/BeatmapPicker.cs index d7b9fa49bd..2317e8562a 100644 --- a/osu.Game/Overlays/OnlineBeatmapSet/BeatmapPicker.cs +++ b/osu.Game/Overlays/BeatmapSet/BeatmapPicker.cs @@ -3,8 +3,6 @@ using System; using System.Linq; -using OpenTK; -using OpenTK.Graphics; using osu.Framework; using osu.Framework.Allocation; using osu.Framework.Configuration; @@ -18,8 +16,10 @@ 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.OnlineBeatmapSet +namespace osu.Game.Overlays.BeatmapSet { public class BeatmapPicker : Container { diff --git a/osu.Game/Overlays/OnlineBeatmapSet/Details.cs b/osu.Game/Overlays/BeatmapSet/Details.cs similarity index 94% rename from osu.Game/Overlays/OnlineBeatmapSet/Details.cs rename to osu.Game/Overlays/BeatmapSet/Details.cs index 958cc2cd18..2fd0a55d9e 100644 --- a/osu.Game/Overlays/OnlineBeatmapSet/Details.cs +++ b/osu.Game/Overlays/BeatmapSet/Details.cs @@ -1,16 +1,16 @@ // Copyright (c) 2007-2017 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE -using OpenTK; -using OpenTK.Graphics; using osu.Framework.Extensions.Color4Extensions; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Shapes; using osu.Game.Beatmaps; using osu.Game.Screens.Select.Details; +using OpenTK; +using OpenTK.Graphics; -namespace osu.Game.Overlays.OnlineBeatmapSet +namespace osu.Game.Overlays.BeatmapSet { public class Details : FillFlowContainer { @@ -48,7 +48,7 @@ namespace osu.Game.Overlays.OnlineBeatmapSet public Details() { - Width = OnlineBeatmapSetOverlay.RIGHT_WIDTH; + Width = BeatmapSetOverlay.RIGHT_WIDTH; AutoSizeAxes = Axes.Y; Spacing = new Vector2(1f); diff --git a/osu.Game/Overlays/OnlineBeatmapSet/DownloadButton.cs b/osu.Game/Overlays/BeatmapSet/DownloadButton.cs similarity index 95% rename from osu.Game/Overlays/OnlineBeatmapSet/DownloadButton.cs rename to osu.Game/Overlays/BeatmapSet/DownloadButton.cs index 855aa3de93..18a0cfd968 100644 --- a/osu.Game/Overlays/OnlineBeatmapSet/DownloadButton.cs +++ b/osu.Game/Overlays/BeatmapSet/DownloadButton.cs @@ -1,13 +1,13 @@ // Copyright (c) 2007-2017 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE -using OpenTK; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Game.Graphics; using osu.Game.Graphics.Sprites; +using OpenTK; -namespace osu.Game.Overlays.OnlineBeatmapSet +namespace osu.Game.Overlays.BeatmapSet { public class DownloadButton : HeaderButton { diff --git a/osu.Game/Overlays/OnlineBeatmapSet/FavouriteButton.cs b/osu.Game/Overlays/BeatmapSet/FavouriteButton.cs similarity index 95% rename from osu.Game/Overlays/OnlineBeatmapSet/FavouriteButton.cs rename to osu.Game/Overlays/BeatmapSet/FavouriteButton.cs index 4998ea1c19..9fd4ac177c 100644 --- a/osu.Game/Overlays/OnlineBeatmapSet/FavouriteButton.cs +++ b/osu.Game/Overlays/BeatmapSet/FavouriteButton.cs @@ -1,15 +1,15 @@ // Copyright (c) 2007-2017 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE -using OpenTK; using osu.Framework.Configuration; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Shapes; using osu.Game.Graphics; using osu.Game.Graphics.Backgrounds; +using OpenTK; -namespace osu.Game.Overlays.OnlineBeatmapSet +namespace osu.Game.Overlays.BeatmapSet { public class FavouriteButton : HeaderButton { diff --git a/osu.Game/Overlays/OnlineBeatmapSet/Header.cs b/osu.Game/Overlays/BeatmapSet/Header.cs similarity index 96% rename from osu.Game/Overlays/OnlineBeatmapSet/Header.cs rename to osu.Game/Overlays/BeatmapSet/Header.cs index 2cd07b2212..a93ccbf704 100644 --- a/osu.Game/Overlays/OnlineBeatmapSet/Header.cs +++ b/osu.Game/Overlays/BeatmapSet/Header.cs @@ -1,8 +1,6 @@ // Copyright (c) 2007-2017 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE -using OpenTK; -using OpenTK.Graphics; using osu.Framework.Allocation; using osu.Framework.Extensions.Color4Extensions; using osu.Framework.Graphics; @@ -13,8 +11,10 @@ using osu.Game.Beatmaps; using osu.Game.Beatmaps.Drawables; using osu.Game.Graphics; using osu.Game.Graphics.Sprites; +using OpenTK; +using OpenTK.Graphics; -namespace osu.Game.Overlays.OnlineBeatmapSet +namespace osu.Game.Overlays.BeatmapSet { public class Header : Container { @@ -124,7 +124,7 @@ namespace osu.Game.Overlays.OnlineBeatmapSet new Container { RelativeSizeAxes = Axes.Both, - Padding = new MarginPadding { Top = 20, Bottom = 30, Horizontal = OnlineBeatmapSetOverlay.X_PADDING }, + Padding = new MarginPadding { Top = 20, Bottom = 30, Horizontal = BeatmapSetOverlay.X_PADDING }, Child = new FillFlowContainer { RelativeSizeAxes = Axes.Both, @@ -196,7 +196,7 @@ namespace osu.Game.Overlays.OnlineBeatmapSet { Anchor = Anchor.BottomRight, Origin = Anchor.BottomRight, - Margin = new MarginPadding { Right = OnlineBeatmapSetOverlay.X_PADDING }, + Margin = new MarginPadding { Right = BeatmapSetOverlay.X_PADDING }, }, }, }, diff --git a/osu.Game/Overlays/OnlineBeatmapSet/HeaderButton.cs b/osu.Game/Overlays/BeatmapSet/HeaderButton.cs similarity index 93% rename from osu.Game/Overlays/OnlineBeatmapSet/HeaderButton.cs rename to osu.Game/Overlays/BeatmapSet/HeaderButton.cs index fe852ec83a..3075020fe6 100644 --- a/osu.Game/Overlays/OnlineBeatmapSet/HeaderButton.cs +++ b/osu.Game/Overlays/BeatmapSet/HeaderButton.cs @@ -8,7 +8,7 @@ using osu.Game.Graphics; using osu.Game.Graphics.Backgrounds; using osu.Game.Graphics.Containers; -namespace osu.Game.Overlays.OnlineBeatmapSet +namespace osu.Game.Overlays.BeatmapSet { public class HeaderButton : OsuClickableContainer { diff --git a/osu.Game/Overlays/OnlineBeatmapSet/Info.cs b/osu.Game/Overlays/BeatmapSet/Info.cs similarity index 93% rename from osu.Game/Overlays/OnlineBeatmapSet/Info.cs rename to osu.Game/Overlays/BeatmapSet/Info.cs index 7782e8b7ab..4a59591a72 100644 --- a/osu.Game/Overlays/OnlineBeatmapSet/Info.cs +++ b/osu.Game/Overlays/BeatmapSet/Info.cs @@ -1,8 +1,6 @@ // Copyright (c) 2007-2017 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE -using OpenTK; -using OpenTK.Graphics; using osu.Framework.Allocation; using osu.Framework.Extensions.Color4Extensions; using osu.Framework.Graphics; @@ -11,8 +9,10 @@ using osu.Framework.Graphics.Shapes; using osu.Game.Beatmaps; using osu.Game.Graphics; using osu.Game.Graphics.Sprites; +using OpenTK; +using OpenTK.Graphics; -namespace osu.Game.Overlays.OnlineBeatmapSet +namespace osu.Game.Overlays.BeatmapSet { public class Info : Container { @@ -67,13 +67,13 @@ namespace osu.Game.Overlays.OnlineBeatmapSet new Container { RelativeSizeAxes = Axes.Both, - Padding = new MarginPadding { Top = 15, Horizontal = OnlineBeatmapSetOverlay.X_PADDING }, + Padding = new MarginPadding { Top = 15, Horizontal = BeatmapSetOverlay.X_PADDING }, Children = new Drawable[] { new Container { RelativeSizeAxes = Axes.Both, - Padding = new MarginPadding { Right = metadata_width + OnlineBeatmapSetOverlay.RIGHT_WIDTH + spacing * 2 }, + Padding = new MarginPadding { Right = metadata_width + BeatmapSetOverlay.RIGHT_WIDTH + spacing * 2 }, Child = new ScrollContainer { RelativeSizeAxes = Axes.Both, @@ -89,7 +89,7 @@ namespace osu.Game.Overlays.OnlineBeatmapSet Width = metadata_width, ScrollbarVisible = false, Padding = new MarginPadding { Horizontal = 10 }, - Margin = new MarginPadding { Right = OnlineBeatmapSetOverlay.RIGHT_WIDTH + spacing }, + Margin = new MarginPadding { Right = BeatmapSetOverlay.RIGHT_WIDTH + spacing }, Child = new FillFlowContainer { RelativeSizeAxes = Axes.X, @@ -108,7 +108,7 @@ namespace osu.Game.Overlays.OnlineBeatmapSet Anchor = Anchor.TopRight, Origin = Anchor.TopRight, RelativeSizeAxes = Axes.Y, - Width = OnlineBeatmapSetOverlay.RIGHT_WIDTH, + Width = BeatmapSetOverlay.RIGHT_WIDTH, Children = new Drawable[] { successRateBackground = new Box diff --git a/osu.Game/Overlays/OnlineBeatmapSet/PreviewButton.cs b/osu.Game/Overlays/BeatmapSet/PreviewButton.cs similarity index 95% rename from osu.Game/Overlays/OnlineBeatmapSet/PreviewButton.cs rename to osu.Game/Overlays/BeatmapSet/PreviewButton.cs index b8673e2a77..bdb06106f0 100644 --- a/osu.Game/Overlays/OnlineBeatmapSet/PreviewButton.cs +++ b/osu.Game/Overlays/BeatmapSet/PreviewButton.cs @@ -1,8 +1,6 @@ // Copyright (c) 2007-2017 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE -using OpenTK; -using OpenTK.Graphics; using osu.Framework.Allocation; using osu.Framework.Audio; using osu.Framework.Audio.Track; @@ -15,8 +13,10 @@ using osu.Game.Beatmaps; using osu.Game.Graphics; using osu.Game.Graphics.Containers; using osu.Game.Graphics.UserInterface; +using OpenTK; +using OpenTK.Graphics; -namespace osu.Game.Overlays.OnlineBeatmapSet +namespace osu.Game.Overlays.BeatmapSet { public class PreviewButton : OsuClickableContainer { diff --git a/osu.Game/Overlays/OnlineBeatmapSet/SuccessRate.cs b/osu.Game/Overlays/BeatmapSet/SuccessRate.cs similarity index 96% rename from osu.Game/Overlays/OnlineBeatmapSet/SuccessRate.cs rename to osu.Game/Overlays/BeatmapSet/SuccessRate.cs index 3389542e64..26335aac9b 100644 --- a/osu.Game/Overlays/OnlineBeatmapSet/SuccessRate.cs +++ b/osu.Game/Overlays/BeatmapSet/SuccessRate.cs @@ -1,17 +1,17 @@ // Copyright (c) 2007-2017 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE +using System; using osu.Framework.Allocation; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; +using osu.Game.Beatmaps; using osu.Game.Graphics; using osu.Game.Graphics.Sprites; using osu.Game.Graphics.UserInterface; -using osu.Game.Beatmaps; using osu.Game.Screens.Select.Details; -using System; -namespace osu.Game.Overlays.OnlineBeatmapSet +namespace osu.Game.Overlays.BeatmapSet { public class SuccessRate : Container { diff --git a/osu.Game/Overlays/OnlineBeatmapSetOverlay.cs b/osu.Game/Overlays/BeatmapSetOverlay.cs similarity index 91% rename from osu.Game/Overlays/OnlineBeatmapSetOverlay.cs rename to osu.Game/Overlays/BeatmapSetOverlay.cs index 8db211e352..d809bc6727 100644 --- a/osu.Game/Overlays/OnlineBeatmapSetOverlay.cs +++ b/osu.Game/Overlays/BeatmapSetOverlay.cs @@ -10,11 +10,11 @@ using osu.Framework.Graphics.Shapes; using osu.Game.Beatmaps; using osu.Game.Graphics; using osu.Game.Graphics.Containers; -using osu.Game.Overlays.OnlineBeatmapSet; +using osu.Game.Overlays.BeatmapSet; namespace osu.Game.Overlays { - public class OnlineBeatmapSetOverlay : WaveOverlayContainer + public class BeatmapSetOverlay : WaveOverlayContainer { public const float X_PADDING = 40; public const float RIGHT_WIDTH = 275; @@ -22,7 +22,7 @@ namespace osu.Game.Overlays private readonly Header header; private readonly Info info; - public OnlineBeatmapSetOverlay() + public BeatmapSetOverlay() { FirstWaveColour = OsuColour.Gray(0.4f); SecondWaveColour = OsuColour.Gray(0.3f); diff --git a/osu.Game/Tests/Visual/TestCaseOnlineBeatmapSetOverlay.cs b/osu.Game/Tests/Visual/TestCaseBeatmapSetOverlay.cs similarity index 96% rename from osu.Game/Tests/Visual/TestCaseOnlineBeatmapSetOverlay.cs rename to osu.Game/Tests/Visual/TestCaseBeatmapSetOverlay.cs index 71113b5478..76ed9979ca 100644 --- a/osu.Game/Tests/Visual/TestCaseOnlineBeatmapSetOverlay.cs +++ b/osu.Game/Tests/Visual/TestCaseBeatmapSetOverlay.cs @@ -12,15 +12,15 @@ using osu.Game.Users; namespace osu.Game.Tests.Visual { - internal class TestCaseOnlineBeatmapSetOverlay : OsuTestCase + internal class TestCaseBeatmapSetOverlay : OsuTestCase { public override string Description => @"view online beatmap sets"; - private readonly OnlineBeatmapSetOverlay overlay; + private readonly BeatmapSetOverlay overlay; - public TestCaseOnlineBeatmapSetOverlay() + public TestCaseBeatmapSetOverlay() { - Add(overlay = new OnlineBeatmapSetOverlay()); + Add(overlay = new BeatmapSetOverlay()); } [BackgroundDependencyLoader] diff --git a/osu.Game/osu.Game.csproj b/osu.Game/osu.Game.csproj index 659af88b3f..ddb29c63c3 100644 --- a/osu.Game/osu.Game.csproj +++ b/osu.Game/osu.Game.csproj @@ -774,19 +774,19 @@ - - - - - - - - - - - - - + + + + + + + + + + + + + From c2bb3ea7bcad14034fa98cf565b7807582018b12 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Mon, 25 Sep 2017 17:58:03 +0800 Subject: [PATCH 26/30] Add minimal viable implementation of BeatmapSetOver in game --- osu.Game/OsuGame.cs | 4 ++++ osu.Game/Overlays/BeatmapSetOverlay.cs | 1 - osu.Game/Overlays/Direct/DirectGridPanel.cs | 7 ------- osu.Game/Overlays/Direct/DirectPanel.cs | 12 +++++++++++- 4 files changed, 15 insertions(+), 9 deletions(-) diff --git a/osu.Game/OsuGame.cs b/osu.Game/OsuGame.cs index b4fbdfb252..c137b8f6f5 100644 --- a/osu.Game/OsuGame.cs +++ b/osu.Game/OsuGame.cs @@ -47,6 +47,8 @@ namespace osu.Game private UserProfileOverlay userProfile; + private BeatmapSetOverlay beatmapSetOverlay; + public virtual Storage GetStorageForStableInstall() => null; private Intro intro @@ -187,6 +189,7 @@ namespace osu.Game Depth = -1 }, overlayContent.Add); LoadComponentAsync(userProfile = new UserProfileOverlay { Depth = -2 }, mainContent.Add); + LoadComponentAsync(beatmapSetOverlay = new BeatmapSetOverlay { Depth = -2 }, mainContent.Add); LoadComponentAsync(musicController = new MusicController { Depth = -3, @@ -223,6 +226,7 @@ namespace osu.Game dependencies.Cache(chat); dependencies.Cache(userProfile); dependencies.Cache(musicController); + dependencies.Cache(beatmapSetOverlay); dependencies.Cache(notificationOverlay); dependencies.Cache(dialogOverlay); diff --git a/osu.Game/Overlays/BeatmapSetOverlay.cs b/osu.Game/Overlays/BeatmapSetOverlay.cs index d809bc6727..6915523975 100644 --- a/osu.Game/Overlays/BeatmapSetOverlay.cs +++ b/osu.Game/Overlays/BeatmapSetOverlay.cs @@ -86,7 +86,6 @@ namespace osu.Game.Overlays public void ShowBeatmapSet(BeatmapSetInfo set) { header.BeatmapSet = info.BeatmapSet = set; - Show(); } } diff --git a/osu.Game/Overlays/Direct/DirectGridPanel.cs b/osu.Game/Overlays/Direct/DirectGridPanel.cs index 3a9e75bd38..0cc1c18d8d 100644 --- a/osu.Game/Overlays/Direct/DirectGridPanel.cs +++ b/osu.Game/Overlays/Direct/DirectGridPanel.cs @@ -12,7 +12,6 @@ using osu.Game.Graphics; using osu.Game.Graphics.Sprites; using osu.Framework.Graphics.Shapes; using osu.Game.Beatmaps; -using osu.Framework.Input; namespace osu.Game.Overlays.Direct { @@ -172,11 +171,5 @@ namespace osu.Game.Overlays.Direct }, }); } - - protected override bool OnClick(InputState state) - { - StartDownload(); - return true; - } } } diff --git a/osu.Game/Overlays/Direct/DirectPanel.cs b/osu.Game/Overlays/Direct/DirectPanel.cs index 6f1f581d0b..4f7f1bb39e 100644 --- a/osu.Game/Overlays/Direct/DirectPanel.cs +++ b/osu.Game/Overlays/Direct/DirectPanel.cs @@ -37,6 +37,7 @@ namespace osu.Game.Overlays.Direct private ProgressBar progressBar; private BeatmapManager beatmaps; private NotificationOverlay notifications; + private BeatmapSetOverlay beatmapSetOverlay; protected override Container Content => content; @@ -63,11 +64,12 @@ namespace osu.Game.Overlays.Direct [BackgroundDependencyLoader(permitNulls: true)] - private void load(APIAccess api, BeatmapManager beatmaps, OsuColour colours, NotificationOverlay notifications) + private void load(APIAccess api, BeatmapManager beatmaps, OsuColour colours, NotificationOverlay notifications, BeatmapSetOverlay beatmapSetOverlay) { this.api = api; this.beatmaps = beatmaps; this.notifications = notifications; + this.beatmapSetOverlay = beatmapSetOverlay; AddInternal(content = new Container { @@ -118,6 +120,14 @@ namespace osu.Game.Overlays.Direct base.OnHoverLost(state); } + protected override bool OnClick(InputState state) + { + ShowInformation(); + return true; + } + + protected void ShowInformation() => beatmapSetOverlay?.ShowBeatmapSet(SetInfo); + protected void StartDownload() { if (!api.LocalUser.Value.IsSupporter) From f9300ec3fe20138bc133dfee2d88a25773d8e0b9 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Mon, 25 Sep 2017 23:34:56 +0800 Subject: [PATCH 27/30] Populate author using existing data for now --- .../Online/API/Requests/GetBeatmapSetsRequest.cs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/osu.Game/Online/API/Requests/GetBeatmapSetsRequest.cs b/osu.Game/Online/API/Requests/GetBeatmapSetsRequest.cs index e4763f73ee..470e13ea7b 100644 --- a/osu.Game/Online/API/Requests/GetBeatmapSetsRequest.cs +++ b/osu.Game/Online/API/Requests/GetBeatmapSetsRequest.cs @@ -8,6 +8,7 @@ using osu.Game.Beatmaps; using osu.Game.Overlays; using osu.Game.Overlays.Direct; using osu.Game.Rulesets; +using osu.Game.Users; namespace osu.Game.Online.API.Requests { @@ -49,6 +50,12 @@ namespace osu.Game.Online.API.Requests [JsonProperty(@"id")] private int onlineId { get; set; } + [JsonProperty(@"creator")] + private string creatorUsername; + + [JsonProperty(@"user_id")] + private long creatorId = 1; + [JsonProperty(@"beatmaps")] private IEnumerable beatmaps { get; set; } @@ -60,6 +67,11 @@ namespace osu.Game.Online.API.Requests Metadata = this, OnlineInfo = new BeatmapSetOnlineInfo { + Author = new User + { + Id = creatorId, + Username = creatorUsername, + }, Covers = covers, Preview = preview, PlayCount = playCount, From f129902ee0ccbce67044105bd6d216c9362195ea Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Mon, 25 Sep 2017 23:35:02 +0800 Subject: [PATCH 28/30] Avoid nullrefs when data is not present --- osu.Game/Screens/Select/Details/AdvancedStats.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/osu.Game/Screens/Select/Details/AdvancedStats.cs b/osu.Game/Screens/Select/Details/AdvancedStats.cs index d92c8ed509..f1215ab33d 100644 --- a/osu.Game/Screens/Select/Details/AdvancedStats.cs +++ b/osu.Game/Screens/Select/Details/AdvancedStats.cs @@ -40,9 +40,9 @@ namespace osu.Game.Screens.Select.Details firstValue.Value = Beatmap?.Difficulty?.CircleSize ?? 0; } - hpDrain.Value = beatmap.Difficulty.DrainRate; - accuracy.Value = beatmap.Difficulty.OverallDifficulty; - approachRate.Value = beatmap.Difficulty.ApproachRate; + hpDrain.Value = beatmap.Difficulty?.DrainRate ?? 0; + accuracy.Value = beatmap.Difficulty?.OverallDifficulty ?? 0; + approachRate.Value = beatmap.Difficulty?.ApproachRate ?? 0; starDifficulty.Value = (float)beatmap.StarDifficulty; } } From c1081e02b23221409ee2cbe5c04c0b829f904e14 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Mon, 25 Sep 2017 23:35:40 +0800 Subject: [PATCH 29/30] Close beatmap overlay on stray mouse clicks --- osu.Game/Overlays/BeatmapSetOverlay.cs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/osu.Game/Overlays/BeatmapSetOverlay.cs b/osu.Game/Overlays/BeatmapSetOverlay.cs index 6915523975..8e28ad33c5 100644 --- a/osu.Game/Overlays/BeatmapSetOverlay.cs +++ b/osu.Game/Overlays/BeatmapSetOverlay.cs @@ -7,6 +7,7 @@ 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.Graphics; using osu.Game.Graphics.Containers; @@ -83,6 +84,12 @@ namespace osu.Game.Overlays FadeEdgeEffectTo(0, DISAPPEAR_DURATION, Easing.Out); } + protected override bool OnClick(InputState state) + { + State = Visibility.Hidden; + return true; + } + public void ShowBeatmapSet(BeatmapSetInfo set) { header.BeatmapSet = info.BeatmapSet = set; From 40f597f762d6513a22e94ca3ac9309eae3306fa3 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Tue, 26 Sep 2017 00:18:35 +0800 Subject: [PATCH 30/30] Add download button to grid view panels --- osu.Game/Overlays/Direct/DirectGridPanel.cs | 9 ++++ osu.Game/Overlays/Direct/DirectListPanel.cs | 44 ----------------- osu.Game/Overlays/Direct/DownloadButton.cs | 53 +++++++++++++++++++++ osu.Game/osu.Game.csproj | 1 + 4 files changed, 63 insertions(+), 44 deletions(-) create mode 100644 osu.Game/Overlays/Direct/DownloadButton.cs diff --git a/osu.Game/Overlays/Direct/DirectGridPanel.cs b/osu.Game/Overlays/Direct/DirectGridPanel.cs index 0cc1c18d8d..1675a2f663 100644 --- a/osu.Game/Overlays/Direct/DirectGridPanel.cs +++ b/osu.Game/Overlays/Direct/DirectGridPanel.cs @@ -149,6 +149,15 @@ namespace osu.Game.Overlays.Direct }, }, }, + new DownloadButton + { + Size = new Vector2(30), + Margin = new MarginPadding(horizontal_padding), + Anchor = Anchor.CentreRight, + Origin = Anchor.CentreRight, + Colour = colours.Gray5, + Action = StartDownload + }, }, }, }, diff --git a/osu.Game/Overlays/Direct/DirectListPanel.cs b/osu.Game/Overlays/Direct/DirectListPanel.cs index b3502b0827..6702b7394c 100644 --- a/osu.Game/Overlays/Direct/DirectListPanel.cs +++ b/osu.Game/Overlays/Direct/DirectListPanel.cs @@ -11,10 +11,8 @@ using osu.Game.Graphics; using osu.Game.Graphics.Sprites; using osu.Framework.Allocation; using osu.Framework.Localisation; -using osu.Framework.Input; using osu.Framework.Graphics.Shapes; using osu.Game.Beatmaps; -using osu.Game.Graphics.Containers; namespace osu.Game.Overlays.Direct { @@ -130,47 +128,5 @@ namespace osu.Game.Overlays.Direct }, }); } - - private class DownloadButton : OsuClickableContainer - { - private readonly SpriteIcon icon; - - public DownloadButton() - { - Children = new Drawable[] - { - icon = new SpriteIcon - { - Anchor = Anchor.Centre, - Origin = Anchor.Centre, - Size = new Vector2(30), - Icon = FontAwesome.fa_osu_chevron_down_o, - }, - }; - } - - protected override bool OnMouseDown(InputState state, MouseDownEventArgs args) - { - icon.ScaleTo(0.9f, 1000, Easing.Out); - return base.OnMouseDown(state, args); - } - - protected override bool OnMouseUp(InputState state, MouseUpEventArgs args) - { - icon.ScaleTo(1f, 500, Easing.OutElastic); - return base.OnMouseUp(state, args); - } - - protected override bool OnHover(InputState state) - { - icon.ScaleTo(1.1f, 500, Easing.OutElastic); - return base.OnHover(state); - } - - protected override void OnHoverLost(InputState state) - { - icon.ScaleTo(1f, 500, Easing.OutElastic); - } - } } } diff --git a/osu.Game/Overlays/Direct/DownloadButton.cs b/osu.Game/Overlays/Direct/DownloadButton.cs new file mode 100644 index 0000000000..28f5344eae --- /dev/null +++ b/osu.Game/Overlays/Direct/DownloadButton.cs @@ -0,0 +1,53 @@ +// Copyright (c) 2007-2017 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using osu.Framework.Graphics; +using osu.Framework.Input; +using osu.Game.Graphics; +using osu.Game.Graphics.Containers; +using OpenTK; + +namespace osu.Game.Overlays.Direct +{ + public class DownloadButton : OsuClickableContainer + { + private readonly SpriteIcon icon; + + public DownloadButton() + { + Children = new Drawable[] + { + icon = new SpriteIcon + { + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + Size = new Vector2(30), + Icon = FontAwesome.fa_osu_chevron_down_o, + }, + }; + } + + protected override bool OnMouseDown(InputState state, MouseDownEventArgs args) + { + icon.ScaleTo(0.9f, 1000, Easing.Out); + return base.OnMouseDown(state, args); + } + + protected override bool OnMouseUp(InputState state, MouseUpEventArgs args) + { + icon.ScaleTo(1f, 500, Easing.OutElastic); + return base.OnMouseUp(state, args); + } + + protected override bool OnHover(InputState state) + { + icon.ScaleTo(1.1f, 500, Easing.OutElastic); + return base.OnHover(state); + } + + protected override void OnHoverLost(InputState state) + { + icon.ScaleTo(1f, 500, Easing.OutElastic); + } + } +} \ No newline at end of file diff --git a/osu.Game/osu.Game.csproj b/osu.Game/osu.Game.csproj index ddb29c63c3..cd4447c734 100644 --- a/osu.Game/osu.Game.csproj +++ b/osu.Game/osu.Game.csproj @@ -398,6 +398,7 @@ +