Пример #1
0
        void Tips()
        {
            this.StartIM();
            for (int i = 0; i < rects.Count; i++)
            {
                var rt = rects[i];
                if (rt.Contains(UI.mousePosRef))
                {
                    //show tips
                    IMUI.fontStyle.normal.textColor = tipsTxtColor;
                    var str  = tips[i];
                    var size = IMUI.CalSize(str);
                    size += fontBorder;

                    var os = offset + osFactor * size;
                    GLUI.DrawString(str, UI.mousePosRef + os, Vectors.half2d);
                    GLUI.BeginOrder(2);
                    var bg = new Rect(UI.mousePosRef + os, size, Vectors.half2d);
                    bg.Draw(tipsBgColor, true);

                    if (Events.MouseDown1to3)
                    {
                        Select(i);
                        return;
                    }
                }
            }
        }
Пример #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);
        }
Пример #3
0
        void Input()
        {
            if (Events.KeyDown(hotkey))
            {
                visible = !visible;
            }
            this.BeginOrtho();
            if (!visible)
            {
                return;
            }

            this.DrawBG();
            var rt     = new RectTrans(this);
            var center = (rt.cornerLT + rt.cornerRT) * 0.5f;
            var pos    = center - 15.Y();

            GLUI.DrawString("控制台(" + hotkey.ToString() + ")", pos, Vectors.half2d);

            var buttonSize = new Vector2(150, 45);

            if (EG.Button("遇战", center - 80.Y(), buttonSize))
            {
                Battle._Start();
            }
            else if (EG.Button("满状态", center - 140.Y(), buttonSize))
            {
                CharCtrl.I.P.hp = CharCtrl.I.P.hpMax;
                CharCtrl.I.P.mp = CharCtrl.I.P.mpMax;
            }
            //if (EG.Button("测试命令", center - 120.Y(), buttonSize))
            //{
            //    SkillMgr.GetSkill("flee").Cast();
            //}
            else if (EG.Button("X", rt.cornerRT - 24.XY() + 2.Y(), 24.XY()))
            {
                visible = !visible;
            }
            else
            {
                this.DoDragWindow();  // 可拖曳窗口
            }
        }
Пример #4
0
Файл: EGUI.cs Проект: wjk17/WSA
        public static bool Button(string name, Vector2 pos, Vector2 buttonSize)
        {
            var rt   = new Rect(pos, buttonSize);
            var down = false;

            if (Events.MouseDown0)
            {
                UITool.DrawButton(rt, Color.white, 2);
                down = rt.Contains(UI.mousePosRef); // down
            }
            else
            {
                if (rt.Contains(UI.mousePosRef)) // hover
                {
                    UITool.DrawButton(rt, Color.white, 1);
                }
                else
                {
                    UITool.DrawButton(rt, Color.white, 0); // normal
                }
            }
            GLUI.DrawString(name, pos, Vectors.half2d);
            return(down);
        }
Пример #5
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++;
            }
        }
Пример #6
0
 void DrawLine(string s)
 {
     GLUI.DrawString(s, pos, Vector2.up);
     pos.y += lineSpace;
 }
Пример #7
0
 internal void DrawName(Vector2 os)
 {
     GLUI.DrawString(name, (rect.pos + os), Vectors.half2d);
 }
Пример #8
0
        private void Update()
        {
            this.BeginOrtho();
            this.Draw(Color.grey);
            var pos = UI.AbsRefPos(rtArea) - rtArea.rect.size * 0.5f;
            var scl = rtAreaSize / SizeInt;

            var os           = Matrix4x4.Translate(START);
            var m_CurveToRef = Matrix4x4.TRS(pos, Quaternion.identity, scl) * os;
            var m_RulerToRef = Matrix4x4.TRS(UI.AbsRefPos(ruler) - rulerSize.X() * 0.5f
                                             , Quaternion.identity, rtSize / SizeInt) * os;

            var a = Vector2.zero;
            var b = Vector2.up * SIZE.y;
            var f = 1f / SIZE.x;

            xSpaceTextInRuler = Mathf.RoundToInt(SIZE.x * gridFactorText);
            var fitted = (xSpaceTextInRuler / 5) * 5;

            if (Mathf.Abs(xSpaceTextInRuler - fitted) > maxError)
            {
                fitted = (xSpaceTextInRuler / 2) * 2;
            }

            xSpaceTextInRuler = Mathf.Max(2, fitted);


            xSpaceLineInRuler = Mathf.RoundToInt(SIZE.x * gridFactorLine);
            fitted            = (xSpaceLineInRuler / 5) * 5;
            if (Mathf.Abs(xSpaceLineInRuler - fitted) > maxError)
            {
                fitted = (xSpaceLineInRuler / 2) * 2;
            }

            xSpaceLineInRuler = Mathf.Max(2, xSpaceLineInRuler);

            // grid
            for (int i = Mathf.RoundToInt(-START.x); i < -START.x + SIZE.x; i++)
            {
                if ((i % xSpaceLineInRuler) == 0)
                {
                    a.x = b.x = i; // 曲线空间坐标
                    DrawLine(a, b, I.clrGrid, m_CurveToRef);
                }
                if ((i % xSpaceTextInRuler) == 0)
                {
                    a.x = i + f * 0.5f;
                    Vector2 c = m_RulerToRef.MultiplyPoint(a);
                    c = rulerPos + c.ToLT();
                    GLUI.DrawString(i.ToString(), c, Vectors.half2d);// 画字 帧号标签
                }
            }
            // timeline
            GLUI.BeginOrder(5);
            b.x = a.x = frameIdx;
            DrawLine(a, b, I.clrTimeLine, m_CurveToRef, width);
            // axis
            GLUI.BeginOrder(2);
            b.x = a.x = 0;
            DrawLine(a, b, I.clrAxis, m_CurveToRef, width);
        }