public byte[] ConvertToFile() { byte[] actual = new byte[] { }; int fileStart = XfbinParser.GetFileSectionIndex(fileBytes) + 0x28; actual = Main.b_AddBytes(actual, fileBytes, 0, 0, fileStart + 0x10); actual = Main.b_AddBytes(actual, new byte[0xD8 * EntryCount]); for (int x = 0; x < EntryCount; x++) { int entryIndex = fileStart + 0x10 + (x * 0xD8); actual = Main.b_ReplaceBytes(actual, BitConverter.GetBytes(actual.Length - entryIndex), entryIndex); actual = Main.b_AddString(actual, CharacterList[x]); actual = Main.b_AddBytes(actual, new byte[0x8 - CharacterList[x].Length]); if (ChaList[x] != "") { int entryChaIndex = entryIndex + 0x18; actual = Main.b_ReplaceBytes(actual, BitConverter.GetBytes(actual.Length - entryChaIndex), entryChaIndex); actual = Main.b_AddString(actual, ChaList[x]); actual = Main.b_AddBytes(actual, new byte[0x10 - ChaList[x].Length]); } if (AccessoryList[x] != "") { int entryAccIndex = entryIndex + 0x20; actual = Main.b_ReplaceBytes(actual, BitConverter.GetBytes(actual.Length - entryAccIndex), entryAccIndex); actual = Main.b_AddString(actual, AccessoryList[x]); actual = Main.b_AddBytes(actual, new byte[0x10 - AccessoryList[x].Length]); } if (NewIdList[x] != "") { int entryIdIndex = entryIndex + 0x28; actual = Main.b_ReplaceBytes(actual, BitConverter.GetBytes(actual.Length - entryIdIndex), entryIdIndex); actual = Main.b_AddString(actual, NewIdList[x]); actual = Main.b_AddBytes(actual, new byte[0x8 - NewIdList[x].Length]); } actual = Main.b_ReplaceBytes(actual, BitConverter.GetBytes(PageList[x]), 0x140 + 0xD8 * x + 8); actual = Main.b_ReplaceBytes(actual, BitConverter.GetBytes(PositionList[x]), 0x140 + 0xD8 * x + 12); actual = Main.b_ReplaceBytes(actual, BitConverter.GetBytes(CostumeList[x]), 0x140 + 0xD8 * x + 16); // Add positions and all that crap actual = Main.b_ReplaceBytes(actual, GibberishBytes[x], 0x140 + 0xD8 * x + 48); } int totalSize = actual.Length - fileStart; // Add EOF actual = Main.b_AddBytes(actual, new byte[] { 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x02, 0x00, 0x79, 0x18, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00 }); // Fix sizes actual = Main.b_ReplaceBytes(actual, BitConverter.GetBytes((short)(EntryCount)), fileStart + 0x2C - 0x28); actual = Main.b_ReplaceBytes(actual, BitConverter.GetBytes(totalSize), fileStart + 0x24 - 0x28, 1); actual = Main.b_ReplaceBytes(actual, BitConverter.GetBytes(totalSize + 4), fileStart + 0x18 - 0x28, 1); return(actual); }
void OpenFile(string path = "") { OpenFileDialog o = new OpenFileDialog(); o.DefaultExt = "xfbin"; if (path == "") { o.ShowDialog(); } else { o.FileName = path; } if (!(o.FileName != "") || !File.Exists(o.FileName)) { return; } filePath = o.FileName; fileOpen = true; byte[] fileBytes = File.ReadAllBytes(filePath); fileStart = XfbinParser.GetFileSectionIndex(fileBytes); header = Main.b_AddBytes(header, fileBytes, 0, fileStart, 0x38); fileStart = fileStart + 0x28; entryCount = Main.b_ReadInt(fileBytes, fileStart + 0x4); for (int x = 0; x < entryCount; x++) { } }
public void OpenFile(string path = "") { OpenFileDialog o = new OpenFileDialog(); o.DefaultExt = "xfbin"; if (path == "") { o.ShowDialog(); } else { o.FileName = path; } if (!(o.FileName != "") || !File.Exists(o.FileName)) { return; } ListBox1.Items.Clear(); FilePath = o.FileName; fileBytes = File.ReadAllBytes(FilePath); // Check for NUCC in header if (!(fileBytes.Length > 0x44 && Main.b_ReadString(fileBytes, 0, 4) == "NUCC")) { MessageBox.Show("Not a valid .xfbin file."); return; } if (XfbinParser.GetNameList(fileBytes)[0] == "characode") { int fileStart = XfbinParser.GetFileSectionIndex(fileBytes); CharacterCount = Main.b_ReadInt(fileBytes, fileStart + 0x1C); CharacterList = new List <string>(); for (int x = 0; x < CharacterCount; x++) { string character = Main.b_ReadString(fileBytes, fileStart + 0x20 + (x * 8)); CharacterList.Add(character); ListBox1.Items.Add((x + 1).ToString("X2") + " = " + character); } FileOpen = true; if (this.Visible) { MessageBox.Show("Characode contains " + CharacterCount + " character IDs."); } } else { MessageBox.Show("Please select a valid characode file."); FilePath = ""; fileBytes = new byte[0]; FileOpen = false; } }
void OpenFile() { OpenFileDialog o = new OpenFileDialog(); o.ShowDialog(); if (o.FileName == "" || File.Exists(o.FileName) == false) { return; } fileName = o.FileName; fileBytes = File.ReadAllBytes(fileName); int fileSectionIndex = XfbinParser.GetFileSectionIndex(fileBytes); int startIndex = fileSectionIndex + 0x1C; int fileIndex = startIndex; // Check for NUCC in header if (!(fileBytes.Length > 0x44 && Main.b_ReadString(fileBytes, 0, 4) == "NUCC")) { MessageBox.Show("Not a valid .xfbin file."); return; } // Get character name prmName = XfbinParser.GetNameList(fileBytes)[0]; prmName = prmName.Substring(0, prmName.Length - 0x8); textBox3.Text = prmName; // Get entry count entryCount = fileBytes[fileSectionIndex + 0x1C]; for (int x = 0; x < entryCount; x++) { fileIndex = startIndex + (0x50 * x); int strIndex = fileIndex + 0x8; string path = Main.b_ReadString(fileBytes, strIndex); pathList.Add(path); strIndex = strIndex + 0x20; string name = Main.b_ReadString(fileBytes, strIndex); nameList.Add(name); listBox1.Items.Add(path + "/" + name); strIndex = strIndex + 0x20; typeList.Add(fileBytes[strIndex]); strIndex = strIndex + 0x8; loadcondList.Add(new byte[] { fileBytes[strIndex], fileBytes[strIndex + 1] }); } fileOpen = true; }
public byte[] ConvertToFile() { byte[] actual = new byte[0]; int startOfFile = XfbinParser.GetFileSectionIndex(fileBytes); for (int x = 0; x < startOfFile + 0x20; x++) { actual = Main.b_AddBytes(actual, new byte[] { fileBytes[x] }); } actual = Main.b_ReplaceBytes(actual, BitConverter.GetBytes(CharacterCount), startOfFile + 0x20 - 0x4); actual = Main.b_ReplaceBytes(actual, BitConverter.GetBytes((CharacterCount * 8) + 0x4), startOfFile + 0x20 - 0x8, 1); actual = Main.b_ReplaceBytes(actual, BitConverter.GetBytes((CharacterCount * 8) + 0x8), startOfFile + 0x20 - 0x8 - 0xC, 1); for (int x = 0; x < CharacterCount; x++) { actual = Main.b_AddBytes(actual, new byte[] { 0, 0, 0, 0, 0, 0, 0, 0 }); actual = Main.b_ReplaceString(actual, CharacterList[x], startOfFile + 0x20 + (0x8 * x)); } byte[] finalBytes = new byte[20] { 0, 0, 0, 8, 0, 0, 0, 2, 0, 99, 0, 0, 0, 0, 0, 4, 0, 0, 0, 0 }; actual = Main.b_AddBytes(actual, finalBytes); return(actual); }