diff --git a/Items/Accessories/AngelicAlliance.cs b/Items/Accessories/AngelicAlliance.cs index aca8d30b28..de51e2910f 100644 --- a/Items/Accessories/AngelicAlliance.cs +++ b/Items/Accessories/AngelicAlliance.cs @@ -3,6 +3,7 @@ using CalamityMod.CalPlayer; using CalamityMod.Items.Materials; using CalamityMod.Rarities; using CalamityMod.Tiles.Furniture.CraftingStations; +using Microsoft.Xna.Framework; using Terraria; using Terraria.Audio; using Terraria.ID; @@ -63,5 +64,7 @@ namespace CalamityMod.Items.Accessories AddTile(). Register(); } + + public static Color RarityColor() => CalamityUtils.MulticolorLerp(Main.GlobalTimeWrappedHourly / 2f % 1f, [ new Color(255, 196, 55), new Color(255, 231, 107), new Color(255, 254, 243) ]); } } diff --git a/Items/Accessories/ProfanedSoulCrystal.cs b/Items/Accessories/ProfanedSoulCrystal.cs index 2d446d05c8..89a8f45dd3 100644 --- a/Items/Accessories/ProfanedSoulCrystal.cs +++ b/Items/Accessories/ProfanedSoulCrystal.cs @@ -637,5 +637,7 @@ namespace CalamityMod.Items.Accessories AddDecraftCondition(CalamityConditions.DownedSupremeCalamitas, CalamityConditions.DownedExoMechs). Register(); } + + public static Color RarityColor() => CalamityUtils.ColorSwap(new Color(255, 166, 0), new Color(25, 250, 25), 6f); //alternates between emerald green and amber (BanditHueh) } } diff --git a/Items/Armor/Demonshade/DemonshadeHelm.cs b/Items/Armor/Demonshade/DemonshadeHelm.cs index 297a2e4bd0..1a3debbb51 100644 --- a/Items/Armor/Demonshade/DemonshadeHelm.cs +++ b/Items/Armor/Demonshade/DemonshadeHelm.cs @@ -80,5 +80,7 @@ namespace CalamityMod.Items.Armor.Demonshade public string ExtensionTexture => "CalamityMod/Items/Armor/Demonshade/DemonshadeHelm_Extension"; public Vector2 ExtensionSpriteOffset(PlayerDrawSet drawInfo) => new Vector2(0, -4f); + + public static Color DemonshadeRarityColor() => CalamityUtils.ColorSwap(new Color(255, 132, 22), new Color(221, 85, 7), 4f); } } diff --git a/Items/CalamityGlobalItemTooltip.cs b/Items/CalamityGlobalItemTooltip.cs index 55823811b7..ed39fe7901 100644 --- a/Items/CalamityGlobalItemTooltip.cs +++ b/Items/CalamityGlobalItemTooltip.cs @@ -415,110 +415,6 @@ namespace CalamityMod.Items { if (item.type == ModContent.ItemType()) nameLine.OverrideColor = new Color(Main.DiscoR, Main.DiscoG, Main.DiscoB); - - // Developer items - if (item.type == ModContent.ItemType()) - nameLine.OverrideColor = new Color(249, 197, 255); - if (item.type == ModContent.ItemType()) - nameLine.OverrideColor = new Color(0, 0, 255); - if (item.type == ModContent.ItemType()) - nameLine.OverrideColor = TheDanceofLight.GetSyncedLightColor(); - if (item.type == ModContent.ItemType()) - nameLine.OverrideColor = new Color(0.34f, 0.34f + 0.66f * Main.DiscoG / 255f, 0.34f + 0.5f * Main.DiscoG / 255f); - if (item.type == ModContent.ItemType()) - nameLine.OverrideColor = ShatteredCommunity.GetRarityColor(); - if (item.type == ModContent.ItemType()) - nameLine.OverrideColor = ShatteredCommunity.GetRarityColor(); - if (item.type == ModContent.ItemType()) - nameLine.OverrideColor = CalamityUtils.ColorSwap(new Color(255, 166, 0), new Color(25, 250, 25), 6f); //alternates between emerald green and amber (BanditHueh) - if (item.type == ModContent.ItemType()) - nameLine.OverrideColor = CalamityUtils.ColorSwap(new Color(210, 0, 255), new Color(255, 248, 24), 4f); - if (item.type == ModContent.ItemType()) - nameLine.OverrideColor = CalamityUtils.ColorSwap(new Color(131, 239, 255), new Color(36, 55, 230), 4f); - if (item.type == ModContent.ItemType()) - nameLine.OverrideColor = CalamityUtils.ColorSwap(new Color(255, 69, 0), new Color(139, 0, 0), 4f); - if (item.type == ModContent.ItemType()) - nameLine.OverrideColor = CalamityUtils.ColorSwap(new Color(191, 45, 71), new Color(185, 187, 253), 4f); - if (item.type == ModContent.ItemType()) - nameLine.OverrideColor = CalamityUtils.ColorSwap(new Color(204, 86, 80), new Color(237, 69, 141), 4f); - if (item.type == ModContent.ItemType()) - nameLine.OverrideColor = new Color(129, 29, 149); - if (item.type == ModContent.ItemType()) - nameLine.OverrideColor = CalamityUtils.ColorSwap(new Color(255, 255, 255), new Color(0xD1, 0xCC, 0x6F), 4f); - if (item.type == ModContent.ItemType()) - nameLine.OverrideColor = new Color(220, 20, 60); - if (item.type == ModContent.ItemType()) - nameLine.OverrideColor = new Color(207, 17, 117); - if (item.type == ModContent.ItemType()) - nameLine.OverrideColor = new Color(227, 226, 180); - if (item.type == ModContent.ItemType()) - nameLine.OverrideColor = CalamityUtils.ColorSwap(new Color(154, 255, 151), new Color(228, 151, 255), 4f); - if (item.type == ModContent.ItemType() || item.type == ModContent.ItemType() || item.type == ModContent.ItemType()) - nameLine.OverrideColor = CalamityUtils.ColorSwap(new Color(255, 132, 22), new Color(221, 85, 7), 4f); - if (item.type == ModContent.ItemType()) - { - nameLine.OverrideColor = CalamityUtils.MulticolorLerp(Main.GlobalTimeWrappedHourly / 2f % 1f, new Color[] - { - new Color(255, 196, 55), - new Color(255, 231, 107), - new Color(255, 254, 243) - }); - } - - // TODO -- for cleanliness, ALL color math should either be a one-line color swap or inside the item's own file - // The items that currently violate this are all below: - // Eternity, Flamsteed Ring, Earth - if (item.type == ModContent.ItemType()) - { - List colorSet = new List() - { - new Color(188, 192, 193), // white - new Color(157, 100, 183), // purple - new Color(249, 166, 77), // honey-ish orange - new Color(255, 105, 234), // pink - new Color(67, 204, 219), // sky blue - new Color(249, 245, 99), // bright yellow - new Color(236, 168, 247), // purplish pink - }; - if (nameLine != null) - { - int colorIndex = (int)(Main.GlobalTimeWrappedHourly / 2 % colorSet.Count); - Color currentColor = colorSet[colorIndex]; - Color nextColor = colorSet[(colorIndex + 1) % colorSet.Count]; - nameLine.OverrideColor = Color.Lerp(currentColor, nextColor, Main.GlobalTimeWrappedHourly % 2f > 1f ? 1f : Main.GlobalTimeWrappedHourly % 1f); - } - } - if (item.type == ModContent.ItemType()) - { - if (Main.GlobalTimeWrappedHourly % 1f < 0.6f) - { - nameLine.OverrideColor = new Color(89, 229, 255); - } - else if (Main.GlobalTimeWrappedHourly % 1f < 0.8f) - { - nameLine.OverrideColor = Color.Lerp(new Color(89, 229, 255), Color.White, (Main.GlobalTimeWrappedHourly % 1f - 0.6f) / 0.2f); - } - else - { - nameLine.OverrideColor = Color.Lerp(Color.White, new Color(89, 229, 255), (Main.GlobalTimeWrappedHourly % 1f - 0.8f) / 0.2f); - } - } - if (item.type == ModContent.ItemType()) - { - List earthColors = new List() - { - Color.OrangeRed, - Color.MediumTurquoise, - Color.LimeGreen - }; - if (nameLine != null) - { - int colorIndex = (int)(Main.GlobalTimeWrappedHourly / 2 % earthColors.Count); - Color currentColor = earthColors[colorIndex]; - Color nextColor = earthColors[(colorIndex + 1) % earthColors.Count]; - nameLine.OverrideColor = Color.Lerp(currentColor, nextColor, Main.GlobalTimeWrappedHourly % 2f > 1f ? 1f : Main.GlobalTimeWrappedHourly % 1f); - } - } } #endregion diff --git a/Items/Tools/CrystylCrusher.cs b/Items/Tools/CrystylCrusher.cs index 79a4fa8f1c..deeaaa7431 100644 --- a/Items/Tools/CrystylCrusher.cs +++ b/Items/Tools/CrystylCrusher.cs @@ -144,5 +144,7 @@ namespace CalamityMod.Items.Tools AddTile(). Register(); } + + public static Color RarityColor() => new Color(129, 29, 149); } } diff --git a/Items/Weapons/Magic/Eternity.cs b/Items/Weapons/Magic/Eternity.cs index 913475841f..f101f76a05 100644 --- a/Items/Weapons/Magic/Eternity.cs +++ b/Items/Weapons/Magic/Eternity.cs @@ -60,5 +60,22 @@ namespace CalamityMod.Items.Weapons.Magic AddTile(). Register(); } + + public static Color RarityColor() + { + List colorSet = [ + new Color(188, 192, 193), // white + new Color(157, 100, 183), // purple + new Color(249, 166, 77), // honey-ish orange + new Color(255, 105, 234), // pink + new Color(67, 204, 219), // sky blue + new Color(249, 245, 99), // bright yellow + new Color(236, 168, 247), // purplish pink + ]; + int colorIndex = (int)(Main.GlobalTimeWrappedHourly / 2 % colorSet.Count); + Color currentColor = colorSet[colorIndex]; + Color nextColor = colorSet[(colorIndex + 1) % colorSet.Count]; + return Color.Lerp(currentColor, nextColor, Main.GlobalTimeWrappedHourly % 2f > 1f ? 1f : Main.GlobalTimeWrappedHourly % 1f); + } } } diff --git a/Items/Weapons/Magic/StaffofBlushie.cs b/Items/Weapons/Magic/StaffofBlushie.cs index d89bd90aa0..6b21277e97 100644 --- a/Items/Weapons/Magic/StaffofBlushie.cs +++ b/Items/Weapons/Magic/StaffofBlushie.cs @@ -2,6 +2,7 @@ using CalamityMod.Projectiles.Magic; using CalamityMod.Rarities; using CalamityMod.Tiles.Furniture.CraftingStations; +using Microsoft.Xna.Framework; using Terraria.ID; using Terraria.ModLoader; @@ -44,5 +45,7 @@ namespace CalamityMod.Items.Weapons.Magic AddTile(). Register(); } + + public static Color RarityColor() => Color.Blue; } } diff --git a/Items/Weapons/Magic/Sylvestaff.cs b/Items/Weapons/Magic/Sylvestaff.cs index 48bfd4d5f2..1e03004da4 100644 --- a/Items/Weapons/Magic/Sylvestaff.cs +++ b/Items/Weapons/Magic/Sylvestaff.cs @@ -111,5 +111,7 @@ namespace CalamityMod.Items.Weapons.Magic spriteBatch.Draw(texture, Item.position - Main.screenPosition, null, lightColor, 0f, Vector2.Zero, scale, SpriteEffects.None, 0); return false; } + + public static Color RarityColor() => new Color(249, 197, 255); } } diff --git a/Items/Weapons/Melee/DraconicDestruction.cs b/Items/Weapons/Melee/DraconicDestruction.cs index b1b62226f8..035b9e70ee 100644 --- a/Items/Weapons/Melee/DraconicDestruction.cs +++ b/Items/Weapons/Melee/DraconicDestruction.cs @@ -62,5 +62,7 @@ namespace CalamityMod.Items.Weapons.Melee AddTile(). Register(); } + + public static Color RarityColor() => CalamityUtils.ColorSwap(new Color(255, 69, 0), new Color(139, 0, 0), 4f); } } diff --git a/Items/Weapons/Melee/Earth.cs b/Items/Weapons/Melee/Earth.cs index bad5ef2a16..58cd6afbea 100644 --- a/Items/Weapons/Melee/Earth.cs +++ b/Items/Weapons/Melee/Earth.cs @@ -76,5 +76,14 @@ namespace CalamityMod.Items.Weapons.Melee AddTile(). Register(); } + + public static Color RarityColor() + { + List earthColors = [ Color.OrangeRed, Color.MediumTurquoise, Color.LimeGreen ]; + int colorIndex = (int)(Main.GlobalTimeWrappedHourly / 2 % earthColors.Count); + Color currentColor = earthColors[colorIndex]; + Color nextColor = earthColors[(colorIndex + 1) % earthColors.Count]; + return Color.Lerp(currentColor, nextColor, Main.GlobalTimeWrappedHourly % 2f > 1f ? 1f : Main.GlobalTimeWrappedHourly % 1f); + } } } diff --git a/Items/Weapons/Melee/IllustriousKnives.cs b/Items/Weapons/Melee/IllustriousKnives.cs index fe800a7be0..2b9106d0ba 100644 --- a/Items/Weapons/Melee/IllustriousKnives.cs +++ b/Items/Weapons/Melee/IllustriousKnives.cs @@ -62,5 +62,7 @@ namespace CalamityMod.Items.Weapons.Melee AddTile(). Register(); } + + public static Color RarityColor() => CalamityUtils.ColorSwap(new Color(154, 255, 151), new Color(228, 151, 255), 4f); } } diff --git a/Items/Weapons/Melee/RedSun.cs b/Items/Weapons/Melee/RedSun.cs index cc2950afc7..b3df54f05a 100644 --- a/Items/Weapons/Melee/RedSun.cs +++ b/Items/Weapons/Melee/RedSun.cs @@ -117,5 +117,7 @@ namespace CalamityMod.Items.Weapons.Melee AddTile(). Register(); } + + public static Color RarityColor() => CalamityUtils.ColorSwap(new Color(204, 86, 80), new Color(237, 69, 141), 4f); } } diff --git a/Items/Weapons/Melee/TriactisTruePaladinianMageHammerofMight.cs b/Items/Weapons/Melee/TriactisTruePaladinianMageHammerofMight.cs index 1c3b293927..538b2cd881 100644 --- a/Items/Weapons/Melee/TriactisTruePaladinianMageHammerofMight.cs +++ b/Items/Weapons/Melee/TriactisTruePaladinianMageHammerofMight.cs @@ -2,6 +2,7 @@ using CalamityMod.Projectiles.Melee; using CalamityMod.Rarities; using CalamityMod.Tiles.Furniture.CraftingStations; +using Microsoft.Xna.Framework; using Terraria; using Terraria.Audio; using Terraria.ID; @@ -44,5 +45,7 @@ namespace CalamityMod.Items.Weapons.Melee AddTile(). Register(); } + + public static Color RarityColor() => new Color(227, 226, 180); } } diff --git a/Items/Weapons/Ranged/Contagion.cs b/Items/Weapons/Ranged/Contagion.cs index 1f941bd2dc..8db0621ddf 100644 --- a/Items/Weapons/Ranged/Contagion.cs +++ b/Items/Weapons/Ranged/Contagion.cs @@ -53,5 +53,7 @@ namespace CalamityMod.Items.Weapons.Ranged Projectile.NewProjectile(source, position, velocity, ModContent.ProjectileType(), damage, knockback, player.whoAmI); return false; } + + public static Color RarityColor() => new Color(207, 17, 117); } } diff --git a/Items/Weapons/Ranged/SomaPrime.cs b/Items/Weapons/Ranged/SomaPrime.cs index 8e85adde27..35963d313e 100644 --- a/Items/Weapons/Ranged/SomaPrime.cs +++ b/Items/Weapons/Ranged/SomaPrime.cs @@ -76,5 +76,7 @@ namespace CalamityMod.Items.Weapons.Ranged AddTile(). Register(); } + + public static Color RarityColor() => CalamityUtils.ColorSwap(new Color(255, 255, 255), new Color(0xD1, 0xCC, 0x6F), 4f); } } diff --git a/Items/Weapons/Ranged/Svantechnical.cs b/Items/Weapons/Ranged/Svantechnical.cs index 4a698709e7..fd621e9b44 100644 --- a/Items/Weapons/Ranged/Svantechnical.cs +++ b/Items/Weapons/Ranged/Svantechnical.cs @@ -82,5 +82,7 @@ namespace CalamityMod.Items.Weapons.Ranged AddTile(). Register(); } + + public static Color RarityColor() => new Color(220, 20, 60); } } diff --git a/Items/Weapons/Rogue/NanoblackReaper.cs b/Items/Weapons/Rogue/NanoblackReaper.cs index 734bbd98e5..9dabaa5cbc 100644 --- a/Items/Weapons/Rogue/NanoblackReaper.cs +++ b/Items/Weapons/Rogue/NanoblackReaper.cs @@ -174,5 +174,7 @@ namespace CalamityMod.Items.Weapons.Rogue AddTile(). Register(); } + + public static Color RarityColor() => new Color(0.34f, 0.34f + 0.66f * Main.DiscoG / 255f, 0.34f + 0.5f * Main.DiscoG / 255f); } } diff --git a/Items/Weapons/Rogue/ScarletDevil.cs b/Items/Weapons/Rogue/ScarletDevil.cs index e588335fb2..ddaac460be 100644 --- a/Items/Weapons/Rogue/ScarletDevil.cs +++ b/Items/Weapons/Rogue/ScarletDevil.cs @@ -53,5 +53,7 @@ namespace CalamityMod.Items.Weapons.Rogue AddTile(). Register(); } + + public static Color RarityColor() => CalamityUtils.ColorSwap(new Color(191, 45, 71), new Color(185, 187, 253), 4f); } } diff --git a/Items/Weapons/Summon/Endogenesis.cs b/Items/Weapons/Summon/Endogenesis.cs index ef31f7934b..51a156fc22 100644 --- a/Items/Weapons/Summon/Endogenesis.cs +++ b/Items/Weapons/Summon/Endogenesis.cs @@ -101,5 +101,7 @@ namespace CalamityMod.Items.Weapons.Summon AddTile(). Register(); } + + public static Color RarityColor() => CalamityUtils.ColorSwap(new Color(131, 239, 255), new Color(36, 55, 230), 4f); } } diff --git a/Items/Weapons/Summon/FlamsteedRing.cs b/Items/Weapons/Summon/FlamsteedRing.cs index 21714b2e37..8177b27702 100644 --- a/Items/Weapons/Summon/FlamsteedRing.cs +++ b/Items/Weapons/Summon/FlamsteedRing.cs @@ -204,5 +204,15 @@ namespace CalamityMod.Items.Weapons.Summon AddTile(). Register(); } + + public static Color RarityColor() + { + if (Main.GlobalTimeWrappedHourly % 1f < 0.6f) + return new Color(89, 229, 255); + else if (Main.GlobalTimeWrappedHourly % 1f < 0.8f) + return Color.Lerp(new Color(89, 229, 255), Color.White, (Main.GlobalTimeWrappedHourly % 1f - 0.6f) / 0.2f); + else + return Color.Lerp(Color.White, new Color(89, 229, 255), (Main.GlobalTimeWrappedHourly % 1f - 0.8f) / 0.2f); + } } } diff --git a/Items/Weapons/Summon/TemporalUmbrella.cs b/Items/Weapons/Summon/TemporalUmbrella.cs index 60ffc3da53..e0c75c272b 100644 --- a/Items/Weapons/Summon/TemporalUmbrella.cs +++ b/Items/Weapons/Summon/TemporalUmbrella.cs @@ -65,5 +65,7 @@ namespace CalamityMod.Items.Weapons.Summon AddTile(). Register(); } + + public static Color RarityColor() => CalamityUtils.ColorSwap(new Color(210, 0, 255), new Color(255, 248, 24), 4f); } } diff --git a/Rarities/HotPink.cs b/Rarities/HotPink.cs index 8896ba5ad8..1f915e2bae 100644 --- a/Rarities/HotPink.cs +++ b/Rarities/HotPink.cs @@ -1,6 +1,14 @@ using System; using System.Collections.Generic; +using CalamityMod.Items.Accessories; using CalamityMod.Items.Accessories.Wings; +using CalamityMod.Items.Armor.Demonshade; +using CalamityMod.Items.Tools; +using CalamityMod.Items.Weapons.Magic; +using CalamityMod.Items.Weapons.Melee; +using CalamityMod.Items.Weapons.Ranged; +using CalamityMod.Items.Weapons.Rogue; +using CalamityMod.Items.Weapons.Summon; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using ReLogic.Graphics; @@ -23,13 +31,45 @@ namespace CalamityMod.Rarities { { ModContent.ItemType(), text => new TiredTailTextEffects(text) } }; + public static Dictionary> CustomColors = new() + { + { ModContent.ItemType(), AngelicAlliance.RarityColor }, + { ModContent.ItemType(), Contagion.RarityColor }, + { ModContent.ItemType(), CrystylCrusher.RarityColor }, + { ModContent.ItemType(), TheDanceofLight.GetSyncedLightColor }, + { ModContent.ItemType(), DemonshadeHelm.DemonshadeRarityColor }, + { ModContent.ItemType(), DemonshadeHelm.DemonshadeRarityColor }, + { ModContent.ItemType(), DemonshadeHelm.DemonshadeRarityColor }, + { ModContent.ItemType(), DraconicDestruction.RarityColor }, + { ModContent.ItemType(), Earth.RarityColor }, + { ModContent.ItemType(), Endogenesis.RarityColor }, + { ModContent.ItemType(), Eternity.RarityColor }, + { ModContent.ItemType(), FlamsteedRing.RarityColor }, + { ModContent.ItemType(), IllustriousKnives.RarityColor }, + { ModContent.ItemType(), NanoblackReaper.RarityColor }, + { ModContent.ItemType(), ShatteredCommunity.GetRarityColor }, // Yes, this reuses Shattered Community's color + { ModContent.ItemType(), ProfanedSoulCrystal.RarityColor }, + { ModContent.ItemType(), RedSun.RarityColor }, + { ModContent.ItemType(), ScarletDevil.RarityColor }, + { ModContent.ItemType(), ShatteredCommunity.GetRarityColor }, + { ModContent.ItemType(), SomaPrime.RarityColor }, + { ModContent.ItemType(), StaffofBlushie.RarityColor }, + { ModContent.ItemType(), Svantechnical.RarityColor }, + { ModContent.ItemType(), Sylvestaff.RarityColor }, + { ModContent.ItemType(), TemporalUmbrella.RarityColor }, + { ModContent.ItemType(), TriactisTruePaladinianMageHammerofMight.RarityColor } + }; + public static void Draw(Item Item, SpriteBatch spriteBatch, string text, int X, int Y, Color textColor, Color lightColor, float rotation, Vector2 origin, Vector2 baseScale, float time, bool renderTextSparkles, DynamicSpriteFont font) { + if (CustomColors.TryGetValue(Item.type, out var color)) // For items which use a custom item color, give them that custom color. + { + textColor = color.Invoke(); + } TextSnippet[] snippets = ChatManager.ParseMessage(text, textColor).ToArray(); - - if (CustomRarities.ContainsKey(Item.type)) //For items in the custom rarity table, give them custom rarity effects. + if (CustomRarities.ContainsKey(Item.type)) // For items in the custom rarity table, give them custom rarity effects. { for (int i = 0; i < snippets.Length; i++) { @@ -45,7 +85,6 @@ namespace CalamityMod.Rarities ChatManager.ConvertNormalSnippets(snippets); ChatManager.DrawColorCodedString(spriteBatch, font, snippets, new(X, Y), textColor, 0, Vector2.Zero, baseScale, out _, -1, true); - } public static void Draw(Item Item, string text, int X, int Y, float rotation, Vector2 origin, Vector2 baseScale, Color? textColor = null, Color? lightColor = null, bool? renderTextSparkles = null)