2020-02-14 09:13:52 +00:00
|
|
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
|
|
|
// See the LICENCE file in the repository root for full licence text.
|
|
|
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
using osu.Framework.Allocation;
|
|
|
|
using osu.Framework.Bindables;
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
using osu.Framework.Graphics.Containers;
|
|
|
|
using osu.Framework.Graphics.Sprites;
|
|
|
|
using osu.Framework.Localisation;
|
|
|
|
using osu.Game.Beatmaps;
|
|
|
|
using osu.Game.Graphics;
|
|
|
|
using osu.Game.Graphics.Sprites;
|
|
|
|
using osu.Game.Graphics.UserInterface;
|
|
|
|
using osu.Game.Rulesets.Mods;
|
|
|
|
using osu.Game.Screens.Play.HUD;
|
|
|
|
using osuTK;
|
|
|
|
|
|
|
|
namespace osu.Game.Screens.Play
|
|
|
|
{
|
|
|
|
/// <summary>
|
|
|
|
/// Displays beatmap metadata inside <see cref="PlayerLoader"/>
|
|
|
|
/// </summary>
|
|
|
|
public class BeatmapMetadataDisplay : Container
|
|
|
|
{
|
|
|
|
private class MetadataLine : Container
|
|
|
|
{
|
|
|
|
public MetadataLine(string left, string right)
|
|
|
|
{
|
|
|
|
AutoSizeAxes = Axes.Both;
|
|
|
|
Children = new Drawable[]
|
|
|
|
{
|
|
|
|
new OsuSpriteText
|
|
|
|
{
|
|
|
|
Anchor = Anchor.TopCentre,
|
|
|
|
Origin = Anchor.TopRight,
|
|
|
|
Margin = new MarginPadding { Right = 5 },
|
|
|
|
Colour = OsuColour.Gray(0.8f),
|
|
|
|
Text = left,
|
|
|
|
},
|
|
|
|
new OsuSpriteText
|
|
|
|
{
|
|
|
|
Anchor = Anchor.TopCentre,
|
|
|
|
Origin = Anchor.TopLeft,
|
|
|
|
Margin = new MarginPadding { Left = 5 },
|
|
|
|
Text = string.IsNullOrEmpty(right) ? @"-" : right,
|
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private readonly WorkingBeatmap beatmap;
|
|
|
|
private readonly Bindable<IReadOnlyList<Mod>> mods;
|
|
|
|
private readonly Drawable facade;
|
2020-02-21 06:33:31 +00:00
|
|
|
private LoadingSpinner loading;
|
2020-02-14 09:13:52 +00:00
|
|
|
|
|
|
|
public IBindable<IReadOnlyList<Mod>> Mods => mods;
|
|
|
|
|
|
|
|
public bool Loading
|
|
|
|
{
|
|
|
|
set
|
|
|
|
{
|
|
|
|
if (value)
|
|
|
|
loading.Show();
|
|
|
|
else
|
|
|
|
loading.Hide();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public BeatmapMetadataDisplay(WorkingBeatmap beatmap, Bindable<IReadOnlyList<Mod>> mods, Drawable facade)
|
|
|
|
{
|
|
|
|
this.beatmap = beatmap;
|
|
|
|
this.facade = facade;
|
|
|
|
|
|
|
|
this.mods = new Bindable<IReadOnlyList<Mod>>();
|
|
|
|
this.mods.BindTo(mods);
|
|
|
|
}
|
|
|
|
|
|
|
|
[BackgroundDependencyLoader]
|
|
|
|
private void load()
|
|
|
|
{
|
|
|
|
var metadata = beatmap.BeatmapInfo?.Metadata ?? new BeatmapMetadata();
|
|
|
|
|
|
|
|
AutoSizeAxes = Axes.Both;
|
|
|
|
Children = new Drawable[]
|
|
|
|
{
|
|
|
|
new FillFlowContainer
|
|
|
|
{
|
|
|
|
AutoSizeAxes = Axes.Both,
|
|
|
|
Origin = Anchor.TopCentre,
|
|
|
|
Anchor = Anchor.TopCentre,
|
|
|
|
Direction = FillDirection.Vertical,
|
|
|
|
Children = new[]
|
|
|
|
{
|
|
|
|
facade.With(d =>
|
|
|
|
{
|
|
|
|
d.Anchor = Anchor.TopCentre;
|
|
|
|
d.Origin = Anchor.TopCentre;
|
|
|
|
}),
|
|
|
|
new OsuSpriteText
|
|
|
|
{
|
|
|
|
Text = new LocalisedString((metadata.TitleUnicode, metadata.Title)),
|
|
|
|
Font = OsuFont.GetFont(size: 36, italics: true),
|
|
|
|
Origin = Anchor.TopCentre,
|
|
|
|
Anchor = Anchor.TopCentre,
|
|
|
|
Margin = new MarginPadding { Top = 15 },
|
|
|
|
},
|
|
|
|
new OsuSpriteText
|
|
|
|
{
|
|
|
|
Text = new LocalisedString((metadata.ArtistUnicode, metadata.Artist)),
|
|
|
|
Font = OsuFont.GetFont(size: 26, italics: true),
|
|
|
|
Origin = Anchor.TopCentre,
|
|
|
|
Anchor = Anchor.TopCentre,
|
|
|
|
},
|
|
|
|
new Container
|
|
|
|
{
|
|
|
|
Size = new Vector2(300, 60),
|
|
|
|
Margin = new MarginPadding(10),
|
|
|
|
Origin = Anchor.TopCentre,
|
|
|
|
Anchor = Anchor.TopCentre,
|
|
|
|
CornerRadius = 10,
|
|
|
|
Masking = true,
|
|
|
|
Children = new Drawable[]
|
|
|
|
{
|
2021-01-05 21:39:59 +00:00
|
|
|
new Sprite
|
2020-02-14 09:13:52 +00:00
|
|
|
{
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
Texture = beatmap?.Background,
|
|
|
|
Origin = Anchor.Centre,
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
FillMode = FillMode.Fill,
|
|
|
|
},
|
2021-01-04 13:42:39 +00:00
|
|
|
loading = new LoadingLayer(true)
|
2020-02-14 09:13:52 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
new OsuSpriteText
|
|
|
|
{
|
|
|
|
Text = beatmap?.BeatmapInfo?.Version,
|
|
|
|
Font = OsuFont.GetFont(size: 26, italics: true),
|
|
|
|
Origin = Anchor.TopCentre,
|
|
|
|
Anchor = Anchor.TopCentre,
|
|
|
|
Margin = new MarginPadding
|
|
|
|
{
|
|
|
|
Bottom = 40
|
|
|
|
},
|
|
|
|
},
|
|
|
|
new MetadataLine("Source", metadata.Source)
|
|
|
|
{
|
|
|
|
Origin = Anchor.TopCentre,
|
|
|
|
Anchor = Anchor.TopCentre,
|
|
|
|
},
|
|
|
|
new MetadataLine("Mapper", metadata.AuthorString)
|
|
|
|
{
|
|
|
|
Origin = Anchor.TopCentre,
|
|
|
|
Anchor = Anchor.TopCentre,
|
|
|
|
},
|
|
|
|
new ModDisplay
|
|
|
|
{
|
|
|
|
Anchor = Anchor.TopCentre,
|
|
|
|
Origin = Anchor.TopCentre,
|
|
|
|
AutoSizeAxes = Axes.Both,
|
|
|
|
Margin = new MarginPadding { Top = 20 },
|
|
|
|
Current = mods
|
2020-07-20 10:24:17 +00:00
|
|
|
},
|
2020-02-14 09:13:52 +00:00
|
|
|
},
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
Loading = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|