iv drip tooltip effect chat tag

This commit is contained in:
doze-zoze committed 2026-04-06 20:42:14 -05:00
1 parent 1268886006
commit 52445e5ea8
3 files changed
+93 -30

No files matched your search

+92
View File
@@ -0,0 +1,92 @@
using System;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using ReLogic.Graphics;
using Terraria;
using Terraria.GameContent;
using Terraria.UI.Chat;
namespace CalamityMod.ChatTags
{
// This is a tag handler for storing custom color effects for text all within the "ceffect" tag; the parameter determining the actual effect in use.
// i.e [ceffect/darksun:Hello World] would apply darksun effect to "Hello World".
public sealed class CustomColorEffectHandler : AbstractTagHandler<CustomColorEffectHandler>
{
protected override string[] TagNames { get; } = ["ceffect"];
public override TextSnippet Parse(string text, Color baseColor = new(), string options = null)
{
if (options.Equals("darksun", StringComparison.OrdinalIgnoreCase))
return new DarksunTextSnippet(text);
if (options.Equals("drunk", StringComparison.OrdinalIgnoreCase))
return new DrunkTextSnippet(text);
return new TextSnippet(text);
}
}
public sealed class DarksunTextSnippet(string text) : TextSnippet
{
public override bool UniqueDraw(bool justCheckingString, out Vector2 size, SpriteBatch spriteBatch, Vector2 position = new Vector2(), Color color = new Color(), float scale = 1)
{
size = new Vector2(GetStringLength(FontAssets.MouseText.Value), FontAssets.MouseText.Value.MeasureString(" ").Y * scale);
if (!justCheckingString && (color.R != 0 || color.G != 0 || color.B != 0))
{
var font = FontAssets.MouseText.Value;
var BorderColor = new Color(255, 191, 73);
var HazeColor = new Color(238, 226, 153);
for (float f = 0f; f < MathHelper.TwoPi; f += MathHelper.TwoPi * 0.05f)
{
ChatManager.DrawColorCodedString(spriteBatch, font, text, position + new Vector2(2, 0).RotatedBy(f + Main.GlobalTimeWrappedHourly), Color.Lerp(BorderColor, HazeColor, (Main.mouseTextColor - 190) / 65f * 0.1f), 0f, Vector2.Zero, new Vector2(scale));
}
ChatManager.DrawColorCodedString(spriteBatch, font, text, position, Color.Black, 0f, Vector2.Zero, new Vector2(scale));
}
return true;
}
public override float GetStringLength(DynamicSpriteFont font)
{
float size = font.MeasureString(text).X;
return size * Scale;
}
}
public sealed class DrunkTextSnippet(string text) : TextSnippet
{
public override bool UniqueDraw(bool justCheckingString, out Vector2 size, SpriteBatch spriteBatch, Vector2 position = new Vector2(), Color color = new Color(), float scale = 1)
{
size = new Vector2(GetStringLength(FontAssets.MouseText.Value), FontAssets.MouseText.Value.MeasureString(" ").Y * scale);
if (!justCheckingString && (color.R != 0 || color.G != 0 || color.B != 0))
{
Main.spriteBatch.End();
Main.spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.Additive, null, null, null, null, Main.UIScaleMatrix);
for (int i = 0; i < 3; i++) // Draw 3 lines of differing opacity, color, and displacement.
{
float timer = (float)Math.Sin(Main.GlobalTimeWrappedHourly + 1f) / 2f;
float angle = (Main.GlobalTimeWrappedHourly * 2f) + (i * MathHelper.TwoPi / 3f);
float radius = timer * (3f + i * 6f);
Vector2 offset = new Vector2((float)Math.Cos(angle) * 1.7f, (float)Math.Sin(angle) * 1f) * radius; // Offset in an elliptical pattern
Vector2 pos = position + offset;
color = CalamityUtils.MulticolorLerp(Math.Abs(timer + (i * 0.2f)) % 1f, Color.LightBlue, Color.LightGreen, (i == 3) ? Color.Blue : (i == 2) ? Color.Red : Color.White);
float opacity = 1f - (i * 0.2f);
float rotation = +(timer * (Main.GlobalTimeWrappedHourly * 0.00001f)); // This precision is intended
ChatManager.DrawColorCodedStringWithShadow(Main.spriteBatch, FontAssets.MouseText.Value, text, pos, color * opacity, rotation, Vector2.Zero, new Vector2(scale));
}
Main.spriteBatch.End();
Main.spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, null, null, null, null, Main.UIScaleMatrix);
}
return true;
}
public override float GetStringLength(DynamicSpriteFont font)
{
float size = font.MeasureString(text).X;
return size * Scale;
}
}
}
-29
View File
@@ -1655,35 +1655,6 @@ namespace CalamityMod.Items
return false;
}
// IV Drip tooltip FX
if (line.Mod == "Terraria" && item.type == ModContent.ItemType<IVDripOnTheRocks>() && line.Name == "Tooltip4")
{
Vector2 basePosition = new Vector2(line.X, line.Y);
Main.spriteBatch.End();
Main.spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.Additive, null, null, null, null, Main.UIScaleMatrix);
for (int i = 0; i < 3; i++) // Draw 3 lines of differing opacity, color, and displacement.
{
float timer = (float)Math.Sin(Main.GlobalTimeWrappedHourly + 1f) / 2f;
float angle = (Main.GlobalTimeWrappedHourly * 2f) + (i * MathHelper.TwoPi / 3f);
float radius = timer * (3f + i * 6f);
Vector2 offset = new Vector2((float)Math.Cos(angle) * 1.7f, (float)Math.Sin(angle) * 1f) * radius; // Offset in an elliptical pattern
Vector2 pos = basePosition + offset;
Color color = MulticolorLerp(Math.Abs(timer + (i * 0.2f)) % 1f, Color.LightBlue, Color.LightGreen, (i == 3) ? Color.Blue : (i == 2) ? Color.Red : Color.White);
float opacity = 1f - (i * 0.2f);
float rotation = line.Rotation + (timer * (Main.GlobalTimeWrappedHourly * 0.00001f)); // This precision is intended
ChatManager.DrawColorCodedStringWithShadow(Main.spriteBatch, line.Font, line.Text, pos, color * opacity, rotation, line.Origin, line.BaseScale, line.MaxWidth, line.Spread);
}
Main.spriteBatch.End();
Main.spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, null, null, null, null, Main.UIScaleMatrix);
return false;
}
if (line.Mod == "Terraria" && item.type == ModContent.ItemType<OntologicalDespoiler>() && (line.Name == "Tooltip1" || line.Name == "Tooltip2" || line.Name == "Tooltip4" || line.Name == "Tooltip5" || line.Name == "Tooltip7"))
{
Color rarityColor = Color.Black;
@@ -1032,7 +1032,7 @@ IVDripOnTheRocks: {
Multiplies all weapon damage by {1}x
Counts as an alcohol stack toward Alcohol Poisoning
{$Common.AlcoholWarning}
'(drunken mumbling)'
[ceffect/drunk:'(drunken mumbling)']
'''
}