Exemplo n.º 1
0
        public CastLib(EndogineHub a_endogine)
        {
            m_endogine = a_endogine;

            //this.Animations = new Animations();
            this.FrameSets = new FrameSets();

            //this.Pictures = new PicRefs();
        }
Exemplo n.º 2
0
        public int ReadFrom(byte[] Buffer, int StartIndex = 0)
        {
            int cursor = StartIndex;

            uint signature = BitConverter.ToUInt32(Buffer, cursor);

            cursor += TypeSizes.INT;

            if (signature == SIGNATURE)
            {
                Version = BitConverter.ToUInt32(Buffer, cursor);
                cursor += TypeSizes.INT;

                // version has to be V9 or higher
                if (version >= VERSION9)
                {
                    // name string has always fixed length
                    Name    = Encoding.Default.GetString(Buffer, cursor, NAMELENGTH);
                    cursor += NAMELENGTH;

                    uint frameCount = BitConverter.ToUInt32(Buffer, cursor);
                    cursor += TypeSizes.INT;

                    uint frameSetCount = BitConverter.ToUInt32(Buffer, cursor);
                    cursor += TypeSizes.INT;

                    // skip max indices, we use dynamic getter
                    cursor += TypeSizes.INT;

                    ShrinkFactor = BitConverter.ToUInt32(Buffer, cursor);
                    cursor      += TypeSizes.INT;

                    Frames.Clear();
                    Frames.Capacity = (int)frameCount;
                    for (uint i = 0; i < frameCount; i++)
                    {
                        BgfBitmap bgfBitmap = new BgfBitmap(i + 1, version, Buffer, cursor);
                        cursor += bgfBitmap.ByteLength;

                        Frames.Add(bgfBitmap);
                    }

                    FrameSets.Clear();
                    FrameSets.Capacity = (int)frameSetCount;
                    for (uint i = 0; i < frameSetCount; i++)
                    {
                        BgfFrameSet frameSet = new BgfFrameSet(i + 1, Buffer, cursor);
                        cursor += frameSet.ByteLength;

                        FrameSets.Add(frameSet);
                    }
                }
                else
                {
                    throw new Exception("Wrong file version: " + version + " (expected " + VERSION9 + " or higher).");
                }
            }
            else
            {
                throw new Exception("Wrong file signature: " + signature + " (expected " + SIGNATURE + ").");
            }

            return(cursor - StartIndex);
        }