diff --git a/PCK-Studio/Classes/FileTypes/PCKFile.cs b/PCK-Studio/Classes/FileTypes/PCKFile.cs index 56ada75e..ef3f4db0 100644 --- a/PCK-Studio/Classes/FileTypes/PCKFile.cs +++ b/PCK-Studio/Classes/FileTypes/PCKFile.cs @@ -10,6 +10,8 @@ namespace PckStudio.Classes.FileTypes public int type { get; } public List Files { get; } = new List(); + public const string XMLVersionString = "XMLVERSION"; + public class FileData { public enum FileType : int @@ -104,7 +106,7 @@ namespace PckStudio.Classes.FileTypes this.type = type; } - public List GatherPropertiesList() + public List GetPropertyList() { var LUT = new List(); Files.ForEach(file => file.properties.ForEach(pair => diff --git a/PCK-Studio/Classes/IO/PCK/PCKFileReader.cs b/PCK-Studio/Classes/IO/PCK/PCKFileReader.cs index 52bc28c0..d4bb97d9 100644 --- a/PCK-Studio/Classes/IO/PCK/PCKFileReader.cs +++ b/PCK-Studio/Classes/IO/PCK/PCKFileReader.cs @@ -9,7 +9,7 @@ namespace PckStudio.Classes.IO.PCK internal class PCKFileReader : StreamDataReader { private PCKFile _file; - private List LUT; + private IList _propertyList; public static PCKFile Read(Stream stream, bool isLittleEndian) { @@ -35,14 +35,14 @@ namespace PckStudio.Classes.IO.PCK private void ReadLookUpTable(Stream stream) { int count = ReadInt(stream); - LUT = new List(count); + _propertyList = new List(count); for (int i = 0; i < count; i++) { int index = ReadInt(stream); string value = ReadString(stream); - LUT.Insert(index, value); + _propertyList.Insert(index, value); } - if (LUT.Contains("XMLVERSION")) + if (_propertyList.Contains(PCKFile.XMLVersionString)) Console.WriteLine(ReadInt(stream)); // xml version num ?? } @@ -66,7 +66,7 @@ namespace PckStudio.Classes.IO.PCK int property_count = ReadInt(stream); for (; 0 < property_count; property_count--) { - string key = LUT[ReadInt(stream)]; + string key = _propertyList[ReadInt(stream)]; string value = ReadString(stream); file.properties.Add((key, value)); } diff --git a/PCK-Studio/Classes/IO/PCK/PCKFileWriter.cs b/PCK-Studio/Classes/IO/PCK/PCKFileWriter.cs index 5de05a67..dd9d6a3b 100644 --- a/PCK-Studio/Classes/IO/PCK/PCKFileWriter.cs +++ b/PCK-Studio/Classes/IO/PCK/PCKFileWriter.cs @@ -9,7 +9,7 @@ namespace PckStudio.Classes.IO.PCK internal class PCKFileWriter : StreamDataWriter { private PCKFile _pckfile; - private List LUT = new List(); + private IList _propertyList; public static void Write(Stream stream, PCKFile file, bool isLittleEndian, bool isSkinsPCK = false) { @@ -19,8 +19,9 @@ namespace PckStudio.Classes.IO.PCK private PCKFileWriter(PCKFile file, bool isLittleEndian, bool isSkinsPCK) : base(isLittleEndian) { _pckfile = file; - LUT = _pckfile.GatherPropertiesList(); - if (!LUT.Contains("XMLVERSION") && isSkinsPCK) LUT.Insert(0, "XMLVERSION"); + _propertyList = _pckfile.GetPropertyList(); + if (!_propertyList.Contains(PCKFile.XMLVersionString) && isSkinsPCK) + _propertyList.Insert(0, PCKFile.XMLVersionString); } protected override void WriteToStream(Stream stream) @@ -40,13 +41,13 @@ namespace PckStudio.Classes.IO.PCK private void WriteLookUpTable(Stream stream) { - WriteInt(stream, LUT.Count); - LUT.ForEach(entry => + WriteInt(stream, _propertyList.Count); + foreach (var entry in _propertyList) { - WriteInt(stream, LUT.IndexOf(entry)); + WriteInt(stream, _propertyList.IndexOf(entry)); WriteString(stream, entry); - }); - if (LUT.Contains("XMLVERSION")) + }; + if (_propertyList.Contains(PCKFile.XMLVersionString)) WriteInt(stream, 0x1337); // :^) } @@ -68,9 +69,9 @@ namespace PckStudio.Classes.IO.PCK WriteInt(stream, file.properties.Count); foreach (var property in file.properties) { - if (!LUT.Contains(property.Item1)) + if (!_propertyList.Contains(property.Item1)) throw new Exception("Tag not in Look Up Table: " + property.Item1); - WriteInt(stream, LUT.IndexOf(property.Item1)); + WriteInt(stream, _propertyList.IndexOf(property.Item1)); WriteString(stream, property.Item2); } WriteBytes(stream, file.data, file.size); diff --git a/PCK-Studio/Forms/Skins-And-Textures/AdvancedOptions.cs b/PCK-Studio/Forms/Skins-And-Textures/AdvancedOptions.cs index bac1745d..0b4bbcaa 100644 --- a/PCK-Studio/Forms/Skins-And-Textures/AdvancedOptions.cs +++ b/PCK-Studio/Forms/Skins-And-Textures/AdvancedOptions.cs @@ -17,7 +17,7 @@ namespace PckStudio InitializeComponent(); currentPCK = currentPCKIn; treeMeta.Nodes.Clear(); - treeMeta.Nodes.AddRange(currentPCK.GatherPropertiesList().Select((s) => new TreeNode(s)).ToArray()); + treeMeta.Nodes.AddRange(currentPCK.GetPropertyList().Select((s) => new TreeNode(s)).ToArray()); } private void applyButton_Click(object sender, EventArgs e) diff --git a/PCK-Studio/MainForm.cs b/PCK-Studio/MainForm.cs index 1deac7af..578ae699 100644 --- a/PCK-Studio/MainForm.cs +++ b/PCK-Studio/MainForm.cs @@ -1211,7 +1211,7 @@ namespace PckStudio private void metaToolStripMenuItem_Click(object sender, EventArgs e) { - MetaList edit = new MetaList(currentPCK.GatherPropertiesList()); + MetaList edit = new MetaList(currentPCK.GetPropertyList()); edit.TopMost = true; edit.TopLevel = true; edit.Show();