Fix multiple order-of-execution issues with osu! logo

Also sets better defaults.
This commit is contained in:
Dean Herbert 2017-11-13 18:43:05 +09:00
parent 615984ca9c
commit 49a5af60e2
7 changed files with 36 additions and 22 deletions

View File

@ -24,7 +24,6 @@ protected override void LogoArriving(OsuLogo logo, bool resuming)
{
base.LogoArriving(logo, resuming);
logo.RelativePositionAxes = Axes.None;
logo.Triangles = false;
logo.Origin = Anchor.BottomRight;
logo.Anchor = Anchor.BottomRight;
@ -47,11 +46,7 @@ protected override void OnEntering(Screen last)
protected override void LogoSuspending(OsuLogo logo)
{
base.LogoSuspending(logo);
logo.FadeOut(100).OnComplete(l =>
{
l.Anchor = Anchor.TopLeft;
l.Origin = Anchor.Centre;
});
logo.FadeOut(100);
}
[BackgroundDependencyLoader]

View File

@ -127,8 +127,6 @@ protected override void LogoArriving(OsuLogo logo, bool resuming)
if (!resuming)
{
logo.Triangles = true;
logo.ScaleTo(1);
logo.FadeIn();
logo.PlayIntro();

View File

@ -112,9 +112,6 @@ protected override void LogoArriving(OsuLogo logo, bool resuming)
buttons.SetOsuLogo(logo);
logo.Triangles = true;
logo.Ripple = false;
logo.FadeColour(Color4.White, 100, Easing.OutQuint);
logo.FadeIn(100, Easing.OutQuint);

View File

@ -221,6 +221,30 @@ public OsuLogo()
};
}
/// <summary>
/// Schedule a new extenral animation. Handled queueing and finishing previous animations in a sane way.
/// </summary>
/// <param name="action">The animation to be performed</param>
/// <param name="waitForPrevious">If true, the new animation is delayed until all previous transforms finish. If false, existing transformed are cleared.</param>
internal void AppendAnimatingAction(Action action, bool waitForPrevious)
{
Action runnableAction = () =>
{
if (waitForPrevious)
this.DelayUntilTransformsFinished().Schedule(action);
else
{
ClearTransforms();
action();
}
};
if (IsLoaded)
runnableAction();
else
Schedule(() => runnableAction());
}
[BackgroundDependencyLoader]
private void load(TextureStore textures, AudioManager audio)
{

View File

@ -76,7 +76,7 @@ private void load(OsuGameBase game, OsuGame osuGame, AudioManager audio)
protected override void OnResuming(Screen last)
{
base.OnResuming(last);
logo.DelayUntilTransformsFinished().Schedule(() => LogoArriving(logo, true));
logo.AppendAnimatingAction(() => LogoArriving(logo, true), true);
sampleExit?.Play();
}
@ -118,11 +118,11 @@ protected override void OnEntering(Screen last)
}
if ((logo = lastOsu?.logo) == null)
LoadComponentAsync(logo = new OsuLogo(), AddInternal);
LoadComponentAsync(logo = new OsuLogo { Alpha = 0 }, AddInternal);
logo.AppendAnimatingAction(() => LogoArriving(logo, false), true);
base.OnEntering(last);
logo.DelayUntilTransformsFinished().Schedule(() => LogoArriving(logo, false));
}
protected override bool OnExiting(Screen next)
@ -155,12 +155,16 @@ protected virtual void LogoArriving(OsuLogo logo, bool resuming)
{
logo.Action = null;
logo.FadeOut(300, Easing.OutQuint);
logo.Anchor = Anchor.TopLeft;
logo.Origin = Anchor.Centre;
logo.RelativePositionAxes = Axes.None;
logo.Triangles = true;
logo.Ripple = true;
}
private void onExitingLogo()
{
logo.ClearTransforms();
LogoExiting(logo);
logo.AppendAnimatingAction(() => { LogoExiting(logo); }, false);
}
/// <summary>
@ -172,8 +176,7 @@ protected virtual void LogoExiting(OsuLogo logo)
private void onSuspendingLogo()
{
logo.ClearTransforms();
LogoSuspending(logo);
logo.AppendAnimatingAction(() => { LogoSuspending(logo); }, false);
}
/// <summary>

View File

@ -99,7 +99,6 @@ protected override void LogoArriving(OsuLogo logo, bool resuming)
{
base.LogoArriving(logo, resuming);
logo.ClearTransforms(targetMember: nameof(Position));
logo.RelativePositionAxes = Axes.Both;
logo.ScaleTo(new Vector2(0.15f), 300, Easing.In);

View File

@ -315,9 +315,7 @@ protected override void LogoArriving(OsuLogo logo, bool resuming)
{
base.LogoArriving(logo, resuming);
logo.ClearTransforms();
logo.RelativePositionAxes = Axes.Both;
Vector2 position = new Vector2(0.95f, 0.96f);
if (logo.Alpha > 0.8f)