diff --git a/PCK-Studio/Forms/Editor/AudioEditor.Designer.cs b/PCK-Studio/Forms/Editor/AudioEditor.Designer.cs index 1841a28c..e64db857 100644 --- a/PCK-Studio/Forms/Editor/AudioEditor.Designer.cs +++ b/PCK-Studio/Forms/Editor/AudioEditor.Designer.cs @@ -42,6 +42,7 @@ namespace PckStudio.Forms.Editor this.toolsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.creditsEditorToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.deleteUnusedBINKAsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.openDataFolderToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.helpToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.howToAddSongsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.whatIsEachCategoryToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); @@ -56,7 +57,7 @@ namespace PckStudio.Forms.Editor this.playOverworldInCreative = new MetroFramework.Controls.MetroCheckBox(); this.compressionUpDown = new System.Windows.Forms.NumericUpDown(); this.metroLabel1 = new MetroFramework.Controls.MetroLabel(); - this.openDataFolderToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.bulkReplaceExistingTracksToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.contextMenuStrip1.SuspendLayout(); this.menuStrip.SuspendLayout(); this.contextMenuStrip2.SuspendLayout(); @@ -80,66 +81,67 @@ namespace PckStudio.Forms.Editor this.contextMenuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { this.addCategoryStripMenuItem, this.removeCategoryStripMenuItem}); - this.contextMenuStrip1.Name = "contextMenuStrip1"; - resources.ApplyResources(this.contextMenuStrip1, "contextMenuStrip1"); - // - // addCategoryStripMenuItem - // - resources.ApplyResources(this.addCategoryStripMenuItem, "addCategoryStripMenuItem"); - this.addCategoryStripMenuItem.Name = "addCategoryStripMenuItem"; - this.addCategoryStripMenuItem.Click += new System.EventHandler(this.addCategoryStripMenuItem_Click); - // - // removeCategoryStripMenuItem - // - this.removeCategoryStripMenuItem.Image = global::PckStudio.Properties.Resources.Del; - this.removeCategoryStripMenuItem.Name = "removeCategoryStripMenuItem"; - resources.ApplyResources(this.removeCategoryStripMenuItem, "removeCategoryStripMenuItem"); - this.removeCategoryStripMenuItem.Click += new System.EventHandler(this.removeCategoryStripMenuItem_Click); - // - // catImages - // - this.catImages.ImageStream = ((System.Windows.Forms.ImageListStreamer)(resources.GetObject("catImages.ImageStream"))); - this.catImages.TransparentColor = System.Drawing.Color.Transparent; - this.catImages.Images.SetKeyName(0, "0_overworld.png"); - this.catImages.Images.SetKeyName(1, "1_nether.png"); - this.catImages.Images.SetKeyName(2, "2_end.png"); - this.catImages.Images.SetKeyName(3, "4_creative.png"); - this.catImages.Images.SetKeyName(4, "3_menu.png"); - this.catImages.Images.SetKeyName(5, "5_mg01.png"); - this.catImages.Images.SetKeyName(6, "6_mg02.png"); - this.catImages.Images.SetKeyName(7, "7_mg03.png"); - this.catImages.Images.SetKeyName(8, "8_unused.png"); - // - // menuStrip - // - resources.ApplyResources(this.menuStrip, "menuStrip"); - this.menuStrip.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(64)))), ((int)(((byte)(64)))), ((int)(((byte)(64))))); - this.menuStrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.contextMenuStrip1.Name = "contextMenuStrip1"; + resources.ApplyResources(this.contextMenuStrip1, "contextMenuStrip1"); + // + // addCategoryStripMenuItem + // + resources.ApplyResources(this.addCategoryStripMenuItem, "addCategoryStripMenuItem"); + this.addCategoryStripMenuItem.Name = "addCategoryStripMenuItem"; + this.addCategoryStripMenuItem.Click += new System.EventHandler(this.addCategoryStripMenuItem_Click); + // + // removeCategoryStripMenuItem + // + this.removeCategoryStripMenuItem.Image = global::PckStudio.Properties.Resources.Del; + this.removeCategoryStripMenuItem.Name = "removeCategoryStripMenuItem"; + resources.ApplyResources(this.removeCategoryStripMenuItem, "removeCategoryStripMenuItem"); + this.removeCategoryStripMenuItem.Click += new System.EventHandler(this.removeCategoryStripMenuItem_Click); + // + // catImages + // + this.catImages.ImageStream = ((System.Windows.Forms.ImageListStreamer)(resources.GetObject("catImages.ImageStream"))); + this.catImages.TransparentColor = System.Drawing.Color.Transparent; + this.catImages.Images.SetKeyName(0, "0_overworld.png"); + this.catImages.Images.SetKeyName(1, "1_nether.png"); + this.catImages.Images.SetKeyName(2, "2_end.png"); + this.catImages.Images.SetKeyName(3, "4_creative.png"); + this.catImages.Images.SetKeyName(4, "3_menu.png"); + this.catImages.Images.SetKeyName(5, "5_mg01.png"); + this.catImages.Images.SetKeyName(6, "6_mg02.png"); + this.catImages.Images.SetKeyName(7, "7_mg03.png"); + this.catImages.Images.SetKeyName(8, "8_unused.png"); + // + // menuStrip + // + resources.ApplyResources(this.menuStrip, "menuStrip"); + this.menuStrip.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(64)))), ((int)(((byte)(64)))), ((int)(((byte)(64))))); + this.menuStrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { this.fileToolStripMenuItem, this.toolsToolStripMenuItem, this.helpToolStripMenuItem}); - this.menuStrip.Name = "menuStrip"; - // - // fileToolStripMenuItem - // - this.fileToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.menuStrip.Name = "menuStrip"; + // + // fileToolStripMenuItem + // + this.fileToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { this.saveToolStripMenuItem1}); - this.fileToolStripMenuItem.ForeColor = System.Drawing.Color.White; - this.fileToolStripMenuItem.Name = "fileToolStripMenuItem"; - resources.ApplyResources(this.fileToolStripMenuItem, "fileToolStripMenuItem"); - // - // saveToolStripMenuItem1 - // - resources.ApplyResources(this.saveToolStripMenuItem1, "saveToolStripMenuItem1"); - this.saveToolStripMenuItem1.Name = "saveToolStripMenuItem1"; - this.saveToolStripMenuItem1.Click += new System.EventHandler(this.saveToolStripMenuItem1_Click); - // - // toolsToolStripMenuItem - // - this.toolsToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.fileToolStripMenuItem.ForeColor = System.Drawing.Color.White; + this.fileToolStripMenuItem.Name = "fileToolStripMenuItem"; + resources.ApplyResources(this.fileToolStripMenuItem, "fileToolStripMenuItem"); + // + // saveToolStripMenuItem1 + // + resources.ApplyResources(this.saveToolStripMenuItem1, "saveToolStripMenuItem1"); + this.saveToolStripMenuItem1.Name = "saveToolStripMenuItem1"; + this.saveToolStripMenuItem1.Click += new System.EventHandler(this.saveToolStripMenuItem1_Click); + // + // toolsToolStripMenuItem + // + this.toolsToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { this.creditsEditorToolStripMenuItem, this.deleteUnusedBINKAsToolStripMenuItem, - this.openDataFolderToolStripMenuItem}); + this.openDataFolderToolStripMenuItem, + this.bulkReplaceExistingTracksToolStripMenuItem}); this.toolsToolStripMenuItem.ForeColor = System.Drawing.Color.White; this.toolsToolStripMenuItem.Name = "toolsToolStripMenuItem"; resources.ApplyResources(this.toolsToolStripMenuItem, "toolsToolStripMenuItem"); @@ -158,6 +160,13 @@ namespace PckStudio.Forms.Editor resources.ApplyResources(this.deleteUnusedBINKAsToolStripMenuItem, "deleteUnusedBINKAsToolStripMenuItem"); this.deleteUnusedBINKAsToolStripMenuItem.Click += new System.EventHandler(this.deleteUnusedBINKAsToolStripMenuItem_Click); // + // openDataFolderToolStripMenuItem + // + this.openDataFolderToolStripMenuItem.Image = global::PckStudio.Properties.Resources.ZZFolder; + this.openDataFolderToolStripMenuItem.Name = "openDataFolderToolStripMenuItem"; + resources.ApplyResources(this.openDataFolderToolStripMenuItem, "openDataFolderToolStripMenuItem"); + this.openDataFolderToolStripMenuItem.Click += new System.EventHandler(this.openDataFolderToolStripMenuItem_Click); + // // helpToolStripMenuItem // this.helpToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { @@ -279,12 +288,11 @@ namespace PckStudio.Forms.Editor this.metroLabel1.Name = "metroLabel1"; this.metroLabel1.Theme = MetroFramework.MetroThemeStyle.Dark; // - // openDataFolderToolStripMenuItem + // bulkReplaceExistingTracksToolStripMenuItem // - this.openDataFolderToolStripMenuItem.Image = global::PckStudio.Properties.Resources.ZZFolder; - this.openDataFolderToolStripMenuItem.Name = "openDataFolderToolStripMenuItem"; - resources.ApplyResources(this.openDataFolderToolStripMenuItem, "openDataFolderToolStripMenuItem"); - this.openDataFolderToolStripMenuItem.Click += new System.EventHandler(this.openDataFolderToolStripMenuItem_Click); + this.bulkReplaceExistingTracksToolStripMenuItem.Name = "bulkReplaceExistingTracksToolStripMenuItem"; + resources.ApplyResources(this.bulkReplaceExistingTracksToolStripMenuItem, "bulkReplaceExistingTracksToolStripMenuItem"); + this.bulkReplaceExistingTracksToolStripMenuItem.Click += new System.EventHandler(this.bulkReplaceExistingFilesToolStripMenuItem_Click); // // AudioEditor // @@ -339,5 +347,6 @@ namespace PckStudio.Forms.Editor private System.Windows.Forms.ToolStripMenuItem bINKACompressionToolStripMenuItem; private MetroFramework.Controls.MetroLabel metroLabel1; private System.Windows.Forms.ToolStripMenuItem openDataFolderToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem bulkReplaceExistingTracksToolStripMenuItem; } } \ No newline at end of file diff --git a/PCK-Studio/Forms/Editor/AudioEditor.cs b/PCK-Studio/Forms/Editor/AudioEditor.cs index 4d9b0a2c..ad3c0bda 100644 --- a/PCK-Studio/Forms/Editor/AudioEditor.cs +++ b/PCK-Studio/Forms/Editor/AudioEditor.cs @@ -457,5 +457,64 @@ namespace PckStudio.Forms.Editor if (Owner.Owner is MainForm p) parent = p; else Close(); } + + private async void bulkReplaceExistingFilesToolStripMenuItem_Click(object sender, EventArgs e) + { + if (!parent.CreateDataFolder()) return; + + OpenFileDialog ofn = new OpenFileDialog(); + ofn.Multiselect = true; + ofn.Filter = "Supported audio files (*.binka,*.wav)|*.binka;*.wav"; + ofn.Title = "Please choose WAV or BINKA files to replace existing track files"; + ofn.ShowDialog(); + ofn.Dispose(); + if (string.IsNullOrEmpty(ofn.FileName)) return; // Return if name is null or if the user cancels + + var totalSongList = new List(); + foreach (string song in audioFile.Categories.SelectMany(cat => cat.SongNames)) + { + totalSongList.Add(song); + } + + foreach (string file in ofn.FileNames) + { + string song_name = Path.GetFileNameWithoutExtension(file); + string file_ext = Path.GetExtension(file).ToLower(); + string new_loc = Path.Combine(parent.GetDataPath(), Path.GetFileNameWithoutExtension(file) + ".binka"); + if (!totalSongList.Contains(song_name) || file == new_loc) continue; + + Console.WriteLine(file); + File.Delete(new_loc); + + if (file_ext == ".wav") // Convert Wave to BINKA + { + Cursor.Current = Cursors.WaitCursor; + pleaseWait waitDiag = new pleaseWait(); + waitDiag.Show(this); + + int error_code = 0; + await Task.Run(() => + { + var process = Process.Start(new ProcessStartInfo + { + FileName = Path.Combine(tempDir, "binka_encode.exe"), + Arguments = $"\"{file}\" \"{new_loc}\" -s -b" + compressionUpDown.Value.ToString(), + UseShellExecute = true, + CreateNoWindow = true, + WindowStyle = ProcessWindowStyle.Hidden + }); + process.Start(); + process.WaitForExit(); + }); + + waitDiag.Close(); + waitDiag.Dispose(); + Cursor.Current = Cursors.Default; + + if (error_code != 0) continue; + } + else if(file_ext == ".binka") File.Copy(file, Path.Combine(parent.GetDataPath(), Path.GetFileName(file))); + } + } } } diff --git a/PCK-Studio/Forms/Editor/AudioEditor.resx b/PCK-Studio/Forms/Editor/AudioEditor.resx index 758df299..1e1140d7 100644 --- a/PCK-Studio/Forms/Editor/AudioEditor.resx +++ b/PCK-Studio/Forms/Editor/AudioEditor.resx @@ -166,7 +166,7 @@ AAEAAAD/////AQAAAAAAAAAMAgAAAFdTeXN0ZW0uV2luZG93cy5Gb3JtcywgVmVyc2lvbj00LjAuMC4w LCBDdWx0dXJlPW5ldXRyYWwsIFB1YmxpY0tleVRva2VuPWI3N2E1YzU2MTkzNGUwODkFAQAAACZTeXN0 ZW0uV2luZG93cy5Gb3Jtcy5JbWFnZUxpc3RTdHJlYW1lcgEAAAAERGF0YQcCAgAAAAkDAAAADwMAAADk - MAAAAk1TRnQBSQFMAgEBCQEAAVgBAAFYAQABEAEAARABAAT/ASEBAAj/AUIBTQE2BwABNgMAASgDAAFA + MAAAAk1TRnQBSQFMAgEBCQEAAWABAAFgAQABEAEAARABAAT/ASEBAAj/AUIBTQE2BwABNgMAASgDAAFA AwABMAMAAQEBAAEgBgABMBIAAzgB/wM1Af8DNQH/AzMB/wMwAf8DLwH/Ay0B/wMtAf8DJAH/AzsB/wM4 Af8DNQH/Ay0B/wMnAf8DNgH/AzIB/8AAAzgB/wN/Af8DeQH/A3kB/wN5Af8DcQH/A3EB/wN5Af8DeQH/ A3EB/wNxAf8DcQH/A3kB/wN5Af8DfwH/AzIB/8AAAzIB/wN2Af8DsAH/A7AB/wOvAf8DrwH/A68B/wOo @@ -410,36 +410,6 @@ False - - 20, 60 - - - 410, 24 - - - 11 - - - menuStrip1 - - - menuStrip - - - System.Windows.Forms.MenuStrip, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - $this - - - 7 - - - 37, 20 - - - File - iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABGdBTUEAALGPC/xhBQAAAAlwSFlzAAAO @@ -456,29 +426,41 @@ Save - - 46, 20 + + 37, 20 - - Tools + + File - 192, 22 + 220, 22 Credits Editor - 192, 22 + 220, 22 Delete Unused BINKAs - - 44, 20 + + 220, 22 - - Help + + Open Data Folder + + + 220, 22 + + + Bulk Replace Existing Tracks + + + 46, 20 + + + Tools 245, 22 @@ -510,14 +492,8 @@ BINKA Compression - - Top, Bottom, Left, Right - - - 282, 8 - - - 174, 70 + + 44, 20 Help @@ -528,8 +504,8 @@ 410, 24 - - 279, 208 + + 11 menuStrip1 @@ -543,8 +519,11 @@ $this - - 6 + + 7 + + + Top, Bottom, Left, Right 282, 8 @@ -680,12 +659,6 @@ 2 - - 192, 22 - - - Open Data Folder - True @@ -752,6 +725,12 @@ System.Windows.Forms.ToolStripMenuItem, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + openDataFolderToolStripMenuItem + + + System.Windows.Forms.ToolStripMenuItem, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + helpToolStripMenuItem @@ -806,10 +785,10 @@ System.Windows.Forms.ToolStripMenuItem, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - openDataFolderToolStripMenuItem + + bulkReplaceExistingTracksToolStripMenuItem - + System.Windows.Forms.ToolStripMenuItem, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089