Beispiel #1
0
        private void btnYaz0Decode_Click(object sender, EventArgs e)
        {
            loadingBar.Visible = true;
            OpenFileDialog oFile = new OpenFileDialog();

            if (tbxFolderRoot.Text != "")
            {
                oFile.InitialDirectory = tbxFolderRoot.Text;
            }
            if (oFile.ShowDialog() == DialogResult.Cancel)
            {
                goto toss;
            }
            string outFile = oFile.FileName;

            {
                if (!Yaz0.Decode(oFile.FileName, Yaz0.DecodeOutputFileRename(oFile.FileName)))
                {
                    MessageBox.Show("Decode error:" + "\n\n" + Yaz0.lerror);
                    goto toss;
                }
            }

            //XML
            if (cbxWriteYaz0Xml.Checked)
            {
                String oFolderName = Path.GetFileNameWithoutExtension(oFile.FileName);
                String oFolderPath = Path.GetDirectoryName(oFile.FileName) + "\\" + oFolderName;
                if (File.Exists(oFolderPath + "_Yaz0Debug.xml"))
                {
                    if (MessageBox.Show(oFolderName + ".xml already exists!" + "\n\n" + "Proceed anyway?", "Overwrite?", MessageBoxButtons.YesNo) == DialogResult.No)
                    {
                        goto toss;
                    }
                }
                if (!DebugWriter.WriteYaz0Xml(oFile.FileName, (oFolderPath + "_Yaz0Debug.xml")))
                {
                    MessageBox.Show("XML file failed to write by unknown reasons");
                }
            }

            MessageBox.Show("Decode complete!" + "\n\n" + outFile);

toss:
            oFile.Dispose();
            GC.Collect();
            loadingBar.Visible = false;
        }
Beispiel #2
0
        private void btnExtractPack_Click(object sender, EventArgs e) //Extract Pack button
        {
            loadingBar.Visible = true;
            OpenFileDialog oFile = new OpenFileDialog();

            if (tbxFolderRoot.Text != "")
            {
                oFile.InitialDirectory = tbxFolderRoot.Text;
            }
            if (oFile.ShowDialog() == DialogResult.Cancel)
            {
                goto toss;
            }

            String oFolderName = Path.GetFileNameWithoutExtension(oFile.FileName);
            String oFolderPath = Path.GetDirectoryName(oFile.FileName) + "\\" + oFolderName;

            // if the output folder exists, prompt user if they want to extract anyway
            if (Directory.Exists(oFolderPath))
            {
                if (MessageBox.Show(oFolderName + " already exists!" + "\n\n" + "Proceed anyway?", "Overwrite?", MessageBoxButtons.YesNo) == DialogResult.No)
                {
                    goto xml;
                }
            }

            //SARC
            bool boolAutoDecode = false;
            bool boolNodeDecode = false;

            if (cbxNodeDecode.Checked) //Node Yaz0 decoding
            {
                boolNodeDecode = true;
            }
            else //Default, without any checkboxes
            {
                if (SARC.IsYaz0File(oFile.FileName))
                {
                    if (MessageBox.Show("This file is Yaz0 encoded!" + "\n\n" + "Want to decode it and attempt to extract?", "Decode and Extact?", MessageBoxButtons.YesNo) != DialogResult.No)
                    {
                        boolAutoDecode = true; //Auto decode just this once since we prompted
                    }
                    else
                    {
                        goto toss; //User clicked no
                    }
                }
            }
            if (!SARC.Extract(oFile.FileName, oFolderPath, boolAutoDecode, boolNodeDecode)) //Extraction
            {
                MessageBox.Show("Extraction error:" + "\n\n" + SARC.lerror);
                goto toss;
            }
            else
            {
                System.Diagnostics.Process.Start(oFolderPath);
            }

            //XML
xml:
            if (cbxWriteSarcXml.Checked)
            {
                if (File.Exists(oFolderPath + "_SarcDebug.xml"))
                {
                    if (MessageBox.Show(oFolderName + ".xml already exists!" + "\n\n" + "Proceed anyway?", "Overwrite?", MessageBoxButtons.YesNo) == DialogResult.No)
                    {
                        goto toss;
                    }
                }
                if (!DebugWriter.WriteSarcXml(oFile.FileName, (oFolderPath + "_SarcDebug.xml")))
                {
                    MessageBox.Show("XML file failed to write by unknown reasons");
                }
            }

toss:
            oFile.Dispose();
            GC.Collect();
            loadingBar.Visible = false;
        }