Exemple #1
0
        private static async Task <bool> installTaskImpl(GameType gameType, CPUArch cpuArch, string path, ProgressBar progressBar)
        {
            await Task.Run(() =>
            {
                bool removeSettings = Boolean.Parse(Properties.Resources.RemoveSettings);
                if (removeSettings)
                {
                    if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
                    {
                        Win32SettingsRemover.removeSettings();
                    }
                    else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
                    {
                        UnixSettingsRemover.removeSettings();
                    }
                    else
                    {
                        MessageBox.Show("Unsupported Operating System");
                    }
                }

                countFiles(gameType, cpuArch);

                progressBar.Invoke(new Action(() =>
                {
                    progressBar.Maximum = total;
                }));

                switch (cpuArch)
                {
                case CPUArch.x64:
                    {
                        ZipManager.extractFiles(Properties.Resources.x64, path, progressBar);
                        break;
                    }

                    /*case CPUArch.x86:
                     *  {
                     *      ZipManager.extractFiles(Properties.Resources.x86, path, progressBar);
                     *      break;
                     *  }*/
                }

                switch (gameType)
                {
                case GameType.BFG:
                    {
                        ZipManager.extractFiles(Properties.Resources._base, path + "/base", progressBar);
                        ZipManager.extractFiles(Properties.Resources.base_BFG, path + "/base", progressBar);
                        break;
                    }

                case GameType.NEW:
                    {
                        ZipManager.extractFiles(Properties.Resources._base, path + "/base", progressBar);
                        ZipManager.extractFiles(Properties.Resources.base_NEW, path + "/base", progressBar);
                        break;
                    }

                case GameType.CLASSIC:
                    {
                        ZipManager.extractFiles(Properties.Resources.base_CLASSIC, path, progressBar);
                        break;
                    }
                }
            });

            return(true);
        }