Esempio n. 1
0
        private void CreateFileDicts(RAFArchive raf, UInt32 offsetFileList, UInt32 offsetStringTable)
        {
            //The file list starts with a uint stating how many files we have
            UInt32 fileListCount = BitConverter.ToUInt32(m_content.SubArray((Int32)offsetFileList, 4), 0);

            //After the file list count, we have the actual data.
            offsetFileList += 4;

            for (UInt32 currentOffset = offsetFileList; currentOffset < offsetFileList + 16 * fileListCount; currentOffset += 16)
            {
                RAFFileListEntry entry = new RAFFileListEntry(raf, ref raf.m_content, currentOffset, offsetStringTable);
                raf.m_fileDictFull.Add(entry.FileName.ToLower(), entry);

                FileInfo fi = new FileInfo(entry.FileName);
                if (!raf.m_fileDictShort.ContainsKey(fi.Name.ToLower()))
                {
                    raf.m_fileDictShort.Add(fi.Name.ToLower(), new List <RAFFileListEntry> {
                        entry
                    });
                }
                else
                {
                    raf.m_fileDictShort[fi.Name.ToLower()].Add(entry);
                }
            }
        }
Esempio n. 2
0
        public static bool Read(RAFFileListEntry file, ref InibinFile data, Logger logger)
        {
            bool result = true;

            logger.Event("Reading inibin: " + file.FileName);

            try
            {
                // Get the data from the archive
                MemoryStream myInput = new MemoryStream( file.GetContent() );
                result = ReadCharacterInibin(myInput, ref data, logger);

                int end = file.FileName.LastIndexOf("/");
                String directory = file.FileName.Substring(0, end);
                String archive = file.RAFArchive.RAFFilePath;
                archive = archive.Replace("\\", "/");
                end = archive.LastIndexOf("/");
                archive = archive.Substring(0, end);

                data.directory = new DirectoryInfo(archive + "/" + directory);
                myInput.Close();
            }
            catch(Exception e)
            {
                logger.Error("Unable to open memory stream: " + file.FileName);
                logger.Error(e.Message);
                result = false;
            }

            return result;
        }
Esempio n. 3
0
        public LOLModel()
        {
            skn = null;
            skl = null;
            texture = null;

            animationList = String.Empty;
            animations = new Dictionary<String, RAFFileListEntry>();

            skinNumber = -1;
        }
Esempio n. 4
0
        /// <summary>
        /// Read in binary .dds file from RAF.
        /// </summary>
        /// <param name="file">The file.</param>
        /// <param name="data">The contents of the file are stored in here.</param>
        /// <returns></returns>
        public static bool Read(RAFFileListEntry file, ref Bitmap bitmap, Logger logger)
        {
            bool result = true;

            logger.Event("Reading dds: " + file.FileName);

            try
            {
                // Create image.
                int[] images = new int[1];
                Il.ilGenImages(1, images);

                // Bind image.
                Il.ilBindImage(images[0]);

                // Load the image data into DevIL.
                byte[] data = file.GetContent();
                result = Il.ilLoadL(Il.IL_DDS, data, data.Length);
                if (result == true)
                {
                    int width = Il.ilGetInteger(Il.IL_IMAGE_WIDTH);
                    int height = Il.ilGetInteger(Il.IL_IMAGE_HEIGHT); ;

                    // Create the bitmap.
                    bitmap = new Bitmap(width, height, PixelFormat.Format32bppArgb);
                    Rectangle rect = new Rectangle(0, 0, width, height);

                    // Store the DevIL image data into the bitmap.
                    BitmapData bitmapData = bitmap.LockBits(rect, ImageLockMode.WriteOnly, PixelFormat.Format32bppArgb);

                    Il.ilConvertImage(Il.IL_BGRA, Il.IL_UNSIGNED_BYTE);
                    Il.ilCopyPixels(0, 0, 0, width, height, 1, Il.IL_BGRA, Il.IL_UNSIGNED_BYTE, bitmapData.Scan0);

                    bitmap.UnlockBits(bitmapData);
                }

                // Free image.
                Il.ilDeleteImages(1, images);

                if (result == false)
                {
                    throw new System.Exception("Unable to load image data.");
                }
            }
            catch(Exception e)
            {
                logger.Error("Unable to open dds file: " + file.FileName);
                logger.Error(e.Message);
                result = false;
            }

            return result;
        }
Esempio n. 5
0
        private RAFFileListEntry CreateFileEntry(string rafPath, UInt32 offset, UInt32 fileSize)
        {
            RAFFileListEntry result = new RAFFileListEntry(this, rafPath, offset, fileSize);

            m_fileDictFull.Add(result.FileName, result);
            FileInfo fi = new FileInfo(result.FileName);

            if (!m_fileDictShort.ContainsKey(fi.Name))
            {
                m_fileDictShort.Add(fi.Name, new List <RAFFileListEntry> {
                    result
                });
            }
            else
            {
                m_fileDictShort[fi.Name].Add(result);
            }
            return(result);
        }
Esempio n. 6
0
        private bool insertFileHelperFunc(string fileName, byte[] content, FileStream datFileStream, bool createNewIfNoExist = false)
        {
            RAFFileListEntry fileEntry = this.GetFileEntry(fileName);

            // File exists in archive
            if (fileEntry != null)
            {
                return(fileEntry.ReplaceContent(content, datFileStream));
            }
            // Create a new file if specified
            else if (createNewIfNoExist)
            {
                // Create a virtual RAFFileEntry using dummy offsets and filesize
                fileEntry = CreateFileEntry(fileName, 0, 0);
                return(fileEntry.ReplaceContent(content, datFileStream));
            }

            return(false);
        }
Esempio n. 7
0
        /// <summary>
        /// Read in binary .anm file from RAF.
        /// </summary>
        /// <param name="file">The file.</param>
        /// <param name="data">The contents of the file are stored in here.</param>
        /// <returns></returns>
        public static bool Read(RAFFileListEntry file, ref ANMFile data, Logger logger)
        {
            bool result = true;

            logger.Event("Reading anm: " + file.FileName);

            try
            {
                // Get the data from the archive
                MemoryStream myInput = new MemoryStream( file.GetContent() );
                result = ReadBinary(myInput, ref data, logger);
                myInput.Close();
            }
            catch(Exception e)
            {
                logger.Error("Unable to open memory stream: " + file.FileName);
                logger.Error(e.Message);
                result = false;
            }

            return result;
        }
Esempio n. 8
0
        /// <summary>
        /// Load texture from RAF.
        /// </summary>
        /// <param name="file">The RAF file entry of the texture.</param>
        /// <param name="target">Only supports 2D.</param>
        /// <returns></returns>
        public bool Create(RAFFileListEntry file, TextureTarget target, SupportedImageEncodings encoding, Logger logger)
        {
            bool result = true;

            this.target = target;

            // Hacky sanity check
            if (target != TextureTarget.Texture2D)
            {
                return false;
            }

            GL.Enable(EnableCap.Texture2D);
            GL.Hint(HintTarget.PerspectiveCorrectionHint, HintMode.Nicest);

            // Create a System.Drawing.Bitmap.
            Bitmap bitmap = null;
            if (encoding == SupportedImageEncodings.DDS)
            {
                // Special case.
                result = DDSReader.Read(file, ref bitmap, logger);
            }
            else
            {
                // Normal case.
                result = CreateBitmap(file.GetContent(), ref bitmap);
            }

            // Pass the Bitmap into OpenGL.
            if (result == true &&
                bitmap != null)
            {
                result = CreateTexture(bitmap, target);
            }

            if (result == true)
            {
                // Set up texture parameters.
                GL.TexEnv(TextureEnvTarget.TextureEnv,
                    TextureEnvParameter.TextureEnvMode,
                    (Int32)TextureEnvModeCombine.Modulate);

                GL.TexParameter(TextureTarget.Texture2D,
                    TextureParameterName.TextureMinFilter,
                    (Int32)TextureMinFilter.Linear);

                GL.TexParameter(TextureTarget.Texture2D,
                    TextureParameterName.TextureMagFilter,
                    (Int32)TextureMagFilter.Linear);

                GL.TexParameter(TextureTarget.Texture2D,
                    TextureParameterName.TextureWrapS,
                    (Int32)TextureWrapMode.Repeat);

                GL.TexParameter(TextureTarget.Texture2D,
                    TextureParameterName.TextureWrapT,
                    (Int32)TextureWrapMode.Repeat);
            }

            return result;
        }
Esempio n. 9
0
 private RAFFileListEntry CreateFileEntry(string rafPath, UInt32 offset, UInt32 fileSize)
 {
     RAFFileListEntry result = new RAFFileListEntry(this, rafPath, offset, fileSize);
     this.fileDictFull.Add(result.FileName, result);
     FileInfo fi = new FileInfo(result.FileName);
     if (!this.fileDictShort.ContainsKey(fi.Name))
         this.fileDictShort.Add(fi.Name, new List<RAFFileListEntry> { result });
     else
         this.fileDictShort[fi.Name].Add(result);
     return result;
 }
Esempio n. 10
0
        private void createFileDicts(RAFArchive raf, UInt32 offsetFileList, UInt32 offsetStringTable)
        {
            //The file list starts with a uint stating how many files we have
            UInt32 fileListCount = BitConverter.ToUInt32(content.SubArray((Int32)offsetFileList, 4), 0);

            //After the file list count, we have the actual data.
            offsetFileList += 4;

            for (UInt32 currentOffset = offsetFileList; currentOffset < offsetFileList + 16 * fileListCount; currentOffset += 16)
            {
                RAFFileListEntry entry = new RAFFileListEntry(raf, ref raf.content, currentOffset, offsetStringTable);
                raf.fileDictFull.Add(entry.FileName.ToLower(), entry);

                FileInfo fi = new FileInfo(entry.FileName);
                if (!raf.fileDictShort.ContainsKey(fi.Name.ToLower()))
                    raf.fileDictShort.Add(fi.Name.ToLower(), new List<RAFFileListEntry> { entry });
                else
                    raf.fileDictShort[fi.Name.ToLower()].Add(entry);
            }
        }
 public RAFFileListEntryWrapper(RAFMasterFileList.RAFSearchResult result)
 {
     e = result.value;
     SearchPhrase = result.searchPhrase;
 }