Example #1
0
 public void copy(bloRectangle other)
 {
     left   = other.left;
     top    = other.top;
     right  = other.right;
     bottom = other.bottom;
 }
Example #2
0
        protected override void drawSelf()
        {
            var context = bloContext.getContext();

            if (context.hasRenderFlags(bloRenderFlags.PictureWireframe))
            {
                GL.PolygonMode(MaterialFace.FrontAndBack, PolygonMode.Line);

                var rect  = new bloRectangle(0, 0, mRect.width, mRect.height);
                var white = new bloColor(bloColor.cWhite);

                GL.Disable(EnableCap.Texture2D);

                GL.Begin(PrimitiveType.Quads);
                GL.Color4(white);
                GL.Vertex2(rect.topleft);
                GL.Color4(white);
                GL.Vertex2(rect.topright);
                GL.Color4(white);
                GL.Vertex2(rect.bottomright);
                GL.Color4(white);
                GL.Vertex2(rect.bottomleft);
                GL.End();

                GL.PolygonMode(MaterialFace.FrontAndBack, PolygonMode.Fill);
            }
            if (mTextureCount > 0 && mTextures[0] != null)
            {
                drawSelf(0, 0, mRect.width, mRect.height, mBinding, mMirror, mRotate90, mWrapS, mWrapT);
            }
        }
Example #3
0
        public bloRectangle setRectangle(bloRectangle rectangle)
        {
            bloRectangle old = mRect;

            mRect = rectangle;
            return(old);
        }
Example #4
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);
 }
Example #5
0
 void initOrtho(bloRectangle viewport)
 {
     GL.MatrixMode(MatrixMode.Projection);
     GL.LoadIdentity();
     GL.Viewport(((ClientRectangle.Width - viewport.width) / 2), ((ClientRectangle.Height - viewport.height) / 2), viewport.width, viewport.height);
     GL.Ortho(viewport.left, viewport.right, (viewport.bottom + 0.5d), viewport.top, -1.0d, 1.0d);
     GL.MatrixMode(MatrixMode.Modelview);
     GL.LoadIdentity();
 }
Example #6
0
        protected override void drawSelf()
        {
            var rect    = new bloRectangle(0, 0, mRect.width, mRect.height);
            var printer = new bloPrint(mFont, mFontSpacing, mFontLeading, mTopColor, mBottomColor);

            printer.setFontSize((mFontWidth >= 0 ? mFontWidth : 0), (mFontHeight >= 0 ? mFontHeight : 0));
            printer.setGradColor(mFromColor, mToColor);
            printer.initialize();
            printer.printReturn(mText, rect.width, rect.height, mHBinding, mVBinding, 0, 0, mCumulativeAlpha);
        }
Example #7
0
 public bloPane(bloPane parentPane, uint name, bool visible, bloRectangle rectangle)
 {
     mParent = parentPane;
     if (mParent != null)
     {
         mParent.mChildren.Add(this);
     }
     mName    = name;
     mVisible = visible;
     mRect    = rectangle;
 }
Example #8
0
 public bloPicture(uint name, bloRectangle rectangle, bloTexture texture, bloPalette palette)
 {
     if (texture == null)
     {
         throw new ArgumentNullException("texture");
     }
     mName         = name;
     mRect         = rectangle;
     mTextures[0]  = texture;
     mTextureCount = 1;
     texture.attachPalette(palette);
 }
Example #9
0
 void initialize(bloTexture topLeft, bloTexture topRight, bloTexture bottomLeft, bloTexture bottomRight, bloWindowMirror mirror, bloRectangle rectangle)
 {
     mTextures[(int)bloTextureBase.TopLeft].texture     = topLeft;
     mTextures[(int)bloTextureBase.TopRight].texture    = topRight;
     mTextures[(int)bloTextureBase.BottomLeft].texture  = bottomLeft;
     mTextures[(int)bloTextureBase.BottomRight].texture = bottomRight;
     for (var i = 0; i < 4; ++i)
     {
         mTextures[i].mirror = (bloMirror)(((int)mirror >> (6 - (i * 2))) & 3);
     }
     mRect        = rectangle;
     mContentRect = new bloRectangle(0, 0, mRect.width, mRect.height);
     mFromColor   = new bloColor(bloColor.cZero);
     mToColor     = new bloColor(bloColor.cOne);
     initializeColor();
     initializeMinSize();
 }
Example #10
0
        void drawSelf(int x, int y, int width, int height, Vector2d uvTopLeft, Vector2d uvTopRight, Vector2d uvBottomLeft, Vector2d uvBottomRight)
        {
            var context = bloContext.getContext();

            context.useProgram();
            context.setProgramInt("textureCount", mTextureCount);
            for (var i = 0; i < mTextureCount; ++i)
            {
                context.setProgramInt(String.Format("texture[{0}]", i), i);
                context.setProgramInt(String.Format("transparency[{0}]", i), mTextures[i].getTransparency());
            }
            context.setProgramVector("blendColorFactor", mKonstColor);
            context.setProgramVector("blendAlphaFactor", mKonstAlpha);
            context.setProgramColor("fromColor", mFromColor);
            context.setProgramColor("toColor", mToColor);

            bloRectangle rect = new bloRectangle(x, y, (x + width), (y + height));

            var topLeftColor     = bloMath.scaleAlpha(mColors[(int)bloTextureBase.TopLeft], mCumulativeAlpha);
            var topRightColor    = bloMath.scaleAlpha(mColors[(int)bloTextureBase.TopRight], mCumulativeAlpha);
            var bottomLeftColor  = bloMath.scaleAlpha(mColors[(int)bloTextureBase.BottomLeft], mCumulativeAlpha);
            var bottomRightColor = bloMath.scaleAlpha(mColors[(int)bloTextureBase.BottomRight], mCumulativeAlpha);

            for (var i = 0; i < mTextureCount; ++i)
            {
                mTextures[i].bind(i);
            }

            GL.Begin(PrimitiveType.Quads);
            GL.TexCoord2(uvTopLeft);
            GL.Color4(topLeftColor);
            GL.Vertex2(rect.topleft);
            GL.TexCoord2(uvTopRight);
            GL.Color4(topRightColor);
            GL.Vertex2(rect.topright);
            GL.TexCoord2(uvBottomRight);
            GL.Color4(bottomRightColor);
            GL.Vertex2(rect.bottomright);
            GL.TexCoord2(uvBottomLeft);
            GL.Color4(bottomLeftColor);
            GL.Vertex2(rect.bottomleft);
            GL.End();

            context.unuseProgram();
        }
Example #11
0
 public static void saveRectangle(XmlWriter writer, bloRectangle rectangle, string name, bool edges = false)
 {
     writer.WriteStartElement(name);
     if (edges)
     {
         writer.WriteElementString("left", rectangle.left.ToString());
         writer.WriteElementString("top", rectangle.top.ToString());
         writer.WriteElementString("right", rectangle.right.ToString());
         writer.WriteElementString("bottom", rectangle.bottom.ToString());
     }
     else
     {
         writer.WriteElementString("x", rectangle.left.ToString());
         writer.WriteElementString("y", rectangle.top.ToString());
         writer.WriteElementString("width", rectangle.width.ToString());
         writer.WriteElementString("height", rectangle.height.ToString());
     }
     writer.WriteEndElement();
 }
Example #12
0
 public bool intersect(bloRectangle other)
 {
     if (left < other.left)
     {
         left = other.left;
     }
     if (top < other.top)
     {
         top = other.top;
     }
     if (right > other.right)
     {
         right = other.right;
     }
     if (bottom > other.bottom)
     {
         bottom = other.bottom;
     }
     return(!isEmpty());
 }
Example #13
0
        protected virtual void loadXml(xElement element)
        {
            if (element == null)
            {
                throw new ArgumentNullException("element");
            }

            mName = convertStringToName(element.Attribute("id") | "");
            setConnectParent(element.Attribute("connect") | false);
            mVisible = (element.Attribute("visible") | true);
            mRect    = bloXml.loadRectangle(element.Element("rectangle"));
            mAngle   = ((element.Element("angle") | 0) % 360);
            if (!Enum.TryParse <bloAnchor>(element.Element("anchor"), true, out mAnchor))
            {
                mAnchor = bloAnchor.TopLeft;
            }
            if (!Enum.TryParse <gxCullMode>(element.Element("cull-mode"), true, out mCullMode))
            {
                mCullMode = gxCullMode.None;
            }
            mAlpha        = (byte)bloMath.clamp((element.Element("alpha") | 255), 0, 255);
            mInheritAlpha = (element.Element("alpha").Attribute("inherit") | true);
        }
Example #14
0
        public static bloRectangle loadRectangle(xElement element, bloRectangle defRectangle = default(bloRectangle))
        {
            if (element == null)
            {
                return(defRectangle);
            }
            var rectangle = new bloRectangle();

            if (element.Element("x") != null && element.Element("y") != null && element.Element("width") != null && element.Element("height") != null)
            {
                rectangle.move(element.Element("x"), element.Element("y"));
                rectangle.resize(element.Element("width"), element.Element("height"));
            }
            else if (element.Element("left") != null && element.Element("top") != null && element.Element("right") != null && element.Element("bottom") != null)
            {
                rectangle.set(element.Element("left"), element.Element("top"), element.Element("right"), element.Element("bottom"));
            }
            else
            {
                rectangle = defRectangle;
            }
            return(rectangle);
        }
Example #15
0
        protected override void loadXml(xElement element)
        {
            base.loadXml(element);

            var finder = bloResourceFinder.getFinder();

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

            mContentRect    = bloXml.loadRectangle(content.Element("rectangle"));
            mContentTexture = finder.find <bloTexture>(content.Element("texture"), "timg");

            mPalette = finder.find <bloPalette>(element.Element("palette"), "tlut");

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

            loadCornerXml(mTextures[cTopLeft], finder, corners.Element("top-left"), 0);
            loadCornerXml(mTextures[cTopRight], finder, corners.Element("top-right"), bloMirror.X);
            loadCornerXml(mTextures[cBottomLeft], finder, corners.Element("bottom-left"), bloMirror.Y);
            loadCornerXml(mTextures[cBottomRight], finder, corners.Element("bottom-right"), (bloMirror.X | bloMirror.Y));

            bloXml.loadGradient(element.Element("gradient"), out mFromColor, out mToColor);

            initializeMinSize();
        }
Example #16
0
 public bloWindow(uint name, bloRectangle rectangle, bloTexture topLeft, bloTexture topRight, bloTexture bottomLeft, bloTexture bottomRight, bloPalette palette)
 {
     mName    = name;
     mPalette = palette;
     initialize(topLeft, topRight, bottomLeft, bottomRight, 0, rectangle);
 }
Example #17
0
        protected override void drawSelf()
        {
            if (mRect.width < mMinWidth || mRect.height < mMinHeight)
            {
                return;
            }
            drawContents();
            if (mHasFrame)
            {
                TextureSlot slot;

                // fill rectangle (not necessarily content rectangle)
                bloRectangle fill = new bloRectangle(
                    mTextures[cTopLeft].getWidth(),
                    mTextures[cTopLeft].getHeight(),
                    (mRect.width - mTextures[cBottomRight].getWidth()),
                    (mRect.height - mTextures[cBottomRight].getHeight())
                    );

                // corners
                drawCorner(mTextures[cTopLeft], 0, 0);
                drawCorner(mTextures[cTopRight], fill.right, 0);
                drawCorner(mTextures[cBottomLeft], 0, fill.bottom);
                drawCorner(mTextures[cBottomRight], fill.right, fill.bottom);

                // edges
                slot = mTextures[cTopRight];                 // top
                slot.draw(
                    fill.left, 0, fill.width, slot.getHeight(),
                    (slot.mirror.hasFlag(bloMirror.X) ? 1.0d : 0.0d),
                    (slot.mirror.hasFlag(bloMirror.Y) ? 0.0d : 1.0d),
                    (slot.mirror.hasFlag(bloMirror.X) ? 1.0d : 0.0d),
                    (slot.mirror.hasFlag(bloMirror.Y) ? 1.0d : 0.0d),
                    mCumulativeAlpha, mFromColor, mToColor
                    );
                slot = mTextures[cBottomRight];                 // bottom
                slot.draw(
                    fill.left, fill.bottom, fill.width, slot.getHeight(),
                    (slot.mirror.hasFlag(bloMirror.X) ? 1.0d : 0.0d),
                    (slot.mirror.hasFlag(bloMirror.Y) ? 0.0d : 1.0d),
                    (slot.mirror.hasFlag(bloMirror.X) ? 1.0d : 0.0d),
                    (slot.mirror.hasFlag(bloMirror.Y) ? 1.0d : 0.0d),
                    mCumulativeAlpha, mFromColor, mToColor
                    );
                slot = mTextures[cBottomLeft];                 // left
                slot.draw(
                    0, fill.top, slot.getWidth(), fill.height,
                    (slot.mirror.hasFlag(bloMirror.X) ? 0.0d : 1.0d),
                    (slot.mirror.hasFlag(bloMirror.Y) ? 1.0d : 0.0d),
                    (slot.mirror.hasFlag(bloMirror.X) ? 1.0d : 0.0d),
                    (slot.mirror.hasFlag(bloMirror.Y) ? 1.0d : 0.0d),
                    mCumulativeAlpha, mFromColor, mToColor
                    );
                slot = mTextures[cBottomRight];                 // right
                slot.draw(
                    fill.right, fill.top, slot.getWidth(), fill.height,
                    (slot.mirror.hasFlag(bloMirror.X) ? 0.0d : 1.0d),
                    (slot.mirror.hasFlag(bloMirror.Y) ? 1.0d : 0.0d),
                    (slot.mirror.hasFlag(bloMirror.X) ? 1.0d : 0.0d),
                    (slot.mirror.hasFlag(bloMirror.Y) ? 1.0d : 0.0d),
                    mCumulativeAlpha, mFromColor, mToColor
                    );
            }
        }
Example #18
0
 public bloWindow(uint name, bloRectangle rectangle, bloTexture texture, bloTextureBase tbase, bloPalette palette)
 {
     mName    = name;
     mPalette = palette;
     initialize(texture, texture, texture, texture, bloEnum.convertMirror(tbase), rectangle);
 }
Example #19
0
 public bloPane(uint name, bloRectangle rectangle)
 {
     mName = name;
     mRect = rectangle;
 }
Example #20
0
        static bool loadCompact(bloPane parent, aBinaryReader reader)
        {
            bloPane lastPane = parent;

            for (;;)
            {
                long   start  = reader.Position;
                ushort typeID = reader.Read16();                 // this is actually a peek in SMS, but f**k that

                switch (typeID)
                {
                default: {
                    Console.WriteLine(">>> Unknown '{0:X4}' section at 0x{1:X6}", typeID, start);
                    return(false);
                }

                case cExitID: {
                    return(true);
                }

                case cEndID: {
                    reader.Step(2);
                    return(true);
                }

                case cBeginID: {
                    reader.Step(2);
                    if (!loadCompact(lastPane, reader))
                    {
                        return(false);
                    }
                    break;
                }

                case cPaneID: {
                    lastPane = new bloPane();
                    lastPane.load(parent, reader, bloFormat.Compact);
                    if (parent is bloScreen)
                    {
                        var oldrect = lastPane.getRectangle();
                        var newrect = new bloRectangle(0, 0, oldrect.width, oldrect.height);
                        parent.setRectangle(newrect);
                    }
                    break;
                }

                case cWindowID: {
                    lastPane = new bloWindow();
                    lastPane.load(parent, reader, bloFormat.Compact);
                    break;
                }

                case cPictureID: {
                    lastPane = new bloPicture();
                    lastPane.load(parent, reader, bloFormat.Compact);
                    break;
                }

                case cTextboxID: {
                    lastPane = new bloTextbox();
                    lastPane.load(parent, reader, bloFormat.Compact);
                    break;
                }
                }
            }
        }
Example #21
0
 public void draw(bloRectangle rectangle, bloMirror mirror, bool rotate90)
 {
     draw(rectangle.left, rectangle.top, rectangle.width, rectangle.height, mirror.hasFlag(bloMirror.X), mirror.hasFlag(bloMirror.Y), rotate90);
 }