1
0
mirror of https://github.com/ppy/osu.git synced 2024-09-23 14:07:24 +08:00
osu-lazer/osu.Game/Screens/Multi/Components/BeatmapTitle.cs

86 lines
2.6 KiB
C#
Raw Normal View History

// 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-12-26 16:07:59 +08:00
using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Framework.Localisation;
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
{
2019-02-05 18:00:01 +08:00
public class BeatmapTitle : MultiplayerComposite
{
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 };
}
2019-02-05 18:00:01 +08:00
[BackgroundDependencyLoader]
private void load()
{
2019-02-05 18:00:01 +08:00
CurrentBeatmap.BindValueChanged(v => updateText(), true);
}
private float textSize = OsuFont.DEFAULT_FONT_SIZE;
2018-12-22 13:01:06 +08:00
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();
2019-02-05 18:00:01 +08:00
if (CurrentBeatmap.Value == null)
2018-12-26 16:07:59 +08:00
textFlow.AddText("No beatmap selected", s =>
{
s.Font = OsuFont.GetFont(s.Font, size: TextSize);
2018-12-26 16:07:59 +08:00
s.Colour = colours.PinkLight;
});
else
{
2018-12-20 19:03:39 +08:00
textFlow.AddLink(new[]
{
new OsuSpriteText
{
2019-02-05 18:00:01 +08:00
Text = new LocalisedString((CurrentBeatmap.Value.Metadata.ArtistUnicode, CurrentBeatmap.Value.Metadata.Artist)),
Font = OsuFont.GetFont(size: TextSize),
2018-12-20 19:03:39 +08:00
},
new OsuSpriteText
{
Text = " - ",
Font = OsuFont.GetFont(size: TextSize),
2018-12-20 19:03:39 +08:00
},
new OsuSpriteText
{
2019-02-05 18:00:01 +08:00
Text = new LocalisedString((CurrentBeatmap.Value.Metadata.TitleUnicode, CurrentBeatmap.Value.Metadata.Title)),
Font = OsuFont.GetFont(size: TextSize),
2018-12-20 19:03:39 +08:00
}
2019-02-05 18:00:01 +08:00
}, null, LinkAction.OpenBeatmap, CurrentBeatmap.Value.OnlineBeatmapID.ToString(), "Open beatmap");
}
}
}
}