2019-06-10 17:17:44 +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.
|
|
|
|
|
|
2022-06-17 07:37:17 +00:00
|
|
|
|
#nullable disable
|
|
|
|
|
|
2019-06-10 17:17:44 +00:00
|
|
|
|
using osu.Framework.Extensions.Color4Extensions;
|
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
|
using osu.Framework.Graphics.Containers;
|
|
|
|
|
using osu.Framework.Graphics.Shapes;
|
|
|
|
|
using osu.Game.Graphics;
|
|
|
|
|
using osu.Game.Graphics.Containers;
|
2021-10-29 08:58:46 +00:00
|
|
|
|
using osu.Game.Online.API.Requests.Responses;
|
2022-01-28 04:53:48 +00:00
|
|
|
|
using osu.Game.Resources.Localisation.Web;
|
2019-06-10 17:17:44 +00:00
|
|
|
|
using osuTK.Graphics;
|
|
|
|
|
|
|
|
|
|
namespace osu.Game.Overlays.BeatmapSet
|
|
|
|
|
{
|
2022-11-24 05:32:20 +00:00
|
|
|
|
public partial class BeatmapAvailability : Container
|
2019-06-10 17:17:44 +00:00
|
|
|
|
{
|
2021-10-29 08:58:46 +00:00
|
|
|
|
private APIBeatmapSet beatmapSet;
|
2019-06-10 17:17:44 +00:00
|
|
|
|
|
2021-10-29 08:58:46 +00:00
|
|
|
|
private bool downloadDisabled => BeatmapSet?.Availability.DownloadDisabled ?? false;
|
|
|
|
|
private bool hasExternalLink => !string.IsNullOrEmpty(BeatmapSet?.Availability.ExternalLink);
|
2019-06-20 16:09:40 +00:00
|
|
|
|
|
2019-06-27 03:33:14 +00:00
|
|
|
|
private readonly LinkFlowContainer textContainer;
|
2019-06-18 22:43:28 +00:00
|
|
|
|
|
2019-06-27 02:40:22 +00:00
|
|
|
|
public BeatmapAvailability()
|
2019-06-10 17:17:44 +00:00
|
|
|
|
{
|
2019-06-13 14:32:27 +00:00
|
|
|
|
RelativeSizeAxes = Axes.X;
|
|
|
|
|
AutoSizeAxes = Axes.Y;
|
|
|
|
|
Padding = new MarginPadding { Top = 10, Right = 20 };
|
2019-06-10 17:17:44 +00:00
|
|
|
|
|
|
|
|
|
Children = new Drawable[]
|
|
|
|
|
{
|
|
|
|
|
new Box
|
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
2019-06-13 14:32:27 +00:00
|
|
|
|
Colour = Color4.Black.Opacity(0.6f),
|
2019-06-10 17:17:44 +00:00
|
|
|
|
},
|
2019-06-27 03:34:22 +00:00
|
|
|
|
textContainer = new LinkFlowContainer(t => t.Font = OsuFont.GetFont(size: 14))
|
2019-06-10 17:17:44 +00:00
|
|
|
|
{
|
2019-06-27 03:34:22 +00:00
|
|
|
|
Direction = FillDirection.Full,
|
2019-06-13 14:32:27 +00:00
|
|
|
|
RelativeSizeAxes = Axes.X,
|
|
|
|
|
AutoSizeAxes = Axes.Y,
|
2019-06-19 14:55:36 +00:00
|
|
|
|
Padding = new MarginPadding(10),
|
2019-06-10 17:17:44 +00:00
|
|
|
|
},
|
|
|
|
|
};
|
2019-06-11 09:29:42 +00:00
|
|
|
|
}
|
|
|
|
|
|
2021-10-29 08:58:46 +00:00
|
|
|
|
public APIBeatmapSet BeatmapSet
|
2019-06-27 03:33:14 +00:00
|
|
|
|
{
|
|
|
|
|
get => beatmapSet;
|
2019-06-27 03:34:22 +00:00
|
|
|
|
|
2019-06-27 03:33:14 +00:00
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
if (value == beatmapSet)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
beatmapSet = value;
|
|
|
|
|
|
|
|
|
|
if (downloadDisabled || hasExternalLink)
|
|
|
|
|
{
|
|
|
|
|
Show();
|
|
|
|
|
updateText();
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
Hide();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2019-06-19 00:37:08 +00:00
|
|
|
|
private void updateText()
|
2019-06-11 09:29:42 +00:00
|
|
|
|
{
|
2019-06-27 03:33:14 +00:00
|
|
|
|
textContainer.Clear();
|
|
|
|
|
textContainer.AddParagraph(downloadDisabled
|
2022-01-28 04:53:48 +00:00
|
|
|
|
? BeatmapsetsStrings.AvailabilityDisabled
|
|
|
|
|
: BeatmapsetsStrings.AvailabilityPartsRemoved, t => t.Colour = Color4.Orange);
|
2019-06-11 09:29:42 +00:00
|
|
|
|
|
2019-06-20 16:09:40 +00:00
|
|
|
|
if (hasExternalLink)
|
2019-06-27 03:33:14 +00:00
|
|
|
|
{
|
|
|
|
|
textContainer.NewParagraph();
|
|
|
|
|
textContainer.NewParagraph();
|
2022-01-28 04:53:48 +00:00
|
|
|
|
textContainer.AddLink(BeatmapsetsStrings.AvailabilityMoreInfo, BeatmapSet.Availability.ExternalLink, creationParameters: t => t.Font = OsuFont.GetFont(size: 10));
|
2019-06-27 03:33:14 +00:00
|
|
|
|
}
|
2019-06-10 17:17:44 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|