mirror of
https://github.com/ppy/osu.git
synced 2024-12-14 12:33:01 +08:00
Fix loading (but not showing) a sheared overlay hiding displayed footer content
Identified by tests. See https://github.com/ppy/osu/actions/runs/9869382635/job/27253010485 & https://github.com/ppy/osu/actions/runs/9869382635/job/27253009622. This change also prevents the initial `PopOut` call in overlays from calling `clearActiveOverlayContainer`, since it's not in the update thread and it's never meant to be called at that point anyway (it's supposed to be accompanied by a previous `PopIn` call adding the footer content).
This commit is contained in:
parent
f0a7a3f856
commit
337f05f9a4
@ -1,6 +1,7 @@
|
||||
// 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.
|
||||
|
||||
using System;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Extensions.Color4Extensions;
|
||||
using osu.Framework.Graphics;
|
||||
@ -123,6 +124,7 @@ namespace osu.Game.Overlays.Mods
|
||||
return base.OnClick(e);
|
||||
}
|
||||
|
||||
private IDisposable? activeOverlayRegistration;
|
||||
private bool hideFooterOnPopOut;
|
||||
|
||||
protected override void PopIn()
|
||||
@ -135,7 +137,7 @@ namespace osu.Game.Overlays.Mods
|
||||
|
||||
if (footer != null)
|
||||
{
|
||||
footer.SetActiveOverlayContainer(this);
|
||||
activeOverlayRegistration = footer.RegisterActiveOverlayContainer(this);
|
||||
|
||||
if (footer.State.Value == Visibility.Hidden)
|
||||
{
|
||||
@ -156,7 +158,8 @@ namespace osu.Game.Overlays.Mods
|
||||
|
||||
if (footer != null)
|
||||
{
|
||||
footer.ClearActiveOverlayContainer();
|
||||
activeOverlayRegistration?.Dispose();
|
||||
activeOverlayRegistration = null;
|
||||
|
||||
if (hideFooterOnPopOut)
|
||||
{
|
||||
|
@ -142,7 +142,7 @@ namespace osu.Game.Screens.Footer
|
||||
temporarilyHiddenButtons.Clear();
|
||||
overlays.Clear();
|
||||
|
||||
ClearActiveOverlayContainer();
|
||||
clearActiveOverlayContainer();
|
||||
|
||||
var oldButtons = buttonsFlow.ToArray();
|
||||
|
||||
@ -187,14 +187,15 @@ namespace osu.Game.Screens.Footer
|
||||
|
||||
private ShearedOverlayContainer? activeOverlay;
|
||||
private Container? contentContainer;
|
||||
|
||||
private readonly List<ScreenFooterButton> temporarilyHiddenButtons = new List<ScreenFooterButton>();
|
||||
|
||||
public void SetActiveOverlayContainer(ShearedOverlayContainer overlay)
|
||||
public IDisposable RegisterActiveOverlayContainer(ShearedOverlayContainer overlay)
|
||||
{
|
||||
if (contentContainer != null)
|
||||
if (activeOverlay != null)
|
||||
{
|
||||
throw new InvalidOperationException(@"Cannot set overlay content while one is already present. " +
|
||||
$@"The previous overlay whose content is {contentContainer.Child.GetType().Name} should be hidden first.");
|
||||
$@"The previous overlay ({activeOverlay.GetType().Name}) should be hidden first.");
|
||||
}
|
||||
|
||||
activeOverlay = overlay;
|
||||
@ -232,29 +233,30 @@ namespace osu.Game.Screens.Footer
|
||||
this.Delay(60).Schedule(() => content.Show());
|
||||
else
|
||||
content.Show();
|
||||
|
||||
return new InvokeOnDisposal(clearActiveOverlayContainer);
|
||||
}
|
||||
|
||||
public void ClearActiveOverlayContainer()
|
||||
private void clearActiveOverlayContainer()
|
||||
{
|
||||
if (contentContainer == null)
|
||||
if (activeOverlay == null)
|
||||
return;
|
||||
|
||||
Debug.Assert(contentContainer != null);
|
||||
contentContainer.Child.Hide();
|
||||
|
||||
double timeUntilRun = contentContainer.Child.LatestTransformEndTime - Time.Current;
|
||||
|
||||
Container expireTarget = contentContainer;
|
||||
contentContainer = null;
|
||||
activeOverlay = null;
|
||||
|
||||
for (int i = 0; i < temporarilyHiddenButtons.Count; i++)
|
||||
makeButtonAppearFromBottom(temporarilyHiddenButtons[i], 0);
|
||||
|
||||
temporarilyHiddenButtons.Clear();
|
||||
|
||||
expireTarget.Delay(timeUntilRun).Expire();
|
||||
|
||||
updateColourScheme(OverlayColourScheme.Aquamarine);
|
||||
|
||||
contentContainer.Delay(timeUntilRun).Expire();
|
||||
contentContainer = null;
|
||||
activeOverlay = null;
|
||||
}
|
||||
|
||||
private void updateColourScheme(OverlayColourScheme colourScheme)
|
||||
|
Loading…
Reference in New Issue
Block a user