Exemple #1
0
        static void Main()
        {
            UseEmbeddedDependencies();
            Patcher.Initialize();
            FileMapInfo.Initialize();
            ModManager.Initialize();
            SplashManager.Initialize();

            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(new BNSBoostForm());
        }
Exemple #2
0
        private void LaunchButton_Click(object sender, EventArgs e)
        {
            LaunchButton.Enabled = false;

            // Need to save ourself since form doesn't do it automatically :/
            Properties.Settings.Default.Region = (string)RegionComboBox.SelectedItem;
            Properties.Settings.Default.Save();

            ToggleBitness(Properties.Settings.Default.Is64Bit);
            ToggleRegion(Properties.Settings.Default.Region);
            ToggleLoadingScreens(DisableLoadingScreensCheckBox.Checked);
            ToggleLauncherWarning();

            var worker = new BackgroundWorker();

            worker.DoWork += (_, arg) =>
            {
                Patcher.Patch(worker);
                ModManager.ApplyMods();
                SplashManager.ApplySplash();
            };

            worker.ProgressChanged += (_, arg) =>
            {
                string display = arg.UserState as string;
                Debug.WriteLine(display);
                LaunchButton.Text = display;
            };

            worker.RunWorkerCompleted += async(_, arg) =>
            {
                string baseDatDir = Path.Combine(GameDirectoryPathTextBox.Text, @"contents\Local\NCWEST\data\");
                foreach (string decompFile in Directory.GetDirectories(baseDatDir))
                {
                    if (!decompFile.EndsWith(".files"))
                    {
                        continue;
                    }
                    Directory.Delete(decompFile, true);
                }

                string extraClientFlags = " -UNATTENDED";
                if (DisableTextureStreamingCheckbox.Checked)
                {
                    extraClientFlags += " -NOTEXTURESTREAMING";
                }
                if (UseAllCoresCheckbox.Checked)
                {
                    extraClientFlags += " -USEALLAVAILABLECORES";
                }

                string launcherPath = LauncherPathTextBox.Text;

                Hide();

                int exitcode = await LaunchAsync(launcherPath, extraClientFlags);

                string message;
                switch (exitcode)
                {
                case 0:
                    Application.Exit();
                    return;

                case 740:
                    message = "You must run BNSBoost with administrator rights.";
                    break;

                default:
                    message = "Launcher exited with error: " + exitcode;
                    break;
                }

                Show();
                Focus();
                MessageBox.Show(message);

                // Launch failed :(
                LaunchButton.Enabled = true;
                LaunchButton.Text    = "Launch!";
            };

            worker.WorkerReportsProgress = true;
            worker.RunWorkerAsync();
        }