示例#1
0
        public override Resource LoadResourceData(ScummBinaryReader reader, string resourceId, IDictionary <string, object> parameters)
        {
            reader.FindDataBlockNoInfo("OBCD");

            // read header
            uint   blockSize = reader.FindDataBlock("CDHD");
            UInt16 id        = reader.ReadUInt16();

            var obj  = ResourceManager.FindObject(id);
            var data = reader.ReadBytes((int)blockSize - 10);

            // read verb block
            blockSize = reader.FindDataBlock("VERB");
            long verbPos = reader.BaseStream.Position - 8;

            // read verbs and offsets
            byte[]   verbs   = new byte[100];
            UInt16[] offsets = new UInt16[100];

            int totalVerbs = 0;

            verbs[totalVerbs] = reader.ReadByte();
            while (verbs[totalVerbs] != 0)
            {
                offsets[totalVerbs] = reader.ReadUInt16();
                verbs[++totalVerbs] = reader.ReadByte();
            }
            // final offset found reading the next block - needed for blocksize
            reader.FindDataBlockNoInfo("OBNA");
            long endPos = reader.BaseStream.Position - 8;

            // read object name
            byte a = reader.ReadByte();

            while (a != 0)
            {
                obj.Name += (char)a;
                a         = reader.ReadByte();
            }
            long backupPos = reader.BaseStream.Position;

            // load verb scripts
            for (int i = 0; i < totalVerbs; ++i)
            {
                long startPos = verbPos + offsets[i];
                uint size     = (uint)(endPos - startPos);

                obj.VerbScript[verbs[i]] =
                    (ScriptV5)resourceManager.Load <Script>("SCRP", id, reader, new Dictionary <string, object>()
                {
                    { "Position", startPos }, { "Blocksize", size }
                });
            }
            reader.BaseStream.Position = backupPos;

            return(obj);
        }
示例#2
0
        public override Resource LoadResourceData(ScummBinaryReader reader, string resourceId, IDictionary <string, object> parameters)
        {
            reader.FindDataBlockNoInfo("OBIM");
            // read header
            uint blockSize = reader.FindDataBlock("IMHD");

            UInt16 id  = reader.ReadUInt16();
            var    obj = ResourceManager.FindObject(id);

            UInt16 numImages = reader.ReadUInt16();
            UInt16 numZs     = reader.ReadUInt16();
            Byte   flags     = reader.ReadByte();
            Byte   unknown   = reader.ReadByte();
            UInt16 x         = reader.ReadUInt16();
            UInt16 y         = reader.ReadUInt16();
            UInt16 width     = reader.ReadUInt16();
            UInt16 height    = reader.ReadUInt16();

            obj.Position = new Vector2(x, y);
            obj.Image    = new Image(width, height);

            var roomPalette = (Color[])parameters["RoomPalette"];

            for (int i = 0; i < numImages; ++i)
            {
                string blockName = String.Format("IM{0:X2}", i + 1);
                if (reader.FindDataBlock(blockName) == 0)
                {
                    throw new InvalidOperationException("Could not find image block.");
                }
                ReadImageDataBlock(reader, obj.Image, roomPalette);
            }

            return(obj.Image);
        }