From 0b7807c6307cb6dfd4ceb4e2b2d87ce397ed7ba9 Mon Sep 17 00:00:00 2001 From: termigator1359 <45545085+termigator1359@users.noreply.github.com> Date: Fri, 11 Dec 2020 21:44:13 -0500 Subject: [PATCH] Ripper Bars and Stealth Bar scale with UI and can now be properly moused over --- UI/RipperUI.cs | 4 ++-- UI/StealthUI.cs | 10 ++++++---- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/UI/RipperUI.cs b/UI/RipperUI.cs index 9c801e2c25..42d1622f0b 100644 --- a/UI/RipperUI.cs +++ b/UI/RipperUI.cs @@ -175,8 +175,8 @@ namespace CalamityMod.UI { float uiScale = Main.UIScale; Rectangle mouse = new Rectangle((int)Main.MouseScreen.X, (int)Main.MouseScreen.Y, 8, 8); - Rectangle rageBar = new Rectangle((int)rageDrawPos.X, (int)rageDrawPos.Y, (int)rageBarSize.X, (int)rageBarSize.Y); - Rectangle adrenBar = new Rectangle((int)adrenDrawPos.X, (int)adrenDrawPos.Y, (int)adrenBarSize.X, (int)adrenBarSize.Y); + Rectangle rageBar = Utils.CenteredRectangle(rageDrawPos, rageBarSize * uiScale); + Rectangle adrenBar = Utils.CenteredRectangle(adrenDrawPos, adrenBarSize * uiScale); bool rageHover = mouse.Intersects(rageBar); bool adrenHover = mouse.Intersects(adrenBar); diff --git a/UI/StealthUI.cs b/UI/StealthUI.cs index 878a0c488f..79fedac613 100644 --- a/UI/StealthUI.cs +++ b/UI/StealthUI.cs @@ -49,8 +49,11 @@ namespace CalamityMod.UI Rectangle barRectangle = new Rectangle(0, 0, (int)(barTexture.Width * completionRatio), barTexture.Width); bool full = modPlayer.rogueStealth >= modPlayer.rogueStealthMax; spriteBatch.Draw(full ? fullBarTexture : barTexture, DrawPosition, barRectangle, Color.White * modPlayer.stealthUIAlpha, 0f, indicatorTexture.Size() * 0.5f, uiScale, SpriteEffects.None, 0); - if (new Rectangle((int)(DrawPosition.X + Main.screenPosition.X - player.width / 2), (int)(DrawPosition.Y + Main.screenPosition.Y), barTexture.Width, barTexture.Height).Intersects( - new Rectangle((int)Main.MouseWorld.X, (int)Main.MouseWorld.Y, 8, 8))) + + Rectangle mouse = new Rectangle((int)Main.MouseScreen.X, (int)Main.MouseScreen.Y, 8, 8); + Rectangle stealthBar = Utils.CenteredRectangle(DrawPosition, barTexture.Size() * uiScale); + + if (stealthBar.Intersects(mouse)) { if (modPlayer.rogueStealthMax > 0f && modPlayer.stealthUIAlpha >= 0.5f) { @@ -64,8 +67,7 @@ namespace CalamityMod.UI } if (!CalamityConfig.Instance.MeterPosLock) { - if (new Rectangle((int)(DrawPosition.X + Main.screenPosition.X - 26), (int)(DrawPosition.Y + Main.screenPosition.Y - 9), 52, 18).Intersects( - new Rectangle((int)Main.MouseWorld.X, (int)Main.MouseWorld.Y, 8, 8))) + if (stealthBar.Intersects(mouse)) { if (Mouse.GetState().LeftButton == ButtonState.Pressed) {