public void DEXWriter() { KKtIO writer = KKtIO.OpenWriter(filepath + (Header.Format > KKtMain.Format.F ? ".dex" : ".bin"), true); writer.Format = Header.Format; if (writer.Format > KKtMain.Format.F) { Header.Lenght = 0x20; Header.DataSize = 0x00; Header.Signature = 0x43505845; Header.SectionSize = 0x00; writer.Write(Header); } writer.Write(0x64); writer.Write(DEX.Length); if (Header.Format == KKtMain.Format.X) { writer.Write(0x28); writer.Write(0x00); writer.Write(0x18 + (int)KKtMain.Align(DEX.Length * 3 * 8, 0x10)); writer.Write(0x00); writer.Seek(KKtMain.Align(DEX.Length * 3 * 8, 0x10) + 0x20 + Header.Lenght, 0); } else { writer.Write(0x20); writer.Write(0x10 + (int)KKtMain.Align(DEX.Length * 3 * 4, 0x10)); writer.Seek(KKtMain.Align(DEX.Length * 3 * 4, 0x10) + 0x30 + Header.Lenght, 0); } for (int i0 = 0; i0 < DEX.Length; i0++) { DEX[i0].MainOffset = writer.Position - Header.Lenght; for (int i1 = 0; i1 < DEX[i0].Main.Count; i1++) { writer.Write((float)DEX[i0].Main[i1].Frame); writer.Write(DEX[i0].Main[i1].Both); writer.Write(DEX[i0].Main[i1].ID); writer.Write((float)DEX[i0].Main[i1].Value); writer.Write((float)DEX[i0].Main[i1].Trans); } writer.Align(0x20, true); DEX[i0].EyesOffset = writer.Position - Header.Lenght; for (int i1 = 0; i1 < DEX[i0].Eyes.Count; i1++) { writer.Write((float)DEX[i0].Eyes[i1].Frame); writer.Write(DEX[i0].Eyes[i1].Both); writer.Write(DEX[i0].Eyes[i1].ID); writer.Write((float)DEX[i0].Eyes[i1].Value); writer.Write((float)DEX[i0].Eyes[i1].Trans); } writer.Align(0x20, true); } for (int i0 = 0; i0 < DEX.Length; i0++) { DEX[i0].NameOffset = writer.Position - Header.Lenght; writer.Write(DEX[i0].Name + "\0"); } writer.Align(0x10, true); if (Header.Format == KKtMain.Format.X) { writer.Seek(Header.Lenght + 0x28, 0); } else { writer.Seek(Header.Lenght + 0x20, 0); } for (int i0 = 0; i0 < DEX.Length; i0++) { writer.Write(DEX[i0].MainOffset); if (Header.Format == KKtMain.Format.X) { writer.Write(0x00); } writer.Write(DEX[i0].EyesOffset); if (Header.Format == KKtMain.Format.X) { writer.Write(0x00); } } for (int i0 = 0; i0 < DEX.Length; i0++) { writer.Write(DEX[i0].NameOffset); if (Header.Format == KKtMain.Format.X) { writer.Write(0x00); } } if (writer.Format > KKtMain.Format.F) { Offset = writer.Length - Header.Lenght; writer.Seek(writer.Length, 0); writer.WriteEOFC(0); writer.Seek(0, 0); Header.DataSize = Offset; Header.SectionSize = Offset; writer.Write(Header); } writer.Close(); }
public void STRWriter() { uint Offset = 0; uint CurrentOffset = 0; KKtIO writer = KKtIO.OpenWriter(filepath + ((int)Header.Format > 5 ? ".str" : ".bin"), true); writer.Format = Header.Format; POF = new KKtMain.POF { Offsets = new List <int>(), POFOffsets = new List <long>() }; writer.IsBE = writer.Format == KKtMain.Format.F2BE; if ((int)writer.Format > 1) { writer.Seek(0x40, 0); writer.WriteEndian(Count); writer.GetOffset(ref POF).WriteEndian(0x80); writer.Seek(0x80, 0); for (int i = 0; i < STR.Count; i++) { writer.GetOffset(ref POF).Write(0x00); writer.WriteEndian(STR[i].ID); } writer.Align(16); } else { for (int i = 0; i < Count; i++) { writer.Write(0x00); } writer.Align(32); } List <string> UsedSTR = new List <string>(); List <int> UsedSTRPos = new List <int>(); int[] STRPos = new int[Count]; for (int i1 = 0; i1 < Count; i1++) { if (UsedSTR.Contains(STR[i1].Str)) { for (int i2 = 0; i2 < Count; i2++) { if (UsedSTR[i2] == STR[i1].Str) { STRPos[i1] = UsedSTRPos[i2]; break; } } } else { STRPos[i1] = (int)writer.Position; UsedSTRPos.Add(STRPos[i1]); UsedSTR.Add(STR[i1].Str); writer.Write(STR[i1].Str + "\0"); } } if (writer.Format > KKtMain.Format.F) { writer.Align(16); Offset = (uint)writer.Position; writer.Seek(0x80, 0); } else { writer.Seek(0, 0); } for (int i1 = 0; i1 < Count; i1++) { writer.WriteEndian(STRPos[i1]); if (writer.Format > KKtMain.Format.F) { writer.Seek(4, (SeekOrigin)1); } } if (writer.Format > KKtMain.Format.F) { writer.Seek(Offset, 0); writer.Write(ref POF, 1); CurrentOffset = (uint)writer.Length; writer.WriteEOFC(0); Header.IsBE = writer.IsBE; Header.Lenght = 0x40; Header.DataSize = (int)(CurrentOffset - Header.Lenght); Header.Signature = 0x41525453; Header.SectionSize = (int)(Offset - Header.Lenght); writer.Seek(0, 0); writer.Write(Header); } writer.Close(); }