void OpenFile() { //CloseFile(); listBox1.Items.Clear(); listBox2.Items.Clear(); OpenFileDialog o = new OpenFileDialog(); o.ShowDialog(); if (o.FileName == "" || File.Exists(o.FileName) == false) { return; } //filePath = o.FileName; byte[] fileBytes = File.ReadAllBytes(o.FileName); int fileStart = XfbinParser.GetFileSectionIndex(fileBytes); List <string> paths = XfbinParser.GetPathList(fileBytes); //paths.Sort(); for (int x = 0; x < paths.Count; x++) { listBox1.Items.Add(paths[x]); } List <string> namepaths = XfbinParser.GetNameList(fileBytes); for (int x = 0; x < namepaths.Count; x++) { listBox2.Items.Add(namepaths[x]); } }
void OpenFile() { OpenFileDialog o = new OpenFileDialog(); o.ShowDialog(); if (o.FileName == "" || File.Exists(o.FileName) == false) { return; } filePath = o.FileName; fileBytes = File.ReadAllBytes(filePath); // Find all ver sections int actualver = 0; while (actualver != -1) { actualver = XfbinParser.FindString(fileBytes, "ver0.000", actualver + 1); //MessageBox.Show(actualver.ToString("X2")); if (actualver != -1) { verList.Add(actualver); verLength.Add(Main.b_ReadIntRev(fileBytes, actualver - 4)); } } // Add all ver section byte data for (int x = 0; x < verList.Count; x++) { List <byte> actualSection = new List <byte>(); int begin = verList[x]; int end = verLength[x]; for (int y = 0; y < end; y++) { actualSection.Add(fileBytes[begin + y]); } verSection.Add(actualSection.ToArray()); //File.WriteAllBytes(filePath + "_" + x.ToString(), actualSection.ToArray()); } // List all anm sections string[] sectionnames = { "Awakening", "Base", "Jutsu", "Ultimate Jutsu", "Effect", "Expansion A", "Expansion B", "Expansion C" }; for (int a = 0; a < verList.Count; a++) { listBox1.Items.Add(sectionnames[a]); byte[] actualSection = verSection[a]; int anmSectionCount = actualSection[0x30]; int start = 0x40; int index = 0x40; plAnmList.Add(new List <byte[]>()); movementList.Add(new List <List <byte[]> >()); // //anmSection.Add(new List<byte[]>()); //anmCount.Add(actualSection[0x30]); for (int x = 0; x < anmSectionCount; x++) { // Add this pl_anm's header to plAnmList List <byte> planmheader = new List <byte>(); for (int y = 0; y < 0xD4; y++) { planmheader.Add(actualSection[start + y]); } //MessageBox.Show(Main.b_ReadString(planmheader.ToArray(), 0)); plAnmList[a].Add(planmheader.ToArray()); movementList[a].Add(new List <byte[]>()); index = start + 0x50; byte m_movcount = actualSection[index]; //MessageBox.Show("ANM " + x.ToString() + " has " + m_movcount.ToString() + " sections"); index = start + 0xD4; // Add each movement section of this pl_anm to the master list for (int y = 0; y < m_movcount; y++) { List <byte> movementsection = new List <byte>(); // Default movement section length is 0x40 int sectionLength = 0x40; int function = actualSection[index + 0x22] * 0x1 + actualSection[index + 0x23] * 0x100; switch (function) { case 0x83: if (index + 0x40 < actualSection.Length) { string str = Main.b_ReadString(actualSection, index + 0x40); if (str == "SPSKILL_END") { sectionLength = 0xA0; } } break; case 0xC1: case 0xC3: case 0xC6: case 0xC8: case 0xCA: case 0xD1: case 0xD3: case 0xD5: case 0xD7: case 0xD9: sectionLength = 0xA0; break; case 0xA0: case 0xA1: case 0xA2: case 0xA3: case 0xA4: case 0xA5: if (index + 0x40 < actualSection.Length) { string str = Main.b_ReadString(actualSection, index + 0x40); if (str.Length > 7 && str.Substring(0, 7) == "SKL_ATK") { sectionLength = 0xA0; } } break; } // If there's a D (from DAMAGE_ID) in section + 0x40, length is 0xA0 if (index + 0x40 < actualSection.Length) { string str = Main.b_ReadString(actualSection, index + 0x40); if (str.Length > 3 && (str.Substring(0, 3) == "DMG" || str.Substring(0, 3) == "DAM")) { sectionLength = 0xA0; } /*char act1 = (char)actualSection[index + 0x40]; * if (!Char.IsDigit(act1) && Char.IsUpper(act1)) * { * byte byte1 = actualSection[index + 0x40 + 0x2A]; // 20 * byte byte2 = actualSection[index + 0x40 + 0x2C]; // 22 * * if(byte1 == 0x0 && byte2 == 0x0) * { * * } * }*/ } // If the first letter of the hitbox is caps, then it's a special 0x60 section // char act = (char)actualSection[index]; // if (actualSection[index] != 0x0 && Char.IsUpper(act) && !Char.IsDigit(act)) sectionLength = 0x40; //MessageBox.Show("Movement " + y.ToString() + " of ANM " + x.ToString() + " is " + sectionLength.ToString("X2") + " bytes long"); for (int z = 0; z < sectionLength; z++) { movementsection.Add(actualSection[z + index]); } index = index + sectionLength; // Add to master list movementList[a][x].Add(movementsection.ToArray()); } start = index; } } fileOpen = true; }
void OpenFile() { CloseFile(); OpenFileDialog o = new OpenFileDialog(); o.ShowDialog(); if (o.FileName == "" || File.Exists(o.FileName) == false) { return; } filePath = o.FileName; fileBytes = File.ReadAllBytes(filePath); int fileStart = XfbinParser.GetFileSectionIndex(fileBytes); int textureCount = 0; ntp3Indices = Main.b_FindBytesList(fileBytes, Encoding.ASCII.GetBytes("NTP3"), fileStart); List <string> textureNames = new List <string>(); List <string> filePaths = XfbinParser.GetPathList(fileBytes); for (int x = 0; x < filePaths.Count; x++) { if (filePaths[x].Substring(filePaths[x].Length - 3, 3) == "nut") { string[] spl = filePaths[x].Split('/'); if (spl.Length < 2) { spl = filePaths[x].Split('\\'); } textureNames.Add(spl[spl.Length - 1]); } } ntp3Size = new List <int>(); gidxCount = new List <int>(); gidxIndices = new List <List <int> >(); gidxSizes = new List <List <int> >(); textureData = new List <List <byte[]> >(); for (int x = 0; x < ntp3Indices.Count; x++) { int size = Main.b_ReadIntRev(fileBytes, ntp3Indices[x] - 0x4); byte count = fileBytes[ntp3Indices[x] + 0x7]; ntp3Size.Add(size); gidxCount.Add(count); byte[] ntp3Header = Main.b_ReadByteArray(fileBytes, ntp3Indices[x], 0x10); ntp3Headers.Add(ntp3Header); gidxIndices.Add(new List <int>()); gidxSizes.Add(new List <int>()); // Get first GIDX index int firstIndex = ntp3Indices[x] + 0x10; gidxIndices[x].Add(firstIndex); byte headersize = fileBytes[firstIndex + 0xD]; gidxHeaderSizes.Add(new List <int>()); gidxHeaderSizes[x].Add(headersize); // Add data for GIDX 0 int gidxsize = Main.b_ReadIntRev(fileBytes, firstIndex); gidxSizes[x].Add(gidxsize); int actualGidxIndex = firstIndex; byte[] gidxHeader = Main.b_ReadByteArray(fileBytes, actualGidxIndex, headersize); gidxHeaders.Add(new List <byte[]>()); gidxHeaders[x].Add(gidxHeader); textureData.Add(new List <byte[]>()); textureData[x].Add(Main.b_ReadByteArray(fileBytes, actualGidxIndex + headersize, gidxsize - headersize)); Console.WriteLine(x.ToString() + ": " + textureData[x][0].Length.ToString("X2")); actualGidxIndex = firstIndex + gidxsize; // Add data for rest of GIDX for (int y = 1; y < count; y++) { gidxsize = Main.b_ReadIntRev(fileBytes, actualGidxIndex); gidxSizes[x].Add(gidxsize); headersize = fileBytes[actualGidxIndex + 0xD]; gidxHeaderSizes[x].Add(headersize); gidxIndices[x].Add(actualGidxIndex); gidxHeader = Main.b_ReadByteArray(fileBytes, actualGidxIndex, headersize); gidxHeaders[x].Add(gidxHeader); textureData[x].Add(Main.b_ReadByteArray(fileBytes, actualGidxIndex + headersize, gidxsize - headersize)); Console.WriteLine(x.ToString() + ": " + textureData[x][y].Length.ToString("X2")); actualGidxIndex = actualGidxIndex + gidxsize; } // Add items to list for (int y = 0; y < count; y++) { listBox1.Items.Add( textureNames[x] + " " + x.ToString() + " " + y.ToString() + " " + "- NTP3: " + ntp3Indices[x].ToString("X2") + ", GIDX: " + gidxIndices[x][y].ToString("X2") + ", Size: " + gidxSizes[x][y].ToString("X2")); } } fileOpen = true; }