Example #1
0
        public void DrawToolTip(SpriteBatch spriteBatch)
        {
            if (!Visible)
            {
                return;
            }

            int width = 400;

            if (toolTipBlock == null || (string)toolTipBlock.userData != ToolTip)
            {
                toolTipBlock             = new GUITextBlock(new Rectangle(0, 0, width, 18), ToolTip, "GUIToolTip", Alignment.TopLeft, Alignment.TopLeft, null, true, GUI.SmallFont);
                toolTipBlock.padding     = new Vector4(5.0f, 5.0f, 5.0f, 5.0f);
                toolTipBlock.rect.Width  = (int)(GUI.SmallFont.MeasureString(toolTipBlock.WrappedText).X + 20);
                toolTipBlock.rect.Height = toolTipBlock.WrappedText.Split('\n').Length * 18 + 7;
                toolTipBlock.userData    = ToolTip;
            }

            toolTipBlock.rect = new Rectangle(MouseOn.Rect.Center.X, MouseOn.rect.Bottom, toolTipBlock.rect.Width, toolTipBlock.rect.Height);
            if (toolTipBlock.rect.Right > GameMain.GraphicsWidth - 10)
            {
                toolTipBlock.rect.Location -= new Point(toolTipBlock.rect.Right - (GameMain.GraphicsWidth - 10), 0);
            }

            toolTipBlock.Draw(spriteBatch);
        }