Exemplo n.º 1
0
        public TXT1(ref EndianBinaryReader reader, ref MAT1 materials, ref FNL1 fonts) : base(ref reader)
        {
            base.setType("Text Box");

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

            mBufferLength  = reader.ReadUInt16();
            mStringLength  = reader.ReadUInt16();
            mMaterialIdx   = reader.ReadUInt16();
            mFontNum       = reader.ReadUInt16();
            mAnotherOrigin = reader.ReadByte();
            mAlignment     = reader.ReadByte();

            reader.ReadBytes(0x2);
            mTextOffset    = reader.ReadUInt32();
            mTopColor      = reader.ReadRGBAColor8();
            mBottomColor   = reader.ReadRGBAColor8();
            mSizeX         = reader.ReadF32();
            mSizeY         = reader.ReadF32();
            mCharacterSize = reader.ReadF32();
            mLineSize      = reader.ReadF32();

            if (mStringLength != 0)
            {
                byte[] str = reader.ReadBytesFrom(startPos + mTextOffset, mStringLength - 2);
                mString = Encoding.GetEncoding(1201).GetString(str);
            }

            mMaterialName = materials.getMaterialNameFromIndex(mMaterialIdx);
            mFontName     = fonts.getFontNameFromIndex(mFontNum);

            reader.Seek(startPos + mSectionSize);
        }
Exemplo n.º 2
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);
        }
Exemplo n.º 3
0
        public PIC1(ref EndianBinaryReader reader, ref MAT1 materials) : base(ref reader)
        {
            base.setType("Picture");

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

            mUVCoordinates = new List <UVCoordSet>();

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

            mMaterialName = materials.getMaterialNameFromIndex(mMaterialIndex);
        }
Exemplo n.º 4
0
        public BRLYT(ref EndianBinaryReader reader) : base()
        {
            reader.SetEndianess(Endianess.Big);
            base.setLayoutVersion(LayoutVersion.Wii);

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

            mBOM          = reader.ReadUInt16();
            mVersion      = reader.ReadUInt16();
            mFileLength   = reader.ReadUInt32();
            mHeaderLength = reader.ReadUInt16();
            mNumSections  = 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;

            for (int i = 0; i < mNumSections; i++)
            {
                string 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);

                    // root panel *should* be the first thing in the list of elements
                    // so if it isn't, then the layout is wrong
                    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);

                    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, ref mMaterialList, ref mFontList);

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

                    prev = txt;

                    break;

                case "usd1":
                    // user data is assigned to the previous read element
                    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 "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;
                }
            }
        }