BrawlBuilder.BrawlBuilder.build_Click C# (CSharp) Méthode

build_Click() private méthode

private build_Click ( object sender, EventArgs e ) : void
sender object
e EventArgs
Résultat void
		private void build_Click(object sender, EventArgs e)
		{
			if (buildWorker.IsBusy)
			{
				// Cancel
				DialogResult cancel = MessageBox.Show("Are you sure you want to cancel the build?", "Cancel?", MessageBoxButtons.YesNo, MessageBoxIcon.Question);

				if (cancel == DialogResult.Yes)
				{
					_dontTouch = true;
					SetStatus("Cancelling...", true);
					buildWorker.CancelAsync();
				}

				return;
			}
				

			// Verify stuff
			if (!File.Exists(brawlIso.Text) && !Directory.Exists("ssbb.d"))
			{
				MessageBox.Show("Brawl ISO location is invalid", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
				return;
			}

			if (modFolder.Text == "" && gctFile.Text == "" && !removeSubspace.Checked && !customID.Checked && !cutomTitle.Checked && !customBanner.Checked)
			{
				MessageBox.Show("You haven't specified any changes, building not required.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
				return;
			}

			if (modFolder.Text != "")
			{
				if (!Directory.Exists(modFolder.Text))
				{
					MessageBox.Show("Mod folder location is invalid", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
					return;
				}				

				string[] brawlFolders = { "effect", "fighter", "game", "info", "info2", "item", "item_gen", "menu", "menu2", "minigame", "module", "movie", "net", "sound", "stage", "system", "toy" };
				if (!Directory.GetDirectories(modFolder.Text).Any(d => brawlFolders.Contains(new DirectoryInfo(d).Name)))
				{
					DialogResult badfolder = MessageBox.Show("It doesn't look like the mod folder you selected contains any replacement Brawl files, are you sure you selected the right foler? Usually it will be called 'pf'.\n\nDo you still want to attempt the build using the selected folder?", "Notice", MessageBoxButtons.YesNo, MessageBoxIcon.Question);

					if (badfolder == DialogResult.No)
						return;
				}
			}

			if (gctFile.Text != "" && !File.Exists(gctFile.Text))
			{
				MessageBox.Show("GCT file location is invalid", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
				return;
			}

			if (customID.Checked && !Regex.IsMatch(gameID.Text, "^[A-Z0-9_]{6}$"))
			{
				MessageBox.Show("Game ID must be 6 characters and be made up of some combination of A-Z (uppercase only), 0-9, and underscores. No other characters are allowed.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
				return;
			}

			if (customBanner.Checked && !File.Exists(banner.Text))
			{
				MessageBox.Show("Banner file location is invalid", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
				return;
			}

			// Ask where to save output
			SaveFileDialog fileDialog = new SaveFileDialog();
			fileDialog.OverwritePrompt = true;
			fileDialog.Title = "Select where you wish to save modded Brawl image...";
			fileDialog.Filter = "ISO Image|*.iso|CISO Image|*.ciso|WBFS Image|*.wbfs|WBI Image|*.wbi|WIA Image|*.wia|WDF Image|*.wdf";

			string id = customID.Checked ? gameID.Text : "RSBE01";
			string title = cutomTitle.Checked ? gameTitle.Text : "Super Smash Bros. Brawl";

			fileDialog.FileName = title + " [" + id + "]";

			DialogResult result = fileDialog.ShowDialog();

			if (result != DialogResult.OK)
				return;

			_saveFileName = fileDialog.FileName;

			// Disable form controls
			foreach (Control c in Controls)
			{
				if (c != exit && c != build)
				{
					c.Tag = c.Enabled;
					c.Enabled = false;
				}
			}

			// Start background worker
			buildWorker.RunWorkerAsync();
		}