Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion osu.Game.Tests/Visual/Gameplay/TestSceneReplayPlayer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ public void TestPlayerLoaderSettingsHover()
AddStep("move mouse to centre of screen", () => InputManager.MoveMouseTo(Player.ScreenSpaceDrawQuad.Centre));
AddUntilStep("wait for settings overlay hidden", () => settingsOverlay().Expanded.Value, () => Is.False);

PlayerSettingsOverlay settingsOverlay() => Player.ChildrenOfType<PlayerSettingsOverlay>().Single();
ReplaySettingsOverlay settingsOverlay() => Player.ChildrenOfType<ReplaySettingsOverlay>().Single();
}

private void loadPlayerWithBeatmap(IBeatmap? beatmap = null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ public void TestSpectatorPlayerInteractiveElementsHidden()
// components wrapped in skinnable target containers load asynchronously, potentially taking more than one frame to load.
// therefore use until step rather than direct assert to account for that.
AddUntilStep("all interactive elements removed", () => this.ChildrenOfType<Player>().All(p =>
!p.ChildrenOfType<PlayerSettingsOverlay>().Any() &&
!p.ChildrenOfType<ReplaySettingsOverlay>().Any() &&
!p.ChildrenOfType<HoldForMenuButton>().Any() &&
p.ChildrenOfType<ArgonSongProgressBar>().SingleOrDefault()?.Interactive == false));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ public void TestGameplaySettingsDoesNotExpandWhenSkinOverlayPresent()
AddStep("move cursor to right of screen too far", () => InputManager.MoveMouseTo(InputManager.ScreenSpaceDrawQuad.TopRight + new Vector2(10240, 0)));
AddUntilStep("settings not visible", () => getPlayerSettingsOverlay().DrawWidth, () => Is.EqualTo(0));

PlayerSettingsOverlay getPlayerSettingsOverlay() => ((Player)Game.ScreenStack.CurrentScreen).ChildrenOfType<PlayerSettingsOverlay>().SingleOrDefault();
ReplaySettingsOverlay getPlayerSettingsOverlay() => ((Player)Game.ScreenStack.CurrentScreen).ChildrenOfType<ReplaySettingsOverlay>().SingleOrDefault();
}

[Test]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ public MultiSpectatorPlayer(Score score, SpectatorPlayerClock spectatorPlayerClo
: base(score, new PlayerConfiguration { AllowUserInteraction = false })
{
this.spectatorPlayerClock = spectatorPlayerClock;

ShowSettingsOverlay = false;
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is still an issue, as it will hide not only the settings overlay but the scrolling text too, which is important because that's the only visual indication as to who's who on the screen.

diff --git a/osu.Game/Screens/Play/SpectatorPlayer.cs b/osu.Game/Screens/Play/SpectatorPlayer.cs
index 910a4aef65..ab01dd9118 100644
--- a/osu.Game/Screens/Play/SpectatorPlayer.cs
+++ b/osu.Game/Screens/Play/SpectatorPlayer.cs
@@ -35,26 +35,31 @@ protected SpectatorPlayer(Score score, PlayerConfiguration? configuration = null
         [BackgroundDependencyLoader]
         private void load()
         {
+            // TODO: This should be customised for `MultiplayerSpectatorPlayer` to be static and only show the player name.
+            // Or maybe we should completely redesign this to show the user avatar and other things if that happens.
+            OsuTextFlowContainer message = new OsuTextFlowContainer(cp => cp.Font = OsuFont.Style.Body) { AutoSizeAxes = Axes.Both };
+            message.AddText("Watching ");
+            message.AddText(Score.ScoreInfo.User.Username, s => s.Font = s.Font.With(weight: FontWeight.SemiBold));
+            message.AddText(" play ");
+            message.AddText(Beatmap.Value.BeatmapInfo.GetDisplayTitleRomanisable(), s => s.Font = s.Font.With(weight: FontWeight.SemiBold));
+            message.AddText(" live", s => s.Font = s.Font.With(weight: FontWeight.Bold));
+            var scrollingMessage = new ScrollingMessage(message)
+            {
+                Y = 96,
+                Anchor = Anchor.TopCentre,
+                Origin = Anchor.TopCentre,
+            };
+
             if (ShowSettingsOverlay)
             {
                 var replayOverlay = new ReplayOverlay();
                 GameplayClockContainer.Add(replayOverlay);
 
-                // TODO: This should be customised for `MultiplayerSpectatorPlayer` to be static and only show the player name.
-                // Or maybe we should completely redesign this to show the user avatar and other things if that happens.
-                OsuTextFlowContainer message = new OsuTextFlowContainer(cp => cp.Font = OsuFont.Style.Body) { AutoSizeAxes = Axes.Both };
-                message.AddText("Watching ");
-                message.AddText(Score.ScoreInfo.User.Username, s => s.Font = s.Font.With(weight: FontWeight.SemiBold));
-                message.AddText(" play ");
-                message.AddText(Beatmap.Value.BeatmapInfo.GetDisplayTitleRomanisable(), s => s.Font = s.Font.With(weight: FontWeight.SemiBold));
-                message.AddText(" live", s => s.Font = s.Font.With(weight: FontWeight.Bold));
-
-                replayOverlay.SetMessage(new ScrollingMessage(message)
-                {
-                    Y = 96,
-                    Anchor = Anchor.TopCentre,
-                    Origin = Anchor.TopCentre,
-                });
+                replayOverlay.SetMessage(scrollingMessage);
+            }
+            else
+            {
+                GameplayClockContainer.Add(scrollingMessage);
             }
         }
 

is a possible alternative.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or it may be easier to incorporate #37164 into this PR since the two will conflict almost instantaneously. This one is removing the virtual method that one is trying to override.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or I guess I merge this and then #37164 immediately after

Yeah, I'd probably be changing that PR to make the text there always visible, not part of this overlay, or something. Will revisit once this is merged, or feel free to do so for me 😅

Can apply your patch above if you want to keep master in a good state.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll just merge as is since it's not going to get lost in merge conflict resolution anyway.

}

[BackgroundDependencyLoader]
Expand All @@ -54,7 +56,6 @@ private void load(CancellationToken cancellationToken)
// also applied in `MultiplayerPlayer.load()`
ScoreProcessor.ApplyNewJudgementsWhenFailed = true;

HUDOverlay.PlayerSettingsOverlay.Expire();
HUDOverlay.HoldToQuit.Expire();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public partial class MultiSpectatorScreen : SpectatorScreen

private readonly Room room;

private PlayerSettingsOverlay playerSettingsOverlay = null!;
private ReplaySettingsOverlay replaySettingsOverlay = null!;
private Bindable<bool> configSettingsOverlay = null!;

/// <summary>
Expand Down Expand Up @@ -138,7 +138,7 @@ private void load(OsuConfigManager config)
{
ReadyToStart = performInitialSeek,
},
playerSettingsOverlay = new PlayerSettingsOverlay
replaySettingsOverlay = new ReplaySettingsOverlay
{
Alpha = 0,
}
Expand Down Expand Up @@ -189,9 +189,9 @@ protected override void LoadComplete()
private void updateVisibility()
{
if (configSettingsOverlay.Value)
playerSettingsOverlay.Show();
replaySettingsOverlay.Show();
else
playerSettingsOverlay.Hide();
replaySettingsOverlay.Hide();
}

protected override void Update()
Expand Down
86 changes: 86 additions & 0 deletions osu.Game/Screens/Play/HUD/ReplayOverlay.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
// 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.Allocation;
using osu.Framework.Bindables;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Input.Bindings;
using osu.Framework.Input.Events;
using osu.Game.Configuration;
using osu.Game.Input.Bindings;

namespace osu.Game.Screens.Play.HUD
{
public partial class ReplayOverlay : CompositeDrawable, IKeyBindingHandler<GlobalAction>
{
public ReplaySettingsOverlay Settings { get; private set; } = null!;

private const int fade_duration = 200;

private Bindable<bool> configSettingsOverlay = null!;
private Container messageContainer = null!;

[BackgroundDependencyLoader]
private void load(OsuConfigManager config)
{
RelativeSizeAxes = Axes.Both;
AlwaysPresent = true;
Alpha = 0;

configSettingsOverlay = config.GetBindable<bool>(OsuSetting.ReplaySettingsOverlay);

InternalChild = new Container
{
RelativeSizeAxes = Axes.Both,
Children = new Drawable[]
{
messageContainer = new Container
{
RelativeSizeAxes = Axes.Both,
Depth = float.MaxValue,
},
Settings = new ReplaySettingsOverlay(),
}
};
}

protected override void LoadComplete()
{
base.LoadComplete();
configSettingsOverlay.BindValueChanged(_ => updateVisibility(), true);
}

private void updateVisibility()
{
if (configSettingsOverlay.Value)
Show();
else
Hide();
}

public bool OnPressed(KeyBindingPressEvent<GlobalAction> e)
{
if (e.Repeat)
return false;

switch (e.Action)
{
case GlobalAction.ToggleReplaySettings:
configSettingsOverlay.Value = !configSettingsOverlay.Value;
return true;
}

return false;
}

public void OnReleased(KeyBindingReleaseEvent<GlobalAction> e)
{
}

public override void Show() => this.FadeIn(fade_duration, Easing.OutQuint);
public override void Hide() => this.FadeOut(fade_duration, Easing.OutQuint);

public void SetMessage(ScrollingMessage scrollingMessage) => messageContainer.Child = scrollingMessage;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,14 @@

namespace osu.Game.Screens.Play.HUD
{
public partial class PlayerSettingsOverlay : ExpandingContainer
public partial class ReplaySettingsOverlay : ExpandingContainer
{
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 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;

Expand All @@ -52,7 +47,7 @@ public partial class PlayerSettingsOverlay : ExpandingContainer
// while collapsed down, so let's avoid that.
protected override bool ComputeIsMaskedAway(RectangleF maskingBounds) => false;

public PlayerSettingsOverlay()
public ReplaySettingsOverlay()
: base(0, EXPANDED_WIDTH)
{
Origin = Anchor.TopRight;
Expand Down Expand Up @@ -81,11 +76,14 @@ public PlayerSettingsOverlay()
Action = () => Expanded.Toggle()
});

AddInternal(new Box
AddRangeInternal(new Drawable[]
{
Colour = ColourInfo.GradientHorizontal(Color4.Black.Opacity(0), Color4.Black.Opacity(0.8f)),
Depth = float.MaxValue,
RelativeSizeAxes = Axes.Both,
new Box
{
Colour = ColourInfo.GradientHorizontal(Color4.Black.Opacity(0), Color4.Black.Opacity(0.8f)),
Depth = float.MaxValue,
RelativeSizeAxes = Axes.Both,
},
});
}

Expand Down
35 changes: 2 additions & 33 deletions osu.Game/Screens/Play/HUDOverlay.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,6 @@ public partial class HUDOverlay : Container, IKeyBindingHandler<GlobalAction>

public const Easing FADE_EASING = Easing.OutQuint;

/// <summary>
/// The total height of all the bottom of screen scoring elements.
/// </summary>
public float BottomScoringElementsHeight { get; private set; }

protected override bool ShouldBeConsideredForInput(Drawable child)
{
// HUD uses AlwaysVisible on child components so they can be in an updated state for next display.
Expand All @@ -56,7 +51,6 @@ protected override bool ShouldBeConsideredForInput(Drawable child)

public readonly ModDisplay ModDisplay;
public readonly HoldForMenuButton HoldToQuit;
public readonly PlayerSettingsOverlay PlayerSettingsOverlay;

[Cached]
private readonly ClicksPerSecondController clicksPerSecondController;
Expand All @@ -82,7 +76,6 @@ protected override bool ShouldBeConsideredForInput(Drawable child)

private Bindable<HUDVisibilityMode> configVisibilityMode;
private Bindable<bool> configLeaderboardVisibility;
private Bindable<bool> configSettingsOverlay;

private readonly BindableBool replayLoaded = new BindableBool();

Expand Down Expand Up @@ -116,8 +109,6 @@ protected override bool ShouldBeConsideredForInput(Drawable child)

public HUDOverlay([CanBeNull] DrawableRuleset drawableRuleset, IReadOnlyList<Mod> mods, PlayerConfiguration configuration)
{
Container rightSettings;

this.drawableRuleset = drawableRuleset;
this.mods = mods;
this.configuration = configuration;
Expand Down Expand Up @@ -170,17 +161,6 @@ public HUDOverlay([CanBeNull] DrawableRuleset drawableRuleset, IReadOnlyList<Mod
HoldToQuit = CreateHoldForMenuButton(),
}
},
rightSettings = new Container
{
RelativeSizeAxes = Axes.Both,
Children = new Drawable[]
{
PlayerSettingsOverlay = new PlayerSettingsOverlay
{
Alpha = 0,
}
}
},
TopLeftElements = new FillFlowContainer
{
AutoSizeAxes = Axes.Both,
Expand All @@ -190,7 +170,7 @@ public HUDOverlay([CanBeNull] DrawableRuleset drawableRuleset, IReadOnlyList<Mod
},
};

hideTargets = new List<Drawable> { mainComponents, TopRightElements, rightSettings };
hideTargets = new List<Drawable> { mainComponents, TopRightElements };

if (rulesetComponents != null)
hideTargets.Add(rulesetComponents);
Expand All @@ -210,7 +190,6 @@ private void load(OsuConfigManager config, RealmKeyBindingStore keyBindingStore,

configVisibilityMode = config.GetBindable<HUDVisibilityMode>(OsuSetting.HUDVisibilityMode);
configLeaderboardVisibility = config.GetBindable<bool>(OsuSetting.GameplayLeaderboard);
configSettingsOverlay = config.GetBindable<bool>(OsuSetting.ReplaySettingsOverlay);

if (configVisibilityMode.Value == HUDVisibilityMode.Never && !hasShownNotificationOnce)
{
Expand Down Expand Up @@ -238,7 +217,6 @@ protected override void LoadComplete()
holdingForHUD.BindValueChanged(_ => updateVisibility());
IsPlaying.BindValueChanged(_ => updateVisibility());
configVisibilityMode.BindValueChanged(_ => updateVisibility());
configSettingsOverlay.BindValueChanged(_ => updateVisibility());

replayLoaded.BindValueChanged(e =>
{
Expand Down Expand Up @@ -295,7 +273,7 @@ protected override void Update()
TopLeftElements.Y = 0;

if (highestBottomScreenSpace.HasValue && DrawHeight - BottomRightElements.DrawHeight > 0)
BottomRightElements.Y = BottomScoringElementsHeight = -Math.Clamp(DrawHeight - ToLocalSpace(highestBottomScreenSpace.Value).Y, 0, DrawHeight - BottomRightElements.DrawHeight);
BottomRightElements.Y = -Math.Clamp(DrawHeight - ToLocalSpace(highestBottomScreenSpace.Value).Y, 0, DrawHeight - BottomRightElements.DrawHeight);
else
BottomRightElements.Y = 0;

Expand Down Expand Up @@ -349,11 +327,6 @@ void processDrawable(ISerialisableDrawable element)

private void updateVisibility()
{
if (configSettingsOverlay.Value && replayLoaded.Value)
PlayerSettingsOverlay.Show();
else
PlayerSettingsOverlay.Hide();

if (ShowHud.Disabled)
return;

Expand Down Expand Up @@ -415,10 +388,6 @@ public bool OnPressed(KeyBindingPressEvent<GlobalAction> e)

switch (e.Action)
{
case GlobalAction.ToggleReplaySettings:
configSettingsOverlay.Value = !configSettingsOverlay.Value;
return true;

case GlobalAction.HoldForHUD:
holdingForHUD.Value = true;
return false;
Expand Down
Loading
Loading