Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stop blocking player load when hovering over osu! logo #26937

Merged
merged 2 commits into from
Mar 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
44 changes: 43 additions & 1 deletion osu.Game.Tests/Visual/Gameplay/TestScenePlayerLoader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,11 @@
using osu.Game.Rulesets.Osu.Mods;
using osu.Game.Rulesets.Scoring;
using osu.Game.Scoring;
using osu.Game.Screens.Menu;
using osu.Game.Screens.Play;
using osu.Game.Screens.Play.PlayerSettings;
using osu.Game.Utils;
using osuTK;
using osuTK.Input;

namespace osu.Game.Tests.Visual.Gameplay
Expand All @@ -53,6 +55,9 @@ public partial class TestScenePlayerLoader : ScreenTestScene
[Cached]
private readonly VolumeOverlay volumeOverlay;

[Cached]
private readonly OsuLogo logo;

[Cached(typeof(BatteryInfo))]
private readonly LocalBatteryInfo batteryInfo = new LocalBatteryInfo();

Expand All @@ -76,7 +81,14 @@ public TestScenePlayerLoader()
Anchor = Anchor.TopLeft,
Origin = Anchor.TopLeft,
},
changelogOverlay = new ChangelogOverlay()
changelogOverlay = new ChangelogOverlay(),
logo = new OsuLogo
{
Anchor = Anchor.BottomRight,
Origin = Anchor.BottomRight,
Scale = new Vector2(0.5f),
Position = new Vector2(128f),
},
});
}

Expand Down Expand Up @@ -204,6 +216,36 @@ public void TestBlockLoadViaFocus()
AddUntilStep("loads after idle", () => !loader.IsCurrentScreen());
}

[Test]
public void TestLoadNotBlockedOnOsuLogo()
{
AddStep("load dummy beatmap", () => resetPlayer(false));
AddUntilStep("wait for current", () => loader.IsCurrentScreen());

AddUntilStep("wait for load ready", () =>
{
moveMouse();
return player?.LoadState == LoadState.Ready;
});

// move mouse in logo while waiting for load to still proceed (it shouldn't be blocked when hovering logo).
AddUntilStep("move mouse in logo", () =>
{
moveMouse();
return !loader.IsCurrentScreen();
});

void moveMouse()
{
notificationOverlay.State.Value = Visibility.Hidden;

InputManager.MoveMouseTo(
logo.ScreenSpaceDrawQuad.TopLeft
+ (logo.ScreenSpaceDrawQuad.BottomRight - logo.ScreenSpaceDrawQuad.TopLeft)
* RNG.NextSingle(0.3f, 0.7f));
}
}

[Test]
public void TestLoadContinuation()
{
Expand Down
11 changes: 9 additions & 2 deletions osu.Game/Screens/Play/PlayerLoader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,8 @@ protected bool BackgroundBrightnessReduction
&& ReadyForGameplay;

protected virtual bool ReadyForGameplay =>
// not ready if the user is hovering one of the panes, unless they are idle.
(IsHovered || idleTracker.IsIdle.Value)
// not ready if the user is hovering one of the panes (logo is excluded), unless they are idle.
(IsHovered || osuLogo?.IsHovered == true || idleTracker.IsIdle.Value)
// not ready if the user is dragging a slider or otherwise.
&& inputManager.DraggedDrawable == null
// not ready if a focused overlay is visible, like settings.
Expand Down Expand Up @@ -306,10 +306,14 @@ public override bool OnExiting(ScreenExitEvent e)
return base.OnExiting(e);
}

private OsuLogo? osuLogo;

protected override void LogoArriving(OsuLogo logo, bool resuming)
{
base.LogoArriving(logo, resuming);

osuLogo = logo;

const double duration = 300;

if (!resuming) logo.MoveTo(new Vector2(0.5f), duration, Easing.OutQuint);
Expand All @@ -328,6 +332,7 @@ protected override void LogoExiting(OsuLogo logo)
{
base.LogoExiting(logo);
content.StopTracking();
osuLogo = null;
}

protected override void LogoSuspending(OsuLogo logo)
Expand All @@ -338,6 +343,8 @@ protected override void LogoSuspending(OsuLogo logo)
logo
.FadeOut(CONTENT_OUT_DURATION / 2, Easing.OutQuint)
.ScaleTo(logo.Scale * 0.8f, CONTENT_OUT_DURATION * 2, Easing.OutQuint);

osuLogo = null;
}

#endregion
Expand Down