Exemplo n.º 1
0
        private void pushWhenLoaded()
        {
            if (!this.IsCurrentScreen())
            {
                return;
            }

            try
            {
                if (!readyForPush)
                {
                    // as the pushDebounce below has a delay, we need to keep checking and cancel a future debounce
                    // if we become unready for push during the delay.
                    cancelLoad();
                    return;
                }

                if (scheduledPushPlayer != null)
                {
                    return;
                }

                scheduledPushPlayer = Scheduler.AddDelayed(() =>
                {
                    contentOut();

                    TransformSequence <PlayerLoader> pushSequence = this.Delay(250);

                    // only show if the warning was created (i.e. the beatmap needs it)
                    // and this is not a restart of the map (the warning expires after first load).
                    if (epilepsyWarning?.IsAlive == true)
                    {
                        const double epilepsy_display_length = 3000;

                        pushSequence.Schedule(() =>
                        {
                            epilepsyWarning.State.Value = Visibility.Visible;

                            this.Delay(epilepsy_display_length).Schedule(() =>
                            {
                                epilepsyWarning.Hide();
                                epilepsyWarning.Expire();
                            });
                        });

                        pushSequence.Delay(epilepsy_display_length);
                    }

                    pushSequence.Schedule(() =>
                    {
                        if (!this.IsCurrentScreen())
                        {
                            return;
                        }

                        LoadTask = null;

                        // By default, we want to load the player and never be returned to.
                        // Note that this may change if the player we load requested a re-run.
                        ValidForResume = false;

                        if (player.LoadedBeatmapSuccessfully)
                        {
                            this.Push(player);
                        }
                        else
                        {
                            this.Exit();
                        }
                    });
                }, 500);
            }
            finally
            {
                Schedule(pushWhenLoaded);
            }
        }