private void LoadFile(Stream TO8CHTX, EndianUtils.Endianness endian, TextUtils.GameTextEncoding encoding, BitUtils.Bitness bits, int languageCount) { Header = new ChatFileHeader(); ulong pos = (ulong)TO8CHTX.Position; Header.Identify = TO8CHTX.ReadUInt64().FromEndian(endian); Header.Filesize = TO8CHTX.ReadUInt32().FromEndian(endian); Header.Lines = TO8CHTX.ReadUInt32().FromEndian(endian); Header.Unknown = TO8CHTX.ReadUInt32().FromEndian(endian); Header.TextStart = TO8CHTX.ReadUInt32().FromEndian(endian); Header.Empty = TO8CHTX.ReadUInt64().FromEndian(endian); Lines = new ChatFileLine[Header.Lines]; int entrySize = (int)(4 + (languageCount + 1) * bits.NumberOfBytes()); for (int i = 0; i < Header.Lines; i++) { Lines[i] = new ChatFileLine(); Lines[i].Location = 0x20 + i * entrySize; Lines[i].NamePointer = TO8CHTX.ReadUInt(bits, endian); Lines[i].TextPointers = new ulong[languageCount]; for (int j = 0; j < languageCount; ++j) { Lines[i].TextPointers[j] = TO8CHTX.ReadUInt(bits, endian); } Lines[i].Unknown = TO8CHTX.ReadUInt32().FromEndian(endian); Lines[i].SName = TO8CHTX.ReadNulltermStringFromLocationAndReset((long)(pos + Lines[i].NamePointer + Header.TextStart), encoding); Lines[i].STexts = new string[languageCount]; for (int j = 0; j < languageCount; ++j) { Lines[i].STexts[j] = TO8CHTX.ReadNulltermStringFromLocationAndReset((long)(pos + Lines[i].TextPointers[j] + Header.TextStart), encoding).Replace('@', ' '); } } }
private void LoadFile(byte[] TO8CHTX, bool isUtf8) { Header = new ChatFileHeader(); Header.Identify = Util.SwapEndian(BitConverter.ToUInt64(TO8CHTX, 0x00)); Header.Filesize = Util.SwapEndian(BitConverter.ToUInt32(TO8CHTX, 0x08)); Header.Lines = Util.SwapEndian(BitConverter.ToUInt32(TO8CHTX, 0x0C)); Header.Unknown = Util.SwapEndian(BitConverter.ToUInt32(TO8CHTX, 0x10)); Header.TextStart = Util.SwapEndian(BitConverter.ToUInt32(TO8CHTX, 0x14)); Header.Empty = Util.SwapEndian(BitConverter.ToUInt64(TO8CHTX, 0x18)); Lines = new ChatFileLine[Header.Lines]; for (int i = 0; i < Header.Lines; i++) { Lines[i] = new ChatFileLine(); Lines[i].Location = 0x20 + i * 0x10; Lines[i].Name = Util.SwapEndian(BitConverter.ToUInt32(TO8CHTX, 0x20 + i * 0x10)); Lines[i].JPN = Util.SwapEndian(BitConverter.ToUInt32(TO8CHTX, 0x24 + i * 0x10)); Lines[i].ENG = Util.SwapEndian(BitConverter.ToUInt32(TO8CHTX, 0x28 + i * 0x10)); Lines[i].Unknown = Util.SwapEndian(BitConverter.ToUInt32(TO8CHTX, 0x2C + i * 0x10)); if (isUtf8) { Lines[i].SName = Util.GetTextUTF8(TO8CHTX, (int)(Lines[i].Name + Header.TextStart)); Lines[i].SJPN = Util.GetTextUTF8(TO8CHTX, (int)(Lines[i].JPN + Header.TextStart)); Lines[i].SENG = Util.GetTextUTF8(TO8CHTX, (int)(Lines[i].ENG + Header.TextStart)).Replace('@', ' '); } else { Lines[i].SName = Util.GetTextShiftJis(TO8CHTX, (int)(Lines[i].Name + Header.TextStart)); Lines[i].SJPN = Util.GetTextShiftJis(TO8CHTX, (int)(Lines[i].JPN + Header.TextStart)); Lines[i].SENG = Util.GetTextShiftJis(TO8CHTX, (int)(Lines[i].ENG + Header.TextStart)).Replace('@', ' '); } } }
private void LoadFile( byte[] TO8CHTX, bool isUtf8 ) { Header = new ChatFileHeader(); Header.Identify = Util.SwapEndian( BitConverter.ToUInt64( TO8CHTX, 0x00 ) ); Header.Filesize = Util.SwapEndian( BitConverter.ToUInt32( TO8CHTX, 0x08 ) ); Header.Lines = Util.SwapEndian( BitConverter.ToUInt32( TO8CHTX, 0x0C ) ); Header.Unknown = Util.SwapEndian( BitConverter.ToUInt32( TO8CHTX, 0x10 ) ); Header.TextStart = Util.SwapEndian( BitConverter.ToUInt32( TO8CHTX, 0x14 ) ); Header.Empty = Util.SwapEndian( BitConverter.ToUInt64( TO8CHTX, 0x18 ) ); Lines = new ChatFileLine[Header.Lines]; for ( int i = 0; i < Header.Lines; i++ ) { Lines[i] = new ChatFileLine(); Lines[i].Location = 0x20 + i * 0x10; Lines[i].Name = Util.SwapEndian( BitConverter.ToUInt32( TO8CHTX, 0x20 + i * 0x10 ) ); Lines[i].JPN = Util.SwapEndian( BitConverter.ToUInt32( TO8CHTX, 0x24 + i * 0x10 ) ); Lines[i].ENG = Util.SwapEndian( BitConverter.ToUInt32( TO8CHTX, 0x28 + i * 0x10 ) ); Lines[i].Unknown = Util.SwapEndian( BitConverter.ToUInt32( TO8CHTX, 0x2C + i * 0x10 ) ); if ( isUtf8 ) { Lines[i].SName = Util.GetTextUTF8( TO8CHTX, (int)( Lines[i].Name + Header.TextStart ) ); Lines[i].SJPN = Util.GetTextUTF8( TO8CHTX, (int)( Lines[i].JPN + Header.TextStart ) ); Lines[i].SENG = Util.GetTextUTF8( TO8CHTX, (int)( Lines[i].ENG + Header.TextStart ) ).Replace( '@', ' ' ); } else { Lines[i].SName = Util.GetTextShiftJis( TO8CHTX, (int)( Lines[i].Name + Header.TextStart ) ); Lines[i].SJPN = Util.GetTextShiftJis( TO8CHTX, (int)( Lines[i].JPN + Header.TextStart ) ); Lines[i].SENG = Util.GetTextShiftJis( TO8CHTX, (int)( Lines[i].ENG + Header.TextStart ) ).Replace( '@', ' ' ); } } }