forked from blushiemagic/MagicStorage
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathInterfaceHelper.cs
More file actions
36 lines (33 loc) · 1.17 KB
/
Copy pathInterfaceHelper.cs
File metadata and controls
36 lines (33 loc) · 1.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
using Microsoft.Xna.Framework;
using Terraria;
using Terraria.UI;
namespace MagicStorage
{
public static class InterfaceHelper
{
public static void Initialize()
{
// Now does nothing due to Reflection usage being removed
}
public static void HideItemIconCache()
{
Main._itemIconCacheTime = 0;
}
public static Rectangle GetFullRectangle(UIElement element)
{
CalculatedStyle dimensions = element.GetDimensions();
Vector2 vector = new(dimensions.X, dimensions.Y);
Vector2 position = new Vector2(dimensions.Width, dimensions.Height) + vector;
vector = Vector2.Transform(vector, Main.UIScaleMatrix);
position = Vector2.Transform(position, Main.UIScaleMatrix);
Rectangle result = new((int) vector.X, (int) vector.Y, (int) (position.X - vector.X), (int) (position.Y - vector.Y));
int width = Main.spriteBatch.GraphicsDevice.Viewport.Width;
int height = Main.spriteBatch.GraphicsDevice.Viewport.Height;
result.X = Utils.Clamp(result.X, 0, width);
result.Y = Utils.Clamp(result.Y, 0, height);
result.Width = Utils.Clamp(result.Width, 0, width - result.X);
result.Height = Utils.Clamp(result.Height, 0, height - result.Y);
return result;
}
}
}