Beispiel #1
0
        public bool LoadResources(Stream file, bool initial = true)
        {
            if (MoSync.Util.StreamReadInt8(file) != 'M')
            {
                return(false);
            }
            if (MoSync.Util.StreamReadInt8(file) != 'A')
            {
                return(false);
            }
            if (MoSync.Util.StreamReadInt8(file) != 'R')
            {
                return(false);
            }
            if (MoSync.Util.StreamReadInt8(file) != 'S')
            {
                return(false);
            }

            uint numResources = ReadUnsignedVarInt(file);
            uint resSize      = ReadUnsignedVarInt(file);


            mCurrentResourceHandle = 1;
            mStaticResourceCount   = 0;

            while (true)
            {
                byte type = MoSync.Util.StreamReadUint8(file);
                if (type == 0)
                {
                    break;
                }

                uint size = ReadUnsignedVarInt(file);
                Util.Log("Resource type " + type + ", size " + size + "\n");

                Resource resource = new Resource(null, type);
                mResources.Add(mCurrentResourceHandle, resource);

                if (initial &&
                    (
                        type == MoSync.Constants.RT_BINARY ||
                        type == MoSync.Constants.RT_IMAGE ||
                        type == MoSync.Constants.RT_SPRITE
                    ))
                {
                    resource.SetFileStream(new BoundedStream(file, file.Position, (long)size));
#if LIB
                    //This needs to be investigated. If I don't call this some syscalls will fail since mInternalObject is null. Used to
                    //work on the previous system.
                    resource.SetInternalObject(new BoundedStream(file, file.Position, (long)size));
#endif
                    file.Seek(size, SeekOrigin.Current);
                }
                else
                {
                    LoadResource(file, type, size, resource);
                }

                mCurrentResourceHandle++;
                mStaticResourceCount++;
            }

            return(true);
        }
Beispiel #2
0
        public bool LoadResources(Stream file, bool initial = true)
        {
            if (MoSync.Util.StreamReadInt8(file) != 'M')
            {
                return(false);
            }
            if (MoSync.Util.StreamReadInt8(file) != 'A')
            {
                return(false);
            }
            if (MoSync.Util.StreamReadInt8(file) != 'R')
            {
                return(false);
            }
            if (MoSync.Util.StreamReadInt8(file) != 'S')
            {
                return(false);
            }

            uint numResources = ReadUnsignedVarInt(file);
            uint resSize      = ReadUnsignedVarInt(file);


            mCurrentResourceHandle = 1;
            mStaticResourceCount   = 0;

            while (true)
            {
                byte type = MoSync.Util.StreamReadUint8(file);
                if (type == 0)
                {
                    break;
                }

                uint size = ReadUnsignedVarInt(file);
                Util.Log("Resource type " + type + ", size " + size + "\n");

                Resource resource = new Resource(null, type);
                mResources.Add(mCurrentResourceHandle, resource);

                if (initial &&
                    (
                        type == MoSync.Constants.RT_BINARY ||
                        type == MoSync.Constants.RT_IMAGE ||
                        type == MoSync.Constants.RT_SPRITE
                    ))
                {
                    resource.SetFileStream(new BoundedStream(file, file.Position, (long)size));
                    file.Seek(size, SeekOrigin.Current);
                }
                else
                {
                    LoadResource(file, type, size, resource);
                }

                mCurrentResourceHandle++;
                mStaticResourceCount++;
            }

            return(true);
        }