2024-11-27 16:47:42 +08:00
|
|
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
2019-01-24 16:43:03 +08:00
|
|
|
// See the LICENCE file in the repository root for full licence text.
|
2018-04-13 17:19:50 +08:00
|
|
|
|
2024-11-27 16:47:42 +08:00
|
|
|
using osu.Framework.Extensions.Color4Extensions;
|
2017-10-03 00:33:58 +08:00
|
|
|
using osu.Framework.Graphics;
|
2024-11-27 16:47:42 +08:00
|
|
|
using osu.Framework.Graphics.Colour;
|
2017-10-03 00:33:58 +08:00
|
|
|
using osu.Framework.Graphics.Containers;
|
2024-11-27 16:47:42 +08:00
|
|
|
using osu.Framework.Graphics.Shapes;
|
|
|
|
using osu.Framework.Graphics.Sprites;
|
|
|
|
using osu.Framework.Input;
|
|
|
|
using osu.Framework.Input.Events;
|
|
|
|
using osu.Game.Graphics.Containers;
|
|
|
|
using osu.Game.Graphics.UserInterface;
|
2018-01-14 03:25:09 +08:00
|
|
|
using osu.Game.Screens.Play.PlayerSettings;
|
2024-11-27 16:47:42 +08:00
|
|
|
using osuTK;
|
|
|
|
using osuTK.Graphics;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
2017-10-03 00:33:58 +08:00
|
|
|
namespace osu.Game.Screens.Play.HUD
|
|
|
|
{
|
2024-11-27 16:47:42 +08:00
|
|
|
public partial class PlayerSettingsOverlay : ExpandingContainer
|
2017-10-03 00:33:58 +08:00
|
|
|
{
|
2024-11-27 16:47:42 +08:00
|
|
|
public VisualSettings VisualSettings { get; private set; }
|
|
|
|
|
|
|
|
private const float padding = 10;
|
|
|
|
|
|
|
|
public const float EXPANDED_WIDTH = player_settings_width + padding * 2;
|
|
|
|
|
|
|
|
private const float player_settings_width = 270;
|
2024-12-01 17:44:26 +08:00
|
|
|
|
|
|
|
private const int fade_duration = 200;
|
2024-11-27 16:47:42 +08:00
|
|
|
|
|
|
|
public override void Show() => this.FadeIn(fade_duration);
|
|
|
|
public override void Hide() => this.FadeOut(fade_duration);
|
|
|
|
|
|
|
|
// we'll handle this ourselves because we have slightly custom logic.
|
|
|
|
protected override bool ExpandOnHover => false;
|
2019-03-06 19:30:14 +08:00
|
|
|
|
2024-01-12 15:12:02 +08:00
|
|
|
protected override Container<Drawable> Content => content;
|
|
|
|
|
|
|
|
private readonly FillFlowContainer content;
|
|
|
|
|
2024-11-27 16:47:42 +08:00
|
|
|
private readonly IconButton button;
|
|
|
|
|
|
|
|
private InputManager inputManager = null!;
|
|
|
|
|
2018-01-14 03:25:09 +08:00
|
|
|
public PlayerSettingsOverlay()
|
2024-11-27 16:47:42 +08:00
|
|
|
: base(0, EXPANDED_WIDTH)
|
2017-10-03 00:33:58 +08:00
|
|
|
{
|
2020-10-15 16:11:02 +08:00
|
|
|
Origin = Anchor.TopRight;
|
2024-11-27 16:47:42 +08:00
|
|
|
Anchor = Anchor.TopRight;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
2024-11-27 16:47:42 +08:00
|
|
|
base.Content.Add(content = new FillFlowContainer
|
2017-10-03 00:33:58 +08:00
|
|
|
{
|
|
|
|
AutoSizeAxes = Axes.Both,
|
|
|
|
Direction = FillDirection.Vertical,
|
|
|
|
Spacing = new Vector2(0, 20),
|
2024-11-27 16:47:42 +08:00
|
|
|
Margin = new MarginPadding(padding),
|
2018-01-16 01:52:52 +08:00
|
|
|
Children = new PlayerSettingsGroup[]
|
2017-10-03 00:33:58 +08:00
|
|
|
{
|
2023-06-09 16:58:44 +08:00
|
|
|
VisualSettings = new VisualSettings { Expanded = { Value = false } },
|
|
|
|
new AudioSettings { Expanded = { Value = false } }
|
2017-10-03 00:33:58 +08:00
|
|
|
}
|
2024-11-27 16:47:42 +08:00
|
|
|
});
|
|
|
|
|
|
|
|
AddInternal(button = new IconButton
|
|
|
|
{
|
|
|
|
Icon = FontAwesome.Solid.Cog,
|
|
|
|
Origin = Anchor.TopRight,
|
|
|
|
Anchor = Anchor.TopLeft,
|
|
|
|
Margin = new MarginPadding(5),
|
|
|
|
Action = () => Expanded.Toggle()
|
|
|
|
});
|
|
|
|
|
|
|
|
AddInternal(new Box
|
|
|
|
{
|
|
|
|
Colour = ColourInfo.GradientHorizontal(Color4.Black.Opacity(0), Color4.Black.Opacity(0.8f)),
|
|
|
|
Depth = float.MaxValue,
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
protected override void LoadComplete()
|
|
|
|
{
|
|
|
|
base.LoadComplete();
|
|
|
|
|
|
|
|
inputManager = GetContainingInputManager()!;
|
2017-10-03 00:33:58 +08:00
|
|
|
}
|
2018-04-13 17:19:50 +08:00
|
|
|
|
2024-11-27 16:47:42 +08:00
|
|
|
protected override void Update()
|
|
|
|
{
|
|
|
|
base.Update();
|
|
|
|
|
|
|
|
Expanded.Value = inputManager.CurrentState.Mouse.Position.X >= button.ScreenSpaceDrawQuad.TopLeft.X;
|
|
|
|
}
|
|
|
|
|
|
|
|
protected override void OnHoverLost(HoverLostEvent e)
|
|
|
|
{
|
|
|
|
// handle un-expanding manually because our children do weird hover blocking stuff.
|
|
|
|
}
|
2024-01-17 13:48:33 +08:00
|
|
|
|
2024-01-17 14:13:59 +08:00
|
|
|
public void AddAtStart(PlayerSettingsGroup drawable) => content.Insert(-1, drawable);
|
2017-10-03 00:33:58 +08:00
|
|
|
}
|
|
|
|
}
|