Even More Modifiers  1.0.0.0
A mod for rolling various bonus stats on items
GuiUtils.cs
Go to the documentation of this file.
1 using Microsoft.Xna.Framework;
2 using Microsoft.Xna.Framework.Graphics;
3 using Terraria.UI;
4 
5 namespace Loot.Ext
6 {
10  internal static class GuiUtils
11  {
12  internal const int SPACING = 25;
13  internal const int PADDING = 5;
14 
15  public static Rectangle BoundsFromParent(this Texture2D texture, Rectangle parentBounds)
16  {
17  var texBounds = texture.Bounds;
18  return new Rectangle(parentBounds.X, parentBounds.Y, texBounds.Width, texBounds.Height);
19  }
20 
21  public static T RightOf<T>(this T @this, UIElement @that) where T : UIElement
22  {
23  @this.Left.Set(@that.Left.Pixels + @that.Width.Pixels + PADDING, 0f);
24  return @this;
25  }
26 
27  public static T LeftOf<T>(this T @this, UIElement @that) where T : UIElement
28  {
29  @this.Left.Set(@that.Left.Pixels - @that.Width.Pixels - PADDING, 0f);
30  return @this;
31  }
32 
33  public static T Below<T>(this T @this, UIElement @that) where T : UIElement
34  {
35  @this.Top.Set(@that.Top.Pixels + @that.Height.Pixels + PADDING, 0f);
36  return @this;
37  }
38 
39  public static T Above<T>(this T @this, UIElement @that) where T : UIElement
40  {
41  @this.Top.Set(@that.Top.Pixels - @that.Height.Pixels - PADDING, 0f);
42  return @this;
43  }
44  }
45 }