Even More Modifiers  1.0.0.0
A mod for rolling various bonus stats on items
GuiCloseButton.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 GuiCloseButton : UIElement
11  {
12  public override void OnInitialize()
13  {
14  Width.Set(Assets.Textures.GUI.CloseButtonTexture.Width, 0);
15  Height.Set(Assets.Textures.GUI.CloseButtonTexture.Height, 0);
16  Top.Set(20 + Assets.Textures.GUI.CloseButtonChainsTexture.Height, 0);
17  Left.Set(422, 0);
18  }
19 
20  protected override void DrawSelf(SpriteBatch spriteBatch)
21  {
22  var parentBounds = GetOuterDimensions().ToRectangle();
23  Rectangle BoundsWithOffset(Vector2 bounds, Point off)
24  {
25  return new Rectangle(parentBounds.X + off.X, parentBounds.Y + off.Y, (int)bounds.X, (int)bounds.Y);
26  }
27 
28  var _btn = Assets.Textures.GUI.CloseButtonTexture;
29  spriteBatch.Draw(
30  _btn,
31  parentBounds,
32  Color.White
33  );
34 
35  var _chains = Assets.Textures.GUI.CloseButtonChainsTexture;
36  Point offset = new Point(
37  0,
38  -_chains.Height
39  );
40 
41  Rectangle rectangle = _chains.BoundsFromParent(BoundsWithOffset(_chains.Size(), offset));
42  spriteBatch.Draw(
43  _chains,
44  rectangle,
45  Color.White
46  );
47 
48  if (parentBounds.Contains(Main.MouseScreen.ToPoint()))
49  {
50  Main.hoverItemName = "Close";
51  if (Main.mouseLeft && Main.mouseLeftRelease)
52  {
53  Loot.Instance.GuiState.ToggleUI(Loot.Instance.GuiInterface);
54  }
55  }
56  }
57  }
58 }