mirror of https://github.com/ppy/osu
Merge branch 'master' into cursor-trail
This commit is contained in:
commit
b27b6c7eb7
|
@ -5,12 +5,14 @@
|
|||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Sprites;
|
||||
using osu.Framework.Input;
|
||||
using osu.Framework.Screens;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Graphics.Sprites;
|
||||
using OpenTK;
|
||||
using osu.Framework.Localisation;
|
||||
using osu.Framework.Threading;
|
||||
using osu.Game.Screens.Menu;
|
||||
using osu.Game.Screens.Play.PlayerSettings;
|
||||
|
||||
|
@ -21,7 +23,6 @@ public class PlayerLoader : ScreenWithBeatmapBackground
|
|||
private Player player;
|
||||
|
||||
private BeatmapMetadataDisplay info;
|
||||
private VisualSettings visualSettings;
|
||||
|
||||
private bool showOverlays = true;
|
||||
public override bool ShowOverlaysOnEnter => showOverlays;
|
||||
|
@ -46,7 +47,8 @@ private void load()
|
|||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
});
|
||||
Add(visualSettings = new VisualSettings
|
||||
|
||||
Add(new VisualSettings
|
||||
{
|
||||
Anchor = Anchor.TopRight,
|
||||
Origin = Anchor.TopRight,
|
||||
|
@ -93,7 +95,7 @@ protected override void OnEntering(Screen last)
|
|||
contentIn();
|
||||
|
||||
info.Delay(750).FadeIn(500);
|
||||
this.Delay(2150).Schedule(pushWhenLoaded);
|
||||
this.Delay(1800).Schedule(pushWhenLoaded);
|
||||
}
|
||||
|
||||
protected override void LogoArriving(OsuLogo logo, bool resuming)
|
||||
|
@ -109,29 +111,65 @@ protected override void LogoArriving(OsuLogo logo, bool resuming)
|
|||
logo.Delay(resuming ? 0 : 500).MoveToOffset(new Vector2(0, -0.24f), 500, Easing.InOutExpo);
|
||||
}
|
||||
|
||||
private bool weHandledMouseDown;
|
||||
|
||||
protected override bool OnMouseDown(InputState state, MouseDownEventArgs args)
|
||||
{
|
||||
weHandledMouseDown = true;
|
||||
return base.OnMouseDown(state, args);
|
||||
}
|
||||
|
||||
protected override bool OnMouseUp(InputState state, MouseUpEventArgs args)
|
||||
{
|
||||
weHandledMouseDown = false;
|
||||
return base.OnMouseUp(state, args);
|
||||
}
|
||||
|
||||
private ScheduledDelegate pushDebounce;
|
||||
|
||||
private bool readyForPush => player.LoadState == LoadState.Ready && IsHovered && (!GetContainingInputManager().CurrentState.Mouse.HasAnyButtonPressed || weHandledMouseDown);
|
||||
|
||||
private void pushWhenLoaded()
|
||||
{
|
||||
if (player.LoadState != LoadState.Ready || visualSettings.IsHovered)
|
||||
if (!IsCurrentScreen) return;
|
||||
|
||||
try
|
||||
{
|
||||
if (!readyForPush)
|
||||
{
|
||||
// as the pushDebounce below has a delay, we need to keep checking and cancel a future debounce
|
||||
// if we become unready for push during the delay.
|
||||
pushDebounce?.Cancel();
|
||||
pushDebounce = null;
|
||||
return;
|
||||
}
|
||||
|
||||
if (pushDebounce != null)
|
||||
return;
|
||||
|
||||
pushDebounce = Scheduler.AddDelayed(() =>
|
||||
{
|
||||
contentOut();
|
||||
|
||||
this.Delay(250).Schedule(() =>
|
||||
{
|
||||
if (!IsCurrentScreen) return;
|
||||
|
||||
if (!Push(player))
|
||||
Exit();
|
||||
else
|
||||
{
|
||||
//By default, we want to load the player and never be returned to.
|
||||
//Note that this may change if the player we load requested a re-run.
|
||||
ValidForResume = false;
|
||||
}
|
||||
});
|
||||
}, 500);
|
||||
}
|
||||
finally
|
||||
{
|
||||
Schedule(pushWhenLoaded);
|
||||
return;
|
||||
}
|
||||
|
||||
contentOut();
|
||||
|
||||
this.Delay(250).Schedule(() =>
|
||||
{
|
||||
if (!IsCurrentScreen) return;
|
||||
|
||||
if (!Push(player))
|
||||
Exit();
|
||||
else
|
||||
{
|
||||
//By default, we want to load the player and never be returned to.
|
||||
//Note that this may change if the player we load requested a re-run.
|
||||
ValidForResume = false;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
protected override bool OnExiting(Screen next)
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
using osu.Framework.Input;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Graphics.Sprites;
|
||||
using osu.Game.Graphics.UserInterface;
|
||||
|
@ -133,5 +134,8 @@ private void load(OsuColour colours)
|
|||
}
|
||||
|
||||
protected override Container<Drawable> Content => content;
|
||||
|
||||
protected override bool OnHover(InputState state) => true;
|
||||
protected override bool OnMouseDown(InputState state, MouseDownEventArgs args) => true;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue