コード例 #1
0
        private EverlookGameLoadingDialog(Builder builder, IntPtr handle, Window parent)
            : base(handle)
        {
            builder.Autoconnect(this);
            this.TransientFor = parent;

            this.CancellationSource = new CancellationTokenSource();

            this.CancelGameLoadingButton.Pressed += (o, args) =>
            {
                this.GameLoadingDialogLabel.Text       = "Cancelling...";
                this.CancelGameLoadingButton.Sensitive = false;

                this.CancellationSource.Cancel();
            };

            this.OverallProgressNotifier = new Progress <OverallLoadingProgress>(overallProgress =>
            {
                this.CurrentLoadingProgress = overallProgress;
            });

            this.GameLoadProgressNotifier = new Progress <GameLoadingProgress>(loadingProgress =>
            {
                SetFraction(loadingProgress.CompletionPercentage);

                string statusText = string.Empty;
                switch (loadingProgress.State)
                {
                case GameLoadingState.SettingUp:
                    {
                        statusText = "Setting up...";
                        break;
                    }

                case GameLoadingState.Loading:
                    {
                        statusText = "Loading...";
                        break;
                    }

                case GameLoadingState.LoadingPackages:
                    {
                        statusText = "Loading packages...";
                        break;
                    }

                case GameLoadingState.LoadingNodeTree:
                    {
                        statusText = "Loading node tree...";
                        break;
                    }

                case GameLoadingState.LoadingDictionary:
                    {
                        statusText = "Loading dictionary for node generation...";
                        break;
                    }

                case GameLoadingState.BuildingNodeTree:
                    {
                        statusText = "Building node tree..";
                        break;
                    }
                }

                SetStatusMessage($"{loadingProgress.Alias} - {statusText}");

                if (!(loadingProgress.NodesCreationProgress is null))
                {
                    DisplayNodeCreationProgress(loadingProgress.CurrentPackage, loadingProgress.NodesCreationProgress);

                    this.IsPulserDisabled = true;
                }
コード例 #2
0
        private EverlookGameLoadingDialog(Builder builder, IntPtr handle, Window parent)
            : base(handle)
        {
            builder.Autoconnect(this);
            this.TransientFor = parent;

            this.CancellationSource = new CancellationTokenSource();

            this.CancelGameLoadingButton.Pressed += (o, args) =>
            {
                this.GameLoadingDialogLabel.Text       = "Cancelling...";
                this.CancelGameLoadingButton.Sensitive = false;

                this.CancellationSource.Cancel();
            };

            this.OverallProgressNotifier = new Progress <OverallLoadingProgress>(overallProgress =>
            {
                this.CurrentLoadingProgress = overallProgress;
            });

            this.GameLoadProgressNotifier = new Progress <GameLoadingProgress>(loadingProgress =>
            {
                SetFraction(loadingProgress.CompletionPercentage);

                string statusText = string.Empty;
                switch (loadingProgress.State)
                {
                case GameLoadingState.SettingUp:
                    {
                        statusText = "Setting up...";
                        break;
                    }

                case GameLoadingState.Loading:
                    {
                        statusText = "Loading...";
                        break;
                    }

                case GameLoadingState.LoadingPackages:
                    {
                        statusText = "Loading packages...";
                        break;
                    }

                case GameLoadingState.LoadingNodeTree:
                    {
                        statusText = "Loading node tree...";
                        break;
                    }

                case GameLoadingState.LoadingDictionary:
                    {
                        statusText = "Loading dictionary for node generation...";
                        break;
                    }

                case GameLoadingState.BuildingNodeTree:
                    {
                        statusText = "Building node tree..";
                        break;
                    }
                }

                SetStatusMessage($"{loadingProgress.Alias} - {statusText}");
            });

            using (Stream shaderStream =
                       Assembly.GetExecutingAssembly().GetManifestResourceStream("Everlook.Content.jokes.txt"))
            {
                if (shaderStream == null)
                {
                    return;
                }

                using (StreamReader sr = new StreamReader(shaderStream))
                {
                    while (sr.BaseStream.Length > sr.BaseStream.Position)
                    {
                        // Add italics to all jokes. Jokes are in Pango markup format
                        this.Jokes.Add($"<i>{sr.ReadLine()}</i>");
                    }
                }
            }

            RefreshJoke();

            this.JokeTimeoutID = GLib.Timeout.Add(6000, () =>
            {
                RefreshJoke();
                return(true);
            });
        }