2019-01-24 16:43:03 +08: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-29 10:13:56 +08:00
|
|
|
|
|
2018-12-26 16:07:59 +08:00
|
|
|
|
using osu.Framework.Allocation;
|
2018-12-07 18:38:46 +08:00
|
|
|
|
using osu.Framework.Configuration;
|
2018-05-29 10:13:56 +08:00
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
|
using osu.Framework.Graphics.Containers;
|
|
|
|
|
using osu.Framework.Localisation;
|
|
|
|
|
using osu.Game.Beatmaps;
|
2018-12-26 16:07:59 +08:00
|
|
|
|
using osu.Game.Graphics;
|
2018-12-20 19:03:39 +08:00
|
|
|
|
using osu.Game.Graphics.Containers;
|
2018-05-29 10:13:56 +08:00
|
|
|
|
using osu.Game.Graphics.Sprites;
|
2018-12-20 19:03:39 +08:00
|
|
|
|
using osu.Game.Online.Chat;
|
2018-05-29 10:13:56 +08:00
|
|
|
|
|
|
|
|
|
namespace osu.Game.Screens.Multi.Components
|
|
|
|
|
{
|
2018-12-07 18:38:46 +08:00
|
|
|
|
public class BeatmapTitle : CompositeDrawable
|
2018-05-29 10:13:56 +08:00
|
|
|
|
{
|
2018-12-20 14:17:33 +08:00
|
|
|
|
public readonly IBindable<BeatmapInfo> Beatmap = new Bindable<BeatmapInfo>();
|
2018-05-29 10:13:56 +08:00
|
|
|
|
|
2018-12-20 19:03:39 +08:00
|
|
|
|
private readonly LinkFlowContainer textFlow;
|
|
|
|
|
|
2018-05-29 10:13:56 +08:00
|
|
|
|
public BeatmapTitle()
|
|
|
|
|
{
|
|
|
|
|
AutoSizeAxes = Axes.Both;
|
|
|
|
|
|
2018-12-20 19:03:39 +08:00
|
|
|
|
InternalChild = textFlow = new LinkFlowContainer { AutoSizeAxes = Axes.Both };
|
2018-05-29 10:13:56 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void LoadComplete()
|
|
|
|
|
{
|
|
|
|
|
base.LoadComplete();
|
2018-12-26 16:07:59 +08:00
|
|
|
|
Beatmap.BindValueChanged(v => updateText(), true);
|
2018-05-29 10:13:56 +08:00
|
|
|
|
}
|
|
|
|
|
|
2018-12-22 13:01:06 +08:00
|
|
|
|
private float textSize = OsuSpriteText.FONT_SIZE;
|
|
|
|
|
|
|
|
|
|
public float TextSize
|
|
|
|
|
{
|
|
|
|
|
get => textSize;
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
if (textSize == value)
|
|
|
|
|
return;
|
|
|
|
|
textSize = value;
|
|
|
|
|
|
|
|
|
|
updateText();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2018-12-26 16:07:59 +08:00
|
|
|
|
[Resolved]
|
|
|
|
|
private OsuColour colours { get; set; }
|
|
|
|
|
|
2018-05-29 10:13:56 +08:00
|
|
|
|
private void updateText()
|
|
|
|
|
{
|
2018-12-07 18:38:46 +08:00
|
|
|
|
if (!IsLoaded)
|
|
|
|
|
return;
|
|
|
|
|
|
2018-12-20 19:03:39 +08:00
|
|
|
|
textFlow.Clear();
|
|
|
|
|
|
2018-12-07 18:38:46 +08:00
|
|
|
|
if (Beatmap.Value == null)
|
2018-12-26 16:07:59 +08:00
|
|
|
|
textFlow.AddText("No beatmap selected", s =>
|
|
|
|
|
{
|
|
|
|
|
s.TextSize = TextSize;
|
|
|
|
|
s.Colour = colours.PinkLight;
|
|
|
|
|
});
|
2018-05-29 10:13:56 +08:00
|
|
|
|
else
|
|
|
|
|
{
|
2018-12-20 19:03:39 +08:00
|
|
|
|
textFlow.AddLink(new[]
|
|
|
|
|
{
|
|
|
|
|
new OsuSpriteText
|
|
|
|
|
{
|
|
|
|
|
Text = new LocalisedString((Beatmap.Value.Metadata.ArtistUnicode, Beatmap.Value.Metadata.Artist)),
|
|
|
|
|
TextSize = TextSize,
|
|
|
|
|
},
|
|
|
|
|
new OsuSpriteText
|
|
|
|
|
{
|
|
|
|
|
Text = " - ",
|
|
|
|
|
TextSize = TextSize,
|
|
|
|
|
},
|
|
|
|
|
new OsuSpriteText
|
|
|
|
|
{
|
|
|
|
|
Text = new LocalisedString((Beatmap.Value.Metadata.TitleUnicode, Beatmap.Value.Metadata.Title)),
|
|
|
|
|
TextSize = TextSize,
|
|
|
|
|
}
|
|
|
|
|
}, null, LinkAction.OpenBeatmap, Beatmap.Value.OnlineBeatmapID.ToString(), "Open beatmap");
|
2018-05-29 10:13:56 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|