示例#1
0
        static void drawPreviewPlateTooltip()
        {
            if (hoveredNode == null ||
                !hoveredNode.Visible)
            {
                return;
            }

            int k = hoveredNode.ID;

            Texture t = hoveredNode.GetMaterial(0).GetTexture(0);

            if (t != null && t.Name.Path != "NoPreviewTexture")
            {
                k = hoveredNode.ID & (0xFFFFFFF ^ SelectableNodeIdFlag);
            }

            string s = previewPlateInfo.ContainsKey(k)
                                ? previewPlateInfo[k]
                                : "???";

            if (s != null)
            {
                Vector2Di p = irr.Device.CursorControl.Position + new Vector2Di(16);
                GUIFont   f = irr.GUI.Skin.GetFont(GUIDefaultFont.Default);

                Dimension2Di d = f.GetDimension(s);
                d.Inflate(16, 12);

                Recti       r = new Recti(p, d);
                VideoDriver v = irr.Driver;

                int ax = r.LowerRightCorner.X - v.ScreenSize.Width;
                int ay = r.LowerRightCorner.Y - v.ScreenSize.Height;
                if (ax > 0 || ay > 0)
                {
                    if (ax < 0)
                    {
                        ax = 0;
                    }
                    if (ay < 0)
                    {
                        ay = 0;
                    }
                    r.Offset(-ax, -ay);
                }

                v.Draw2DRectangle(r, new Color(0xbb223355));
                v.Draw2DRectangleOutline(r, new Color(0xbb445577));

                f.Draw(s, r.UpperLeftCorner + new Vector2Di(8, 6), Color.SolidYellow);
            }
        }