示例#1
0
        protected override void loadBlo1(aBinaryReader reader)
        {
            base.loadBlo1(reader);

            var finder = bloResourceFinder.getFinder();

            int numparams = reader.Read8();

            mFont = finder.find <bloResFont>(reader, "font");

            mTopColor    = new bloColor(reader.Read32());
            mBottomColor = new bloColor(reader.Read32());

            int binding = reader.Read8();

            mHBinding = (bloTextboxHBinding)((binding >> 2) & 3);
            mVBinding = (bloTextboxVBinding)((binding >> 0) & 3);

            mFontSpacing = reader.ReadS16();
            mFontLeading = reader.ReadS16();
            mFontWidth   = reader.Read16();
            mFontHeight  = reader.Read16();

            int strlen = reader.Read16();

            setString(reader.Read8s(strlen));

            numparams -= 10;

            if (numparams > 0)
            {
                if (reader.Read8() != 0)
                {
                    setConnectParent(true);
                }
                --numparams;
            }

            if (numparams > 0)
            {
                mFromColor = new bloColor(reader.Read32());
                --numparams;
            }
            else
            {
                mFromColor = new bloColor(bloColor.cZero);
            }

            if (numparams > 0)
            {
                mToColor = new bloColor(reader.Read32());
                --numparams;
            }
            else
            {
                mToColor = new bloColor(bloColor.cOne);
            }

            reader.Skip(4);
        }
示例#2
0
 public bloTextbox(uint name, bloRectangle rectangle, bloFont font, string text, bloTextboxHBinding hbind, bloTextboxVBinding vbind)
 {
     mName     = name;
     mRect     = rectangle;
     mFont     = font;
     mHBinding = hbind;
     mVBinding = vbind;
     setString(text);
 }
示例#3
0
        public void printReturn(ushort[] buffer, int width, int height, bloTextboxHBinding hbind, bloTextboxVBinding vbind, int x, int y, int alpha)
        {
            if (mFont == null)
            {
                return;
            }
            initchar();
            mOrigin = new bloPoint((int)mCursor.X, (int)mCursor.Y);
            int[]    lines = new int[cMaxLines + 1];
            Vector2d size;
            double   totalHeight = (parse(buffer, width, lines, out size, alpha, false) + mState.fontHeight);

            switch (vbind)
            {
            case bloTextboxVBinding.Top: break;

            case bloTextboxVBinding.Bottom: y += (bloMath.round(totalHeight) - height); break;

            case bloTextboxVBinding.Center: y += ((bloMath.round(totalHeight) - height) / 2); break;
            }
            int i = 0;

            while (lines[i] != -1)
            {
                switch (hbind)
                {
                case bloTextboxHBinding.Left: {
                    lines[i] = 0;
                    break;
                }

                case bloTextboxHBinding.Right: {
                    lines[i] = (width - lines[i]);
                    break;
                }

                case bloTextboxHBinding.Center: {
                    lines[i] = ((width - lines[i]) / 2);
                    break;
                }
                }
                ++i;
            }
            initchar();
            mCursor += new Vector2d(x, (y + mState.fontHeight));
            mOrigin  = new bloPoint((int)mCursor.X, (int)mCursor.Y);
            parse(buffer, width, lines, out size, alpha, true);
        }
示例#4
0
        protected override void loadCompact(aBinaryReader reader)
        {
            base.loadCompact(reader);

            var finder = bloResourceFinder.getFinder();

            mFont = finder.find <bloResFont>(reader, "font");

            mTopColor    = new bloColor(reader.Read32());
            mBottomColor = new bloColor(reader.Read32());

            int hbinding = reader.Read8();

            mHBinding = (bloTextboxHBinding)(hbinding & 127);
            mVBinding = (bloTextboxVBinding)reader.Read8();

            if ((hbinding & 0x80) != 0)
            {
                mFontSpacing = reader.ReadS16();
                mFontLeading = reader.ReadS16();
                mFontWidth   = reader.Read16();
                mFontHeight  = reader.Read16();
            }
            else if (mFont != null)
            {
                mFontSpacing = 0;
                mFontLeading = mFont.getLeading();
                mFontWidth   = mFont.getWidth();
                mFontHeight  = mFont.getHeight();
            }
            else
            {
                mFontSpacing = 0;
                mFontLeading = 0;
                mFontWidth   = 0;
                mFontHeight  = 0;
            }

            int strlen = reader.Read16();

            setString(reader.Read8s(strlen));

            mFromColor = new bloColor(bloColor.cZero);
            mToColor   = new bloColor(bloColor.cOne);

            reader.Skip(4);
        }
示例#5
0
        protected override void loadXml(xElement element)
        {
            base.loadXml(element);

            var finder = bloResourceFinder.getFinder();

            mFont = finder.find <bloResFont>(element.Element("font"), "font");

            mText = bloXml.loadTextBuffer(element.Element("text"), mFont);

            var white  = new bloColor(bloColor.cWhite);
            var colors = element.Element("colors");

            mTopColor    = bloXml.loadColor(colors.Element("top"), white);
            mBottomColor = bloXml.loadColor(colors.Element("bottom"), white);

            var binding = element.Element("binding");

            if (!Enum.TryParse <bloTextboxHBinding>(binding.Element("horizontal"), true, out mHBinding))
            {
                mHBinding = bloTextboxHBinding.Left;
            }

            if (!Enum.TryParse <bloTextboxVBinding>(binding.Element("vertical"), true, out mVBinding))
            {
                mVBinding = bloTextboxVBinding.Top;
            }

            var typesetting = element.Element("typesetting");
            int leading     = (mFont != null ? mFont.getLeading() : 20);
            int width       = (mFont != null ? mFont.getWidth() : 20);
            int height      = (mFont != null ? mFont.getHeight() : 20);

            mFontSpacing = (typesetting.Element("spacing") | 0);
            mFontLeading = (typesetting.Element("leading") | leading);
            mFontWidth   = (typesetting.Element("width") | width);
            mFontHeight  = (typesetting.Element("height") | height);

            bloXml.loadGradient(element.Element("gradient"), out mFromColor, out mToColor);
        }
示例#6
0
 public static bool hasFlag(this bloTextboxHBinding value, bloTextboxHBinding flag)
 {
     return((value & flag) == flag);
 }