Tidy up implementation and show on returning with new song

This commit is contained in:
Dean Herbert 2020-01-24 16:23:41 +09:00
parent 3f6fa93365
commit f9a54dfb1d
2 changed files with 25 additions and 32 deletions

View File

@ -78,27 +78,6 @@ namespace osu.Game.Screens.Menu
holdDelay = config.GetBindable<float>(OsuSetting.UIHoldActivationDelay); holdDelay = config.GetBindable<float>(OsuSetting.UIHoldActivationDelay);
loginDisplayed = statics.GetBindable<bool>(Static.LoginOverlayDisplayed); loginDisplayed = statics.GetBindable<bool>(Static.LoginOverlayDisplayed);
AddInternal(songTicker = new SongTicker
{
Anchor = Anchor.TopRight,
Origin = Anchor.TopRight,
Margin = new MarginPadding { Right = 15, Top = 5 }
});
if (host.CanExit)
{
AddInternal(exitConfirmOverlay = new ExitConfirmOverlay
{
Action = () =>
{
if (holdDelay.Value > 0)
confirmAndExit();
else
this.Exit();
}
});
}
AddRangeInternal(new Drawable[] AddRangeInternal(new Drawable[]
{ {
buttonsContainer = new ParallaxContainer buttonsContainer = new ParallaxContainer
@ -117,8 +96,28 @@ namespace osu.Game.Screens.Menu
} }
}, },
sideFlashes = new MenuSideFlashes(), sideFlashes = new MenuSideFlashes(),
songTicker = new SongTicker
{
Anchor = Anchor.TopRight,
Origin = Anchor.TopRight,
Margin = new MarginPadding { Right = 15, Top = 5 }
}
}); });
if (host.CanExit)
{
AddInternal(exitConfirmOverlay = new ExitConfirmOverlay
{
Action = () =>
{
if (holdDelay.Value > 0)
confirmAndExit();
else
this.Exit();
}
});
}
buttons.StateChanged += state => buttons.StateChanged += state =>
{ {
switch (state) switch (state)
@ -236,9 +235,6 @@ namespace osu.Game.Screens.Menu
buttons.State = ButtonSystemState.EnteringMode; buttons.State = ButtonSystemState.EnteringMode;
songTicker.FadeOut(100, Easing.OutQuint);
songTicker.AllowUpdates = false;
this.FadeOut(FADE_OUT_DURATION, Easing.InSine); this.FadeOut(FADE_OUT_DURATION, Easing.InSine);
buttonsContainer.MoveTo(new Vector2(-800, 0), FADE_OUT_DURATION, Easing.InSine); buttonsContainer.MoveTo(new Vector2(-800, 0), FADE_OUT_DURATION, Easing.InSine);
@ -249,8 +245,6 @@ namespace osu.Game.Screens.Menu
{ {
base.OnResuming(last); base.OnResuming(last);
songTicker.AllowUpdates = true;
(Background as BackgroundScreenDefault)?.Next(); (Background as BackgroundScreenDefault)?.Next();
//we may have consumed our preloaded instance, so let's make another. //we may have consumed our preloaded instance, so let's make another.
@ -277,8 +271,10 @@ namespace osu.Game.Screens.Menu
} }
buttons.State = ButtonSystemState.Exit; buttons.State = ButtonSystemState.Exit;
this.FadeOut(3000);
songTicker.Hide(); songTicker.Hide();
this.FadeOut(3000);
return base.OnExiting(next); return base.OnExiting(next);
} }

View File

@ -1,4 +1,4 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence. // 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. // See the LICENCE file in the repository root for full licence text.
using osu.Framework.Allocation; using osu.Framework.Allocation;
@ -17,8 +17,6 @@ namespace osu.Game.Screens.Menu
{ {
private const int fade_duration = 800; private const int fade_duration = 800;
public bool AllowUpdates { get; set; } = true;
[Resolved] [Resolved]
private Bindable<WorkingBeatmap> beatmap { get; set; } private Bindable<WorkingBeatmap> beatmap { get; set; }
@ -58,8 +56,7 @@ namespace osu.Game.Screens.Menu
private void onBeatmapChanged(ValueChangedEvent<WorkingBeatmap> working) private void onBeatmapChanged(ValueChangedEvent<WorkingBeatmap> working)
{ {
if (!AllowUpdates) var metadata = beatmap.Value.Metadata;
return;
var metadata = working.NewValue.Metadata; var metadata = working.NewValue.Metadata;