Add metadata details

This commit is contained in:
Jorolf
2017-03-24 23:02:24 +01:00
parent 796218cb00
commit d8724e5e3e
5 changed files with 145 additions and 8 deletions

View File

@ -1,6 +1,7 @@
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
// 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<Drawable> 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;
}
}
}

View File

@ -0,0 +1,87 @@
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
// 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<SpriteText> 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<SpriteText>
{
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;
}
}
}