Exemple #1
0
        void Input()
        {
            this.BeginOrtho();
            var vs = UITool.GetVS(rt.cornerLB, rtSize, Vector2.zero);

            GenTex2D();
            GLUI.BeginOrder(0);
            GLUI.DrawTex(tex, vs);

            // frame
            GLUI.BeginOrder(1);
            this.DrawBG(frameWidth, false);
            vs = UITool.GetVS(rt.center, Vector2.one * texPlayerSize, Vectors.half2d);
            GLUI.DrawTex(texPlayer, vs);

            if (Events.MouseDown0)
            {
                prevMousePos = UI.mousePosRef;
                prevViewOs   = viewMapOs;
            }
            else if (Events.Mouse0)
            {
                var os = (UI.mousePosRef - prevMousePos).RoundToInt();
                os        = (os * Vector2.one / viewScale).RoundToInt();
                viewMapOs = prevViewOs - os;
            }
        }
Exemple #2
0
        void _Input()
        {
            this.BeginOrtho();
            this.DrawBG();
            var rtHead = new Rect(headRT);
            var rtName = new Rect(nameRT);
            var rtProp = new Rect(propRT);

            GLUI.DrawTex(headTex, UITool.GetVS(rtHead.cornerLB, rtHead.size, Vector2.zero));
            var P = CharCtrl.I.P;

            GLUI.DrawString(rtName.center, P.charName, Vectors.half2d);
            GLUI.DrawString(rtProp.cornerLB, "生命: " + P.hp + "/" + P.hpMax);
            GLUI.DrawString(rtProp.cornerLB + -28.Y(), "魔法: " + P.mp + "/" + P.mpMax);
            GLUI.DrawString(rtProp.cornerLB + -28 * 2.Y(), "经验值: " + P.exp + "/" + P.expMax);
            GLUI.DrawString(rtProp.cornerLB + -28 * 3.Y(), "等级: " + P.lvl);
        }
Exemple #3
0
        public void Input()
        {
            ic.order = drawOrder;
            this.BeginOrtho();
            var startPos = this.AbsRefPos();

            rects = new List <Rect>();
            for (int y = 0; y < gridCount.y; y++)
            {
                for (int x = 0; x < gridCount.x; x++)
                {
                    rects.Add(new Rect(startPos + gridOsFactor * new Vector2(x, y) *
                                       (gridOs + gridSize), gridSize, pivot));
                }
            }
            var i = 0; bool clicked = false;

            foreach (var rt in rects)
            {
                if (visible.NotEmpty() && !visible[i])
                {
                    i++; continue;
                }
                GLUI.fontColor = fontColor;
                GLUI.BeginOrder(0);

                if (!clickable[i])
                {
                    DrawButton(rt, 2);
                }
                else
                {
                    if (rt.Contains(UI.mousePosRef) && clickable[i])
                    {
                        OnOver(i);
                        if (Events.Mouse1to3)
                        {
                            DrawButton(rt, 2);
                            if (Events.MouseDown1to3 && !clicked)
                            {
                                OnClick(i);
                                clicked = true;
                            }
                        }
                        else
                        {
                            DrawButton(rt, 1);
                            if (drawTips)
                            {
                                // tips
                                var str  = names[i];
                                var size = IMUI.CalSize(str);
                                size += fontBorder;

                                var os = offset + osFactor * size;
                                GLUI.DrawString(str, UI.mousePosRef + os, Vectors.half2d);
                                GLUI.BeginOrder(3);
                                var bg = new Rect(UI.mousePosRef + os, size, Vectors.half2d);
                                bg.Draw(Color.white, true);
                            }
                        }
                    }
                    else
                    {
                        DrawButton(rt, 0);
                    }
                    if (drawName)
                    {
                        GLUI.DrawString(names[i], (rt.pos + nameOffset), Vectors.half2d);
                    }
                    GLUI.BeginOrder(1);
                    if (textures.NotEmpty() && textures[i] != null)
                    {
                        GLUI.DrawTex(textures[i], rt.ToPointsCWLT(-1));
                    }

                    GLUI.SetLineMat();
                    GLUI.BeginOrder(0);
                }
                // 待做优化 tex和line分开两个loop
                GLUI.BeginOrder(2);
                if (drawBorder)
                {
                    rt.Draw(drawBorderClr, false);
                }
                i++;
            }
        }
Exemple #4
0
        public static void DrawBG(this Rect rt, Texture2D tex, float cornerSize, Color color, bool drawCenter = true)
        {
            var corSize_Ref = Vector2.one * 10f;
            var corSize     = Vector2.one * cornerSize;
            var texSize     = tex.Size();
            var corSize_uv  = corSize_Ref / texSize;
            var w           = rt.size.x - corSize.x * 2f;
            var h           = rt.size.y - corSize.y * 2f;

            var wS = new Vector2(w, corSize.y);
            var hS = new Vector2(corSize.x, h);

            var wS_uv = new Vector2(texSize.x - corSize_Ref.x * 2, corSize_Ref.y) / texSize;
            var hS_uv = new Vector2(corSize_Ref.x, texSize.y - corSize_Ref.y * 2) / texSize;

            // LBcorner
            var uv = GetVS(Vector2.zero, corSize_uv, Vector2.zero);
            var v  = GetVS(rt.cornerLB, corSize, Vector2.zero);

            GLUI.DrawTex(tex, color, v, uv);

            // LT
            uv = GetVS(Vector2.up, corSize_uv, Vector2.up);
            v  = GetVS(rt.cornerLT, corSize, Vector2.up);
            GLUI.DrawTex(tex, color, v, uv);

            // RT
            uv = GetVS(Vector2.one, corSize_uv, Vector2.one);
            v  = GetVS(rt.cornerRT, corSize, Vector2.one);
            GLUI.DrawTex(tex, color, v, uv);

            // RB
            uv = GetVS(Vector2.right, corSize_uv, Vector2.right);
            v  = GetVS(rt.cornerRB, corSize, Vector2.right);
            GLUI.DrawTex(tex, color, v, uv);

            // T
            uv = GetVS(Vector2.up + corSize_uv.X(), wS_uv, Vector2.up);
            v  = GetVS(rt.cornerLT + corSize.X(), wS, Vector2.up);
            GLUI.DrawTex(tex, color, v, uv);

            // B
            uv = GetVS(corSize_uv.X(), wS_uv, Vector2.zero);
            v  = GetVS(rt.cornerLB + corSize.X(), wS, Vector2.zero);
            GLUI.DrawTex(tex, color, v, uv);

            // L
            uv = GetVS(corSize_uv.Y(), hS_uv, Vector2.zero);
            v  = GetVS(rt.cornerLB + corSize.Y(), hS, Vector2.zero);
            GLUI.DrawTex(tex, color, v, uv);

            // R
            uv = GetVS(Vector2.right + corSize_uv.Y(), hS_uv, Vector2.right);
            v  = GetVS(rt.cornerRB + corSize.Y(), hS, Vector2.right);
            GLUI.DrawTex(tex, color, v, uv);

            if (drawCenter)
            {
                // Center
                uv = GetVS(corSize_uv, Vector2.one - corSize_uv * 2f, Vector2.zero);
                v  = GetVS(rt.cornerLB + corSize, new Vector2(w, h), Vector2.zero);
                GLUI.DrawTex(tex, color, v, uv);
            }
        }
Exemple #5
0
 internal void DrawTexture()
 {
     GLUI.DrawTex(texture, rect.ToPointsCWLT(-1));
 }