Added open file tool to Audio Editor

This commit is contained in:
MattNL
2023-06-16 08:32:57 -04:00
parent 6b3df15a77
commit d27f5abc03
4 changed files with 57 additions and 5 deletions

View File

@@ -60,6 +60,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.openToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.contextMenuStrip1.SuspendLayout();
this.menuStrip.SuspendLayout();
this.contextMenuStrip2.SuspendLayout();
@@ -132,6 +133,7 @@ namespace PckStudio.Forms.Editor
// fileToolStripMenuItem
//
this.fileToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.openToolStripMenuItem,
this.saveToolStripMenuItem1});
this.fileToolStripMenuItem.ForeColor = System.Drawing.Color.White;
this.fileToolStripMenuItem.Name = "fileToolStripMenuItem";
@@ -305,6 +307,13 @@ namespace PckStudio.Forms.Editor
this.metroLabel1.Name = "metroLabel1";
this.metroLabel1.Theme = MetroFramework.MetroThemeStyle.Dark;
//
// openToolStripMenuItem
//
this.openToolStripMenuItem.Image = global::PckStudio.Properties.Resources.file_import;
this.openToolStripMenuItem.Name = "openToolStripMenuItem";
resources.ApplyResources(this.openToolStripMenuItem, "openToolStripMenuItem");
this.openToolStripMenuItem.Click += new System.EventHandler(this.openToolStripMenuItem_Click);
//
// AudioEditor
//
resources.ApplyResources(this, "$this");
@@ -363,5 +372,6 @@ namespace PckStudio.Forms.Editor
private System.Windows.Forms.ToolStripMenuItem changeCategoryToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem organizeTracksToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem convertToWAVToolStripMenuItem;
}
private System.Windows.Forms.ToolStripMenuItem openToolStripMenuItem;
}
}

View File

@@ -643,5 +643,35 @@ namespace PckStudio.Forms.Editor
saveToolStripMenuItem1_Click(sender, EventArgs.Empty);
}
}
}
private void openToolStripMenuItem_Click(object sender, EventArgs e)
{
using (var ofd = new OpenFileDialog())
{
ofd.CheckFileExists = true;
ofd.Multiselect = false;
ofd.Filter = "Audio.pck (Minecraft Music Cues)|*.pck";
if (ofd.ShowDialog() == DialogResult.OK)
{
try
{
var reader = new PckAudioFileReader(
_isLittleEndian
? OMI.Endianness.LittleEndian
: OMI.Endianness.BigEndian);
audioFile = reader.FromFile(ofd.FileName);
SetUpTree();
}
catch (Exception ex)
{
MessageBox.Show(this, $"Failed to read the selected file\nError: {ex.Message}", "Failed to read audio file");
}
}
else if (audioPCK is null)
{
Close();
}
}
}
}
}

View File

@@ -172,7 +172,7 @@
AAEAAAD/////AQAAAAAAAAAMAgAAAFdTeXN0ZW0uV2luZG93cy5Gb3JtcywgVmVyc2lvbj00LjAuMC4w
LCBDdWx0dXJlPW5ldXRyYWwsIFB1YmxpY0tleVRva2VuPWI3N2E1YzU2MTkzNGUwODkFAQAAACZTeXN0
ZW0uV2luZG93cy5Gb3Jtcy5JbWFnZUxpc3RTdHJlYW1lcgEAAAAERGF0YQcCAgAAAAkDAAAADwMAAACK
NAAAAk1TRnQBSQFMAgEBCQEAAdgBAAHYAQABEAEAARABAAT/ASEBAAj/AUIBTQE2BwABNgMAASgDAAFA
NAAAAk1TRnQBSQFMAgEBCQEAAeABAAHgAQABEAEAARABAAT/ASEBAAj/AUIBTQE2BwABNgMAASgDAAFA
AwABMAMAAQEBAAEgBgABMBIAATkBXgFzAf8BOQFeAXMB/wE5AV4BcwH/AT4BYgF8Af8BMwFUAWkB/wEz
AVQBaQH/AT4BYgF8Af8BMwFUAWkB/wE5AV4BcwH/ATkBXgFzAf8BOQFeAXMB/wEzAVQBaQH/ASYBPQFM
Af8BMwFUAWkB/wEzAVQBaQH/ATkBXgFzAf/AAAFiAZgBvAH/AWIBmAG8Af8BTQGEAZ8B/wFNAYQBnwH/
@@ -432,6 +432,12 @@
<data name="menuStrip.AutoSize" type="System.Boolean, mscorlib">
<value>False</value>
</data>
<data name="openToolStripMenuItem.Size" type="System.Drawing.Size, System.Drawing">
<value>180, 22</value>
</data>
<data name="openToolStripMenuItem.Text" xml:space="preserve">
<value>Open</value>
</data>
<data name="saveToolStripMenuItem1.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABGdBTUEAALGPC/xhBQAAAAlwSFlzAAAO
@@ -443,7 +449,7 @@
</value>
</data>
<data name="saveToolStripMenuItem1.Size" type="System.Drawing.Size, System.Drawing">
<value>98, 22</value>
<value>180, 22</value>
</data>
<data name="saveToolStripMenuItem1.Text" xml:space="preserve">
<value>Save</value>
@@ -840,6 +846,12 @@
<data name="&gt;&gt;convertToWAVToolStripMenuItem.Type" xml:space="preserve">
<value>System.Windows.Forms.ToolStripMenuItem, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;openToolStripMenuItem.Name" xml:space="preserve">
<value>openToolStripMenuItem</value>
</data>
<data name="&gt;&gt;openToolStripMenuItem.Type" xml:space="preserve">
<value>System.Windows.Forms.ToolStripMenuItem, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;$this.Name" xml:space="preserve">
<value>AudioEditor</value>
</data>

View File

@@ -300,7 +300,7 @@ namespace PckStudio.Forms.Editor
}
catch (Exception ex)
{
MessageBox.Show(this, $"Failed to save the selected file\nError: {ex.Message}", "Failed to save .col file");
MessageBox.Show(this, $"Failed to save the selected file\nError: {ex.Message}", "Failed to save behaviour file");
}
}
else return;