Exemple #1
0
        public RelicChunkyFile(string name, ChunkyStructureCollection col)
        {
            structCol = col;
            filename  = name;

            foreach (RelicChunkyStructure strct in structCol)
            {
                strct.ParentFile = this;
            }
        }
Exemple #2
0
        public static RelicChunkyFile ReadChunkyFile(string filepath)
        {
            if (!File.Exists(filepath))
            {
                throw new RelicTools.Exceptions.FileNotFoundException("No 'RelicChunky' file found at " + filepath);
            }

            FileInfo     chunkyFile = new FileInfo(filepath);
            BinaryReader br         = new BinaryReader(chunkyFile.OpenRead());

            byte[] start    = br.ReadBytes(4);
            int    version  = 0;
            string fileType = "";

            if (start[1] == 0 && start[2] == 0 && start[3] == 0)
            {
                version  = start[0];
                fileType = ReadString(br, 4, 8);
            }
            else
            {
                br.BaseStream.Seek(0, SeekOrigin.Begin);
            }

            ChunkyStructureCollection structCol = ReadChunkyFileStructure(br);

            br.Close();

            string filename = filepath.Substring(filepath.LastIndexOf(Path.DirectorySeparatorChar) + 1);

            if (filepath.EndsWith(".rec"))
            {
                return(new RECFile(filename, structCol, version, fileType));
            }
            else if (structCol.Count == 1 && structCol[0].RootChunks[0].ID == "TPAT")
            {
                return(new WTPFile(filename, structCol));
            }
            else if (structCol.Count == 1 && structCol[0].RootChunks[0].ID == "SHRF")
            {
                return(new RSHFile(filename, structCol));
            }
            else if (structCol.Count == 1 && structCol[0].RootChunks[0].ID == "TXTR")
            {
                return(new RTXFile(filename, structCol));
            }
            else
            {
                return(new RelicChunkyFile(filename, structCol));
            }
        }
Exemple #3
0
        public WTPFile(string filename, ChunkyStructureCollection col) : base(filename, col)
        {
            ChunkyFolder       folder   = (ChunkyFolder)col[0].RootChunks[0];
            int                children = folder.Children.Count;
            ChunkyChunk        chunk    = null;
            ChunkyDataINFOTPAT info     = null;

            for (int i = 0; i < children; i++)
            {
                chunk = folder.Children[i];

                if (chunk is ChunkyDataINFOTPAT)
                {
                    info   = (ChunkyDataINFOTPAT)chunk;
                    width  = info.Width;
                    height = info.Height;
                }
            }
        }
Exemple #4
0
        public RTXFile(string filename, ChunkyStructureCollection col) : base(filename, col)
        {
            int lastIndex = filename.LastIndexOf('_');

            if (lastIndex == -1 || filename.IndexOf('_') == lastIndex)
            {
                throw new InvalidFileException("RTX file name specified must end with a skin name and number e.g. _default_0.rtx");
            }

            try
            {
                int dot = filename.LastIndexOf('.');
                lastIndex++;
                id = int.Parse(filename.Substring(lastIndex, dot - lastIndex));
            }
            catch (FormatException)
            {
                throw new InvalidFileException("RTX file name specified must end with a skin name and number e.g. _default_0.rtx");
            }

            FindAttributes((ChunkyFolder)this.ChunkyStructures[0].RootChunks[0]);
        }
Exemple #5
0
        private static ChunkyStructureCollection ReadChunkyStructure(BinaryReader br, long fileLength)
        {
            //long end = fileLength - 20;
            ChunkyStructureCollection structCol = new ChunkyStructureCollection();
            int unknown1 = br.ReadInt32();
            int unknown2 = br.ReadInt32();
            int unknown3 = br.ReadInt32();

            byte[] bytes = br.ReadBytes((int)(fileLength - br.BaseStream.Position));

            structCol.Add(new RelicChunkyStructure(RelicChunkReader.ReadChunkyChunks(bytes), unknown1, unknown2, unknown3));

            if (RelicChunkReader.HasRemainingBytes())
            {
                byte[] remainingData = RelicChunkReader.GetRemainingBytes();

                if (remainingData[0] == 0x52 && remainingData[1] == 0x65 && remainingData[2] == 0x6C && remainingData[3] == 0x69)
                {
                    MemoryStream ms  = new MemoryStream(remainingData);
                    BinaryReader br2 = new BinaryReader(ms);
                    ChunkyStructureCollection col = ReadChunkyFileStructure(br2);

                    foreach (RelicChunkyStructure strct in col)
                    {
                        structCol.Add(strct);
                    }
                }
                else
                {
                    ChunkyCollection col = new ChunkyCollection();
                    col.Add(new ChunkyRawData(remainingData));
                    structCol.Add(new RelicChunkyStructure(col));
                }
            }

            return(structCol);
        }
Exemple #6
0
 public RECFile(string filename, ChunkyStructureCollection chunkyStructs, int ver, string type) : base(filename, chunkyStructs)
 {
     version = ver;
     recType = type;
 }
Exemple #7
0
 public RSHFile(string filename, ChunkyStructureCollection col) : base(filename, col)
 {
 }