Inheritance: McbResource
Example #1
0
        private void ReadResources(BinaryReaderEx reader, long rstOffset)
        {
            for (var i = 0; i < this.rstChunk.ResourceOffsets.Count; i++)
            {
                long offset = rstOffset + this.rstChunk.ResourceOffsets[i];
                reader.BaseStream.Position = offset;

                ResHeader resHeader = new ResHeader();
                int       magic     = reader.ReadInt32();

                if (magic != 0x53455240)
                {
                    throw new InvalidOperationException("Expected @RST (0x53455240), found " + magic.ToString("X"));
                }

                resHeader.ChunkBlocks = reader.ReadInt16();
                resHeader.Unknown1    = reader.ReadInt16();
                resHeader.ResType     = reader.ReadFixedLengthString(8).TrimEnd('\0');
                resHeader.Unknown2    = reader.ReadInt32();
                resHeader.Unknown3    = reader.ReadInt32();

                McbResource resource;
                switch (resHeader.ResType)
                {
                case "String":
                    resource = new McbStrings(resHeader);
                    break;

                case "motionC":
                    resource = new McbMotionC(resHeader);
                    break;

                case "RIDTBL":
                case "Effect":
                case "ClipGid":
                    resource = new McbResource(resHeader);
                    break;

                default:
                    throw new InvalidOperationException("Unknown Mcb Resource: " + resHeader.ResType);
                }
                resource.Parent = this;
                resource.LoadSection(reader);
                this.Children.Add(resource);
            }

            var strings       = this.GetChildOfType <McbStrings>();
            var stringEntries = this.FindAllChildren <StringEntry>();

            foreach (var entry in stringEntries)
            {
                entry.DisplayName = strings.Strings[entry.StringIndex];
            }
        }
Example #2
0
        private void ReadResources(BinaryReaderEx reader, long rstOffset)
        {
            for (var i = 0; i < this.rstChunk.ResourceOffsets.Count; i++)
            {
                long offset = rstOffset + this.rstChunk.ResourceOffsets[i];
                reader.BaseStream.Position = offset;

                ResHeader resHeader = new ResHeader();
                int magic = reader.ReadInt32();

                if (magic != 0x53455240)
                {
                    throw new InvalidOperationException("Expected @RST (0x53455240), found " + magic.ToString("X"));
                }

                resHeader.ChunkBlocks = reader.ReadInt16();
                resHeader.Unknown1 = reader.ReadInt16();
                resHeader.ResType = reader.ReadFixedLengthString(8).TrimEnd('\0');
                resHeader.Unknown2 = reader.ReadInt32();
                resHeader.Unknown3 = reader.ReadInt32();

                McbResource resource;
                switch (resHeader.ResType)
                {
                    case "String":
                        resource = new McbStrings(resHeader);
                        break;
                    case "motionC":
                        resource = new McbMotionC(resHeader);
                        break;
                    case "RIDTBL":
                    case "Effect":
                    case "ClipGid":
                        resource = new McbResource(resHeader);
                        break;
                    default:
                        throw new InvalidOperationException("Unknown Mcb Resource: " + resHeader.ResType);
                }
                resource.Parent = this;
                resource.LoadSection(reader);
                this.Children.Add(resource);
            }

            var strings = this.GetChildOfType<McbStrings>();
            var stringEntries = this.FindAllChildren<StringEntry>();
            foreach (var entry in stringEntries)
            {
                entry.DisplayName = strings.Strings[entry.StringIndex];
            }
        }