Skip to content

Commit

Permalink
Merge pull request ppy#26937 from frenzibyte/fix-osu-logo-blocking-load
Browse files Browse the repository at this point in the history
Stop blocking player load when hovering over osu! logo
  • Loading branch information
peppy authored Mar 21, 2024
2 parents 3e764ae + 0502997 commit 970e45f
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 3 deletions.
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 @@ -25,9 +25,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 Down Expand Up @@ -55,6 +57,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 @@ -78,7 +83,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 @@ -212,6 +224,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 @@ -110,8 +110,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 @@ -335,10 +335,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 @@ -357,6 +361,7 @@ protected override void LogoExiting(OsuLogo logo)
{
base.LogoExiting(logo);
content.StopTracking();
osuLogo = null;
}

protected override void LogoSuspending(OsuLogo logo)
Expand All @@ -367,6 +372,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

0 comments on commit 970e45f

Please sign in to comment.