Ejemplo n.º 1
0
        private void InitializeMods()
        {
            var mods = ModManager.GetModList();

            ModListView.Items.Clear();
            foreach (var mod in mods)
            {
                var modCheckBox = new ListViewItem
                {
                    Text        = mod.Name + (mod.Description != null ? " (" + mod.Description + ")" : ""),
                    ToolTipText = mod.Description,
                    Name        = mod.Name,
                    Checked     = mod.Enabled
                };

                ModListView.Items.Add(modCheckBox);
            }

            ModListView.ItemCheck += (who, evt) =>
            {
                ModManager.EnableMod(ModListView.Items[evt.Index].Name, evt.NewValue == CheckState.Checked);
            };
        }
Ejemplo n.º 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();
        }