Exemple #1
0
        public TXT1(ref EndianBinaryReader reader, ref MAT1 materials, ref FNL1 fonts, uint version) : base(ref reader)
        {
            base.setType("Text Box");

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

            mTextLength    = reader.ReadUInt16();
            mMaxTextLength = reader.ReadUInt16();
            mMaterialIndex = reader.ReadUInt16();
            mFontIndex     = reader.ReadUInt16();

            byte alignment = reader.ReadByte();

            mHorizontalTextAligment = (TextAlignment)((alignment >> 2) & 0x3);
            mVerticalTextAlignment  = (TextAlignment)(alignment & 0x3);

            byte lineAlignment = reader.ReadByte();

            mLineAlignment = (LineAlignment)lineAlignment;

            byte flag = reader.ReadByte();

            mPerCharTransform   = Convert.ToBoolean((flag >> 4) & 0x1);
            mBorderFormat       = (BorderFormat)((flag >> 2) & 0x3);
            mRestrictTextLength = Convert.ToBoolean((flag >> 1) & 0x1);
            mShadowEnabled      = Convert.ToBoolean(flag & 0x1);

            reader.ReadByte(); // padding

            mItalicTilt = reader.ReadF32();
            mTextOffset = reader.ReadUInt32();

            mFontTopColor    = reader.ReadRGBAColor8();
            mFontBottomColor = reader.ReadRGBAColor8();
            mFontSizeX       = reader.ReadF32();
            mFontSizeY       = reader.ReadF32();
            mCharSpace       = reader.ReadF32();
            mLineSpace       = reader.ReadF32();
            mNameOffset      = reader.ReadUInt32();

            mShadowX           = reader.ReadF32();
            mShadowY           = reader.ReadF32();
            mShadowSizeX       = reader.ReadF32();
            mShadowSizeY       = reader.ReadF32();
            mShadowTopColor    = reader.ReadRGBAColor8();
            mShadowBottomColor = reader.ReadRGBAColor8();
            mShadowItalic      = reader.ReadF32();

            if (version == 0x8030000)
            {
                reader.ReadUInt32(); // this might be something, but probably padding
            }
            if (version != 0x3030000)
            {
                mPerCharTransformOffset = reader.ReadUInt32();
            }
            else
            {
                mPerCharTransformOffset = 0;
            }

            mMaterialName = materials.getMaterialNameFromIndex(mMaterialIndex);
            mFontName     = fonts.getFontNameFromIndex(mFontIndex);

            // read the textbox text (which is mostly useless)
            mText = reader.ReadUTF16StringFrom(startPos + mTextOffset);
            mName = reader.ReadStringNTFrom(startPos + mNameOffset);

            // this is the last structure in the file, and we don't even get a count...

            /*if (mPerCharTransformOffset != 0)
             * {
             *  reader.Seek(startPos + mPerCharTransformOffset);
             *
             *  mTransforms = new List<PerCharTransform>();
             *
             *  uint numEntries = (mSectionSize - mPerCharTransformOffset) / 0xC;
             *
             *  for (int i = 0; i < numEntries; i++)
             *      mTransforms.Add(new PerCharTransform(ref reader));
             * }*/

            // and we are done
            reader.Seek(startPos + mSectionSize);
        }
Exemple #2
0
        public BFLYT(ref EndianBinaryReader reader) : base()
        {
            if (reader.ReadString(4) != "FLYT")
            {
                Console.WriteLine("Bad magic. Expected FLYT.");
                return;
            }

            mBOM = reader.ReadUInt16();

            if (mBOM == 0xFEFF)
            {
                reader.SetEndianess(utils.Endian.Endianess.Little);
            }
            else
            {
                reader.SetEndianess(utils.Endian.Endianess.Big);
            }

            mHeaderSize = reader.ReadUInt16();
            mVersion    = reader.ReadUInt32();

            mVersionMajor  = mVersion >> 24;
            mVersionMinor  = (mVersion >> 16) & 0xFF;
            mVersionMicro  = (mVersion >> 8) & 0xFF;
            mVersionMicro2 = mVersion & 0xFF;

            string str = String.Format("Version: {0}.{1}.{2}.{3}", mVersionMajor, mVersionMinor, mVersionMicro, mVersionMicro2);

            Console.WriteLine(str);

            mFileSize    = reader.ReadUInt32();
            mNumSections = reader.ReadUInt16();
            reader.ReadUInt16();

            mLayoutParams = new LYT1(ref reader);

            // for panels
            LayoutBase prev   = null;
            LayoutBase parent = null;

            bool isRootPaneSet  = false;
            bool isRootGroupSet = false;

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

            string magic = "";

            for (ushort i = 0; i < mNumSections - 1; 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, mVersion);
                    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, ref mMaterialList, mVersionMajor, mVersionMinor);

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

                    prev = pic;
                    break;

                case "txt1":
                    TXT1 txt = new TXT1(ref reader, ref mMaterialList, ref mFontList, mVersion);

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

                    prev = txt;
                    break;

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

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

                    prev = bnd;

                    break;

                case "prt1":
                    PRT1 prt = new PRT1(ref reader);

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

                    prev = prt;
                    break;

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

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

                    prev = window;
                    break;

                case "cnt1":
                    CNT1 cnt = new CNT1(ref reader, mVersionMajor);

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

                    prev = cnt;
                    break;

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

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

                    break;

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

                    reader.ReadUInt32();
                    break;

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

                    reader.ReadUInt32();
                    break;

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

                    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;
                }
            }
        }