2019-01-24 17:43:03 +09: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 18:19:50 +09:00
|
|
|
|
|
2018-11-20 16:51:59 +09:00
|
|
|
|
using osuTK.Graphics;
|
2017-06-12 12:56:07 +03:00
|
|
|
|
using osu.Framework.Allocation;
|
|
|
|
|
using osu.Framework.Extensions.Color4Extensions;
|
|
|
|
|
using osu.Framework.Graphics;
|
2019-04-02 14:51:28 +09:00
|
|
|
|
using osu.Framework.Graphics.Effects;
|
2019-11-08 11:13:53 +09:00
|
|
|
|
using osu.Framework.Graphics.UserInterface;
|
2018-04-13 18:19:50 +09:00
|
|
|
|
|
2017-06-12 12:56:07 +03:00
|
|
|
|
namespace osu.Game.Graphics.UserInterface
|
|
|
|
|
{
|
2017-08-28 14:42:52 +09:00
|
|
|
|
public partial class OsuContextMenu : OsuMenu
|
2017-06-12 12:56:07 +03:00
|
|
|
|
{
|
2021-08-07 14:19:05 +02:00
|
|
|
|
[Resolved]
|
2024-11-28 06:41:43 +09:00
|
|
|
|
private OsuMenuSamples menuSamples { get; set; } = null!;
|
2018-04-13 18:19:50 +09:00
|
|
|
|
|
2025-02-05 16:24:13 +09:00
|
|
|
|
public OsuContextMenu(bool playSamples)
|
|
|
|
|
: base(Direction.Vertical, topLevelMenu: false, playSamples)
|
2017-06-12 12:56:07 +03:00
|
|
|
|
{
|
2017-09-04 09:10:04 +09:00
|
|
|
|
MaskingContainer.CornerRadius = 5;
|
|
|
|
|
MaskingContainer.EdgeEffect = new EdgeEffectParameters
|
2017-08-25 15:10:12 +09:00
|
|
|
|
{
|
|
|
|
|
Type = EdgeEffectType.Shadow,
|
|
|
|
|
Colour = Color4.Black.Opacity(0.1f),
|
|
|
|
|
Radius = 4,
|
|
|
|
|
};
|
2018-04-13 18:19:50 +09:00
|
|
|
|
|
2017-09-04 09:10:04 +09:00
|
|
|
|
ItemsContainer.Padding = new MarginPadding { Vertical = DrawableOsuMenuItem.MARGIN_VERTICAL };
|
2020-09-08 18:55:53 +09:00
|
|
|
|
|
|
|
|
|
MaxHeight = 250;
|
2017-08-25 15:10:12 +09:00
|
|
|
|
}
|
2018-04-13 18:19:50 +09:00
|
|
|
|
|
2017-08-25 15:10:12 +09:00
|
|
|
|
[BackgroundDependencyLoader]
|
2022-01-15 01:06:39 +01:00
|
|
|
|
private void load(OsuColour colours)
|
2017-08-25 15:10:12 +09:00
|
|
|
|
{
|
|
|
|
|
BackgroundColour = colours.ContextMenuGray;
|
2021-08-06 20:59:26 +09:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void AnimateOpen()
|
|
|
|
|
{
|
2025-02-05 16:24:13 +09:00
|
|
|
|
if (PlaySamples && !WasOpened)
|
|
|
|
|
menuSamples.PlayClickSample();
|
2021-08-06 20:59:26 +09:00
|
|
|
|
|
2025-02-05 16:24:13 +09:00
|
|
|
|
base.AnimateOpen();
|
2021-08-06 20:59:26 +09:00
|
|
|
|
}
|
2019-11-08 11:13:53 +09:00
|
|
|
|
|
2025-02-05 16:24:13 +09:00
|
|
|
|
protected override Menu CreateSubMenu() => new OsuContextMenu(false); // sub menu samples are handled by OsuMenu.OnSubmenuOpen.
|
2017-06-12 12:56:07 +03:00
|
|
|
|
}
|
2018-01-05 20:21:19 +09:00
|
|
|
|
}
|