2019-01-24 08:43:03 +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.
|
2018-05-29 02:13:56 +00:00
|
|
|
|
|
2018-12-26 08:07:59 +00:00
|
|
|
|
using osu.Framework.Allocation;
|
2018-05-29 02:13:56 +00:00
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
|
using osu.Framework.Localisation;
|
2018-12-26 08:07:59 +00:00
|
|
|
|
using osu.Game.Graphics;
|
2018-12-20 11:03:39 +00:00
|
|
|
|
using osu.Game.Graphics.Containers;
|
2018-05-29 02:13:56 +00:00
|
|
|
|
using osu.Game.Graphics.Sprites;
|
2018-12-20 11:03:39 +00:00
|
|
|
|
using osu.Game.Online.Chat;
|
2018-05-29 02:13:56 +00:00
|
|
|
|
|
|
|
|
|
namespace osu.Game.Screens.Multi.Components
|
|
|
|
|
{
|
2019-02-05 10:00:01 +00:00
|
|
|
|
public class BeatmapTitle : MultiplayerComposite
|
2018-05-29 02:13:56 +00:00
|
|
|
|
{
|
2018-12-20 11:03:39 +00:00
|
|
|
|
private readonly LinkFlowContainer textFlow;
|
|
|
|
|
|
2018-05-29 02:13:56 +00:00
|
|
|
|
public BeatmapTitle()
|
|
|
|
|
{
|
|
|
|
|
AutoSizeAxes = Axes.Both;
|
|
|
|
|
|
2018-12-20 11:03:39 +00:00
|
|
|
|
InternalChild = textFlow = new LinkFlowContainer { AutoSizeAxes = Axes.Both };
|
2018-05-29 02:13:56 +00:00
|
|
|
|
}
|
|
|
|
|
|
2019-02-05 10:00:01 +00:00
|
|
|
|
[BackgroundDependencyLoader]
|
|
|
|
|
private void load()
|
2018-05-29 02:13:56 +00:00
|
|
|
|
{
|
2019-02-22 11:13:38 +00:00
|
|
|
|
CurrentItem.BindValueChanged(_ => updateText(), true);
|
2018-05-29 02:13:56 +00:00
|
|
|
|
}
|
|
|
|
|
|
2019-02-12 04:04:46 +00:00
|
|
|
|
private float textSize = OsuFont.DEFAULT_FONT_SIZE;
|
2018-12-22 05:01:06 +00:00
|
|
|
|
|
|
|
|
|
public float TextSize
|
|
|
|
|
{
|
|
|
|
|
get => textSize;
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
if (textSize == value)
|
|
|
|
|
return;
|
2019-02-28 04:31:40 +00:00
|
|
|
|
|
2018-12-22 05:01:06 +00:00
|
|
|
|
textSize = value;
|
|
|
|
|
|
|
|
|
|
updateText();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2018-12-26 08:07:59 +00:00
|
|
|
|
[Resolved]
|
|
|
|
|
private OsuColour colours { get; set; }
|
|
|
|
|
|
2018-05-29 02:13:56 +00:00
|
|
|
|
private void updateText()
|
|
|
|
|
{
|
2019-02-13 05:57:40 +00:00
|
|
|
|
if (LoadState < LoadState.Loading)
|
2018-12-07 10:38:46 +00:00
|
|
|
|
return;
|
|
|
|
|
|
2018-12-20 11:03:39 +00:00
|
|
|
|
textFlow.Clear();
|
|
|
|
|
|
2019-02-11 10:11:34 +00:00
|
|
|
|
var beatmap = CurrentItem.Value?.Beatmap;
|
|
|
|
|
|
|
|
|
|
if (beatmap == null)
|
2019-11-11 11:53:22 +00:00
|
|
|
|
{
|
2018-12-26 08:07:59 +00:00
|
|
|
|
textFlow.AddText("No beatmap selected", s =>
|
|
|
|
|
{
|
2019-02-20 10:32:30 +00:00
|
|
|
|
s.Font = s.Font.With(size: TextSize);
|
2018-12-26 08:07:59 +00:00
|
|
|
|
s.Colour = colours.PinkLight;
|
|
|
|
|
});
|
2019-11-11 11:53:22 +00:00
|
|
|
|
}
|
2018-05-29 02:13:56 +00:00
|
|
|
|
else
|
|
|
|
|
{
|
2018-12-20 11:03:39 +00:00
|
|
|
|
textFlow.AddLink(new[]
|
|
|
|
|
{
|
|
|
|
|
new OsuSpriteText
|
|
|
|
|
{
|
2019-02-11 10:11:34 +00:00
|
|
|
|
Text = new LocalisedString((beatmap.Metadata.ArtistUnicode, beatmap.Metadata.Artist)),
|
2019-02-12 04:04:46 +00:00
|
|
|
|
Font = OsuFont.GetFont(size: TextSize),
|
2018-12-20 11:03:39 +00:00
|
|
|
|
},
|
|
|
|
|
new OsuSpriteText
|
|
|
|
|
{
|
|
|
|
|
Text = " - ",
|
2019-02-12 04:04:46 +00:00
|
|
|
|
Font = OsuFont.GetFont(size: TextSize),
|
2018-12-20 11:03:39 +00:00
|
|
|
|
},
|
|
|
|
|
new OsuSpriteText
|
|
|
|
|
{
|
2019-02-11 10:11:34 +00:00
|
|
|
|
Text = new LocalisedString((beatmap.Metadata.TitleUnicode, beatmap.Metadata.Title)),
|
2019-02-12 04:04:46 +00:00
|
|
|
|
Font = OsuFont.GetFont(size: TextSize),
|
2018-12-20 11:03:39 +00:00
|
|
|
|
}
|
2019-11-01 02:40:51 +00:00
|
|
|
|
}, LinkAction.OpenBeatmap, beatmap.OnlineBeatmapID.ToString(), "Open beatmap");
|
2018-05-29 02:13:56 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|