Exemplo n.º 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;
                    }
                }
            }
        }
Exemplo n.º 2
0
        public override void ExecuteCommand(Cmd command)
        {
            var cmd = command as IMCmd;

            switch (cmd.type)
            {
            case IMCmdType.DrawText:
                if (ArgType <string, Vector2, Color>(cmd))
                {
                    IMUI._DrawText((string)cmd.args[0], (Vector2)cmd.args[1], (Color)cmd.args[2]);
                }
                else if (ArgType <string, Vector2, Vector2, Color>(cmd))
                {
                    IMUI._DrawText((string)cmd.args[0], (Vector2)cmd.args[1], (Vector2)cmd.args[2], (Color)cmd.args[3]);
                }
                break;

            default:
                throw null;
            }
        }
Exemplo n.º 3
0
Arquivo: UIGrid.cs Projeto: wjk17/WSA
        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++;
            }
        }