コード例 #1
0
        private void btnBuildPack_Click(object sender, EventArgs e) // Build Pack button
        {
            FolderBrowserDialog oFolder = new FolderBrowserDialog();
            SaveFileDialog      sFile   = new SaveFileDialog();

            if (cbxSetDataOffset.Checked)
            {
                try{ int.Parse(tbxDataOffset.Text, System.Globalization.NumberStyles.HexNumber); } //check if it's a hex value (textbox limited to 4 characters)
                catch { MessageBox.Show("Error:" + "\n\n" + "Fixed Data Offset is not a hex value!"); goto toss; }
            }
            oFolder.Description = "Select folder to build into Pack file";
            if (tbxFolderRoot.Text != "")
            {
                oFolder.SelectedPath = tbxFolderRoot.Text;
            }
            if (oFolder.ShowDialog() == DialogResult.Cancel)
            {
                goto toss;
            }
            int numFiles = Directory.GetFiles(oFolder.SelectedPath, "*", SearchOption.AllDirectories).Length;

            sFile.Filter             = "PACK|*.pack|SARC|*.sarc|SSARC|*.ssarc|RARC|*.rarc|SGENVB|*.sgenvb|SBFARC|*.sbfarc|SBLARC|*.sblarc|SBACTORPACK|*sbactorpack|All Files|*.*";
            sFile.InitialDirectory   = oFolder.SelectedPath.Remove(oFolder.SelectedPath.LastIndexOf("\\")); //Previous folder, as selected is to build outside of it.
            sFile.FileName           = System.IO.Path.GetFileName(oFolder.SelectedPath);
            lblProcessStatus.Visible = true;
            if (sFile.ShowDialog() == DialogResult.Cancel)
            {
                goto toss;
            }

            if (cbxSetDataOffset.Checked)
            {
                uint dataOffset = (uint)int.Parse(tbxDataOffset.Text, System.Globalization.NumberStyles.HexNumber);
                if (!PACK.Build(oFolder.SelectedPath, sFile.FileName, dataOffset))
                {
                    MessageBox.Show("Failed to build!" + "\n\n" + PACK.lerror);
                    goto toss;
                }
            }
            else
            {
                if (!PACK.Build(oFolder.SelectedPath, sFile.FileName))
                {
                    MessageBox.Show("Failed to build!" + "\n\n" + PACK.lerror);
                    goto toss;
                }
            }

            MessageBox.Show("Building Complete!" + "\n\n" + sFile.FileName);

toss:
            oFolder.Dispose();
            sFile.Dispose();
            GC.Collect();
            lblProcessStatus.Visible = false;
        }
コード例 #2
0
        private void multiPACK_Click(object sender, EventArgs e)
        {
            FolderBrowserDialog rFolder = new FolderBrowserDialog();

            if (rFolder.ShowDialog() == DialogResult.OK)
            {
                string[] directories = Directory.GetDirectories(rFolder.SelectedPath);
                foreach (string item2 in directories)
                {
                    PACK.Build(item2, item2.TrimEnd(Path.DirectorySeparatorChar) + extnBX.Text);
                }
            }
        }