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-04-13 09:19:50 +00:00
|
|
|
|
|
2021-10-17 12:42:04 +00:00
|
|
|
|
using osu.Framework.Allocation;
|
2021-07-21 11:15:07 +00:00
|
|
|
|
using osu.Framework.Extensions;
|
|
|
|
|
using osu.Framework.Extensions.LocalisationExtensions;
|
2018-03-27 00:04:45 +00:00
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
|
using osu.Framework.Graphics.Containers;
|
2022-08-02 07:30:14 +00:00
|
|
|
|
using osu.Framework.Graphics.Cursor;
|
2018-03-27 00:04:45 +00:00
|
|
|
|
using osu.Framework.Graphics.Shapes;
|
2022-08-02 07:30:14 +00:00
|
|
|
|
using osu.Framework.Localisation;
|
2019-02-12 04:04:46 +00:00
|
|
|
|
using osu.Game.Graphics;
|
2018-03-27 00:04:45 +00:00
|
|
|
|
using osu.Game.Graphics.Sprites;
|
2022-08-02 07:30:14 +00:00
|
|
|
|
using osu.Game.Localisation;
|
2021-10-17 12:42:04 +00:00
|
|
|
|
using osu.Game.Overlays;
|
2018-11-20 07:51:59 +00:00
|
|
|
|
using osuTK.Graphics;
|
2018-04-13 09:19:50 +00:00
|
|
|
|
|
2018-03-27 00:04:45 +00:00
|
|
|
|
namespace osu.Game.Beatmaps.Drawables
|
|
|
|
|
{
|
2022-08-02 07:30:14 +00:00
|
|
|
|
public partial class BeatmapSetOnlineStatusPill : CircularContainer, IHasTooltip
|
2018-03-27 00:04:45 +00:00
|
|
|
|
{
|
2021-11-24 09:42:47 +00:00
|
|
|
|
private BeatmapOnlineStatus status;
|
2018-09-20 03:35:07 +00:00
|
|
|
|
|
2021-11-24 09:42:47 +00:00
|
|
|
|
public BeatmapOnlineStatus Status
|
2018-03-27 00:04:45 +00:00
|
|
|
|
{
|
2018-09-13 06:54:58 +00:00
|
|
|
|
get => status;
|
2018-03-27 00:04:45 +00:00
|
|
|
|
set
|
|
|
|
|
{
|
2018-09-20 03:35:07 +00:00
|
|
|
|
if (status == value)
|
|
|
|
|
return;
|
2019-02-28 04:31:40 +00:00
|
|
|
|
|
2018-03-27 00:04:45 +00:00
|
|
|
|
status = value;
|
2018-04-13 09:19:50 +00:00
|
|
|
|
|
2021-10-17 12:42:04 +00:00
|
|
|
|
if (IsLoaded)
|
|
|
|
|
updateState();
|
2018-03-27 00:04:45 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2018-04-13 09:19:50 +00:00
|
|
|
|
|
2018-09-20 03:35:07 +00:00
|
|
|
|
public float TextSize
|
|
|
|
|
{
|
2019-02-12 04:04:46 +00:00
|
|
|
|
get => statusText.Font.Size;
|
2019-02-20 10:32:30 +00:00
|
|
|
|
set => statusText.Font = statusText.Font.With(size: value);
|
2018-09-20 03:35:07 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public MarginPadding TextPadding
|
|
|
|
|
{
|
|
|
|
|
get => statusText.Padding;
|
|
|
|
|
set => statusText.Padding = value;
|
|
|
|
|
}
|
|
|
|
|
|
2021-10-17 12:42:04 +00:00
|
|
|
|
private readonly OsuSpriteText statusText;
|
|
|
|
|
private readonly Box background;
|
|
|
|
|
|
|
|
|
|
[Resolved]
|
|
|
|
|
private OsuColour colours { get; set; } = null!;
|
|
|
|
|
|
|
|
|
|
[Resolved(CanBeNull = true)]
|
|
|
|
|
private OverlayColourProvider? colourProvider { get; set; }
|
2020-02-05 15:31:14 +00:00
|
|
|
|
|
2018-09-20 03:35:07 +00:00
|
|
|
|
public BeatmapSetOnlineStatusPill()
|
2018-03-27 00:04:45 +00:00
|
|
|
|
{
|
|
|
|
|
Masking = true;
|
2018-04-13 09:19:50 +00:00
|
|
|
|
|
2018-03-27 00:04:45 +00:00
|
|
|
|
Children = new Drawable[]
|
|
|
|
|
{
|
2020-02-05 15:31:14 +00:00
|
|
|
|
background = new Box
|
2018-03-27 00:04:45 +00:00
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
|
Colour = Color4.Black,
|
|
|
|
|
},
|
|
|
|
|
statusText = new OsuSpriteText
|
|
|
|
|
{
|
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
|
Origin = Anchor.Centre,
|
2019-02-12 04:04:46 +00:00
|
|
|
|
Font = OsuFont.GetFont(weight: FontWeight.Bold)
|
2018-03-27 00:04:45 +00:00
|
|
|
|
},
|
|
|
|
|
};
|
2018-09-13 06:54:58 +00:00
|
|
|
|
|
2021-11-24 09:42:47 +00:00
|
|
|
|
Status = BeatmapOnlineStatus.None;
|
2021-10-17 12:42:04 +00:00
|
|
|
|
TextPadding = new MarginPadding { Horizontal = 5, Bottom = 1 };
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void LoadComplete()
|
|
|
|
|
{
|
|
|
|
|
base.LoadComplete();
|
|
|
|
|
updateState();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void updateState()
|
|
|
|
|
{
|
2021-11-24 09:42:47 +00:00
|
|
|
|
Alpha = Status == BeatmapOnlineStatus.None ? 0 : 1;
|
2021-10-17 12:42:04 +00:00
|
|
|
|
|
|
|
|
|
statusText.Text = Status.GetLocalisableDescription().ToUpper();
|
|
|
|
|
|
|
|
|
|
if (colourProvider != null)
|
2021-11-24 09:42:47 +00:00
|
|
|
|
statusText.Colour = status == BeatmapOnlineStatus.Graveyard ? colourProvider.Background1 : colourProvider.Background3;
|
2021-10-17 12:42:04 +00:00
|
|
|
|
else
|
2021-12-10 05:15:00 +00:00
|
|
|
|
statusText.Colour = status == BeatmapOnlineStatus.Graveyard ? colours.GreySeaFoamLight : Color4.Black;
|
2021-10-17 12:42:04 +00:00
|
|
|
|
|
2021-12-10 05:15:00 +00:00
|
|
|
|
background.Colour = OsuColour.ForBeatmapSetOnlineStatus(Status) ?? colourProvider?.Light1 ?? colours.GreySeaFoamLighter;
|
2018-03-27 00:04:45 +00:00
|
|
|
|
}
|
2022-08-02 07:30:14 +00:00
|
|
|
|
|
|
|
|
|
public LocalisableString TooltipText
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
switch (Status)
|
|
|
|
|
{
|
|
|
|
|
case BeatmapOnlineStatus.LocallyModified:
|
|
|
|
|
return SongSelectStrings.LocallyModifiedTooltip;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return string.Empty;
|
|
|
|
|
}
|
|
|
|
|
}
|
2018-03-27 00:04:45 +00:00
|
|
|
|
}
|
|
|
|
|
}
|