diff --git a/PCK-Studio/MainForm.Designer.cs b/PCK-Studio/MainForm.Designer.cs index 6c7fe187..4de6a5a9 100644 --- a/PCK-Studio/MainForm.Designer.cs +++ b/PCK-Studio/MainForm.Designer.cs @@ -109,6 +109,7 @@ this.PS3PCKInstallerToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.VitaPCKInstallerToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.joinDevelopmentDiscordToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.trelloBoardToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.miscToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.addCustomPackImageToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.contextMenuMetaTree = new System.Windows.Forms.ContextMenuStrip(this.components); @@ -138,9 +139,11 @@ this.label11 = new MetroFramework.Controls.MetroLabel(); this.treeViewMain = new System.Windows.Forms.TreeView(); this.imageList = new System.Windows.Forms.ImageList(this.components); - this.pictureBoxImagePreview = new PckStudio.PictureBoxWithInterpolationMode(); this.LittleEndianCheckBox = new MetroFramework.Controls.MetroCheckBox(); - this.trelloBoardToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.convertMusicFilesToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.wavBinkaToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.binkaWavToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.pictureBoxImagePreview = new PckStudio.PictureBoxWithInterpolationMode(); this.contextMenuPCKEntries.SuspendLayout(); this.menuStrip.SuspendLayout(); this.contextMenuMetaTree.SuspendLayout(); @@ -708,10 +711,17 @@ this.joinDevelopmentDiscordToolStripMenuItem.Name = "joinDevelopmentDiscordToolStripMenuItem"; this.joinDevelopmentDiscordToolStripMenuItem.Click += new System.EventHandler(this.joinDevelopmentDiscordToolStripMenuItem_Click); // + // trelloBoardToolStripMenuItem + // + this.trelloBoardToolStripMenuItem.Name = "trelloBoardToolStripMenuItem"; + resources.ApplyResources(this.trelloBoardToolStripMenuItem, "trelloBoardToolStripMenuItem"); + this.trelloBoardToolStripMenuItem.Click += new System.EventHandler(this.trelloBoardToolStripMenuItem_Click); + // // miscToolStripMenuItem // this.miscToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { - this.addCustomPackImageToolStripMenuItem}); + this.addCustomPackImageToolStripMenuItem, + this.convertMusicFilesToolStripMenuItem}); this.miscToolStripMenuItem.ForeColor = System.Drawing.Color.White; this.miscToolStripMenuItem.Name = "miscToolStripMenuItem"; resources.ApplyResources(this.miscToolStripMenuItem, "miscToolStripMenuItem"); @@ -1023,14 +1033,6 @@ resources.ApplyResources(this.imageList, "imageList"); this.imageList.TransparentColor = System.Drawing.Color.Transparent; // - // pictureBoxImagePreview - // - resources.ApplyResources(this.pictureBoxImagePreview, "pictureBoxImagePreview"); - this.pictureBoxImagePreview.BackColor = System.Drawing.Color.Transparent; - this.pictureBoxImagePreview.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.NearestNeighbor; - this.pictureBoxImagePreview.Name = "pictureBoxImagePreview"; - this.pictureBoxImagePreview.TabStop = false; - // // LittleEndianCheckBox // resources.ApplyResources(this.LittleEndianCheckBox, "LittleEndianCheckBox"); @@ -1040,11 +1042,33 @@ this.LittleEndianCheckBox.Theme = MetroFramework.MetroThemeStyle.Dark; this.LittleEndianCheckBox.UseSelectable = true; // - // trelloBoardToolStripMenuItem + // convertMusicFilesToolStripMenuItem // - this.trelloBoardToolStripMenuItem.Name = "trelloBoardToolStripMenuItem"; - resources.ApplyResources(this.trelloBoardToolStripMenuItem, "trelloBoardToolStripMenuItem"); - this.trelloBoardToolStripMenuItem.Click += new System.EventHandler(this.trelloBoardToolStripMenuItem_Click); + this.convertMusicFilesToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.wavBinkaToolStripMenuItem, + this.binkaWavToolStripMenuItem}); + this.convertMusicFilesToolStripMenuItem.Name = "convertMusicFilesToolStripMenuItem"; + resources.ApplyResources(this.convertMusicFilesToolStripMenuItem, "convertMusicFilesToolStripMenuItem"); + // + // wavBinkaToolStripMenuItem + // + this.wavBinkaToolStripMenuItem.Name = "wavBinkaToolStripMenuItem"; + resources.ApplyResources(this.wavBinkaToolStripMenuItem, "wavBinkaToolStripMenuItem"); + this.wavBinkaToolStripMenuItem.Click += new System.EventHandler(this.wavBinkaToolStripMenuItem_Click); + // + // binkaWavToolStripMenuItem + // + this.binkaWavToolStripMenuItem.Name = "binkaWavToolStripMenuItem"; + resources.ApplyResources(this.binkaWavToolStripMenuItem, "binkaWavToolStripMenuItem"); + this.binkaWavToolStripMenuItem.Click += new System.EventHandler(this.binkaWavToolStripMenuItem_Click); + // + // pictureBoxImagePreview + // + resources.ApplyResources(this.pictureBoxImagePreview, "pictureBoxImagePreview"); + this.pictureBoxImagePreview.BackColor = System.Drawing.Color.Transparent; + this.pictureBoxImagePreview.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.NearestNeighbor; + this.pictureBoxImagePreview.Name = "pictureBoxImagePreview"; + this.pictureBoxImagePreview.TabStop = false; // // MainForm // @@ -1196,6 +1220,9 @@ private System.Windows.Forms.ToolStripMenuItem behavioursbinToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem entityMaterialsbinToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem trelloBoardToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem convertMusicFilesToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem wavBinkaToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem binkaWavToolStripMenuItem; } } diff --git a/PCK-Studio/MainForm.cs b/PCK-Studio/MainForm.cs index 7023903d..ae54aef6 100644 --- a/PCK-Studio/MainForm.cs +++ b/PCK-Studio/MainForm.cs @@ -2253,6 +2253,82 @@ namespace PckStudio { Process.Start("https://trello.com/b/0XLNOEbe/pck-studio"); } + + private async void wavBinkaToolStripMenuItem_Click(object sender, EventArgs e) + { + int success = 0; + int exitCode = 0; + + OpenFileDialog ofn = new OpenFileDialog(); + ofn.Multiselect = true; + ofn.Filter = "WAV files (*.wav)|*.wav"; + ofn.Title = "Please choose WAV files to convert to BINKA"; + ofn.ShowDialog(); + ofn.Dispose(); + if (ofn.FileNames.Length < 1) return; // Return if empty or if the user cancels + + Forms.Additional_Popups.Audio.pleaseWait waitDiag = new Forms.Additional_Popups.Audio.pleaseWait(); + waitDiag.Show(this); + foreach (string file in ofn.FileNames) + { + string songName = string.Join("_", Path.GetFileNameWithoutExtension(file).Split(Path.GetInvalidFileNameChars())); + songName = System.Text.RegularExpressions.Regex.Replace(songName, @"[^\u0000-\u007F]+", "_"); // Replace UTF characters + string cacheSongLoc = Path.Combine(Program.AppDataCache, songName + Path.GetExtension(file)); + + if (File.Exists(cacheSongLoc)) File.Delete(cacheSongLoc); + + using (var reader = new NAudio.Wave.WaveFileReader(file)) //read from original location + { + var newFormat = new NAudio.Wave.WaveFormat(reader.WaveFormat.SampleRate, 16, reader.WaveFormat.Channels); + using (var conversionStream = new NAudio.Wave.WaveFormatConversionStream(newFormat, reader)) + { + NAudio.Wave.WaveFileWriter.CreateWaveFile(cacheSongLoc, conversionStream); //write to new location + } + reader.Close(); + reader.Dispose(); + } + + Cursor.Current = Cursors.WaitCursor; + + await System.Threading.Tasks.Task.Run(() => + { + exitCode = Classes.Binka.FromWav(cacheSongLoc, Path.Combine(Path.GetDirectoryName(file), Path.GetFileNameWithoutExtension(file) + ".binka"), 4); + }); + + if (exitCode != 0) continue; + + success++; + } + + waitDiag.Close(); + waitDiag.Dispose(); + MessageBox.Show(this, $"Successfully converted {success}/{ofn.FileNames.Length} file{(ofn.FileNames.Length != 1 ? "s" : "")}", "Done!"); + } + + private void binkaWavToolStripMenuItem_Click(object sender, EventArgs e) + { + int success = 0; + + OpenFileDialog ofn = new OpenFileDialog(); + ofn.Multiselect = true; + ofn.Filter = "BINKA files (*.binka)|*.binka"; + ofn.Title = "Please choose BINKA files to convert to WAV"; + ofn.ShowDialog(); + ofn.Dispose(); + if (ofn.FileNames.Length < 1) return; // Return if empty or if the user cancels + + Forms.Additional_Popups.Audio.pleaseWait waitDiag = new Forms.Additional_Popups.Audio.pleaseWait(); + waitDiag.Show(this); + foreach (string file in ofn.FileNames) + { + Classes.Binka.ToWav(file, Path.Combine(Path.GetDirectoryName(file), Path.GetFileNameWithoutExtension(file) + ".binka")); + success++; + } + + waitDiag.Close(); + waitDiag.Dispose(); + MessageBox.Show(this, $"Successfully converted {success}/{ofn.FileNames.Length} file{(ofn.FileNames.Length != 1 ? "s" : "")}", "Done!"); + } } public class PckNodeSorter : System.Collections.IComparer, IComparer diff --git a/PCK-Studio/MainForm.resx b/PCK-Studio/MainForm.resx index 87f4f54a..033a24e2 100644 --- a/PCK-Studio/MainForm.resx +++ b/PCK-Studio/MainForm.resx @@ -28511,11 +28511,29 @@ Add Custom Pack Icon + + 180, 22 + + + Wav -> Binka + + + 180, 22 + + + Binka -> Wav + + + 195, 22 + + + Convert Music Files + - 47, 20 + 46, 20 - Misc. + Tools 24, 44 @@ -33927,6 +33945,12 @@ System.Windows.Forms.ToolStripMenuItem, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + trelloBoardToolStripMenuItem + + + System.Windows.Forms.ToolStripMenuItem, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + miscToolStripMenuItem @@ -33969,10 +33993,22 @@ System.Windows.Forms.ImageList, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - trelloBoardToolStripMenuItem + + convertMusicFilesToolStripMenuItem - + + System.Windows.Forms.ToolStripMenuItem, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + wavBinkaToolStripMenuItem + + + System.Windows.Forms.ToolStripMenuItem, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + binkaWavToolStripMenuItem + + System.Windows.Forms.ToolStripMenuItem, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089