1
0
mirror of https://github.com/ppy/osu.git synced 2026-05-18 11:20:24 +08:00
Files
osu-lazer/osu.Game/Screens/SelectV2/PanelGroupRankedStatus.cs
T
Bartłomiej Dach 3070a0068a Change graveyard colour yet again
Editorial decision. The "brighter" colour was still too dark to be able
to even see any semblance of shade, or the triangles in the background.
2025-10-10 12:34:28 +02:00

217 lines
7.6 KiB
C#

// 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 System;
using System.Diagnostics;
using osu.Framework.Allocation;
using osu.Framework.Extensions.Color4Extensions;
using osu.Framework.Extensions.LocalisationExtensions;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Colour;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes;
using osu.Framework.Graphics.Sprites;
using osu.Framework.Graphics.UserInterface;
using osu.Game.Beatmaps;
using osu.Game.Graphics;
using osu.Game.Graphics.Backgrounds;
using osu.Game.Graphics.Sprites;
using osu.Game.Graphics.UserInterface;
using osu.Game.Overlays;
using osuTK;
using osuTK.Graphics;
using WebCommonStrings = osu.Game.Resources.Localisation.Web.CommonStrings;
namespace osu.Game.Screens.SelectV2
{
public partial class PanelGroupRankedStatus : Panel
{
public const float HEIGHT = PanelGroup.HEIGHT;
[Resolved]
private OverlayColourProvider colourProvider { get; set; } = null!;
private Drawable iconContainer = null!;
private Box backgroundBorder = null!;
private Box contentBackground = null!;
private OsuSpriteText starRatingText = null!;
private CircularContainer countPill = null!;
private OsuSpriteText countText = null!;
private TrianglesV2 triangles = null!;
private Box glow = null!;
[Resolved]
private OsuColour colours { get; set; } = null!;
[BackgroundDependencyLoader]
private void load()
{
Height = PanelGroup.HEIGHT;
Icon = iconContainer = new Container
{
AlwaysPresent = true,
RelativeSizeAxes = Axes.Y,
Alpha = 0f,
Child = new SpriteIcon
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Icon = FontAwesome.Solid.ChevronDown,
Size = new Vector2(12),
},
};
Background = backgroundBorder = new Box
{
RelativeSizeAxes = Axes.Both,
Colour = colourProvider.Highlight1,
};
AccentColour = colourProvider.Highlight1;
Content.Children = new Drawable[]
{
contentBackground = new Box
{
RelativeSizeAxes = Axes.Both,
},
triangles = new TrianglesV2
{
RelativeSizeAxes = Axes.Both,
Thickness = 0.02f,
SpawnRatio = 0.6f,
Colour = ColourInfo.GradientHorizontal(colourProvider.Background6, colourProvider.Background5)
},
glow = new Box
{
RelativeSizeAxes = Axes.Both,
Width = 0.5f,
Colour = ColourInfo.GradientHorizontal(colourProvider.Highlight1, colourProvider.Highlight1.Opacity(0f)),
},
new FillFlowContainer
{
Anchor = Anchor.CentreLeft,
Origin = Anchor.CentreLeft,
AutoSizeAxes = Axes.Both,
Spacing = new Vector2(10f, 0f),
Margin = new MarginPadding { Left = 10f },
Children = new Drawable[]
{
starRatingText = new OsuSpriteText
{
Anchor = Anchor.CentreLeft,
Origin = Anchor.CentreLeft,
UseFullGlyphHeight = false,
Font = OsuFont.Style.Heading2,
}
}
},
countPill = new CircularContainer
{
Anchor = Anchor.CentreRight,
Origin = Anchor.CentreRight,
Size = new Vector2(50f, 14f),
Margin = new MarginPadding { Right = 30f },
Masking = true,
Children = new Drawable[]
{
new Box
{
RelativeSizeAxes = Axes.Both,
Colour = Color4.Black.Opacity(0.7f),
},
countText = new OsuSpriteText
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Font = OsuFont.Style.Caption1.With(weight: FontWeight.Bold),
UseFullGlyphHeight = false,
}
},
}
};
}
protected override void LoadComplete()
{
base.LoadComplete();
Expanded.BindValueChanged(_ => onExpanded(), true);
}
private Color4 statusColour;
protected override void PrepareForUse()
{
base.PrepareForUse();
Debug.Assert(Item != null);
var group = (RankedStatusGroupDefinition)Item.Model;
BeatmapOnlineStatus status = group.Status;
statusColour = OsuColour.ForBeatmapSetOnlineStatus(status) ?? throw new ArgumentOutOfRangeException(nameof(status), status, null);
switch (status)
{
case BeatmapOnlineStatus.Graveyard:
// special override - the colour returned by `ForBeatmapSetOnlineStatus()` for graveyard is pitch black and doesn't allow for any contrast
statusColour = colours.Gray5;
iconContainer.Colour = Color4.White;
break;
default:
iconContainer.Colour = colourProvider.Background5;
break;
}
AccentColour = statusColour;
backgroundBorder.Colour = statusColour;
contentBackground.Colour = statusColour.Darken(1f);
glow.Colour = ColourInfo.GradientHorizontal(statusColour, statusColour.Opacity(0f));
starRatingText.Text = group.Title;
ColourInfo colour = ColourInfo.GradientHorizontal(statusColour.Darken(0.6f), statusColour.Darken(0.8f));
triangles.Colour = colour;
countText.Text = Item.NestedItemCount.ToLocalisableString(@"N0");
onExpanded();
}
private void onExpanded()
{
const float duration = 500;
iconContainer.ResizeWidthTo(Expanded.Value ? 20f : 5f, duration, Easing.OutQuint);
iconContainer.FadeTo(Expanded.Value ? 1f : 0f, duration, Easing.OutQuint);
glow.FadeTo(Expanded.Value ? 0.4f : 0, duration, Easing.OutQuint);
}
protected override void Update()
{
base.Update();
// Move the count pill in the opposite direction to keep it pinned to the screen regardless of the X position of TopLevelContent.
countPill.X = -TopLevelContent.X;
}
public override MenuItem[] ContextMenuItems
{
get
{
if (Item == null)
return Array.Empty<MenuItem>();
return new MenuItem[]
{
new OsuMenuItem(Expanded.Value ? WebCommonStrings.ButtonsCollapse.ToSentence() : WebCommonStrings.ButtonsExpand.ToSentence(), MenuItemType.Highlighted, () => TriggerClick())
};
}
}
}
}