Пример #1
0
        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]);
            }
        }
Пример #2
0
        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;
        }