diff --git a/osu-framework b/osu-framework index 26f3091dca..ecc5e3189e 160000 --- a/osu-framework +++ b/osu-framework @@ -1 +1 @@ -Subproject commit 26f3091dcaf47e3b355b7f7ad83b292621d7d6b5 +Subproject commit ecc5e3189e8229d36095882b9a7a0efc95402be9 diff --git a/osu.Desktop/OsuGameDesktop.cs b/osu.Desktop/OsuGameDesktop.cs index 1e4bf3119d..5f05fae213 100644 --- a/osu.Desktop/OsuGameDesktop.cs +++ b/osu.Desktop/OsuGameDesktop.cs @@ -12,15 +12,12 @@ using osu.Desktop.Overlays; using osu.Framework.Graphics.Containers; using osu.Framework.Platform; using osu.Game; -using osu.Game.Screens.Menu; using OpenTK.Input; namespace osu.Desktop { internal class OsuGameDesktop : OsuGame { - private VersionManager versionManager; - public OsuGameDesktop(string[] args = null) : base(args) { @@ -82,16 +79,11 @@ namespace osu.Desktop { base.LoadComplete(); - LoadComponentAsync(versionManager = new VersionManager { Depth = int.MinValue }); - - ScreenChanged += s => + LoadComponentAsync(new VersionManager { Depth = int.MinValue }, v => { - if (s is Intro && s.ChildScreen == null) - { - Add(versionManager); - versionManager.State = Visibility.Visible; - } - }; + Add(v); + v.State = Visibility.Visible; + }); } public override void SetHost(GameHost host) diff --git a/osu.Game/OsuGame.cs b/osu.Game/OsuGame.cs index d1baca68db..1e7b0dc0bc 100644 --- a/osu.Game/OsuGame.cs +++ b/osu.Game/OsuGame.cs @@ -157,40 +157,49 @@ namespace osu.Game BeatmapManager.PostNotification = n => notificationOverlay?.Post(n); BeatmapManager.GetStableStorage = GetStorageForStableInstall; - AddRange(new Drawable[] { + AddRange(new Drawable[] + { new VolumeControlReceptor { RelativeSizeAxes = Axes.Both, ActionRequested = action => volume.Adjust(action) }, - mainContent = new Container - { - RelativeSizeAxes = Axes.Both, - }, - volume = new VolumeControl(), - overlayContent = new Container { RelativeSizeAxes = Axes.Both }, - new OnScreenDisplay(), + mainContent = new Container { RelativeSizeAxes = Axes.Both }, + overlayContent = new Container { RelativeSizeAxes = Axes.Both, Depth = float.MinValue }, }); - LoadComponentAsync(screenStack = new Loader(), d => + loadComponentSingleFile(screenStack = new Loader(), d => { screenStack.ModePushed += screenAdded; screenStack.Exited += screenRemoved; mainContent.Add(screenStack); }); + loadComponentSingleFile(Toolbar = new Toolbar + { + Depth = -5, + OnHome = delegate + { + hideAllOverlays(); + intro?.ChildScreen?.MakeCurrent(); + }, + }, overlayContent.Add); + + loadComponentSingleFile(volume = new VolumeControl(), AddInternal); + loadComponentSingleFile(new OnScreenDisplay(), AddInternal); + //overlay elements - LoadComponentAsync(direct = new DirectOverlay { Depth = -1 }, mainContent.Add); - LoadComponentAsync(social = new SocialOverlay { Depth = -1 }, mainContent.Add); - LoadComponentAsync(chat = new ChatOverlay { Depth = -1 }, mainContent.Add); - LoadComponentAsync(settings = new MainSettings + loadComponentSingleFile(direct = new DirectOverlay { Depth = -1 }, mainContent.Add); + loadComponentSingleFile(social = new SocialOverlay { Depth = -1 }, mainContent.Add); + loadComponentSingleFile(chat = new ChatOverlay { Depth = -1 }, mainContent.Add); + loadComponentSingleFile(settings = new MainSettings { GetToolbarHeight = () => ToolbarOffset, Depth = -1 }, overlayContent.Add); - LoadComponentAsync(userProfile = new UserProfileOverlay { Depth = -2 }, mainContent.Add); - LoadComponentAsync(beatmapSetOverlay = new BeatmapSetOverlay { Depth = -3 }, mainContent.Add); - LoadComponentAsync(musicController = new MusicController + loadComponentSingleFile(userProfile = new UserProfileOverlay { Depth = -2 }, mainContent.Add); + loadComponentSingleFile(beatmapSetOverlay = new BeatmapSetOverlay { Depth = -3 }, mainContent.Add); + loadComponentSingleFile(musicController = new MusicController { Depth = -4, Position = new Vector2(0, Toolbar.HEIGHT), @@ -198,16 +207,16 @@ namespace osu.Game Origin = Anchor.TopRight, }, overlayContent.Add); - LoadComponentAsync(notificationOverlay = new NotificationOverlay + loadComponentSingleFile(notificationOverlay = new NotificationOverlay { Depth = -4, Anchor = Anchor.TopRight, Origin = Anchor.TopRight, }, overlayContent.Add); - LoadComponentAsync(dialogOverlay = new DialogOverlay + loadComponentSingleFile(dialogOverlay = new DialogOverlay { - Depth = -5, + Depth = -6, }, overlayContent.Add); Logger.NewEntry += entry => @@ -246,16 +255,6 @@ namespace osu.Game }; } - LoadComponentAsync(Toolbar = new Toolbar - { - Depth = -4, - OnHome = delegate - { - hideAllOverlays(); - intro?.ChildScreen?.MakeCurrent(); - }, - }, overlayContent.Add); - settings.StateChanged += delegate { switch (settings.State) @@ -272,6 +271,17 @@ namespace osu.Game Cursor.State = Visibility.Hidden; } + private Task asyncLoadStream; + + private void loadComponentSingleFile(T d, Action add) + where T : Drawable + { + // 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, + // we could avoid the need for scheduling altogether. + Schedule(() => { asyncLoadStream = asyncLoadStream?.ContinueWith(t => LoadComponentAsync(d, add).Wait()) ?? LoadComponentAsync(d, add); }); + } + public bool OnPressed(GlobalAction action) { if (intro == null) return false; diff --git a/osu.Game/Overlays/Toolbar/ToolbarUserArea.cs b/osu.Game/Overlays/Toolbar/ToolbarUserArea.cs index c1fd234628..95a25fcb86 100644 --- a/osu.Game/Overlays/Toolbar/ToolbarUserArea.cs +++ b/osu.Game/Overlays/Toolbar/ToolbarUserArea.cs @@ -1,6 +1,7 @@ // Copyright (c) 2007-2017 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE +using osu.Framework.Allocation; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Primitives; @@ -11,11 +12,12 @@ namespace osu.Game.Overlays.Toolbar internal class ToolbarUserArea : Container { public LoginOverlay LoginOverlay; - private readonly ToolbarUserButton button; + private ToolbarUserButton button; public override RectangleF BoundingBox => button.BoundingBox; - public ToolbarUserArea() + [BackgroundDependencyLoader] + private void load() { RelativeSizeAxes = Axes.Y; AutoSizeAxes = Axes.X; @@ -36,4 +38,4 @@ namespace osu.Game.Overlays.Toolbar }; } } -} \ No newline at end of file +}