Battle_Script_Pro.Form1.btnDecompile_Click C# (CSharp) Method

btnDecompile_Click() private method

private btnDecompile_Click ( object sender, EventArgs e ) : void
sender object
e EventArgs
return void
        private void btnDecompile_Click(object sender, EventArgs e)
        {
            this.Cursor = Cursors.WaitCursor;
            int location = 0;
            bool success = Int32.TryParse(txtDecompileOffset.Text, out location);
            if (!success)
            {
                success = Int32.TryParse(ToDecimal(txtDecompileOffset.Text), out location);
                if (!success)
                {
                    MessageBox.Show("Could not parse the offset you entered.");
                }
            }
            try
            {
                CreateNewTab(null);
                headersNeeded = new Dictionary<string, bool>();
                headersNeeded.Add("abilities", false);
                headersNeeded.Add("moves", false);
                headersNeeded.Add("pokemon", false);
                headersNeeded.Add("item", false);
                List<string> toReturn = DecompileScript(location, File.ReadAllBytes(selectedROMPath)).ToList();
                bool insertReturn = false;
                int countLines = 0;
                foreach (string s in headersNeeded.Keys)
                {
                    if (headersNeeded[s])
                    {
                        toReturn.Insert(0, "#include " + s + ".bsh");
                        countLines++;
                        insertReturn = true;
                    }
                }
                if (insertReturn)
                {
                    toReturn.Insert(countLines, "");
                }
                scripts[tabControl1.SelectedIndex].Lines = toReturn.ToArray();
                headersNeeded.Clear();
            }
            catch (IOException)
            {
                MessageBox.Show("Unable to read ROM. Please close whatever the ROM is open in, and try again.");
            }
            catch (Exception exc)
            {
                MessageBox.Show("There was an unknown exception. Please forward this error message to Jambo51 through the tool's thread:\n" + exc);
            }
            this.Cursor = Cursors.Default;
            decompiledOffsets.Clear();
            unsaved[tabControl1.SelectedIndex] = false;
        }
Form1