3 using Microsoft.Xna.Framework;
4 using Microsoft.Xna.Framework.Graphics;
8 namespace Loot.UI.Tabs.Soulforging
10 internal class GuiSoulgauge : UIElement
15 public const int MAX_FRAME = 4;
16 public const int MAX_TICK = 6;
17 public static Vector2 FRAME =
new Vector2(124, 106);
19 public static bool IsAnimation(GaugeLevel level)
20 => level != GaugeLevel.ZERO && level != GaugeLevel.HUNDRED;
28 return Assets.Textures.Soulgauge.EmptyTexture;
29 case GaugeLevel.HUNDRED:
30 return Assets.Textures.Soulgauge.FullTexture;
31 case GaugeLevel.TWENTY:
32 return Assets.Textures.Soulgauge.Anim20;
33 case GaugeLevel.FOURTY:
34 return Assets.Textures.Soulgauge.Anim40;
35 case GaugeLevel.SIXTY:
36 return Assets.Textures.Soulgauge.Anim60;
37 case GaugeLevel.EIGHTY:
38 return Assets.Textures.Soulgauge.Anim80;
49 if (_tick >= MAX_TICK)
53 if (_frame >= MAX_FRAME)
60 public static Rectangle GetDrawFrame()
61 =>
new Rectangle(0, _frame * (
int)FRAME.Y, (
int)FRAME.X, (
int)FRAME.Y);
65 public string GaugeText(GaugeLevel level)
72 case GaugeLevel.HUNDRED:
74 case GaugeLevel.TWENTY:
76 case GaugeLevel.FOURTY:
78 case GaugeLevel.SIXTY:
80 case GaugeLevel.EIGHTY:
85 public int GetRelativePercentage()
87 var player = Main.LocalPlayer.GetModPlayer<LootEssencePlayer>();
88 return (
int)((float)player.Essence / (
float)player.TopEssence * 100f);
91 public GaugeLevel GetGaugeLevel()
93 var relative = GetRelativePercentage();
94 if (relative <= 0)
return GaugeLevel.ZERO;
95 if (relative <= 20)
return GaugeLevel.TWENTY;
96 if (relative <= 40)
return GaugeLevel.FOURTY;
97 if (relative <= 60)
return GaugeLevel.SIXTY;
98 if (relative <= 80)
return GaugeLevel.EIGHTY;
99 if (relative <= 100)
return GaugeLevel.HUNDRED;
100 return GaugeLevel.ZERO;
104 public GaugeLevel GaugeLevel => GetGaugeLevel();
107 public override void OnInitialize()
114 protected override void DrawSelf(SpriteBatch spriteBatch)
116 var player = Main.LocalPlayer.GetModPlayer<LootEssencePlayer>();
120 $
"Soul level: {GetRelativePercentage()}% (Total essence: {player.Essence})";
124 CalculatedStyle dimensions = GetDimensions();
132 spriteBatch.Draw(DrawTexture, dimensions.Position(), Color.White);
static Rectangle GetDrawFrame()
static bool IsAnimation(GaugeLevel level)
static Texture2D GetTextureByLevel(GaugeLevel level)
static Texture2D _activeTexture