Some Music Editor changes

-Fixed a bug where the newly added "Play overworld songs in creative" feature where the songs were being added while in the editor instead of upon closing it.
-The categories now properly sort in the PCK file
This commit is contained in:
MattNL
2022-07-31 16:13:39 -04:00
parent 50ce3e2666
commit 28ee5a59d7
3 changed files with 42 additions and 22 deletions

View File

@@ -208,6 +208,7 @@ namespace PckStudio.Forms.Utilities
this.Name = "AudioEditor";
this.Style = MetroFramework.MetroColorStyle.Silver;
this.Theme = MetroFramework.MetroThemeStyle.Dark;
this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.AudioEditor_FormClosing);
this.FormClosed += new System.Windows.Forms.FormClosedEventHandler(this.AudioEditor_FormClosed);
this.Load += new System.EventHandler(this.AudioEditor_Load);
this.contextMenuStrip1.ResumeLayout(false);

View File

@@ -29,7 +29,6 @@ namespace PckStudio.Forms.Utilities
PCKFile.FileData audioPCKFile;
bool _isLittleEndian;
public List<string> cats = new List<string>();
public class NodeSorter : System.Collections.IComparer
{
public int Compare(object x, object y)
@@ -444,23 +443,13 @@ namespace PckStudio.Forms.Utilities
bool emptyCat = false;
PCKFile.FileData overworldMF = new PCKFile.FileData("", -1);
foreach (PCKFile.FileData mf in audioPCK.Files)
List <PCKFile.FileData> new_order = audioPCK.Files.OrderBy(fd => fd.type).ToList();
audioPCK.Files.Clear();
foreach (PCKFile.FileData mf in new_order)
{
mf.filepath = "";
if (metroCheckBox1.Checked && mf.type == 0) overworldMF = mf;
if (metroCheckBox1.Checked && mf.type == 3 && overworldMF.type != -1)
{
foreach (ValueTuple<string,string> property in overworldMF.properties)
{
if (property.Item1 == "CUENAME" && !mf.properties.Contains(property))
{
mf.properties.Add(property);
Console.WriteLine(property.Item2);
}
}
mf.filepath = "include_overworld";
}
audioPCK.Files.Add(mf);
if (mf.properties.Count == 0) emptyCat = true;
}
@@ -515,5 +504,35 @@ namespace PckStudio.Forms.Utilities
prompt.ShowDialog();
credits = prompt.Credits;
}
}
private void AudioEditor_FormClosing(object sender, FormClosingEventArgs e)
{
if (saved != true) return;
PCKFile.FileData overworldMF = new PCKFile.FileData("", -1);
foreach (PCKFile.FileData mf in audioPCK.Files)
{
mf.filepath = "";
if (metroCheckBox1.Checked && mf.type == 0) overworldMF = mf;
if (metroCheckBox1.Checked && mf.type == 3 && overworldMF.type != -1)
{
foreach (ValueTuple<string, string> property in overworldMF.properties)
{
if (property.Item1 == "CUENAME" && !mf.properties.Contains(property))
{
mf.properties.Add(property);
Console.WriteLine(property.Item2);
}
}
mf.filepath = "include_overworld";
}
}
using (var stream = new MemoryStream())
{
PCKFileWriter.Write(stream, audioPCK, _isLittleEndian);
audioPCKFile.SetData(stream.ToArray());
}
}
}
}

View File

@@ -146,7 +146,7 @@
AAEAAAD/////AQAAAAAAAAAMAgAAAFdTeXN0ZW0uV2luZG93cy5Gb3JtcywgVmVyc2lvbj00LjAuMC4w
LCBDdWx0dXJlPW5ldXRyYWwsIFB1YmxpY0tleVRva2VuPWI3N2E1YzU2MTkzNGUwODkFAQAAACZTeXN0
ZW0uV2luZG93cy5Gb3Jtcy5JbWFnZUxpc3RTdHJlYW1lcgEAAAAERGF0YQcCAgAAAAkDAAAADwMAAADk
MAAAAk1TRnQBSQFMAgEBCQEAASgBAAEoAQABEAEAARABAAT/ASEBAAj/AUIBTQE2BwABNgMAASgDAAFA
MAAAAk1TRnQBSQFMAgEBCQEAATABAAEwAQABEAEAARABAAT/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
@@ -543,13 +543,13 @@
<value>232, 64</value>
</data>
<data name="metroCheckBox1.Size" type="System.Drawing.Size, System.Drawing">
<value>193, 15</value>
<value>194, 15</value>
</data>
<data name="metroCheckBox1.TabIndex" type="System.Int32, mscorlib">
<value>14</value>
</data>
<data name="metroCheckBox1.Text" xml:space="preserve">
<value>Add overworld songs to creative</value>
<value>Play overworld songs in Creative</value>
</data>
<data name="&gt;&gt;metroCheckBox1.Name" xml:space="preserve">
<value>metroCheckBox1</value>
@@ -561,7 +561,7 @@
<value>$this</value>
</data>
<data name="&gt;&gt;metroCheckBox1.ZOrder" xml:space="preserve">
<value>0</value>
<value>2</value>
</data>
<metadata name="$this.Localizable" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>