diff --git a/osu.Desktop.VisualTests/Tests/TestCaseDetails.cs b/osu.Desktop.VisualTests/Tests/TestCaseDetails.cs new file mode 100644 index 0000000000..b97c61218f --- /dev/null +++ b/osu.Desktop.VisualTests/Tests/TestCaseDetails.cs @@ -0,0 +1,31 @@ +using osu.Framework.Graphics; +using osu.Framework.Screens.Testing; +using osu.Game.Database; +using osu.Game.Screens.Select; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace osu.Desktop.VisualTests.Tests +{ + class TestCaseDetails : TestCase + { + + public override void Reset() + { + base.Reset(); + + Add(new Details + { + RelativeSizeAxes = Axes.Both, + Metadata = new BeatmapMetadata + { + Source = "Some guy", + Tags = "beatmap metadata example with a very very long list of tags and not much creativity", + }, + }); + } + } +} diff --git a/osu.Desktop.VisualTests/osu.Desktop.VisualTests.csproj b/osu.Desktop.VisualTests/osu.Desktop.VisualTests.csproj index f1b4a99510..d94358a6a1 100644 --- a/osu.Desktop.VisualTests/osu.Desktop.VisualTests.csproj +++ b/osu.Desktop.VisualTests/osu.Desktop.VisualTests.csproj @@ -1,4 +1,4 @@ - + {69051C69-12AE-4E7D-A3E6-460D2E282312} @@ -183,6 +183,7 @@ + @@ -211,7 +212,7 @@ - + diff --git a/osu.Game/Screens/Select/BeatmapDetailArea.cs b/osu.Game/Screens/Select/BeatmapDetailArea.cs index 21e4d643f2..c7ee57e36c 100644 --- a/osu.Game/Screens/Select/BeatmapDetailArea.cs +++ b/osu.Game/Screens/Select/BeatmapDetailArea.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; using osu.Framework.Allocation; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; @@ -17,8 +18,9 @@ namespace osu.Game.Screens.Select private readonly Container content; protected override Container Content => content; - public readonly Container Details; //todo: replace with a real details view when added + public readonly Details Details; public readonly Leaderboard Leaderboard; + private BeatmapDetailTab currentTab; private APIAccess api; @@ -32,7 +34,11 @@ namespace osu.Game.Screens.Select set { beatmap = value; - if (IsLoaded) Schedule(updateScores); + if (IsLoaded) + if(currentTab == BeatmapDetailTab.Details) + Schedule(updateDetails); + else + Schedule(updateScores); } } @@ -50,15 +56,15 @@ namespace osu.Game.Screens.Select case BeatmapDetailTab.Details: Details.Show(); Leaderboard.Hide(); + updateDetails(); break; default: Details.Hide(); Leaderboard.Show(); + updateScores(); break; } - - //for now let's always update scores. - updateScores(); + currentTab = tab; }, }, content = new Container @@ -70,7 +76,7 @@ namespace osu.Game.Screens.Select Add(new Drawable[] { - Details = new Container + Details = new Details { RelativeSizeAxes = Axes.Both, }, @@ -107,5 +113,16 @@ namespace osu.Game.Screens.Select getScoresRequest.Success += r => Leaderboard.Scores = r.Scores; api.Queue(getScoresRequest); } + + + + private void updateDetails() + { + if (!IsLoaded) return; + + if (api == null || beatmap?.BeatmapInfo == null) return; + + Details.Metadata = beatmap.Beatmap.Metadata; + } } } diff --git a/osu.Game/Screens/Select/Details.cs b/osu.Game/Screens/Select/Details.cs new file mode 100644 index 0000000000..7748bcd1b5 --- /dev/null +++ b/osu.Game/Screens/Select/Details.cs @@ -0,0 +1,87 @@ +// Copyright (c) 2007-2017 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using System.Linq; +using osu.Framework.Graphics.Containers; +using osu.Framework.Graphics; +using osu.Game.Database; +using osu.Framework.Graphics.Sprites; +using osu.Framework.Graphics.Primitives; +using osu.Game.Graphics; +using OpenTK; +using osu.Framework.Allocation; + +namespace osu.Game.Screens.Select +{ + public class Details : Container + { + private FillFlowContainer metadataContainer; + private SpriteText description; + private SpriteText source; + private FillFlowContainer tags; + private BeatmapMetadata metadata; + public BeatmapMetadata Metadata + { + get + { + return metadata; + } + + set + { + if (metadata == value) return; + metadata = value; + source.Text = metadata.Source; + tags.Children = metadata.Tags.Split(' ').ToList().Select(text => new SpriteText { Text = text }); + } + } + + public Details() + { + Children = new[] + { + metadataContainer = new FillFlowContainer() + { + Anchor = Anchor.TopRight, + Origin = Anchor.TopRight, + RelativeSizeAxes = Axes.X, + AutoSizeAxes = Axes.Y, + Width = 0.4f, + Direction = FillDirection.Vertical, + Children = new Drawable[] + { + new SpriteText + { + Text = "Description", + }, + description = new SpriteText(), + new SpriteText + { + Text = "Source", + Margin = new MarginPadding { Top = 20 }, + }, + source = new SpriteText(), + new SpriteText + { + Text = "Tags", + Margin = new MarginPadding { Top = 20 }, + }, + tags = new FillFlowContainer + { + RelativeSizeAxes = Axes.X, + Spacing = new Vector2(3,0), + }, + }, + } + }; + } + + [BackgroundDependencyLoader] + private void load(OsuColour colour) + { + description.Colour = colour.GrayB; + source.Colour = colour.GrayB; + tags.Colour = colour.Yellow; + } + } +} diff --git a/osu.Game/osu.Game.csproj b/osu.Game/osu.Game.csproj index 989e605c16..9d7627b5f2 100644 --- a/osu.Game/osu.Game.csproj +++ b/osu.Game/osu.Game.csproj @@ -201,6 +201,7 @@ +