public void BINWriter(string file) { if (SpriteSets == null) { return; } if (SpriteSets.Length == 0) { return; } List <string> setName = new List <string>(); List <string> setFileName = new List <string>(); List <int> ids = new List <int>(); List <int> setIds = new List <int>(); List <int> notAdd = new List <int>(); SpriteTexture temp; SpriteSet set; for (i = 0; i < SpriteSets.Length; i++) { set = SpriteSets[i]; if (set.Name != null) { if (setName.Contains(set.Name)) { notAdd.Add(i); continue; } else { setName.Add(set.Name); } } if (set.FileName != null) { if (setFileName.Contains(set.FileName)) { notAdd.Add(i); continue; } else { setFileName.Add(set.FileName); } } if (set.NewId) { SpriteSets[i].Id = null; for (i0 = 0; i0 < set.Textures.Length; i0++) { SpriteSets[i].Textures[i0].Id = null; } for (i0 = 0; i0 < set.Sprites.Length; i0++) { SpriteSets[i].Sprites[i0].Id = null; } continue; } if (set.Id != null) { if (setIds.Contains((int)set.Id)) { notAdd.Add(i); continue; } else { setIds.Add((int)set.Id); } } for (i0 = 0; i0 < set.Sprites.Length; i0++) { temp = set.Sprites[i0]; if (temp.Id != null) { if (ids.Contains((int)temp.Id)) { notAdd.Add(i); break; } else { ids.Add((int)temp.Id); } } } if (i0 < set.Sprites.Length) { continue; } for (i0 = 0; i0 < set.Textures.Length; i0++) { temp = set.Textures[i0]; if (temp.Id != null) { if (ids.Contains((int)temp.Id)) { notAdd.Add(i); break; } else { ids.Add((int)temp.Id); } } } } setName = null; setFileName = null; for (i = 0; i < SpriteSets.Length; i++) { set = SpriteSets[i]; if (notAdd.Contains(i)) { continue; } if (!set.NewId) { continue; } i1 = 0; if (set.Id == null) { while (true) { if (!setIds.Contains(i1)) { SpriteSets[i].Id = i1; setIds.Add(i1); break; } i1++; } } for (i0 = 0, i1 = 0; i0 < set.Textures.Length; i0++) { while (set.Textures[i0].Id == null) { if (!ids.Contains(i1)) { ids.Add((int)(SpriteSets[i].Textures[i0].Id = i1)); } else { i1++; } } } for (i0 = 0, i1 = 0; i0 < set.Sprites.Length; i0++) { while (set.Sprites[i0].Id == null) { if (!ids.Contains(i1)) { ids.Add((int)(SpriteSets[i].Sprites[i0].Id = i1)); } else { i1++; } } } } ids = null; setIds = null; for (i = 0, i0 = 0, i2 = 0; i < SpriteSets.Length; i++) { if (!notAdd.Contains(i)) { i0 += SpriteSets[i].Sprites.Length + SpriteSets[i].Textures.Length; i2++; } } i1 = i0 * 12; i1 = i1.A(0x20) + 0x20; _IO = File.OpenWriter(file + ".bin", true); _IO.W(i2); _IO.W(i1); _IO.W(i0); _IO.W(0x20); _IO.W(0x9066906690669066); _IO.W(0x9066906690669066); _IO.P = (i1 + i2 * 0x10).A(0x20); for (i = 0; i < SpriteSets.Length; i++) { if (notAdd.Contains(i)) { continue; } for (i0 = 0; i0 < SpriteSets[i].Textures.Length; i0++) { SpriteSets[i].Textures[i0].NameOffset = _IO.P; _IO.W(SpriteSets[i].Textures[i0].Name + "\0"); } for (i0 = 0; i0 < SpriteSets[i].Sprites.Length; i0++) { SpriteSets[i].Sprites[i0].NameOffset = _IO.P; _IO.W(SpriteSets[i].Sprites[i0].Name + "\0"); } } for (i = 0; i < SpriteSets.Length; i++) { if (notAdd.Contains(i)) { continue; } SpriteSets[i].NameOffset = _IO.P; _IO.W(SpriteSets[i].Name + "\0"); SpriteSets[i].FileNameOffset = _IO.P; _IO.W(SpriteSets[i].FileName + "\0"); } _IO.A(0x08, true); _IO.P = 0x20; for (i = 0, i2 = 0; i < SpriteSets.Length; i++) { if (notAdd.Contains(i)) { i2++; continue; } for (i0 = 0; i0 < SpriteSets[i].Textures.Length; i0++) { _IO.W(SpriteSets[i].Textures[i0].Id); _IO.W(SpriteSets[i].Textures[i0].NameOffset); _IO.W((ushort)i0); _IO.W((ushort)(0x1000 | (i - i2))); } for (i0 = 0; i0 < SpriteSets[i].Sprites.Length; i0++) { _IO.W(SpriteSets[i].Sprites[i0].Id); _IO.W(SpriteSets[i].Sprites[i0].NameOffset); _IO.W((ushort)i0); _IO.W((ushort)(i - i2)); } } _IO.A(0x20); for (i = 0, i2 = 0; i < SpriteSets.Length; i++) { if (notAdd.Contains(i)) { i2++; continue; } _IO.W(SpriteSets[i].Id); _IO.W(SpriteSets[i].NameOffset); _IO.W(SpriteSets[i].FileNameOffset); _IO.W(i - i2); } _IO.C(); }
public void STRWriter(string filepath) { if (STRs == null || STRs.Length == 0 || header.Format > Format.F2BE) { return; } uint offset = 0; uint currentOffset = 0; _IO = File.OpenWriter(filepath + (header.Format > Format.AFT && header.Format < Format.FT ? ".str" : ".bin"), true); _IO.Format = header.Format; pof.Offsets = KKdList <long> .New; long count = STRs.LongLength; if (_IO.Format > Format.AFT && _IO.Format < Format.FT) { _IO.P = 0x40; _IO.WX(count, ref pof); _IO.WX(0x80); _IO.P = 0x80; for (int i = 0; i < count; i++) { _IO.W(0x00L); } _IO.A(0x10); } else { for (int i = 0; i < count; i++) { _IO.W(0x00); } _IO.A(0x20); } KKdList <string> usedSTR = KKdList <string> .New; KKdList <int> usedSTRPos = KKdList <int> .New; int[] STRPos = new int[count]; usedSTRPos.Add(_IO.P); usedSTR.Add(""); _IO.W(0); for (int i = 0; i < count; i++) { if (!usedSTR.Contains(STRs[i].Str.V)) { STRPos[i] = _IO.P; usedSTRPos.Add(STRPos[i]); usedSTR.Add(STRs[i].Str.V); _IO.W(STRs[i].Str.V); _IO.W(0); } else { for (int i2 = 0; i2 < count; i2++) { if (usedSTR[i2] == STRs[i].Str.V) { STRPos[i] = usedSTRPos[i2]; break; } } } } if (_IO.Format > Format.AFT) { _IO.A(0x10); offset = _IO.U32P; _IO.P = 0x80; for (int i = 0; i < count; i++) { pof.Offsets.Add(_IO.P); _IO.WE(STRPos[i]); _IO.WE(STRs[i].ID); } _IO.U32P = offset; _IO.W(pof, false, 1); currentOffset = _IO.U32P; _IO.WEOFC(); header.DataSize = (int)(currentOffset - 0x40); header.Signature = 0x41525453; header.SectionSize = (int)(offset - 0x40); _IO.P = 0; _IO.W(header, true); } else { _IO.P = 0; for (int i = 0; i < count; i++) { _IO.W(STRPos[i]); } } _IO.C(); }
public void BINWriter(string file) { if (AetSets == null) { return; } if (AetSets.Length == 0) { return; } List <string> SetName = new List <string>(); List <string> SetFileName = new List <string>(); List <int> Ids = new List <int>(); List <int> SetIds = new List <int>(); List <int> NotAdd = new List <int>(); AET temp; AetSet set; for (i = 0; i < AetSets.Length; i++) { set = AetSets[i]; if (set.Name != null) { if (SetName.Contains(set.Name)) { NotAdd.Add(i); continue; } else { SetName.Add(set.Name); } } if (set.FileName != null) { if (SetFileName.Contains(set.FileName)) { NotAdd.Add(i); continue; } else { SetFileName.Add(set.FileName); } } if (set.NewId) { AetSets[i].Id = null; for (i0 = 0; i0 < set.Aets.Length; i0++) { AetSets[i].Aets[i0].Id = null; } continue; } if (set.Id != null) { if (SetIds.Contains((int)set.Id)) { NotAdd.Add(i); continue; } else { SetIds.Add((int)set.Id); } } for (i0 = 0; i0 < set.Aets.Length; i0++) { temp = set.Aets[i0]; if (temp.Id != null) { if (Ids.Contains((int)temp.Id)) { NotAdd.Add(i); break; } else { Ids.Add((int)temp.Id); } } } } SetName = null; SetFileName = null; for (i = 0; i < AetSets.Length; i++) { set = AetSets[i]; if (NotAdd.Contains(i)) { continue; } if (!set.NewId) { continue; } i1 = 0; if (set.Id == null) { while (true) { if (!SetIds.Contains(i1)) { AetSets[i].Id = i1; SetIds.Add(i1); break; } i1++; } } for (i0 = 0, i1 = 0; i0 < set.Aets.Length; i0++) { if (set.Aets[i0].Id == null) { while (true) { if (!Ids.Contains(i1)) { AetSets[i].Aets[i0].Id = i1; Ids.Add(i1); break; } i1++; } } } } Ids = null; SetIds = null; for (i = 0, i0 = 0, i2 = 0; i < AetSets.Length; i++) { if (!NotAdd.Contains(i)) { i0 += AetSets[i].Aets.Length; i2++; } } i1 = i0 * 12; i1 = i1.A(0x20) + 0x20; _IO = File.OpenWriter(file + ".bin", true); _IO.W(i2); _IO.W(i1); _IO.W(i0); _IO.W(0x20); _IO.W(0x9066906690669066); _IO.W(0x9066906690669066); _IO.P = (i1 + i2 * 0x14).A(0x20); for (i = 0; i < AetSets.Length; i++) { if (NotAdd.Contains(i)) { continue; } AetSets[i].NameOffset = _IO.P; _IO.W(AetSets[i].Name + "\0"); AetSets[i].FileNameOffset = _IO.P; _IO.W(AetSets[i].FileName + "\0"); } for (i = 0; i < AetSets.Length; i++) { if (NotAdd.Contains(i)) { continue; } for (i0 = 0; i0 < AetSets[i].Aets.Length; i0++) { AetSets[i].Aets[i0].NameOffset = _IO.P; _IO.W(AetSets[i].Aets[i0].Name + "\0"); } } _IO.A(0x08, true); _IO.P = 0x20; for (i = 0, i2 = 0; i < AetSets.Length; i++) { if (NotAdd.Contains(i)) { i2++; continue; } for (i0 = 0; i0 < AetSets[i].Aets.Length; i0++) { _IO.W(AetSets[i].Aets[i0].Id); _IO.W(AetSets[i].Aets[i0].NameOffset); _IO.W((ushort)i0); _IO.W((ushort)(i - i2)); } } _IO.A(0x20); for (i = 0, i2 = 0; i < AetSets.Length; i++) { if (NotAdd.Contains(i)) { i2++; continue; } _IO.W(AetSets[i].Id); _IO.W(AetSets[i].NameOffset); _IO.W(AetSets[i].FileNameOffset); _IO.W(i - i2); _IO.W(AetSets[i].SpriteSetId); } _IO.C(); }
public void BINWriter(string file) { if (AetSets == null) { return; } if (AetSets.Length == 0) { return; } KKdList <string> setName = KKdList <string> .New; KKdList <string> setFileName = KKdList <string> .New; KKdList <int> ids = KKdList <int> .New; KKdList <int> setIds = KKdList <int> .New; KKdList <int> notAdd = KKdList <int> .New; AET temp; AetSet set; for (i = 0; i < AetSets.Length; i++) { set = AetSets[i]; if (set.Name != null) { if (setName.Contains(set.Name)) { notAdd.Add(i); continue; } else { setName.Add(set.Name); } } if (set.FileName != null) { if (setFileName.Contains(set.FileName)) { notAdd.Add(i); continue; } else { setFileName.Add(set.FileName); } } if (set.NewId) { AetSets[i].Id = null; for (i0 = 0; i0 < set.Aets.Length; i0++) { AetSets[i].Aets[i0].Id = null; } continue; } if (set.Id != null) { if (setIds.Contains((int)set.Id)) { notAdd.Add(i); continue; } else { setIds.Add((int)set.Id); } } for (i0 = 0; i0 < set.Aets.Length; i0++) { temp = set.Aets[i0]; if (temp.Id != null) { if (ids.Contains((int)temp.Id)) { notAdd.Add(i); break; } else { ids.Add((int)temp.Id); } } } } setName.Dispose(); setFileName.Dispose(); for (i = 0; i < AetSets.Length; i++) { set = AetSets[i]; if (notAdd.Contains(i)) { continue; } if (!set.NewId) { continue; } i1 = 0; if (set.Id == null) { while (true) { if (!setIds.Contains(i1)) { AetSets[i].Id = i1; setIds.Add(i1); break; } i1++; } } for (i0 = 0, i1 = 0; i0 < set.Aets.Length; i0++) { if (set.Aets[i0].Id == null) { while (true) { if (!ids.Contains(i1)) { AetSets[i].Aets[i0].Id = i1; ids.Add(i1); break; } i1++; } } } } ids.Dispose(); setIds.Dispose(); for (i = 0, i0 = 0, i2 = 0; i < AetSets.Length; i++) { if (!notAdd.Contains(i)) { i0 += AetSets[i].Aets.Length; i2++; } } i1 = i0 * 12; i1 = i1.A(0x20) + 0x20; s = File.OpenWriter(file + ".bin", true); s.W(i2); s.W(i1); s.W(i0); s.W(0x20); s.W(0x9066906690669066); s.W(0x9066906690669066); s.P = (i1 + i2 * 0x14).A(0x20); for (i = 0; i < AetSets.Length; i++) { if (notAdd.Contains(i)) { continue; } AetSets[i].NameOffset = s.P; s.W(AetSets[i].Name + "\0"); AetSets[i].FileNameOffset = s.P; s.W(AetSets[i].FileName + "\0"); } for (i = 0; i < AetSets.Length; i++) { if (notAdd.Contains(i)) { continue; } for (i0 = 0; i0 < AetSets[i].Aets.Length; i0++) { AetSets[i].Aets[i0].NameOffset = s.P; s.W(AetSets[i].Aets[i0].Name + "\0"); } } s.A(0x08, true); s.P = 0x20; for (i = 0, i2 = 0; i < AetSets.Length; i++) { if (notAdd.Contains(i)) { i2++; continue; } for (i0 = 0; i0 < AetSets[i].Aets.Length; i0++) { s.W(AetSets[i].Aets[i0].Id); s.W(AetSets[i].Aets[i0].NameOffset); s.W((ushort)i0); s.W((ushort)(i - i2)); } } s.A(0x20); for (i = 0, i2 = 0; i < AetSets.Length; i++) { if (notAdd.Contains(i)) { i2++; continue; } s.W(AetSets[i].Id); s.W(AetSets[i].NameOffset); s.W(AetSets[i].FileNameOffset); s.W(i - i2); s.W(AetSets[i].SpriteSetId); } notAdd.Dispose(); s.C(); }
public void DEXWriter(string filepath, Format Format) { if (Dex == null || Dex.Length < 1) { return; } header = new Header(); _IO = File.OpenWriter(filepath + (Format > Format.F && Format < Format.FT ? ".dex" : ".bin"), true); header.Format = _IO.Format = Format; _IO.O = Format > Format.F ? 0x20 : 0; _IO.W(0x64); _IO.W(Dex.Length); _IO.WX(header.IsX ? 0x28 : 0x20); _IO.WX(0x00); int Position0 = _IO.P; _IO.W(0x00L); _IO.W(0x00L); for (i = 0; i < Dex.Length * 3; i++) { _IO.WX(0x00); } _IO.A(0x20); for (i0 = 0; i0 < Dex.Length; i0++) { Dex[i0].MainOffset = _IO.P; for (i1 = 0; i1 < Dex[i0].Main.Count; i1++) { _IO.W(Dex[i0].Main[i1].Frame); _IO.W(Dex[i0].Main[i1].Both); _IO.W(Dex[i0].Main[i1].ID); _IO.W(Dex[i0].Main[i1].Value); _IO.W(Dex[i0].Main[i1].Trans); } _IO.W(999999f); _IO.W(0xFFFF); _IO.W(0x0L); _IO.A(0x20); Dex[i0].EyesOffset = _IO.P; for (i1 = 0; i1 < Dex[i0].Eyes.Count; i1++) { _IO.W(Dex[i0].Eyes[i1].Frame); _IO.W(Dex[i0].Eyes[i1].Both); _IO.W(Dex[i0].Eyes[i1].ID); _IO.W(Dex[i0].Eyes[i1].Value); _IO.W(Dex[i0].Eyes[i1].Trans); } _IO.W(999999f); _IO.W(0xFFFF); _IO.W(0x0L); _IO.A(0x20); } for (i = 0; i < Dex.Length; i0++) { Dex[i].NameOffset = _IO.P; _IO.W(Dex[i].Name + "\0"); } _IO.A(0x10, true); _IO.P = header.IsX ? 0x28 : 0x20; for (i = 0; i < Dex.Length; i++) { _IO.WX(Dex[i].MainOffset); _IO.WX(Dex[i].EyesOffset); } int namesPosition = _IO.P; for (i = 0; i < Dex.Length; i++) { _IO.WX(Dex[i].NameOffset); } _IO.P = Position0 - (header.IsX ? 8 : 4); _IO.W(namesPosition); if (Format > Format.F) { int offset = _IO.L; _IO.O = 0; _IO.P = _IO.L; _IO.WEOFC(0); _IO.P = 0; header.DataSize = offset; header.SectionSize = offset; header.Signature = 0x43505845; _IO.W(header, true); } _IO.C(); }
public void STRWriter(string filepath) { if (Strings == null || Strings.Length == 0 || header.Format > Format.F2) { return; } uint offset = 0; uint currentOffset = 0; Format format = header.Format; s = File.OpenWriter(filepath + (header.Format > Format.AFT && header.Format < Format.FT ? ".str" : ".bin"), true); s.Format = header.Format; s.IsBE = header.UseBigEndian; pof.Offsets = KKdList <long> .New; long count = Strings.LongLength; if (s.Format > Format.AFT && s.Format < Format.FT) { s.P = 0x40; s.WX(count, ref pof); s.WX(0x80); s.P = 0x80; for (int i = 0; i < count; i++) { s.W(0x00L); } } else { for (int i = 0; i < count; i++) { s.W(0x00); } } s.A(0x10); KKdList <string> usedSTR = KKdList <string> .New; KKdList <int> usedSTRPos = KKdList <int> .New; int[] STRPos = new int[count]; for (int i = 0; i < count; i++) { if (usedSTR.Contains(Strings[i].Str.V)) { for (int i2 = 0; i2 < count; i2++) { if (usedSTR[i2] == Strings[i].Str.V) { STRPos[i] = usedSTRPos[i2]; break; } } } else { usedSTRPos.Add(STRPos[i] = s.P); usedSTR.Add(Strings[i].Str.V); s.W(Strings[i].Str.V); s.W((byte)0); if (format < Format.F) { s.A(0x8); } } } s.A(0x4); s.L = s.P; if (s.Format > Format.AFT) { s.A(0x10); offset = s.PU32; s.P = 0x80; for (int i = 0; i < count; i++) { pof.Offsets.Add(s.P); s.WE(STRPos[i]); s.WE(Strings[i].ID); } s.PU32 = offset; s.W(pof, false, 1); s.WEOFC(1); currentOffset = s.PU32; s.WEOFC(); header.DataSize = currentOffset - 0x40; header.Signature = 0x41525453; header.SectionSize = offset - 0x40; header.UseSectionSize = true; s.P = 0; s.W(header, true); } else { s.P = 0; s.IsBE = header.Format < Format.F; for (int i = 0; i < count; i++) { s.WE(STRPos[i]); } } s.C(); }