From 63fac543a869d5a81562da2e8134752c51812310 Mon Sep 17 00:00:00 2001 From: MattNL Date: Mon, 8 Aug 2022 12:39:56 -0400 Subject: [PATCH] Several small Audio Editor fixes --- .../Forms/Editor/AudioEditor.Designer.cs | 1 + .../Forms/Editor/AudioEditor.cs | 37 +++++++++++-------- .../Forms/Editor/AudioEditor.resx | 2 +- 3 files changed, 24 insertions(+), 16 deletions(-) diff --git a/MinecraftUSkinEditor/Forms/Editor/AudioEditor.Designer.cs b/MinecraftUSkinEditor/Forms/Editor/AudioEditor.Designer.cs index 9afe8a3a..bb4417b0 100644 --- a/MinecraftUSkinEditor/Forms/Editor/AudioEditor.Designer.cs +++ b/MinecraftUSkinEditor/Forms/Editor/AudioEditor.Designer.cs @@ -63,6 +63,7 @@ namespace PckStudio.Forms.Editor this.treeView1.LabelEdit = true; this.treeView1.Name = "treeView1"; this.treeView1.AfterSelect += new System.Windows.Forms.TreeViewEventHandler(this.treeView1_AfterSelect); + this.treeView1.KeyDown += new System.Windows.Forms.KeyEventHandler(this.treeView1_KeyDown); // // contextMenuStrip1 // diff --git a/MinecraftUSkinEditor/Forms/Editor/AudioEditor.cs b/MinecraftUSkinEditor/Forms/Editor/AudioEditor.cs index 773d29c2..c7fccafe 100644 --- a/MinecraftUSkinEditor/Forms/Editor/AudioEditor.cs +++ b/MinecraftUSkinEditor/Forms/Editor/AudioEditor.cs @@ -245,6 +245,12 @@ namespace PckStudio.Forms.Editor } } + private void treeView1_KeyDown(object sender, KeyEventArgs e) + { + if (e.KeyCode == Keys.Delete) + removeCategoryStripMenuItem_Click(sender, e); + } + public void treeView2_KeyDown(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Delete) @@ -253,13 +259,10 @@ namespace PckStudio.Forms.Editor private void removeEntryMenuItem_Click(object sender, EventArgs e) { - if (treeView1.SelectedNode is TreeNode main && - treeView2.SelectedNode is TreeNode sub && - sub.Tag is string s && - main.Tag is PCKAudioFile.AudioCategory category) + if (treeView2.SelectedNode != null && treeView1.SelectedNode.Tag is PCKAudioFile.AudioCategory category) { - if (category.SongNames.Remove(s)) - sub.Remove(); + category.SongNames.Remove(treeView2.SelectedNode.Text); + treeView2.SelectedNode.Remove(); } } @@ -273,11 +276,15 @@ namespace PckStudio.Forms.Editor bool duplicate_song = false; // To handle if a file already in the pack is dropped back in if (File.Exists(new_loc)) { - duplicate_song = File.ReadAllBytes(file).Length == File.ReadAllBytes(new_loc).Length; - if (!duplicate_song) + duplicate_song = File.ReadAllBytes(file) == File.ReadAllBytes(new_loc); + if (duplicate_song) { - DialogResult user_prompt = MessageBox.Show("\"" + Path.GetFileNameWithoutExtension(file) + ".binka\" already exists. Continuing will replace the existing file. Are you sure you want to continue moving the file? By pressing no, you will skip this file. You can also cancel all pending file operations.", "File already exists", MessageBoxButtons.YesNoCancel); - if (user_prompt == DialogResult.Cancel) break; + DialogResult user_prompt = MessageBox.Show("\"" + Path.GetFileNameWithoutExtension(file) + ".binka\" already exists. Continuing will replace the existing file. Are you sure you want to continue moving the file? By pressing no, the song entry will be added without moving the file. You can also cancel this operation and all files in queue.", "File already exists", MessageBoxButtons.YesNoCancel); + while (user_prompt == DialogResult.None) ; // Stops the editor from adding or processing the file until the user had made their choice + if (user_prompt == DialogResult.Cancel) + { + break; + } else if (user_prompt == DialogResult.No) continue; } } @@ -328,9 +335,9 @@ namespace PckStudio.Forms.Editor private void Binka_DragDrop(object sender, DragEventArgs e) { - if (treeView1.SelectedNode is TreeNode t && t.Tag is PCKFile.FileData && - // Gets the MainForm so we can access the Save Location - Owner.Owner is MainForm parent) + //MessageBox.Show((Owner.Owner as MainForm).saveLocation); + // Gets the MainForm so we can access the Save Location + if (treeView1.SelectedNode != null && Owner.Owner is MainForm parent) { string DataDirectory = Path.Combine(Path.GetDirectoryName(parent.saveLocation), "Data"); if (!Directory.Exists(DataDirectory)) @@ -349,7 +356,7 @@ namespace PckStudio.Forms.Editor !audioFile.HasCategory(PCKAudioFile.AudioCategory.EAudioType.Nether) || !audioFile.HasCategory(PCKAudioFile.AudioCategory.EAudioType.End)) { - MessageBox.Show("The game will crash upon loading your pack if the Overworld, Nether and End categories don't all exist.", "Mandatory Categories Missing"); + MessageBox.Show("Your changes were not saved. The game will crash when loading your pack if the Overworld, Nether and End categories don't all exist with at least one valid song.", "Mandatory Categories Missing"); return; } @@ -412,7 +419,7 @@ namespace PckStudio.Forms.Editor private void AudioEditor_FormClosing(object sender, FormClosingEventArgs e) { - if (saved) return; + if (!saved) return; saveToolStripMenuItem1_Click(sender, e); } } diff --git a/MinecraftUSkinEditor/Forms/Editor/AudioEditor.resx b/MinecraftUSkinEditor/Forms/Editor/AudioEditor.resx index 37e149c3..838a1802 100644 --- a/MinecraftUSkinEditor/Forms/Editor/AudioEditor.resx +++ b/MinecraftUSkinEditor/Forms/Editor/AudioEditor.resx @@ -166,7 +166,7 @@ AAEAAAD/////AQAAAAAAAAAMAgAAAFdTeXN0ZW0uV2luZG93cy5Gb3JtcywgVmVyc2lvbj00LjAuMC4w LCBDdWx0dXJlPW5ldXRyYWwsIFB1YmxpY0tleVRva2VuPWI3N2E1YzU2MTkzNGUwODkFAQAAACZTeXN0 ZW0uV2luZG93cy5Gb3Jtcy5JbWFnZUxpc3RTdHJlYW1lcgEAAAAERGF0YQcCAgAAAAkDAAAADwMAAADk - MAAAAk1TRnQBSQFMAgEBCQEAATgBAAE4AQABEAEAARABAAT/ASEBAAj/AUIBTQE2BwABNgMAASgDAAFA + MAAAAk1TRnQBSQFMAgEBCQEAAUABAAFAAQABEAEAARABAAT/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