コード例 #1
0
 /// <summary>
 ///  Constructs a KIFINT entry with the specified file name, entry data, parent KIFINT archive.
 /// </summary>
 /// <param name="fileName">
 ///  The cached name of the file. Calling <see cref="Kifint.KIFENTRY.FileName"/> is wasteful.
 /// </param>
 /// <param name="kifEntry">The decrypted data for the entry.</param>
 /// <param name="kifint">The parent KIFINT arhive.</param>
 internal KifintEntry(string fileName, Kifint.KIFENTRY kifEntry, Kifint kifint)
 {
     Kifint   = kifint;
     FileName = fileName;
     Offset   = kifEntry.Offset;
     Length   = kifEntry.Length;
 }
コード例 #2
0
        /// <summary>
        ///  Reads the KIFINT archive from the stream. For use with <see cref="KifintLookup"/>.
        /// </summary>
        /// <param name="reader">The reader for the current stream.</param>
        /// <param name="version">The current version being read.</param>
        /// <param name="installDir">The installation directory where the archive is located.</param>
        /// <returns>The loaded cached KIFINT archive.</returns>
        internal static Kifint Read(BinaryReader reader, int version, string installDir, KifintType type)
        {
            Kifint kifint = new Kifint {
                FilePath    = Path.Combine(installDir, reader.ReadString()),
                ArchiveType = type,
            };

            kifint.IsEncrypted = reader.ReadBoolean();
            kifint.FileKey     = reader.ReadUInt32();
            if (!kifint.IsEncrypted)
            {
                kifint.FileKey = 0;
            }

            int count = reader.ReadInt32();
            Dictionary <string, KifintEntry> entries = new Dictionary <string, KifintEntry>(count);

            for (int i = 0; i < count; i++)
            {
                KifintEntry entry = KifintEntry.Read(reader, version, kifint);
                entries.Add(entry.FileName, entry);
            }
            kifint.Entries = new ReadOnlyDictionary <string, KifintEntry>(entries);
            return(kifint);
        }
コード例 #3
0
 /// <summary>
 ///  Reads the KIFINT archive from the stream. For use with <see cref="KifintLookup"/>.
 /// </summary>
 /// <param name="reader">The reader for the current stream.</param>
 /// <param name="version">The current version being read.</param>
 /// <param name="kifint">The KIFINT archive containing this entry.</param>
 /// <returns>The loaded cached KIFINT.</returns>
 internal static KifintEntry Read(BinaryReader reader, int version, Kifint kifint)
 {
     return(new KifintEntry {
         Kifint = kifint,
         FileName = reader.ReadString(),
         Offset = reader.ReadUInt32(),
         Length = reader.ReadInt32(),
     });
 }
コード例 #4
0
        /// <summary>
        ///  Constructs the KIFINT archive list and sorts the entry file names.
        /// </summary>
        /// <param name="kifint">The associated KIFINT archive.</param>
        public KifintList(Kifint kifint)
        {
            StringComparer comparer = StringComparer.InvariantCultureIgnoreCase;

            FilePath = kifint.FilePath;
            Entries  = kifint.Entries.Values.Select(e => e.FileName)
                       .OrderBy(e => e, comparer)
                       .ToList()
                       .AsReadOnly();
        }
コード例 #5
0
 /// <summary>
 ///  Opens the file stream for the specified KIFINT archive and closes the existing stream if there is one.
 ///  <para/>
 ///  This method does not reopen the stream if the specified KIFINT archive is the currenly open archive.
 /// </summary>
 /// <param name="kifint">The KIFINT archive to open the stream for.</param>
 ///
 /// <exception cref="ArgumentNullException">
 ///  <paramref name="kifint"/> is null.
 /// </exception>
 public void Open(Kifint kifint)
 {
     if (kifint == null)
     {
         throw new ArgumentNullException(nameof(kifint));
     }
     if (kifint == Kifint)
     {
         return;                 // We're already open.
     }
     Close();
     Stream = File.OpenRead(kifint.FilePath);
     Kifint = kifint;
 }
コード例 #6
0
 /// <summary>
 ///  Constructs and opens the file stream for the specified KIFINT archive and closes the existing stream if
 ///  there is one.
 /// </summary>
 /// <param name="kifint">The KIFINT archive to open the stream for.</param>
 ///
 /// <exception cref="ArgumentNullException">
 ///  <paramref name="kifint"/> is null.
 /// </exception>
 public KifintStream(Kifint kifint)
 {
     Open(kifint);
 }
コード例 #7
0
 /// <summary>
 ///  Extracts the ANM animation information from the entry.
 /// </summary>
 /// <returns>The extracted <see cref="Anm"/> animation information.</returns>
 public Anm ExtractAnm()
 {
     return(Kifint.ExtractAnm(this));
 }
コード例 #8
0
 /// <summary>
 ///  Extracts the HG-3 image information ONLY and does not extract the actual images.
 /// </summary>
 /// <returns>The extracted <see cref="Hg3"/> information.</returns>
 public Hg3 ExtractHg3()
 {
     return(Kifint.ExtractHg3(this));
 }
コード例 #9
0
 /// <summary>
 ///  Extracts the HG-3 file and the images contained within to the output <paramref name="directory"/>.
 /// </summary>
 /// <param name="directory">The output directory to save the images to.</param>
 /// <param name="expand">True if the images are expanded to their full size when saving.</param>
 /// <returns>The extracted <see cref="Hg3"/> information.</returns>
 public Hg3 ExtractHg3AndImages(string directory, bool expand)
 {
     return(Kifint.ExtractHg3AndImages(this, directory, expand));
 }
コード例 #10
0
 /// <summary>
 ///  Extracts the KIFINT entry to a <see cref="MemoryStream"/>.
 /// </summary>
 /// <returns>A memory stream containing the data of the decrypted entry.</returns>
 public MemoryStream ExtractToStream()
 {
     return(Kifint.ExtractToStream(this));
 }
コード例 #11
0
 /// <summary>
 ///  Extracts the KIFINT entry to a <see cref="byte[]"/>.
 /// </summary>
 /// <returns>A byte array containing the data of the decrypted entry.</returns>
 public byte[] Extract()
 {
     return(Kifint.Extract(this));
 }