mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/PCK-Studio.git
synced 2026-06-06 16:16:04 +00:00
PCKFile - Add "XMLVERSION" const, Rename 'GatherPropertiesList' -> 'GetPropertyList'
This commit is contained in:
@@ -10,6 +10,8 @@ namespace PckStudio.Classes.FileTypes
|
||||
public int type { get; }
|
||||
public List<FileData> Files { get; } = new List<FileData>();
|
||||
|
||||
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<string> GatherPropertiesList()
|
||||
public List<string> GetPropertyList()
|
||||
{
|
||||
var LUT = new List<string>();
|
||||
Files.ForEach(file => file.properties.ForEach(pair =>
|
||||
|
||||
@@ -9,7 +9,7 @@ namespace PckStudio.Classes.IO.PCK
|
||||
internal class PCKFileReader : StreamDataReader<PCKFile>
|
||||
{
|
||||
private PCKFile _file;
|
||||
private List<string> LUT;
|
||||
private IList<string> _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<string>(count);
|
||||
_propertyList = new List<string>(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));
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@ namespace PckStudio.Classes.IO.PCK
|
||||
internal class PCKFileWriter : StreamDataWriter
|
||||
{
|
||||
private PCKFile _pckfile;
|
||||
private List<string> LUT = new List<string>();
|
||||
private IList<string> _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);
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user