1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-16 03:42:58 +08:00
osu-lazer/osu.Game/Screens/Multi/Components/BeatmapTitle.cs

91 lines
2.6 KiB
C#
Raw Normal View History

// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
2018-12-26 16:07:59 +08:00
using osu.Framework.Allocation;
using osu.Framework.Configuration;
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;
using osu.Game.Graphics.Sprites;
2018-12-20 19:03:39 +08:00
using osu.Game.Online.Chat;
namespace osu.Game.Screens.Multi.Components
{
public class BeatmapTitle : CompositeDrawable
{
2018-12-20 14:17:33 +08:00
public readonly IBindable<BeatmapInfo> Beatmap = new Bindable<BeatmapInfo>();
2018-12-20 19:03:39 +08:00
private readonly LinkFlowContainer textFlow;
public BeatmapTitle()
{
AutoSizeAxes = Axes.Both;
2018-12-20 19:03:39 +08:00
InternalChild = textFlow = new LinkFlowContainer { AutoSizeAxes = Axes.Both };
}
protected override void LoadComplete()
{
base.LoadComplete();
2018-12-26 16:07:59 +08:00
Beatmap.BindValueChanged(v => updateText(), true);
}
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; }
private void updateText()
{
if (!IsLoaded)
return;
2018-12-20 19:03:39 +08:00
textFlow.Clear();
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;
});
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");
}
}
}
}