Пример #1
0
        private void Extract()
        {
            string Dir    = null;
            var    Dialog = folderBrowserDialog1.ShowDialog();

            if (Dialog != DialogResult.Cancel)
            {
                Dir = folderBrowserDialog1.SelectedPath;
                if (treeView1.SelectedNode.Nodes.Count == 0)
                {
                    try
                    {
                        var File = Rom.FileDict[$"/{treeView1.SelectedNode.FullPath}"];
                        Rom.OpenFile(File).WriteAllBytes($"{Dir}/{File.Name}");
                    }
                    catch (Exception)
                    {
                    }
                }
                else
                {
                    try
                    {
                        foreach (TreeNode node in treeView1.SelectedNode.Nodes)
                        {
                            var File = Rom.FileDict[$"/{node.FullPath}"];
                            Rom.OpenFile(File).WriteAllBytes($"{Dir}/{File.Name}");
                        }
                    }
                    catch (Exception)
                    {
                    }
                }
            }
        }
Пример #2
0
        //Export all messages to CNMT
        private void exportTextTocnmtToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (Rom != null)
            {
                var Dialog = folderBrowser.ShowDialog();
                if (Dialog != DialogResult.Cancel)
                {
                    foreach (string f in Rom.FileDict.Keys)
                    {
                        if (f.StartsWith("/Message/"))
                        {
                            var File = Rom.FileDict[f];
                            Rom.OpenFile(File).WriteAllBytes($"{folderBrowser.SelectedPath}/{f.Substring(9)}");
                        }
                    }
                    string outputDir = System.IO.Path.GetDirectoryName(Application.ExecutablePath);
                    Console.WriteLine("a");
                    System.Diagnostics.Process.Start(Path.Combine(outputDir, "zs/7z.exe"), $"e {folderBrowser.SelectedPath}/{"*.zs"} -o{folderBrowser.SelectedPath}").WaitForExit();
                    Console.WriteLine("b");

                    DirectoryInfo d = new DirectoryInfo(folderBrowser.SelectedPath);
                    foreach (var file in d.GetFiles("*"))
                    {
                        if (file.Extension == ".zs")
                        {
                            file.Delete();
                        }
                        else if (file.Extension == ".sarc")
                        {
                            Process p = System.Diagnostics.Process.Start(Path.Combine(outputDir, "sarc/sarc_tool.exe"), file.FullName);
                            p.WaitForExit();
                            p.Close();
                            file.Delete();
                        }
                    }
                }
            }
            else
            {
                MessageBox.Show("Please load the files first !");
            }
        }
Пример #3
0
        private void treeView1_NodeMouseClick(object sender, TreeNodeMouseClickEventArgs e)
        {
            if (e.Button == MouseButtons.Left)
            {
                if (e.Node.Nodes.Count == 0)
                {
                    var Size = (decimal)Rom.FileDict[$"/{e.Node.FullPath}"].DataLength;

                    if (Size == 0)
                    {
                        label1.Text = $"Size: 0 bytes (empty file)";
                    }
                    else if (Size > 1024 && Size < 1048576)
                    {
                        Size       /= 1024;
                        label1.Text = $"Size: {Size:0.00}KB";
                    }
                    else if (Size > 1048576 && Size < 1073741824)
                    {
                        Size       /= 1048576;
                        label1.Text = $"Size: {Size:0.00}MB";
                    }
                    else if (Size > 1073741824)
                    {
                        Size       /= 1073741824;
                        label1.Text = $"Size: {Size:0.00}GB";
                    }
                    else
                    {
                        label1.Text = $"Size: {Size} bytes";
                    }

                    var Name = Rom.FileDict[$"/{e.Node.FullPath}"].Name;

                    label4.Text = Name;

                    var Ext = Name.Split('.')[Name.Count(c => c == '.')].ToUpper();

                    if (CheckExtension(Ext, "bfstm"))
                    {
                        try
                        {
                            label6.Visible = true;
                            label7.Visible = true;

                            button2.Visible = true;
                            button3.Visible = true;

                            SoundFile = new VGAudio.Containers.NintendoWare.BCFstmReader().Read
                                        (
                                Rom.OpenFile(Rom.FileDict[$"/{e.Node.FullPath}"])
                                        )
                                        .GetAllFormats()
                                        .ToArray()[0];

                            label6.Text = $"Length: {new TimeSpan((SoundFile.SampleCount / SoundFile.SampleRate) * 10000000).ToString("mm':'ss")}";
                            label7.Text = $"Sample rate: {(decimal)(SoundFile.SampleRate / 1000)}KHz";
                        }
                        catch (Exception)
                        {
                        }
                    }
                    else if (CheckExtension(Ext, "wav"))
                    {
                        try
                        {
                            label6.Visible = true;
                            label7.Visible = true;

                            button2.Visible = true;
                            button3.Visible = true;

                            SoundFile = new VGAudio.Containers.Wave.WaveReader().Read
                                        (
                                Rom.OpenFile(Rom.FileDict[$"/{e.Node.FullPath}"])
                                        )
                                        .GetAllFormats()
                                        .ToArray()[0];

                            label6.Text = $"Length: {new TimeSpan((SoundFile.SampleCount / SoundFile.SampleRate) * 10000000).ToString("mm':'ss")}";
                            label7.Text = $"Sample rate: {(decimal)(SoundFile.SampleRate / 1000)}KHz";
                        }
                        catch (Exception)
                        {
                        }
                    }
                    else
                    {
                        label6.Visible = false;
                        label7.Visible = false;

                        button2.Visible = false;
                        button3.Visible = false;
                    }

                    label5.Text = $"{Ext} file";
                }
                else
                {
                    if (e.Node.Nodes.Count == 1)
                    {
                        label5.Text = "1 file";
                    }
                    else
                    {
                        label5.Text = $"{e.Node.Nodes.Count} files";
                    }

                    label4.Text = e.Node.Name;
                    label1.Text = "Folder";
                }
            }
            else if (e.Button == MouseButtons.Right)
            {
                if (treeView1.SelectedNode.Nodes.Count == 0)
                {
                    extractFileToolStripMenuItem.Text = "Extract file...";
                    contextMenuStrip1.Show(Cursor.Position);
                }
                else
                {
                    extractFileToolStripMenuItem.Text = "Extract folder...";
                    contextMenuStrip1.Show(Cursor.Position);
                }
            }
        }