1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-08 03:37:35 +08:00

Fix home button not closing login and now playing overlays (#6758)

Fix home button not closing login and now playing overlays

Co-authored-by: Dean Herbert <pe@ppy.sh>
This commit is contained in:
Dean Herbert 2019-11-12 15:40:28 +09:00 committed by GitHub
commit e32f88c770
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -102,8 +102,6 @@ namespace osu.Game
private readonly List<OverlayContainer> overlays = new List<OverlayContainer>(); private readonly List<OverlayContainer> overlays = new List<OverlayContainer>();
private readonly List<VisibilityContainer> toolbarElements = new List<VisibilityContainer>();
private readonly List<OverlayContainer> visibleBlockingOverlays = new List<OverlayContainer>(); private readonly List<OverlayContainer> visibleBlockingOverlays = new List<OverlayContainer>();
public OsuGame(string[] args = null) public OsuGame(string[] args = null)
@ -134,17 +132,13 @@ namespace osu.Game
/// <summary> /// <summary>
/// Close all game-wide overlays. /// Close all game-wide overlays.
/// </summary> /// </summary>
/// <param name="hideToolbarElements">Whether the toolbar (and accompanying controls) should also be hidden.</param> /// <param name="hideToolbar">Whether the toolbar should also be hidden.</param>
public void CloseAllOverlays(bool hideToolbarElements = true) public void CloseAllOverlays(bool hideToolbar = true)
{ {
foreach (var overlay in overlays) foreach (var overlay in overlays)
overlay.Hide(); overlay.Hide();
if (hideToolbarElements) if (hideToolbar) Toolbar.Hide();
{
foreach (var overlay in toolbarElements)
overlay.Hide();
}
} }
private DependencyContainer dependencies; private DependencyContainer dependencies;
@ -572,11 +566,7 @@ namespace osu.Game
CloseAllOverlays(false); CloseAllOverlays(false);
menuScreen?.MakeCurrent(); menuScreen?.MakeCurrent();
}, },
}, d => }, topMostOverlayContent.Add);
{
topMostOverlayContent.Add(d);
toolbarElements.Add(d);
});
loadComponentSingleFile(volume = new VolumeOverlay(), leftFloatingOverlayContent.Add, true); loadComponentSingleFile(volume = new VolumeOverlay(), leftFloatingOverlayContent.Add, true);
@ -615,11 +605,7 @@ namespace osu.Game
GetToolbarHeight = () => ToolbarOffset, GetToolbarHeight = () => ToolbarOffset,
Anchor = Anchor.TopRight, Anchor = Anchor.TopRight,
Origin = Anchor.TopRight, Origin = Anchor.TopRight,
}, d => }, rightFloatingOverlayContent.Add, true);
{
rightFloatingOverlayContent.Add(d);
toolbarElements.Add(d);
}, true);
loadComponentSingleFile(new AccountCreationOverlay(), topMostOverlayContent.Add, true); loadComponentSingleFile(new AccountCreationOverlay(), topMostOverlayContent.Add, true);
loadComponentSingleFile(new DialogOverlay(), topMostOverlayContent.Add, true); loadComponentSingleFile(new DialogOverlay(), topMostOverlayContent.Add, true);
@ -629,8 +615,8 @@ namespace osu.Game
Add(externalLinkOpener = new ExternalLinkOpener()); Add(externalLinkOpener = new ExternalLinkOpener());
// side overlays which cancel each other.
var singleDisplaySideOverlays = new OverlayContainer[] { Settings, notifications }; var singleDisplaySideOverlays = new OverlayContainer[] { Settings, notifications };
overlays.AddRange(singleDisplaySideOverlays);
foreach (var overlay in singleDisplaySideOverlays) foreach (var overlay in singleDisplaySideOverlays)
{ {
@ -644,7 +630,6 @@ namespace osu.Game
// eventually informational overlays should be displayed in a stack, but for now let's only allow one to stay open at a time. // eventually informational overlays should be displayed in a stack, but for now let's only allow one to stay open at a time.
var informationalOverlays = new OverlayContainer[] { beatmapSetOverlay, userProfile }; var informationalOverlays = new OverlayContainer[] { beatmapSetOverlay, userProfile };
overlays.AddRange(informationalOverlays);
foreach (var overlay in informationalOverlays) foreach (var overlay in informationalOverlays)
{ {
@ -658,7 +643,6 @@ namespace osu.Game
// ensure only one of these overlays are open at once. // ensure only one of these overlays are open at once.
var singleDisplayOverlays = new OverlayContainer[] { chatOverlay, social, direct, changelogOverlay }; var singleDisplayOverlays = new OverlayContainer[] { chatOverlay, social, direct, changelogOverlay };
overlays.AddRange(singleDisplayOverlays);
foreach (var overlay in singleDisplayOverlays) foreach (var overlay in singleDisplayOverlays)
{ {
@ -759,6 +743,9 @@ namespace osu.Game
if (cache) if (cache)
dependencies.Cache(d); dependencies.Cache(d);
if (d is OverlayContainer overlay)
overlays.Add(overlay);
// schedule is here to ensure that all component loads are done after LoadComplete is run (and thus all dependencies are cached). // schedule is here to ensure that all component loads are done after LoadComplete is run (and thus all dependencies are cached).
// with some better organisation of LoadComplete to do construction and dependency caching in one step, followed by calls to loadComponentSingleFile, // with some better organisation of LoadComplete to do construction and dependency caching in one step, followed by calls to loadComponentSingleFile,
// we could avoid the need for scheduling altogether. // we could avoid the need for scheduling altogether.