Even More Modifiers  1.0.0.0
A mod for rolling various bonus stats on items
GuiTextPanel.cs
Go to the documentation of this file.
1 using Microsoft.Xna.Framework.Graphics;
2 using Terraria;
3 using Terraria.GameContent.UI.Elements;
4 
5 namespace Loot.UI.Common.Controls.Panel
6 {
7  internal class GuiTextPanel : GuiPanel
8  {
9  private const string DEFAULT_TEXT = "...";
10  private string _hoverText;
11  private UIText _text;
12 
13  public override void OnInitialize()
14  {
15  base.OnInitialize();
16  _text = new UIText(DEFAULT_TEXT, 0.75f);
17  Frame.Append(_text);
18  }
19 
20  public void SetHoverText(string line)
21  {
22  _hoverText = line;
23  }
24 
25  public void UpdateText(string line)
26  {
27  if (_text == null) return;
28  _text.SetText(line);
29  _text.Left.Pixels = GuiTab.PADDING;
30  _text.Top.Set(Main.fontMouseText.MeasureString(line).Y * 0.375f, 0);
31  }
32 
33  public void ResetText()
34  {
35  UpdateText(DEFAULT_TEXT);
36  }
37 
38  protected override void DrawSelf(SpriteBatch spriteBatch)
39  {
40  base.DrawSelf(spriteBatch);
41 
42  if (IsMouseHovering)
43  {
44  Main.hoverItemName = _hoverText ?? _text.Text;
45  }
46  }
47  }
48 }