Esempio n. 1
0
    //////////////////
    // Rects
    //////////////////
    private float GetTotalWidth()
    {
        float width     = 0f;
        float widestTab = 0f;

        for (int i = 0; i < tabs.Count; i++)
        {
            float newWidth = OGDrawHelper.GetLabelWidth(tabs[i].title, GetTabStyle(i).text);
            width += newWidth;

            if (newWidth > widestTab)
            {
                widestTab = newWidth;
            }
        }

        if (width > drawRct.width)
        {
            maxTabs = (int)Mathf.Clamp(Mathf.Floor(drawRct.width / widestTab), 1f, tabs.Count);
        }
        else
        {
            maxTabs = tabs.Count;
        }

        return(width);
    }
Esempio n. 2
0
    /////////////////
    // Draw
    /////////////////
    override public void DrawSkin()
    {
        // Background
        OGDrawHelper.DrawSlicedSprite(drawRct, styles.basic, drawDepth, tint, clipTo);

        // Thumb
        OGDrawHelper.DrawSprite(GetThumbRect(), styles.thumb, drawDepth, tint, clipTo);
    }
Esempio n. 3
0
    ////////////////////
    // Draw
    ////////////////////
    override public void DrawSkin()
    {
        if (currentStyle == null)
        {
            return;
        }

        OGDrawHelper.DrawSlicedSprite(drawRct, currentStyle, drawDepth, tint, clipTo);
    }
Esempio n. 4
0
    ////////////////
    // Draw
    ////////////////
    override public void DrawSkin()
    {
        OGDrawHelper.DrawSlicedSprite(GetTickRect(), isDown ? styles.active : styles.basic, drawDepth, tint, clipTo);

        if (isTicked)
        {
            OGDrawHelper.DrawSprite(GetTickRect(), styles.ticked, drawDepth, tint, clipTo);
        }
    }
Esempio n. 5
0
    override public void DrawText()
    {
        if (currentStyle == null)
        {
            return;
        }

        if (containedObject != null && displayName)
        {
            OGDrawHelper.DrawLabel(drawRct, containedObject.gameObject.name, currentStyle.text, drawDepth, tint, clipTo);
        }
    }
Esempio n. 6
0
    override public void DrawLine()
    {
        for (int i = 0; i < connections.Length; i++)
        {
            if (connections[i] != null && connections[i].node != null)
            {
                if (lineType == LineType.Straight)
                {
                    if (connections[i].segments.Length == 0)
                    {
                        OGDrawHelper.DrawLine(drawRct.center, connections[i].node.drawRct.center, drawDepth);
                    }
                    else
                    {
                        for (int s = 0; s < connections[i].segments.Length; s++)
                        {
                            if (s == 0)
                            {
                                OGDrawHelper.DrawLine(drawRct.center, drawRct.center + ToVector2(connections[i].segments[s]), drawDepth);
                            }
                            else if (s == connections[i].segments.Length - 1)
                            {
                                OGDrawHelper.DrawLine(drawRct.center + ToVector2(connections[i].segments[s - 1]), drawRct.center + ToVector2(connections[i].segments[s]), drawDepth);
                                OGDrawHelper.DrawLine(drawRct.center + ToVector2(connections[i].segments[s]), connections[i].node.drawRct.center, drawDepth);
                            }
                            else
                            {
                                OGDrawHelper.DrawLine(drawRct.center + ToVector2(connections[i].segments[s - 1]), drawRct.center + ToVector2(connections[i].segments[s]), drawDepth);
                            }
                        }
                    }
                }
                else
                {
                    Vector3 startDir = Vector3.zero;
                    Vector3 endDir   = Vector3.zero;

                    if (connections[i].segments.Length > 0)
                    {
                        startDir = connections[i].segments[0];
                    }

                    if (connections[i].segments.Length > 1)
                    {
                        endDir = connections[i].segments[1];
                    }

                    OGDrawHelper.DrawCurve(drawRct.center, startDir, endDir, connections[i].node.drawRct.center, 10);
                }
            }
        }
    }
Esempio n. 7
0
    ////////////////////
    // Draw
    ////////////////////
    override public void DrawSkin()
    {
        if (currentStyle == null)
        {
            return;
        }

        OGDrawHelper.DrawSlicedSprite(drawRct, currentStyle, drawDepth, tint, clipTo);

        if (enableImage)
        {
            OGDrawHelper.DrawSprite(GetImageRect(), styles.thumb, drawDepth, tint, clipTo);
        }
    }
Esempio n. 8
0
    //////////////////
    // Draw
    //////////////////
    override public void DrawSkin()
    {
        if (drawRct == new Rect())
        {
            return;
        }

        if (tile.x == 1 && tile.y == 1)
        {
            OGDrawHelper.DrawSlicedSprite(drawRct, styles.basic, drawDepth, tint, clipTo);
        }
        else
        {
            OGDrawHelper.DrawTiledSlicedSprite(drawRct, styles.basic, drawDepth, tint, tile.x, tile.y, clipTo);
        }
    }
Esempio n. 9
0
    override public void DrawSkin()
    {
        OGDrawHelper.DrawSlicedSprite(drawRct, styles.basic, drawDepth - 10, tint);

        if (scrollbarVisibility == ScrollbarVisibility.Auto)
        {
            if (bounds.x < 0 && !IsInfiniteX() && lockAxis != ScrollDirection.Y)
            {
                OGDrawHelper.DrawSlicedSprite(GetScrollbarXRect(), styles.thumb, drawDepth - 9, tint);
            }

            if (bounds.y < 0 && !IsInfiniteY() && lockAxis != ScrollDirection.X)
            {
                OGDrawHelper.DrawSlicedSprite(GetScrollbarYRect(), styles.thumb, drawDepth - 9, tint);
            }
        }
    }
Esempio n. 10
0
    ////////////////////
    // Draw
    ////////////////////
    override public void DrawSkin()
    {
        if (isDown)
        {
            OGDrawHelper.DrawSlicedSprite(GetRootBackgroundRect(), styles.active, drawDepth, tint, clipTo);

            // Draw item graphics
            for (int s = 0; s < submenu.Length; s++)
            {
                if (submenu[s].isTicked)
                {
                    OGDrawHelper.DrawSprite(GetTickRect(s, true), styles.ticked, drawDepth, tint, clipTo);
                }
                else if (submenu[s].nestedMenu.Length > 0)
                {
                    OGDrawHelper.DrawSprite(GetTickRect(s, true), styles.thumb, drawDepth, tint, clipTo);
                }

                if (GetRootItemStyle(s) == styles.hover)
                {
                    OGDrawHelper.DrawSprite(GetRootItemRect(s), styles.hover, drawDepth, tint, clipTo);
                }
            }

            if (activeNestedMenu != -1)
            {
                OGDrawHelper.DrawSlicedSprite(GetNestedBackgroundRect(), styles.active, drawDepth, tint, clipTo);

                for (int n = 0; n < submenu[activeNestedMenu].nestedMenu.Length; n++)
                {
                    if (submenu[activeNestedMenu].nestedMenu[n].isTicked)
                    {
                        OGDrawHelper.DrawSprite(GetTickRect(n, false), styles.ticked, drawDepth, tint, clipTo);
                    }

                    if (GetNestedItemStyle(n) == styles.hover)
                    {
                        OGDrawHelper.DrawSprite(GetNestedItemRect(n), styles.hover, drawDepth, tint, clipTo);
                    }
                }
            }
        }
    }
Esempio n. 11
0
    override public void DrawText()
    {
        for (int i = focusTab; i < focusTab + maxTabs; i++)
        {
            OGDrawHelper.DrawLabel(GetTabRect(i), tabs[i].title, GetTabStyle(i).text, drawDepth, tint, clipTo);
        }

        if (overflow)
        {
            if (activeTab > 0)
            {
                OGDrawHelper.DrawLabel(GetLeftRect(), leftArrow, styles.thumb.text, drawDepth, tint, clipTo);
            }

            if (activeTab < tabs.Count - 1)
            {
                OGDrawHelper.DrawLabel(GetRightRect(), rightArrow, styles.thumb.text, drawDepth, tint, clipTo);
            }
        }
    }
Esempio n. 12
0
    override public void DrawText()
    {
        OGDrawHelper.DrawLabel(drawRct, title, styles.basic.text, drawDepth, tint);

        if (isDown)
        {
            for (int s = 0; s < submenu.Length; s++)
            {
                OGDrawHelper.DrawLabel(GetRootItemRect(s), submenu[s].name, GetRootItemStyle(s).text, drawDepth, tint, clipTo);
            }

            if (activeNestedMenu != -1)
            {
                for (int n = 0; n < submenu[activeNestedMenu].nestedMenu.Length; n++)
                {
                    OGDrawHelper.DrawLabel(GetNestedItemRect(n), submenu[activeNestedMenu].nestedMenu[n].name, GetNestedItemStyle(n).text, drawDepth, tint, clipTo);
                }
            }
        }
    }
Esempio n. 13
0
    //////////////////
    // Draw
    //////////////////
    override public void DrawSkin()
    {
        for (int i = focusTab; i < focusTab + maxTabs; i++)
        {
            OGDrawHelper.DrawSlicedSprite(GetTabRect(i), GetTabStyle(i), drawDepth, tint, clipTo);
        }

        if (overflow)
        {
            if (activeTab > 0)
            {
                OGDrawHelper.DrawSlicedSprite(GetLeftRect(), styles.thumb, drawDepth, tint, clipTo);
            }

            if (activeTab < tabs.Count - 1)
            {
                OGDrawHelper.DrawSlicedSprite(GetRightRect(), styles.thumb, drawDepth, tint, clipTo);
            }
        }
    }
Esempio n. 14
0
    override public void DrawText()
    {
        if (isUp)
        {
            OGDrawHelper.DrawLabel(drawRct, title, styles.basic.text, drawDepth, tint, clipTo);

            for (int i = 0; i < options.Length; i++)
            {
                OGDrawHelper.DrawLabel(GetOptionRect(i), options[i], GetOptionStyle(i).text, drawDepth, tint, clipTo);
            }
        }
        else if (!string.IsNullOrEmpty(selectedOption))
        {
            OGDrawHelper.DrawLabel(drawRct, selectedOption, currentStyle.text, drawDepth, tint, clipTo);
        }
        else
        {
            OGDrawHelper.DrawLabel(drawRct, title, currentStyle.text, drawDepth, tint, clipTo);
        }
    }
Esempio n. 15
0
    ///////////////////
    // Draw
    ///////////////////
    override public void DrawSkin()
    {
        if (isUp)
        {
            OGDrawHelper.DrawSlicedSprite(GetExpandedRect(), currentStyle, drawDepth, tint, clipTo);

            for (int i = 0; i < options.Length; i++)
            {
                if (GetOptionStyle(i) == styles.hover)
                {
                    OGDrawHelper.DrawSprite(GetOptionRect(i), styles.hover, drawDepth, tint, clipTo);
                }
            }
        }
        else
        {
            OGDrawHelper.DrawSlicedSprite(drawRct, currentStyle, drawDepth, tint, clipTo);
            OGDrawHelper.DrawSprite(GetThumbRect(), styles.thumb, drawDepth, tint, clipTo);
        }
    }
Esempio n. 16
0
    override public void DrawText()
    {
        if (!listening || betaEditor.enabled)
        {
            if (hideText)
            {
                string secure = "";

                for (int i = 0; i < text.Length; i++)
                {
                    secure += "*";
                }

                OGDrawHelper.DrawLabel(drawRct, secure, currentStyle.text, drawDepth, tint, this, betaEditor);
            }
            else
            {
                OGDrawHelper.DrawLabel(drawRct, text, currentStyle.text, drawDepth, tint, this, betaEditor);
            }
        }
    }
Esempio n. 17
0
    /////////////////
    // Draw
    /////////////////
    override public void DrawSkin()
    {
        OGDrawHelper.DrawSlicedSprite(drawRct, currentStyle, drawDepth, tint, clipTo);

        if (listening && betaEditor.enabled)
        {
            Color color = tint;

            if (betaEditor.cursorIndex != betaEditor.cursorSelectIndex)
            {
                color = new Color(1 - color.r, 1 - color.g, 1 - color.b, color.a);

                for (int i = 0; i < betaEditor.selectionRects.Length; i++)
                {
                    OGDrawHelper.DrawSprite(betaEditor.selectionRects[i], styles.thumb, drawDepth, color, this);
                }
            }
            else
            {
                OGDrawHelper.DrawSprite(betaEditor.cursorRect, styles.thumb, drawDepth, color, this);
            }
        }
    }
Esempio n. 18
0
 override public void DrawText()
 {
     OGDrawHelper.DrawLabel(drawRct, text, currentStyle.text, drawDepth, tint, clipTo);
 }
Esempio n. 19
0
    ////////////////////
    // Update
    ////////////////////
    override public void UpdateWidget()
    {
        // Persistent vars
        isSelectable = true;

        if (fitToText)
        {
            singleLine = true;
        }

        // Update data
        mouseRct      = drawRct;
        isAlwaysOnTop = listening;

        if (fitToText)
        {
            this.transform.localScale = new Vector3(OGDrawHelper.GetLabelWidth(text, currentStyle.text), this.transform.localScale.y, this.transform.localScale.z);
        }

        if (string.IsNullOrEmpty(text))
        {
            text = "";
        }

        if (singleLine)
        {
            text = text.Replace("\n", "").Replace("\r", "");
        }

        if (!string.IsNullOrEmpty(regex) && regex != "\\" && regexPreset != RegExPreset.None)
        {
            text = Regex.Replace(text, "[" + regex + "]", "");
        }

        // Styles
        if (listening)
        {
            currentStyle = styles.active;
        }
        else
        {
            currentStyle = styles.basic;
        }

        if (betaEditor.enabled)
        {
            text = betaEditor.Update(text, drawRct);
        }

        // ^ Regex presets
        if (regexPreset != currentPreset)
        {
            currentPreset = regexPreset;

            if (currentPreset == RegExPreset.None)
            {
                regex = "";
            }
            else if (currentPreset == RegExPreset.OnlyNumbers)
            {
                regex = "^0-9";
            }
            else if (currentPreset == RegExPreset.OnlyASCII)
            {
                regex = "^a-zA-Z0-9";
            }
            else if (currentPreset == RegExPreset.NoSpaces)
            {
                regex = " ";
            }
            else if (currentPreset == RegExPreset.OnlyNumbersAndPeriod)
            {
                regex = "^0-9.";
            }
        }
    }
Esempio n. 20
0
    //////////////////
    // Draw loop
    //////////////////
    public void OnPostRender()
    {
        if (skin != null && widgets != null)
        {
            int      i = 0;
            int      o = 0;
            OGWidget w;

            GL.PushMatrix();
            GL.LoadPixelMatrix(0, screenWidth, 0, screenHeight);

            // Draw skin
            GL.Begin(GL.QUADS);
            OGDrawHelper.SetPass(skin.atlas);

            for (i = 0; i < widgets.Length; i++)
            {
                w = widgets[i];

                if (w == null)
                {
                    continue;
                }
                else if (w.drawRct.x == 0 && w.drawRct.y == 0 && w.drawRct.height == 0 && w.drawRct.width == 0)
                {
                    w.Recalculate();
                    continue;
                }

                if (w.currentStyle == null)
                {
                    w.currentStyle = w.styles.basic;
                }

                if (w.gameObject.activeSelf && w.isDrawn && w.drawRct.height > 0 && w.drawRct.width > 0)
                {
                    w.DrawSkin();
                }
            }

            GL.End();

            // Draw text
            for (i = 0; i < skin.fonts.Length; i++)
            {
                if (skin.fonts[0] == null)
                {
                    continue;
                }

                GL.Begin(GL.QUADS);

                if (skin.fontShader != null && skin.fonts[i].bitmapFont != null)
                {
                    skin.fonts[i].bitmapFont.material.shader = skin.fontShader;
                }

                if (skin.fonts[i].bitmapFont != null)
                {
                    OGDrawHelper.SetPass(skin.fonts[i].bitmapFont.material);
                }

                for (o = 0; o < widgets.Length; o++)
                {
                    w = widgets[o];

                    if (w == null)
                    {
                        continue;
                    }

                    if (w.styles == null)
                    {
                        skin.ApplyDefaultStyles(w);
                    }
                    else if (w.isDrawn && w.gameObject.activeSelf)
                    {
                        if (w.currentStyle != null && w.currentStyle.text.fontIndex == i)
                        {
                            if (w.currentStyle.text.font == null)
                            {
                                w.currentStyle.text.font = skin.fonts[i];
                            }

                            w.DrawText();
                        }
                    }
                }

                GL.End();
            }

            // Draw lines
            if (lineMaterial != null)
            {
                GL.Begin(GL.LINES);
                lineMaterial.SetPass(0);

                for (i = 0; i < widgets.Length; i++)
                {
                    w = widgets[i];

                    if (w != null && w.gameObject.activeSelf && w.isDrawn)
                    {
                        w.DrawLine();
                    }
                }

                GL.End();
            }

            // Draw textures
            for (i = 0; i < widgets.Length; i++)
            {
                w = widgets[i];

                if (w != null && w.gameObject.activeSelf && w.isDrawn)
                {
                    w.DrawGL();
                }
            }


            GL.PopMatrix();
        }
    }
Esempio n. 21
0
 //////////////////
 // Draw
 //////////////////
 override public void DrawSkin()
 {
     OGDrawHelper.DrawSlicedSprite(drawRct, currentStyle, drawDepth, tint, clipTo);
 }
Esempio n. 22
0
 //////////////////
 // Draw
 //////////////////
 override public void DrawText()
 {
     OGDrawHelper.DrawLabel(drawRct, text, styles.basic.text, fontSize, alignment, drawDepth, tint, clipTo, null);
 }
Esempio n. 23
0
 override public void DrawText()
 {
     OGDrawHelper.DrawLabel(drawRct, text, styles.basic.text, drawDepth, tint, clipTo);
 }