// Tool Tips public static void RunToolTip(string id, string title, string text, UIPrimaryDirection dir) { if (!UIHandler.globalUI.toolTip._MaintainToolTip(id)) { UIHandler.globalUI.toolTip._CreateToolTip(id, title, text, dir); UIHandler.globalUI.toolTip._MaintainToolTip(id); } }
// The uid is a unique identifier to prevent re-building a tool tip on every frame. // This method will NOT update the endFrame (to avoid programmers trying to run it without "_MaintainToolTip"). Use "_MaintainToolTip" to determine if this is needed. // Use UIHandler.RunToolTip() instead of this method. public void _CreateToolTip(string uid, string title, string text, UIPrimaryDirection dir = UIPrimaryDirection.None) { this.uid = uid; // Measure Strings Vector2 measureTitle = UIHandler.theme.smallHeaderFont.font.MeasureString(title); Vector2 measureText = UIHandler.theme.normalFont.font.MeasureString(text); // Text + Multi-Line Handler this.title = title; this.text = TextHelper.WrapTextSplit(UIHandler.theme.normalFont.font, text, UIHandler.theme.tooltips.ItemWidth - 16 - 16); // This will prevent the ToolTip from appearing on this frame. // THIS IS INTENTIONAL. It's to avoid trying to use "_CreateToolTip" when you're supposed to use "_MaintainToolTip". this.endFrame = 0; // Size Setup this.SetHeight((short)(measureTitle.Y + measureText.Y * this.text.Length + 10 + 10 + 6)); this.SetWidth(UIHandler.theme.tooltips.ItemWidth); // Position this.dir = dir; }