Exemple #1
0
 private void BtnDecompressAs_Click(object sender, EventArgs e)
 {
     if (!string.IsNullOrEmpty(txtInput.Text))
     {
         DtpkFile track = LoadTrack();
         if (track != null && !track.Is2018Format)
         {
             SaveFileDialog sfd = new SaveFileDialog();
             sfd.Filter = "AM2 DTPK Digital Track PacKage (*.snd)|*.snd|All Files (*.*)|*.*";
             if (sfd.ShowDialog(this) == DialogResult.OK)
             {
                 DtpkFile unpacked = track.Decompress(chk32bit.Checked);
                 File.WriteAllBytes(sfd.FileName, unpacked.FileData);
                 txtTrackInfo.Text = $"Original File:{Environment.NewLine}" + track.PrintSamplesInfo() +
                                     $"{Environment.NewLine}{Environment.NewLine}Decompressed File:{Environment.NewLine}" +
                                     unpacked.PrintSamplesInfo();
             }
         }
         else
         {
             MessageBox.Show("This track appears to be in the format used by the 2018 ports, which doesn't contain compressed samples. Nothing to decompress.", "Nothing to do", MessageBoxButtons.OK, MessageBoxIcon.Error);
         }
     }
 }
Exemple #2
0
 static void Main(string[] args)
 {
     if (args.Length > 0)
     {
         //Note: This console output won't actually print to the console because it's a desktop app.
         //It can be fixed, but this is a bonus feature anyway so just use it correctly.
         Console.WriteLine("DTPKUtil Command Line");
         if (args[0].Equals("/?") || args[0].Equals("-help"))
         {
             Console.WriteLine("  -help These instructions");
             Console.WriteLine("  -decompress <inputFile> <outputFile>");
             Console.WriteLine("      Decompress a .SND file normally.");
             Console.WriteLine("  -decompress32 <inputFile> <outputFile>");
             Console.WriteLine("      Decompress a .SND file and expand samples for PC release.");
             return;
         }
         if (args.Length >= 3)
         {
             if (args[0].Equals("-decompress") && args.Length == 3)
             {
                 try
                 {
                     if (File.Exists(args[1]))
                     {
                         DtpkFile file = new DtpkFile(File.ReadAllBytes(args[1]));
                         file = file.Decompress(false);
                         File.WriteAllBytes(args[2], file.FileData);
                         Console.WriteLine("File decompressed successfully");
                         return;
                     }
                 }
                 finally
                 {
                     Console.WriteLine("Bad file specified");
                 }
             }
             else if (args[0].Equals("-decompress32") && args.Length == 3)
             {
                 try
                 {
                     if (File.Exists(args[1]))
                     {
                         DtpkFile file = new DtpkFile(File.ReadAllBytes(args[1]));
                         file = file.Decompress(true);
                         File.WriteAllBytes(args[2], file.FileData);
                         Console.WriteLine("File decompressed successfully");
                         return;
                     }
                 }
                 finally
                 {
                     Console.WriteLine("Bad file specified");
                 }
             }
             else
             {
                 Console.WriteLine("Launched with unexpected arguments. Use -help for instructions");
             }
             return;
         }
     }
     Application.EnableVisualStyles();
     Application.SetCompatibleTextRenderingDefault(false);
     Application.Run(new MainView());
 }