2019-01-24 17:43:03 +09: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.
|
2018-05-28 23:13:56 -03:00
|
|
|
|
|
2020-02-13 18:48:28 +09:00
|
|
|
|
using System.Linq;
|
2018-12-26 17:07:59 +09:00
|
|
|
|
using osu.Framework.Allocation;
|
2018-05-28 23:13:56 -03:00
|
|
|
|
using osu.Framework.Graphics;
|
2021-02-22 17:14:13 +09:00
|
|
|
|
using osu.Framework.Localisation;
|
2018-12-26 17:07:59 +09:00
|
|
|
|
using osu.Game.Graphics;
|
2018-12-20 20:03:39 +09:00
|
|
|
|
using osu.Game.Graphics.Containers;
|
|
|
|
|
using osu.Game.Online.Chat;
|
2018-05-28 23:13:56 -03:00
|
|
|
|
|
2020-12-25 16:50:00 +01:00
|
|
|
|
namespace osu.Game.Screens.OnlinePlay.Components
|
2018-05-28 23:13:56 -03:00
|
|
|
|
{
|
2020-12-25 17:12:33 +01:00
|
|
|
|
public class BeatmapTitle : OnlinePlayComposite
|
2018-05-28 23:13:56 -03:00
|
|
|
|
{
|
2018-12-20 20:03:39 +09:00
|
|
|
|
private readonly LinkFlowContainer textFlow;
|
|
|
|
|
|
2018-05-28 23:13:56 -03:00
|
|
|
|
public BeatmapTitle()
|
|
|
|
|
{
|
|
|
|
|
AutoSizeAxes = Axes.Both;
|
|
|
|
|
|
2018-12-20 20:03:39 +09:00
|
|
|
|
InternalChild = textFlow = new LinkFlowContainer { AutoSizeAxes = Axes.Both };
|
2018-05-28 23:13:56 -03:00
|
|
|
|
}
|
|
|
|
|
|
2019-02-05 19:00:01 +09:00
|
|
|
|
[BackgroundDependencyLoader]
|
|
|
|
|
private void load()
|
2018-05-28 23:13:56 -03:00
|
|
|
|
{
|
2020-02-17 15:06:14 +09:00
|
|
|
|
Playlist.CollectionChanged += (_, __) => updateText();
|
2020-02-13 18:48:28 +09:00
|
|
|
|
|
|
|
|
|
updateText();
|
2018-05-28 23:13:56 -03:00
|
|
|
|
}
|
|
|
|
|
|
2019-02-12 13:04:46 +09:00
|
|
|
|
private float textSize = OsuFont.DEFAULT_FONT_SIZE;
|
2018-12-22 14:01:06 +09:00
|
|
|
|
|
|
|
|
|
public float TextSize
|
|
|
|
|
{
|
|
|
|
|
get => textSize;
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
if (textSize == value)
|
|
|
|
|
return;
|
2019-02-28 13:31:40 +09:00
|
|
|
|
|
2018-12-22 14:01:06 +09:00
|
|
|
|
textSize = value;
|
|
|
|
|
|
|
|
|
|
updateText();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2018-12-26 17:07:59 +09:00
|
|
|
|
[Resolved]
|
|
|
|
|
private OsuColour colours { get; set; }
|
|
|
|
|
|
2018-05-28 23:13:56 -03:00
|
|
|
|
private void updateText()
|
|
|
|
|
{
|
2019-02-13 14:57:40 +09:00
|
|
|
|
if (LoadState < LoadState.Loading)
|
2018-12-07 19:38:46 +09:00
|
|
|
|
return;
|
|
|
|
|
|
2018-12-20 20:03:39 +09:00
|
|
|
|
textFlow.Clear();
|
|
|
|
|
|
2020-02-13 18:48:28 +09:00
|
|
|
|
var beatmap = Playlist.FirstOrDefault()?.Beatmap;
|
2019-02-11 19:11:34 +09:00
|
|
|
|
|
|
|
|
|
if (beatmap == null)
|
2019-11-11 19:53:22 +08:00
|
|
|
|
{
|
2018-12-26 17:07:59 +09:00
|
|
|
|
textFlow.AddText("No beatmap selected", s =>
|
|
|
|
|
{
|
2019-02-20 19:32:30 +09:00
|
|
|
|
s.Font = s.Font.With(size: TextSize);
|
2018-12-26 17:07:59 +09:00
|
|
|
|
s.Colour = colours.PinkLight;
|
|
|
|
|
});
|
2019-11-11 19:53:22 +08:00
|
|
|
|
}
|
2018-05-28 23:13:56 -03:00
|
|
|
|
else
|
|
|
|
|
{
|
2021-10-30 18:31:43 +02:00
|
|
|
|
var metadataInfo = beatmap.Value.Metadata;
|
|
|
|
|
|
|
|
|
|
string artistUnicode = string.IsNullOrEmpty(metadataInfo.ArtistUnicode) ? metadataInfo.Artist : metadataInfo.ArtistUnicode;
|
|
|
|
|
string titleUnicode = string.IsNullOrEmpty(metadataInfo.TitleUnicode) ? metadataInfo.Title : metadataInfo.TitleUnicode;
|
|
|
|
|
|
|
|
|
|
var title = new RomanisableString($"{artistUnicode} - {titleUnicode}".Trim(), $"{metadataInfo.Artist} - {metadataInfo.Title}".Trim());
|
|
|
|
|
|
|
|
|
|
textFlow.AddLink(title, LinkAction.OpenBeatmap, beatmap.Value.OnlineID.ToString(), "Open beatmap");
|
2018-05-28 23:13:56 -03:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|