1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-16 10:17:36 +08:00
osu-lazer/osu.Game/Overlays/BeatmapSet/BeatmapAvailability.cs

87 lines
2.7 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.
2022-06-17 15:37:17 +08:00
#nullable disable
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;
using osu.Game.Online.API.Requests.Responses;
using osu.Game.Resources.Localisation.Web;
using osuTK.Graphics;
namespace osu.Game.Overlays.BeatmapSet
{
2022-11-24 13:32:20 +08:00
public partial class BeatmapAvailability : Container
{
private APIBeatmapSet beatmapSet;
private bool downloadDisabled => BeatmapSet?.Availability.DownloadDisabled ?? false;
private bool hasExternalLink => !string.IsNullOrEmpty(BeatmapSet?.Availability.ExternalLink);
2019-06-21 00:09:40 +08:00
2019-06-27 11:33:14 +08:00
private readonly LinkFlowContainer textContainer;
2019-06-27 10:40:22 +08:00
public BeatmapAvailability()
{
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),
},
2019-06-27 11:34:22 +08:00
textContainer = new LinkFlowContainer(t => t.Font = OsuFont.GetFont(size: 14))
{
2019-06-27 11:34:22 +08:00
Direction = FillDirection.Full,
RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y,
2019-06-19 22:55:36 +08:00
Padding = new MarginPadding(10),
},
};
2019-06-11 17:29:42 +08:00
}
public APIBeatmapSet BeatmapSet
2019-06-27 11:33:14 +08:00
{
get => beatmapSet;
2019-06-27 11:34:22 +08:00
2019-06-27 11:33:14 +08:00
set
{
if (value == beatmapSet)
return;
beatmapSet = value;
if (downloadDisabled || hasExternalLink)
{
Show();
updateText();
}
else
Hide();
}
}
2019-06-19 08:37:08 +08:00
private void updateText()
2019-06-11 17:29:42 +08:00
{
2019-06-27 11:33:14 +08:00
textContainer.Clear();
textContainer.AddParagraph(downloadDisabled
? BeatmapsetsStrings.AvailabilityDisabled
: BeatmapsetsStrings.AvailabilityPartsRemoved, t => t.Colour = Color4.Orange);
2019-06-11 17:29:42 +08:00
2019-06-21 00:09:40 +08:00
if (hasExternalLink)
2019-06-27 11:33:14 +08:00
{
textContainer.NewParagraph();
textContainer.NewParagraph();
textContainer.AddLink(BeatmapsetsStrings.AvailabilityMoreInfo, BeatmapSet.Availability.ExternalLink, creationParameters: t => t.Font = OsuFont.GetFont(size: 10));
2019-06-27 11:33:14 +08:00
}
}
}
}