diff --git a/ExtraTextures/UI/ModeIndicator.png b/ExtraTextures/UI/ModeIndicator.png new file mode 100644 index 0000000000..82cfc906fb Binary files /dev/null and b/ExtraTextures/UI/ModeIndicator.png differ diff --git a/ExtraTextures/UI/ModeIndicatorArma.png b/ExtraTextures/UI/ModeIndicatorArma.png deleted file mode 100644 index 619f29b4a2..0000000000 Binary files a/ExtraTextures/UI/ModeIndicatorArma.png and /dev/null differ diff --git a/ExtraTextures/UI/ModeIndicatorDeath.png b/ExtraTextures/UI/ModeIndicatorDeath.png deleted file mode 100644 index cdf63aea54..0000000000 Binary files a/ExtraTextures/UI/ModeIndicatorDeath.png and /dev/null differ diff --git a/ExtraTextures/UI/ModeIndicatorMalice.png b/ExtraTextures/UI/ModeIndicatorMalice.png deleted file mode 100644 index c19e5c029e..0000000000 Binary files a/ExtraTextures/UI/ModeIndicatorMalice.png and /dev/null differ diff --git a/ExtraTextures/UI/ModeIndicatorRev.png b/ExtraTextures/UI/ModeIndicatorRev.png deleted file mode 100644 index 6086ff88b7..0000000000 Binary files a/ExtraTextures/UI/ModeIndicatorRev.png and /dev/null differ diff --git a/UI/ModeIndicatorUI.cs b/UI/ModeIndicatorUI.cs index 5967268016..2d2f300f52 100644 --- a/UI/ModeIndicatorUI.cs +++ b/UI/ModeIndicatorUI.cs @@ -6,67 +6,52 @@ using Terraria.ModLoader; namespace CalamityMod.UI { - public class ModeIndicatorUI - { - public static readonly Vector2 OffsetToAreaCenter = new Vector2(0f, 4f); - public static Vector2 DifficultyIconOffset => new Vector2(0f, -13f); - public static Vector2 ArmageddonIconOffset => new Vector2(12f, 7f); - public static Vector2 MaliceIconOffset => new Vector2(-12f, 7f); - public static void Draw(SpriteBatch spriteBatch) - { - // The mode indicator should only be displayed when the inventory is open, to prevent obstruction. - if (!Main.playerInventory) - return; + public class ModeIndicatorUI + { + public static void Draw(SpriteBatch spriteBatch) + { + // The mode indicator should only be displayed when the inventory is open, to prevent obstruction. + if (!Main.playerInventory) + return; - Texture2D outerAreaTexture = ModContent.GetTexture("CalamityMod/ExtraTextures/UI/ModeIndicatorArea"); - Texture2D revengeanceIconTexture = ModContent.GetTexture("CalamityMod/ExtraTextures/UI/ModeIndicatorRev"); - Texture2D deathIconTexture = ModContent.GetTexture("CalamityMod/ExtraTextures/UI/ModeIndicatorDeath"); - Texture2D armageddonIconTexture = ModContent.GetTexture("CalamityMod/ExtraTextures/UI/ModeIndicatorArma"); - Texture2D maliceIconTexture = ModContent.GetTexture("CalamityMod/ExtraTextures/UI/ModeIndicatorMalice"); + Texture2D indicatorTexture = ModContent.GetTexture("CalamityMod/ExtraTextures/UI/ModeIndicator"); + int indicatorFrame = 0; + if (CalamityWorld.revenge) + indicatorFrame = 1; + if (CalamityWorld.death) + indicatorFrame = 2; + if (CalamityWorld.malice) + indicatorFrame = 3; - Rectangle mouseRectangle = Utils.CenteredRectangle(Main.MouseScreen, Vector2.One * 2f); + Rectangle mouseRectangle = Utils.CenteredRectangle(Main.MouseScreen, Vector2.One * 2f); + Rectangle indicatorFrameArea = indicatorTexture.Frame(1, 4, 0, indicatorFrame); + Vector2 drawCenter = new Vector2(Main.screenWidth - 400f, 72f) + indicatorFrameArea.Size() * 0.5f; - Vector2 drawCenter = new Vector2(Main.screenWidth - 400f, 72f) + outerAreaTexture.Size() * 0.5f; + spriteBatch.Draw(indicatorTexture, drawCenter, indicatorFrameArea, Color.White, 0f, indicatorFrameArea.Size() * 0.5f, 1f, SpriteEffects.None, 0f); - spriteBatch.Draw(outerAreaTexture, drawCenter, null, Color.White, 0f, outerAreaTexture.Size() * 0.5f, 1f, SpriteEffects.None, 0f); + // Draw active indication text. + bool renderingText = false; + if (mouseRectangle.Intersects(Utils.CenteredRectangle(drawCenter, indicatorFrameArea.Size()))) + { + string modeToDisplay = "Revengeance"; + bool modeIsActive = CalamityWorld.revenge; + if (CalamityWorld.death) + { + modeToDisplay = "Death"; + modeIsActive = CalamityWorld.death; + } + if (CalamityWorld.malice) + { + modeToDisplay = "Malice"; + modeIsActive = CalamityWorld.malice; + } - Texture2D difficultyIconToUse = CalamityWorld.death ? deathIconTexture : revengeanceIconTexture; - bool modeIsActive = CalamityWorld.revenge; - bool renderingText = false; - if (CalamityWorld.revenge) - spriteBatch.Draw(difficultyIconToUse, drawCenter + DifficultyIconOffset, null, Color.White, 0f, difficultyIconToUse.Size() * 0.5f, 1f, SpriteEffects.None, 0f); + Main.instance.MouseText($"{modeToDisplay} Mode is {(modeIsActive ? "active" : "not active")}."); + renderingText = true; + } - // Rev/Death active text. - if (mouseRectangle.Intersects(Utils.CenteredRectangle(drawCenter + DifficultyIconOffset, difficultyIconToUse.Size()))) - { - Main.instance.MouseText($"{(CalamityWorld.death ? "Death" : "Revengeance")} Mode is {(modeIsActive ? "active" : "not active")}."); - renderingText = true; - } - - if (CalamityWorld.armageddon) - { - spriteBatch.Draw(armageddonIconTexture, drawCenter + ArmageddonIconOffset, null, Color.White, 0f, armageddonIconTexture.Size() * 0.5f, 1f, SpriteEffects.None, 0f); - } - - // Armageddon active text. - if (!renderingText && mouseRectangle.Intersects(Utils.CenteredRectangle(drawCenter + ArmageddonIconOffset, armageddonIconTexture.Size()))) - { - Main.instance.MouseText($"Armageddon is {(CalamityWorld.armageddon ? "active" : "not active")}."); - renderingText = true; - } - - if (CalamityWorld.malice) - spriteBatch.Draw(maliceIconTexture, drawCenter + MaliceIconOffset, null, Color.White, 0f, maliceIconTexture.Size() * 0.5f, 1f, SpriteEffects.None, 0f); - - // Malice active text. - if (!renderingText && mouseRectangle.Intersects(Utils.CenteredRectangle(drawCenter + MaliceIconOffset, armageddonIconTexture.Size()))) - { - Main.instance.MouseText($"Malice Mode is {(CalamityWorld.malice ? "active" : "not active")}."); - renderingText = true; - } - - if (renderingText) - Main.instance.MouseTextHackZoom(string.Empty); - } - } + if (renderingText) + Main.instance.MouseTextHackZoom(string.Empty); + } + } }