mirror of
https://github.com/ppy/osu.git
synced 2024-12-05 10:33:22 +08:00
Merge pull request #30749 from Sheppsu/multi-spectator-settings-sidebar
Add player settings to multi spectator screen
This commit is contained in:
commit
52b8753a12
@ -184,7 +184,7 @@ namespace osu.Game.Overlays
|
||||
content.ResizeHeightTo(0, animate ? transition_duration : 0, Easing.OutQuint);
|
||||
}
|
||||
|
||||
headerContent.FadeColour(Expanded.Value ? Color4.White : OsuColour.Gray(0.5f), 200, Easing.OutQuint);
|
||||
headerContent.FadeColour(Expanded.Value ? Color4.White : OsuColour.Gray(0.7f), 200, Easing.OutQuint);
|
||||
}
|
||||
|
||||
private void updateFadeState()
|
||||
|
@ -126,7 +126,8 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer.Spectate
|
||||
syncManager = new SpectatorSyncManager(masterClockContainer)
|
||||
{
|
||||
ReadyToStart = performInitialSeek,
|
||||
}
|
||||
},
|
||||
new PlayerSettingsOverlay()
|
||||
};
|
||||
|
||||
for (int i = 0; i < Users.Count; i++)
|
||||
|
@ -1,46 +1,102 @@
|
||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||
// 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 osu.Framework.Extensions.Color4Extensions;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Colour;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osuTK;
|
||||
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;
|
||||
using osu.Game.Screens.Play.PlayerSettings;
|
||||
using osuTK;
|
||||
using osuTK.Graphics;
|
||||
|
||||
namespace osu.Game.Screens.Play.HUD
|
||||
{
|
||||
public partial class PlayerSettingsOverlay : VisibilityContainer
|
||||
public partial class PlayerSettingsOverlay : ExpandingContainer
|
||||
{
|
||||
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;
|
||||
|
||||
private const int fade_duration = 200;
|
||||
|
||||
public readonly VisualSettings VisualSettings;
|
||||
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;
|
||||
|
||||
protected override Container<Drawable> Content => content;
|
||||
|
||||
private readonly FillFlowContainer content;
|
||||
|
||||
public PlayerSettingsOverlay()
|
||||
{
|
||||
Anchor = Anchor.TopRight;
|
||||
Origin = Anchor.TopRight;
|
||||
AutoSizeAxes = Axes.Both;
|
||||
private readonly IconButton button;
|
||||
|
||||
InternalChild = content = new FillFlowContainer
|
||||
private InputManager inputManager = null!;
|
||||
|
||||
public PlayerSettingsOverlay()
|
||||
: base(0, EXPANDED_WIDTH)
|
||||
{
|
||||
Origin = Anchor.TopRight;
|
||||
Anchor = Anchor.TopRight;
|
||||
|
||||
base.Content.Add(content = new FillFlowContainer
|
||||
{
|
||||
Anchor = Anchor.TopRight,
|
||||
Origin = Anchor.TopRight,
|
||||
AutoSizeAxes = Axes.Both,
|
||||
Direction = FillDirection.Vertical,
|
||||
Spacing = new Vector2(0, 20),
|
||||
Margin = new MarginPadding(padding),
|
||||
Children = new PlayerSettingsGroup[]
|
||||
{
|
||||
VisualSettings = new VisualSettings { Expanded = { Value = false } },
|
||||
new AudioSettings { Expanded = { Value = false } }
|
||||
}
|
||||
};
|
||||
});
|
||||
|
||||
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 PopIn() => this.FadeIn(fade_duration);
|
||||
protected override void PopOut() => this.FadeOut(fade_duration);
|
||||
protected override void LoadComplete()
|
||||
{
|
||||
base.LoadComplete();
|
||||
|
||||
inputManager = GetContainingInputManager()!;
|
||||
}
|
||||
|
||||
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.
|
||||
}
|
||||
|
||||
public void AddAtStart(PlayerSettingsGroup drawable) => content.Insert(-1, drawable);
|
||||
}
|
||||
|
@ -115,6 +115,8 @@ namespace osu.Game.Screens.Play
|
||||
|
||||
public HUDOverlay([CanBeNull] DrawableRuleset drawableRuleset, IReadOnlyList<Mod> mods, bool alwaysShowLeaderboard = true)
|
||||
{
|
||||
Container rightSettings;
|
||||
|
||||
this.drawableRuleset = drawableRuleset;
|
||||
this.mods = mods;
|
||||
|
||||
@ -146,7 +148,6 @@ namespace osu.Game.Screens.Play
|
||||
Children = new Drawable[]
|
||||
{
|
||||
ModDisplay = CreateModsContainer(),
|
||||
PlayerSettingsOverlay = CreatePlayerSettingsOverlay(),
|
||||
}
|
||||
},
|
||||
bottomRightElements = new FillFlowContainer
|
||||
@ -164,6 +165,14 @@ namespace osu.Game.Screens.Play
|
||||
HoldToQuit = CreateHoldForMenuButton(),
|
||||
}
|
||||
},
|
||||
rightSettings = new Container
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Children = new Drawable[]
|
||||
{
|
||||
PlayerSettingsOverlay = new PlayerSettingsOverlay(),
|
||||
}
|
||||
},
|
||||
LeaderboardFlow = new FillFlowContainer
|
||||
{
|
||||
AutoSizeAxes = Axes.Both,
|
||||
@ -173,7 +182,7 @@ namespace osu.Game.Screens.Play
|
||||
},
|
||||
};
|
||||
|
||||
hideTargets = new List<Drawable> { mainComponents, topRightElements };
|
||||
hideTargets = new List<Drawable> { mainComponents, topRightElements, rightSettings };
|
||||
|
||||
if (rulesetComponents != null)
|
||||
hideTargets.Add(rulesetComponents);
|
||||
@ -389,8 +398,6 @@ namespace osu.Game.Screens.Play
|
||||
Origin = Anchor.TopRight,
|
||||
};
|
||||
|
||||
protected PlayerSettingsOverlay CreatePlayerSettingsOverlay() => new PlayerSettingsOverlay();
|
||||
|
||||
public bool OnPressed(KeyBindingPressEvent<GlobalAction> e)
|
||||
{
|
||||
if (e.Repeat)
|
||||
|
Loading…
Reference in New Issue
Block a user