Example #1
0
        /// <summary>
        /// Allocates a new tag at the end of the tag list without updating the file.
        /// You can give the tag data by using one of the overwrite functions.
        /// </summary>
        /// <param name="type">The tag's type information.</param>
        /// <returns>The allocated tag.</returns>
        public TagInstance AllocateTag(TagGroup type)
        {
            var tagIndex = _tags.Count;
            var tag      = new TagInstance(tagIndex, type);

            _tags.Add(tag);
            return(tag);
        }
Example #2
0
        /// <summary>
        /// Reads the header for the tag instance from a stream.
        /// </summary>
        /// <param name="reader">The stream to read from.</param>
        internal void ReadHeader(BinaryReader reader)
        {
            Checksum  = reader.ReadUInt32();                             // 0x00 uint32 checksum
            TotalSize = reader.ReadUInt32();                             // 0x04 uint32 total size
            var numDependencies   = reader.ReadInt16();                  // 0x08 int16  dependencies count
            var numDataFixups     = reader.ReadInt16();                  // 0x0A int16  data fixup count
            var numResourceFixups = reader.ReadInt16();                  // 0x0C int16  resource fixup count

            reader.BaseStream.Position += 2;                             // 0x0E int16  (padding)
            MainStructOffset            = reader.ReadUInt32();           // 0x10 uint32 main struct offset
            var groupTag            = new Tag(reader.ReadInt32());       // 0x14 int32  group tag
            var parentGroupTag      = new Tag(reader.ReadInt32());       // 0x18 int32  parent group tag
            var grandparentGroupTag = new Tag(reader.ReadInt32());       // 0x1C int32  grandparent group tag
            var groupName           = new StringId(reader.ReadUInt32()); // 0x20 uint32 group name stringid

            Group = new TagGroup(groupTag, parentGroupTag, grandparentGroupTag, groupName);

            // Read dependencies
            var dependencies = new HashSet <int>();

            for (var j = 0; j < numDependencies; j++)
            {
                dependencies.Add(reader.ReadInt32());
            }
            Dependencies = new ReadOnlySet <int>(dependencies);

            // Read offsets
            _pointerOffsets = new List <uint>(numDataFixups);
            for (var j = 0; j < numDataFixups; j++)
            {
                _pointerOffsets.Add(PointerToOffset(reader.ReadUInt32()));
            }
            _resourceOffsets = new List <uint>(numResourceFixups);
            for (var j = 0; j < numResourceFixups; j++)
            {
                _resourceOffsets.Add(PointerToOffset(reader.ReadUInt32()));
            }
        }
Example #3
0
 /// <summary>
 /// Finds the first tag in a given group.
 /// </summary>
 /// <param name="group">The group.</param>
 /// <returns>The first tag in the given group, or <c>null</c> otherwise.</returns>
 public TagInstance FindFirstInGroup(TagGroup group)
 {
     return(FindFirstInGroup(group.Tag));
 }
Example #4
0
 /// <summary>
 /// Finds all tags in a given group.
 /// </summary>
 /// <param name="group">The group.</param>
 /// <returns>All tags in the given group.</returns>
 public IEnumerable <TagInstance> FindAllInGroup(TagGroup group)
 {
     return(FindAllInGroup(group.Tag));
 }
Example #5
0
 internal TagInstance(int index, TagGroup group)
 {
     Index = index;
     Group = group;
 }
Example #6
0
 /// <summary>
 /// Determines whether the tag belongs to a tag group.
 /// </summary>
 /// <param name="group">The tag group.</param>
 /// <returns><c>true</c> if the tag belongs to the group.</returns>
 public bool IsInGroup(TagGroup group)
 {
     return(Group.BelongsTo(group));
 }