2021-09-20 03:09:03 +08: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 15:37:17 +08:00
|
|
|
#nullable disable
|
|
|
|
|
2021-09-17 17:30:38 +08:00
|
|
|
using osu.Framework.Allocation;
|
|
|
|
using osu.Framework.Extensions.Color4Extensions;
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
using osu.Framework.Graphics.Effects;
|
|
|
|
using osu.Framework.Graphics.UserInterface;
|
|
|
|
using osu.Game.Graphics;
|
|
|
|
using osu.Game.Graphics.UserInterface;
|
2023-01-14 07:31:27 +08:00
|
|
|
using osu.Game.Users.Drawables;
|
2021-09-17 17:30:38 +08:00
|
|
|
using osuTK;
|
|
|
|
using osuTK.Graphics;
|
|
|
|
|
|
|
|
namespace osu.Game.Overlays.Login
|
|
|
|
{
|
2022-11-24 13:32:20 +08:00
|
|
|
public partial class UserDropdown : OsuEnumDropdown<UserAction>
|
2021-09-17 17:30:38 +08:00
|
|
|
{
|
|
|
|
protected override DropdownHeader CreateHeader() => new UserDropdownHeader();
|
|
|
|
|
|
|
|
protected override DropdownMenu CreateMenu() => new UserDropdownMenu();
|
|
|
|
|
|
|
|
public Color4 StatusColour
|
|
|
|
{
|
|
|
|
set
|
|
|
|
{
|
|
|
|
if (Header is UserDropdownHeader h)
|
|
|
|
h.StatusColour = value;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-11-24 13:32:20 +08:00
|
|
|
protected partial class UserDropdownMenu : OsuDropdownMenu
|
2021-09-17 17:30:38 +08:00
|
|
|
{
|
|
|
|
public UserDropdownMenu()
|
|
|
|
{
|
|
|
|
Masking = true;
|
|
|
|
CornerRadius = 5;
|
|
|
|
|
|
|
|
Margin = new MarginPadding { Bottom = 5 };
|
|
|
|
|
|
|
|
EdgeEffect = new EdgeEffectParameters
|
|
|
|
{
|
|
|
|
Type = EdgeEffectType.Shadow,
|
|
|
|
Colour = Color4.Black.Opacity(0.25f),
|
|
|
|
Radius = 4,
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
[BackgroundDependencyLoader]
|
|
|
|
private void load(OsuColour colours)
|
|
|
|
{
|
|
|
|
BackgroundColour = colours.Gray3;
|
2021-10-20 04:47:18 +08:00
|
|
|
SelectionColour = colours.Gray4;
|
|
|
|
HoverColour = colours.Gray5;
|
2021-09-17 17:30:38 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
protected override DrawableDropdownMenuItem CreateDrawableDropdownMenuItem(MenuItem item) => new DrawableUserDropdownMenuItem(item);
|
|
|
|
|
2022-11-24 13:32:20 +08:00
|
|
|
private partial class DrawableUserDropdownMenuItem : DrawableOsuDropdownMenuItem
|
2021-09-17 17:30:38 +08:00
|
|
|
{
|
|
|
|
public DrawableUserDropdownMenuItem(MenuItem item)
|
|
|
|
: base(item)
|
|
|
|
{
|
|
|
|
Foreground.Padding = new MarginPadding { Top = 5, Bottom = 5, Left = 10, Right = 5 };
|
|
|
|
CornerRadius = 5;
|
|
|
|
}
|
|
|
|
|
|
|
|
protected override Drawable CreateContent() => new Content
|
|
|
|
{
|
|
|
|
Label = { Margin = new MarginPadding { Left = UserDropdownHeader.LABEL_LEFT_MARGIN - 11 } }
|
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-11-24 13:32:20 +08:00
|
|
|
private partial class UserDropdownHeader : OsuDropdownHeader
|
2021-09-17 17:30:38 +08:00
|
|
|
{
|
|
|
|
public const float LABEL_LEFT_MARGIN = 20;
|
|
|
|
|
2023-01-14 07:31:27 +08:00
|
|
|
private readonly StatusIcon statusIcon;
|
2021-09-17 17:30:38 +08:00
|
|
|
|
|
|
|
public Color4 StatusColour
|
|
|
|
{
|
|
|
|
set => statusIcon.FadeColour(value, 500, Easing.OutQuint);
|
|
|
|
}
|
|
|
|
|
|
|
|
public UserDropdownHeader()
|
|
|
|
{
|
|
|
|
Foreground.Padding = new MarginPadding { Left = 10, Right = 10 };
|
|
|
|
Margin = new MarginPadding { Bottom = 5 };
|
|
|
|
Masking = true;
|
|
|
|
CornerRadius = 5;
|
|
|
|
EdgeEffect = new EdgeEffectParameters
|
|
|
|
{
|
|
|
|
Type = EdgeEffectType.Shadow,
|
|
|
|
Colour = Color4.Black.Opacity(0.25f),
|
|
|
|
Radius = 4,
|
|
|
|
};
|
|
|
|
|
|
|
|
Icon.Size = new Vector2(14);
|
|
|
|
Icon.Margin = new MarginPadding(0);
|
|
|
|
|
2023-01-14 07:31:27 +08:00
|
|
|
Foreground.Add(statusIcon = new StatusIcon
|
2021-09-17 17:30:38 +08:00
|
|
|
{
|
|
|
|
Anchor = Anchor.CentreLeft,
|
|
|
|
Origin = Anchor.CentreLeft,
|
|
|
|
Size = new Vector2(14),
|
|
|
|
});
|
|
|
|
|
|
|
|
Text.Margin = new MarginPadding { Left = LABEL_LEFT_MARGIN };
|
|
|
|
}
|
|
|
|
|
|
|
|
[BackgroundDependencyLoader]
|
|
|
|
private void load(OsuColour colours)
|
|
|
|
{
|
|
|
|
BackgroundColour = colours.Gray3;
|
2021-10-17 00:33:17 +08:00
|
|
|
BackgroundColourHover = colours.Gray5;
|
2021-09-17 17:30:38 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|