Even More Modifiers  1.0.0.0
A mod for rolling various bonus stats on items
GuiHeader.cs
Go to the documentation of this file.
1 using Loot.Ext;
2 using Loot.UI.Common;
3 using Microsoft.Xna.Framework;
4 using Microsoft.Xna.Framework.Graphics;
5 using Terraria;
6 using Terraria.UI;
7 
8 namespace Loot.UI
9 {
10  internal class GuiHeader : UIElement
11  {
12  private string _headerText;
13 
14  public int GetOffset() => Assets.Textures.GUI.HeaderTexture.Height;
15 
16  public void SetHeader(string newText)
17  {
18  _headerText = newText;
19  }
20 
21  public override void OnInitialize()
22  {
23  Width.Set(Assets.Textures.GUI.HeaderTexture.Width, 0);
24  Height.Set(Assets.Textures.GUI.HeaderTexture.Height, 0);
25  }
26 
27  protected override void DrawSelf(SpriteBatch spriteBatch)
28  {
29  var parentBounds = GetOuterDimensions().ToRectangle();
30 
31  var _header = Assets.Textures.GUI.HeaderTexture;
32  spriteBatch.Draw(
33  _header,
34  _header.BoundsFromParent(parentBounds),
35  Color.White
36  );
37 
38  var _decoration = Assets.Textures.GUI.SkullDecorationTexture;
39  var decorationBounds = _decoration.BoundsFromParent(parentBounds);
40  decorationBounds.Offset((int)(Width.Pixels * 0.5f - _decoration.Width * 0.5f), (int)(-_decoration.Height * 0.5f));
41 
42  spriteBatch.Draw(
43  _decoration,
44  decorationBounds,
45  Color.White
46  );
47 
48  var textPos = GetOuterDimensions().Center();
49  var measure = Main.fontMouseText.MeasureString(_headerText);
50  textPos.X -= measure.X * 0.5f;
51  textPos.Y -= measure.Y * 0.3725f;
52 
53  Utils.DrawBorderStringFourWay(
54  spriteBatch,
55  Main.fontMouseText,
56  _headerText,
57  textPos.X,
58  textPos.Y,
59  Color.White,
60  Color.Black,
61  Vector2.Zero
62  );
63  }
64  }
65 }