From 35b97f02beb33e578cb51d753a97c9f5582867dd Mon Sep 17 00:00:00 2001 From: MattNL Date: Fri, 21 Oct 2022 19:34:55 -0400 Subject: [PATCH] Brought SkinsPCK support for PCK writer from the SubPCK-Support branch --- PCK-Studio/Classes/IO/PCK/PCKFileWriter.cs | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/PCK-Studio/Classes/IO/PCK/PCKFileWriter.cs b/PCK-Studio/Classes/IO/PCK/PCKFileWriter.cs index 1d655d5a..d253dd30 100644 --- a/PCK-Studio/Classes/IO/PCK/PCKFileWriter.cs +++ b/PCK-Studio/Classes/IO/PCK/PCKFileWriter.cs @@ -11,17 +11,16 @@ namespace PckStudio.Classes.IO private PCKFile _pckfile; private List LUT = new List(); - public static void Write(Stream stream, PCKFile file, bool isLittleEndian) + public static void Write(Stream stream, PCKFile file, bool isLittleEndian, bool isSkinsPCK = false) { - new PCKFileWriter(file, isLittleEndian).WriteToStream(stream); + new PCKFileWriter(file, isLittleEndian, isSkinsPCK).WriteToStream(stream); } - private PCKFileWriter(PCKFile file, bool isLittleEndian) : base(isLittleEndian) + private PCKFileWriter(PCKFile file, bool isLittleEndian, bool isSkinsPCK) : base(isLittleEndian) { _pckfile = file; LUT = _pckfile.GatherPropertiesList(); - // fix for Skins.pck - //if (!file.HasFile("localisation.loc", PCKFile.FileData.FileType.LocalisationFile) && !LUT.Contains("XMLVERSION")) LUT.Insert(0, "XMLVERSION"); + if (!LUT.Contains("XMLVERSION") && isSkinsPCK) LUT.Insert(0, "XMLVERSION"); } private void WriteToStream(Stream stream) @@ -42,11 +41,11 @@ namespace PckStudio.Classes.IO private void WriteLookUpTable(Stream stream) { WriteInt(stream, LUT.Count); - for(int i = 0; i < LUT.Count; i++) + LUT.ForEach(entry => { - WriteInt(stream, i); - WriteString(stream, LUT[i]); - }; + WriteInt(stream, LUT.IndexOf(entry)); + WriteString(stream, entry); + }); if (LUT.Contains("XMLVERSION")) WriteInt(stream, 0x1337); // :^) } @@ -78,4 +77,4 @@ namespace PckStudio.Classes.IO } } } -} +} \ No newline at end of file