Beispiel #1
0
        private void loadComponentSingleFile <T>(T d, Action <T> add)
            where T : Drawable
        {
            var focused = d as FocusedOverlayContainer;

            if (focused != null)
            {
                focused.StateChanged += s =>
                {
                    visibleOverlayCount += s == Visibility.Visible ? 1 : -1;
                    screenStack.FadeColour(visibleOverlayCount > 0 ? OsuColour.Gray(0.5f) : Color4.White, 500, Easing.OutQuint);
                };
            }

            // 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); });
        }
Beispiel #2
0
        private void loadComponentSingleFile <T>(T d, Action <T> add)
            where T : Drawable
        {
            var focused = d as FocusedOverlayContainer;

            if (focused != null)
            {
                focused.StateChanged += s =>
                {
                    visibleOverlayCount += s == Visibility.Visible ? 1 : -1;
                    screenStack.FadeColour(visibleOverlayCount > 0 ? OsuColour.Gray(0.5f) : Color4.White, 500, Easing.OutQuint);
                };
            }

            // 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(() =>
            {
                var previousLoadStream = asyncLoadStream;

                //chain with existing load stream
                asyncLoadStream = Task.Run(async() =>
                {
                    if (previousLoadStream != null)
                    {
                        await previousLoadStream;
                    }

                    try
                    {
                        Logger.Log($"Loading {d}...", level: LogLevel.Debug);
                        await LoadComponentAsync(d, add);
                        Logger.Log($"Loaded {d}!", level: LogLevel.Debug);
                    }
                    catch (OperationCanceledException)
                    {
                    }
                });
            });
        }