1
0
mirror of https://github.com/ppy/osu.git synced 2024-09-22 06:47:24 +08:00

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

@ -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",
},
});
}
}
}

View File

@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0">
<PropertyGroup>
<ProjectGuid>{69051C69-12AE-4E7D-A3E6-460D2E282312}</ProjectGuid>
@ -183,6 +183,7 @@
<Compile Include="Benchmark.cs" />
<Compile Include="Program.cs" />
<Compile Include="Tests\TestCaseChatDisplay.cs" />
<Compile Include="Tests\TestCaseDetails.cs" />
<Compile Include="Tests\TestCaseDrawings.cs" />
<Compile Include="Tests\TestCaseGamefield.cs" />
<Compile Include="Tests\TestCaseMusicController.cs" />
@ -211,7 +212,7 @@
<Compile Include="Tests\TestCaseBeatmapDetailArea.cs" />
</ItemGroup>
<ItemGroup />
<ItemGroup />
<ItemGroup />
<ItemGroup>
<Folder Include="Beatmaps\" />
</ItemGroup>

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;
}
}
}

View File

@ -201,6 +201,7 @@
<Compile Include="Screens\Play\SkipButton.cs" />
<Compile Include="Modes\UI\StandardComboCounter.cs" />
<Compile Include="Screens\Select\BeatmapCarousel.cs" />
<Compile Include="Screens\Select\Details.cs" />
<Compile Include="Screens\Select\FilterCriteria.cs" />
<Compile Include="Screens\Select\Filter\GroupMode.cs" />
<Compile Include="Screens\Select\Filter\SortMode.cs" />