Beispiel #1
0
        public WND1(ref EndianBinaryReader reader, ref MAT1 materials) : base(ref reader)
        {
            base.setType("Window");

            long startPos = reader.Pos() - 0x4C;

            mContentOverflowLeft   = reader.ReadF32();
            mContentOverflowRight  = reader.ReadF32();
            mContentOverflowTop    = reader.ReadF32();
            mContentOverflowBottom = reader.ReadF32();
            mFrameCount            = reader.ReadByte();
            mFlag = reader.ReadByte();
            reader.ReadUInt16(); // padding
            mWindowContentOffset = reader.ReadUInt32();
            mWindowFrameOffset   = reader.ReadUInt32();

            mTopLeftColor     = reader.ReadRGBAColor8();
            mTopRightColor    = reader.ReadRGBAColor8();
            mBottomLeftColor  = reader.ReadRGBAColor8();
            mBottomRightColor = reader.ReadRGBAColor8();
            mMaterialIndex    = reader.ReadUInt16();
            mNumUVSets        = reader.ReadByte();
            reader.ReadByte(); // padding

            mUVSets = new List <UVCoordSet>();

            for (byte i = 0; i < mNumUVSets; i++)
            {
                mUVSets.Add(reader.ReadUVCoordSet());
            }

            // now we read our window frames
            reader.Seek(startPos + mWindowFrameOffset);

            mFrameOffsets = new List <int>();

            for (byte i = 0; i < mFrameCount; i++)
            {
                mFrameOffsets.Add(reader.ReadInt32());
            }

            mFrames = new List <WND1Frame>();

            foreach (int offset in mFrameOffsets)
            {
                reader.Seek(startPos + offset);
                mFrames.Add(new WND1Frame(ref reader));
            }

            mMaterialName = materials.getMaterialNameFromIndex(mMaterialIndex);

            reader.Seek(startPos + mSectionSize);
        }
Beispiel #2
0
        public BCLYT(ref EndianBinaryReader reader)
        {
            reader.SetEndianess(Endianess.Little);

            if (reader.ReadString(4) != "CLYT")
            {
                Console.WriteLine("Bad magic. Expected CLYT.");
                return;
            }

            mBOM          = reader.ReadUInt16();
            mHeaderLength = reader.ReadUInt16();
            mRevision     = reader.ReadUInt32();
            mFileSize     = reader.ReadUInt32();
            mSectionCount = reader.ReadUInt32();

            mLayoutParams = new LYT1(ref reader);

            mUserDataEntries = new List <USD1>();

            LayoutBase prev   = null;
            LayoutBase parent = null;

            // for groups
            LayoutBase previousGroup = null;
            LayoutBase groupParent   = null;

            bool isRootPaneSet  = false;
            bool isRootGroupSet = false;

            string magic = "";

            for (uint i = 0; i < mSectionCount; i++)
            {
                magic = reader.ReadString(4);

                switch (magic)
                {
                case "txl1":
                    mTextureList = new TXL1(ref reader);
                    break;

                case "fnl1":
                    mFontList = new FNL1(ref reader);
                    break;

                case "mat1":
                    mMaterialList = new MAT1(ref reader);
                    break;

                case "pan1":
                    PAN1 panel = new PAN1(ref reader);

                    if (!isRootPaneSet)
                    {
                        mRootPanel    = panel;
                        isRootPaneSet = true;
                    }

                    if (parent != null)
                    {
                        parent.addChild(panel);
                        panel.setParent(parent);
                    }

                    prev = panel;
                    break;

                case "pic1":
                    PIC1 pic = new PIC1(ref reader);

                    if (parent != null)
                    {
                        parent.addChild(pic);
                        pic.setParent(parent);
                    }

                    prev = pic;

                    break;

                case "bnd1":
                    BND1 bnd = new BND1(ref reader);

                    if (parent != null)
                    {
                        parent.addChild(bnd);
                        bnd.setParent(parent);
                    }

                    prev = bnd;

                    break;

                case "txt1":
                    TXT1 txt = new TXT1(ref reader);
                    if (parent != null)
                    {
                        parent.addChild(txt);
                        txt.setParent(parent);
                    }

                    prev = txt;
                    break;

                case "usd1":
                    USD1 usd = new USD1(ref reader);

                    if (prev != null)
                    {
                        prev.addUserData(usd);
                    }

                    break;

                case "wnd1":
                    WND1 window = new WND1(ref reader, ref mMaterialList);

                    if (parent != null)
                    {
                        parent.addChild(window);
                        window.setParent(parent);
                    }

                    prev = window;
                    break;

                case "pas1":
                    if (prev != null)
                    {
                        parent = prev;
                    }

                    reader.ReadUInt32();
                    break;

                case "pae1":
                    prev   = parent;
                    parent = prev.getParent();

                    reader.ReadUInt32();
                    break;

                case "pts1":
                    MessageBox.Show("PTS1 found! Do tell shibboleet about this...");
                    break;

                case "grp1":
                    GRP1 group = new GRP1(ref reader);

                    if (!isRootGroupSet)
                    {
                        mRootGroup     = group;
                        isRootGroupSet = true;
                    }

                    if (groupParent != null)
                    {
                        groupParent.addChild(group);
                        group.setParent(groupParent);
                    }

                    previousGroup = group;
                    break;

                case "grs1":
                    if (previousGroup != null)
                    {
                        groupParent = previousGroup;
                    }

                    reader.ReadUInt32();
                    break;

                case "gre1":
                    previousGroup = groupParent;
                    groupParent   = previousGroup.getParent();

                    reader.ReadUInt32();
                    break;

                default:
                    Console.WriteLine("Unsupported magic " + magic);
                    break;
                }
            }
        }