1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-11 20:59:35 +08:00
osu-lazer/osu.Game/Overlays/BeatmapSet/BeatmapNotAvailable.cs

97 lines
3.3 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.
using osu.Framework.Extensions.Color4Extensions;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes;
2019-06-11 17:29:42 +08:00
using osu.Game.Beatmaps;
using osu.Game.Graphics;
using osu.Game.Graphics.Containers;
using osuTK.Graphics;
namespace osu.Game.Overlays.BeatmapSet
{
public class BeatmapNotAvailable : Container
{
2019-06-11 17:29:42 +08:00
private BeatmapSetInfo beatmapSet;
2019-06-21 00:43:31 +08:00
private bool downloadDisabled => BeatmapSet?.OnlineInfo.Availability?.DownloadDisabled ?? false;
private bool hasExternalLink => !string.IsNullOrEmpty(BeatmapSet?.OnlineInfo.Availability?.ExternalLink);
2019-06-21 00:09:40 +08:00
2019-06-11 17:29:42 +08:00
public BeatmapSetInfo BeatmapSet
{
get => beatmapSet;
set
{
2019-06-19 08:37:08 +08:00
if (value == beatmapSet)
return;
2019-06-11 17:29:42 +08:00
beatmapSet = value;
2019-06-19 19:43:18 +08:00
linkContainer.Clear();
2019-06-21 00:09:40 +08:00
if (downloadDisabled || hasExternalLink)
{
Show();
2019-06-19 09:27:31 +08:00
updateText();
2019-06-21 00:09:40 +08:00
}
else Hide();
2019-06-11 17:29:42 +08:00
}
}
2019-06-19 19:43:18 +08:00
private readonly TextFlowContainer textContainer;
private readonly LinkFlowContainer linkContainer;
2019-06-11 17:29:42 +08:00
public BeatmapNotAvailable()
{
RelativeSizeAxes = Axes.X;
AutoSizeAxes = Axes.Y;
Padding = new MarginPadding { Top = 10, Right = 20 };
Children = new Drawable[]
{
new Box
{
RelativeSizeAxes = Axes.Both,
Colour = Color4.Black.Opacity(0.6f),
},
new FillFlowContainer
{
RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y,
Direction = FillDirection.Vertical,
2019-06-19 22:55:36 +08:00
Padding = new MarginPadding(10),
Children = new Drawable[]
{
2019-06-21 19:18:20 +08:00
textContainer = new TextFlowContainer(t => t.Font = OsuFont.GetFont(size: 14, weight: FontWeight.Medium))
{
2019-06-19 19:43:18 +08:00
Direction = FillDirection.Full,
RelativeSizeAxes = Axes.X,
2019-06-19 19:43:18 +08:00
AutoSizeAxes = Axes.Y,
Colour = Color4.Orange,
},
2019-06-21 19:18:20 +08:00
linkContainer = new LinkFlowContainer(t => t.Font = OsuFont.GetFont(size: 10))
{
Direction = FillDirection.Full,
RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y,
2019-06-19 22:55:36 +08:00
Padding = new MarginPadding { Top = 10 },
},
},
},
};
2019-06-11 17:29:42 +08:00
}
2019-06-19 08:37:08 +08:00
private void updateText()
2019-06-11 17:29:42 +08:00
{
2019-06-21 00:09:40 +08:00
textContainer.Text = downloadDisabled
2019-06-11 17:29:42 +08:00
? "This beatmap is currently not available for download."
: "Portions of this beatmap have been removed at the request of the creator or a third-party rights holder.";
2019-06-21 00:09:40 +08:00
if (hasExternalLink)
2019-06-19 19:43:18 +08:00
linkContainer.AddLink("Check here for more information.", BeatmapSet.OnlineInfo.Availability.ExternalLink);
}
}
}