1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-06 18:10:04 +08:00
osu-lazer/osu.Game/Screens/Play/HUD/PlayerSettingsOverlay.cs

75 lines
2.3 KiB
C#
Raw Normal View History

// 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 17:19:50 +08:00
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
2018-10-02 11:02:47 +08:00
using osu.Framework.Input.Events;
2018-11-20 15:51:59 +08:00
using osuTK;
2018-04-13 17:19:50 +08:00
using osu.Game.Screens.Play.PlayerSettings;
2018-11-20 15:51:59 +08:00
using osuTK.Input;
2018-04-13 17:19:50 +08:00
namespace osu.Game.Screens.Play.HUD
{
public class PlayerSettingsOverlay : VisibilityContainer
{
private const int fade_duration = 200;
public bool ReplayLoaded;
public readonly PlaybackSettings PlaybackSettings;
2019-02-28 12:31:40 +08:00
2018-04-13 17:19:50 +08:00
public readonly VisualSettings VisualSettings;
2018-04-13 17:19:50 +08:00
//public readonly CollectionSettings CollectionSettings;
2018-04-13 17:19:50 +08:00
//public readonly DiscussionSettings DiscussionSettings;
public PlayerSettingsOverlay()
{
AlwaysPresent = true;
RelativeSizeAxes = Axes.Both;
Child = new FillFlowContainer<PlayerSettingsGroup>
{
Anchor = Anchor.TopRight,
Origin = Anchor.TopRight,
AutoSizeAxes = Axes.Both,
Direction = FillDirection.Vertical,
Spacing = new Vector2(0, 20),
Margin = new MarginPadding { Top = 100, Right = 10 },
Children = new PlayerSettingsGroup[]
{
//CollectionSettings = new CollectionSettings(),
//DiscussionSettings = new DiscussionSettings(),
PlaybackSettings = new PlaybackSettings(),
VisualSettings = new VisualSettings { Expanded = false }
}
};
Show();
2018-04-13 17:19:50 +08:00
}
protected override void PopIn() => this.FadeIn(fade_duration);
protected override void PopOut() => this.FadeOut(fade_duration);
//We want to handle keyboard inputs all the time in order to trigger ToggleVisibility() when not visible
public override bool PropagateNonPositionalInputSubTree => true;
2018-04-13 17:19:50 +08:00
2018-10-02 11:02:47 +08:00
protected override bool OnKeyDown(KeyDownEvent e)
2018-04-13 17:19:50 +08:00
{
2018-10-02 11:02:47 +08:00
if (e.Repeat) return false;
2018-04-13 17:19:50 +08:00
if (e.ControlPressed)
2018-04-13 17:19:50 +08:00
{
2018-10-02 11:02:47 +08:00
if (e.Key == Key.H && ReplayLoaded)
2018-04-13 17:19:50 +08:00
{
ToggleVisibility();
return true;
}
}
2018-10-02 11:02:47 +08:00
return base.OnKeyDown(e);
2018-04-13 17:19:50 +08:00
}
}
}