public override bool PreDrawTooltipLine(Item item, DrawableTooltipLine line, ref int yOffset) { if (item.rare == ExpiryRarity.ShaderRarityExample) { // If the tooltip is the item's name... if (line.Name == "ItemName") { // End the current spriteBatch... Main.spriteBatch.End(); // ...and begin it again with SpriteSortMode.Immediate, which is needed for shaders to be applied. Main.spriteBatch.Begin(SpriteSortMode.Immediate, null, null, null, null, null, Main.UIScaleMatrix); // Now, we can apply shaders... Let's just get a shader from an existing dye. ArmorShaderData armorShaderDye = GameShaders.Armor.GetShaderFromItemId(ItemID.VortexDye); // ArmorShaderData.Apply() passes parameters to the shader based on drawData. // uSourceRect would usually be set to the sourceRect of given drawData, and // uImageSize0 would usually be set to the width and height of the texture of the drawData // However, we didn't pass any drawData, so let's just set these values manually... Vector2 nameStringDimensions = Terraria.UI.Chat.ChatManager.GetStringSize(line.font, item.Name, line.baseScale); armorShaderDye.Shader.Parameters["uSourceRect"].SetValue(new Vector4(0, 0, nameStringDimensions.X, nameStringDimensions.Y)); armorShaderDye.Shader.Parameters["uImageSize0"].SetValue(new Vector2(nameStringDimensions.X, nameStringDimensions.Y)); armorShaderDye.Apply(null); // If there's going to be a lot of rarity shaders, these should probably be moved to a separate method. } } // We want all the lines to draw, so we're returning true. return(true); }
public override bool PreDrawTooltipLine(DrawableTooltipLine line, ref int yOffset) { if (line.mod == "Terraria" && line.Name == "ItemName") { Main.spriteBatch.End(); Main.spriteBatch.Begin(SpriteSortMode.Immediate, null, null, null, null, null, Main.UIScaleMatrix); Effect hallowed = SGAmod.HallowedEffect; Utils.DrawBorderString(Main.spriteBatch, line.text, new Vector2(line.X, line.Y), Color.White); float percother = 0.50f + (float)Math.Sin(Main.GlobalTime / 0.5f) / 2.5f; Color color = Color.Lerp(Color.Lerp(Color.Red, Color.Blue, percother), Color.Gray, 0.35f); hallowed.Parameters["alpha"].SetValue(0.5f); hallowed.Parameters["prismAlpha"].SetValue(0.75f); hallowed.Parameters["prismColor"].SetValue(color.ToVector3()); hallowed.Parameters["rainbowScale"].SetValue(5f); hallowed.Parameters["overlayScale"].SetValue(new Vector2(2, 1)); hallowed.Parameters["overlayTexture"].SetValue(SGAmod.Instance.GetTexture("SmallLaser")); hallowed.Parameters["overlayProgress"].SetValue(new Vector3(Main.GlobalTime / 4f, 0f, Main.GlobalTime * 1f)); hallowed.Parameters["overlayAlpha"].SetValue(1.50f); hallowed.Parameters["overlayStrength"].SetValue(new Vector3(1f, 0f, 0f)); hallowed.Parameters["overlayMinAlpha"].SetValue(0f); hallowed.CurrentTechnique.Passes["Prism"].Apply(); Utils.DrawBorderString(Main.spriteBatch, line.text, new Vector2(line.X, line.Y), Color.White); Main.spriteBatch.End(); Main.spriteBatch.Begin(SpriteSortMode.Deferred, null, null, null, null, null, Main.UIScaleMatrix); return(false); } return(true); }
internal override TwoColumnLine Create(Item item, DrawableTooltipLine line) { TimeSpan span = TimeSpan.FromSeconds(item.buffTime / 60f); string text = ""; if (span.Hours > 0) { text += $"{span.Hours} hour{(span.Hours > 1 ? "s" : "")} "; } if (span.Minutes > 0) { text += $"{span.Minutes} minute{(span.Minutes > 1 ? "s" : "")} "; } if (span.Seconds > 0) { text += $"{span.Seconds} second{(span.Seconds > 1 ? "s" : "")} "; } text = text.Trim(); return(new TwoColumnLine(line) { textLeft = "Buff duration", textRight = text, colorRight = Utility.DoubleLerp(Color.Red, Color.Yellow, Color.LimeGreen, item.buffTime / EnhancedTooltip.GetStat(EnhancedTooltip.Stat.BuffTime)) }); }
internal override TwoColumnLine Create(Item item, DrawableTooltipLine line) { return(new TwoColumnLine(line) { textLeft = "Heals", textRight = item.healLife + " life", colorRight = Utility.DoubleLerp(Color.Red, Color.Yellow, Color.LimeGreen, item.healLife / EnhancedTooltip.GetStat(EnhancedTooltip.Stat.HealLife)) }); }
internal override TwoColumnLine Create(Item item, DrawableTooltipLine line) { return(new TwoColumnLine(line) { textLeft = "Hammer power", textRight = Config.NumberStyles.FormatNumber(item.hammer), colorRight = Utility.DoubleLerp(Color.Red, Color.Yellow, Color.LimeGreen, item.hammer / EnhancedTooltip.GetStat(EnhancedTooltip.Stat.HammerPower)) }); }
internal override TwoColumnLine Create(Item item, DrawableTooltipLine line) { return(new TwoColumnLine(line) { textLeft = "Range", textRight = (item.tileBoost > 0 ? "+" : "") + item.tileBoost, colorRight = Utility.DoubleLerp(Color.Red, Color.Yellow, Color.LimeGreen, item.tileBoost / EnhancedTooltip.GetStat(EnhancedTooltip.Stat.TileBoost)) }); }
internal override TwoColumnLine Create(Item item, DrawableTooltipLine line) { return(new TwoColumnLine(line) { textLeft = "Consumes", textRight = item.mana + " mana", colorRight = Utility.DoubleLerp(Color.LimeGreen, Color.Yellow, Color.Red, item.mana / EnhancedTooltip.GetStat(EnhancedTooltip.Stat.UseMana)) }); }
public override void PostDrawTooltipLine(Item item, DrawableTooltipLine line) { if (item.rare == ExpiryRarity.ShaderRarityExample) { if (line.Name == "ItemName") { // We don't want the shader to apply to the rest of the tooltips, so we end the spriteBatch here. Main.spriteBatch.End(); // Begin the spriteBatch again so the rest of the tooltips can be drawn. // These begin parameters can be found in Main.MouseTextHackZoom() before the tooltips are drawn. Main.spriteBatch.Begin(SpriteSortMode.Deferred, null, null, null, null, null, Main.UIScaleMatrix); } } }
public override bool PreDrawTooltipLine(DrawableTooltipLine line, ref int yOffset) { if (line.mod == "Terraria" && line.Name == "ItemName") { Main.spriteBatch.End(); //end and begin main.spritebatch to apply a shader Main.spriteBatch.Begin(SpriteSortMode.Immediate, null, null, null, null, null, Main.UIScaleMatrix); GameShaders.Armor.Apply(GameShaders.Armor.GetShaderIdFromItemId(ItemID.LivingRainbowDye), item, null); //use living rainbow dye shader Utils.DrawBorderString(Main.spriteBatch, line.text, new Vector2(line.X, line.Y), Color.White, 1); //draw the tooltip manually Main.spriteBatch.End(); //then end and begin again to make remaining tooltip lines draw in the default way Main.spriteBatch.Begin(SpriteSortMode.Deferred, null, null, null, null, null, Main.UIScaleMatrix); return(false); } return(true); }
public override bool PreDrawTooltipLine(DrawableTooltipLine line, ref int yOffset) { if (!line.oneDropLogo) { // You are not allowed to change these, modders should use ModifyTooltips to modify them //line.text = "you shall not pass..."; //line.oneDropLogo = false; //line.color = Color.AliceBlue; //line.overrideColor = Color.AliceBlue; //line.isModifier = false; //line.isModifierBad = false; //line.index = 1; // Let's draw the item name centered so it's in the middle, and let's add a form of separator string sepText = "-----"; // This is our separator, which will go between the item name and the rest float sepHeight = line.font.MeasureString(sepText).Y; // Height of our separator // If our line text equals our item name, this is our tooltip line for the item name // if (line.text == item.HoverName) // What is more accurate to check is the layer name and mod if (line.Name == "ItemName" && line.mod == "Terraria") // We check for Terraria so we modify the vanilla tooltip and not a modded one // This could be important, in case some mod does a lot of custom work and removes the standard tooltip // For tooltip layers, check the documentation for TooltipLine { // Our offset is half the width of our box, minus the padding of one side float boxOffset = boxSize.X / 2 - paddingForBox; // The X coordinate where we draw is where the line would draw, plus the box offset, // which would place the START of the string at the center, so we subtract half of the line width to center it completely float drawX = line.X + boxOffset - line.font.MeasureString(sepText).X / 2; float drawY = line.Y + sepHeight / 2; // Note how our line object has many properties we can use for drawing // Here we draw the separator, note that it'd make more sense to use PostDraw for this, but either will work ChatManager.DrawColorCodedStringWithShadow(Main.spriteBatch, line.font, sepText, new Vector2(drawX, drawY), line.color, line.rotation, line.origin, line.baseScale, line.maxWidth, line.spread); // Here we do the same thing as we did for drawX, which will center our ItemName tooltip line.X += (int)boxOffset - (int)line.font.MeasureString(line.text).X / 2; // yOffset affects the offset that is added every next line, so this will cause the line to come after the separator to be drawn slightly lower yOffset = (int)sepHeight / 4; } else { // Reset the offset for other lines yOffset = 0; } } return(true); }
public override bool PreDrawTooltipLine(DrawableTooltipLine line, ref int yOffset) { if (line.mod == "Terraria" && line.Name == "ItemName") { Main.spriteBatch.End(); //end and begin main.spritebatch to apply a shader Main.spriteBatch.Begin(SpriteSortMode.Immediate, null, null, null, null, null, Main.UIScaleMatrix); var lineshader = GameShaders.Misc["PulseUpwards"].UseColor(new Color(42, 42, 99)).UseSecondaryColor(Fargowiltas.EModeColor()); lineshader.Apply(null); Utils.DrawBorderString(Main.spriteBatch, line.text, new Vector2(line.X, line.Y), Color.White, 1); //draw the tooltip manually Main.spriteBatch.End(); //then end and begin again to make remaining tooltip lines draw in the default way Main.spriteBatch.Begin(SpriteSortMode.Deferred, null, null, null, null, null, Main.UIScaleMatrix); return(false); } return(true); }
internal override TwoColumnLine Create(Item item, DrawableTooltipLine line) { int damage = Main.LocalPlayer.GetWeaponDamage(item); if (item.type == 3829 || item.type == 3830 || item.type == 3831) { damage *= 3; } string text; if (item.melee) { text = Language.GetTextValue("LegacyTooltip.2"); } else if (item.ranged) { text = Language.GetTextValue("LegacyTooltip.3"); } else if (item.magic) { text = Language.GetTextValue("LegacyTooltip.4"); } else if (item.summon) { text = Language.GetTextValue("LegacyTooltip.53"); } else if (item.thrown) { text = Language.GetTextValue("LegacyTooltip.58"); } else { text = " Damage"; } char startChar = text[1]; text = text.Remove(0, 2); text = text.Insert(0, char.ToUpper(startChar).ToString()); return(new TwoColumnLine(line) { textLeft = text, textRight = Config.NumberStyles.FormatNumber(damage), colorRight = Utility.DoubleLerp(Color.Red, Color.Yellow, Color.LimeGreen, item.damage / GetMaxDamage(item)) }); }
internal override TwoColumnLine Create(Item item, DrawableTooltipLine line) { string speedText; if (item.useAnimation <= 8) { speedText = "Insanely fast"; } else if (item.useAnimation <= 20) { speedText = "Very fast"; } else if (item.useAnimation <= 25) { speedText = "Fast"; } else if (item.useAnimation <= 30) { speedText = "Average"; } else if (item.useAnimation <= 35) { speedText = "Slow"; } else if (item.useAnimation <= 45) { speedText = "Very slow"; } else if (item.useAnimation <= 55) { speedText = "Extremely slow"; } else { speedText = "Snail"; } return(new TwoColumnLine(line) { textLeft = "Speed", textRight = $"{speedText} ({item.useAnimation})", colorRight = Utility.DoubleLerp(Color.LimeGreen, Color.Yellow, Color.Red, item.useAnimation / GetMaxSpeed(item)) }); }
internal override TwoColumnLine Create(Item item, DrawableTooltipLine line) { Player player = Main.LocalPlayer; int critChance = 0; if (item.melee) { critChance = player.meleeCrit - player.HeldItem.crit + item.crit; ItemLoader.GetWeaponCrit(item, player, ref critChance); PlayerHooks.GetWeaponCrit(player, item, ref critChance); } else if (item.ranged) { critChance = player.rangedCrit - player.HeldItem.crit + item.crit; ItemLoader.GetWeaponCrit(item, player, ref critChance); PlayerHooks.GetWeaponCrit(player, item, ref critChance); } else if (item.magic) { critChance = player.magicCrit - player.HeldItem.crit + item.crit; ItemLoader.GetWeaponCrit(item, player, ref critChance); PlayerHooks.GetWeaponCrit(player, item, ref critChance); } else if (item.thrown) { critChance = player.thrownCrit - player.HeldItem.crit + item.crit; ItemLoader.GetWeaponCrit(item, player, ref critChance); PlayerHooks.GetWeaponCrit(player, item, ref critChance); } else if (!item.summon) { critChance = item.crit; ItemLoader.GetWeaponCrit(item, player, ref critChance); PlayerHooks.GetWeaponCrit(player, item, ref critChance); } return(new TwoColumnLine(line) { textLeft = "Critical strike chance", textRight = critChance + "%", colorRight = Utility.DoubleLerp(Color.Red, Color.Yellow, Color.LimeGreen, critChance / GetMaxCrit(item)) }); }
public override bool PreDrawTooltipLine(DrawableTooltipLine line, ref int yOffset) { if (line.Name == "ItemName") { Vector2 lineposition = new Vector2(line.OriginalX, line.OriginalY); Utils.DrawBorderString(Main.spriteBatch, line.text, lineposition, Color.LightGoldenrodYellow); Main.spriteBatch.End(); Main.spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.Additive, null, null, null, null, Main.UIScaleMatrix); //starting a new spritebatch here, since additive blend mode seems to be the only way to make the line transparent? for (int i = 0; i < 4; i++) { Vector2 drawpos = lineposition + new Vector2(0, 2 * (((float)Math.Sin(Main.GlobalTime * 4) / 2) + 0.5f)).RotatedBy(i * MathHelper.PiOver2); Utils.DrawBorderString(Main.spriteBatch, line.text, drawpos, Color.Goldenrod); } Main.spriteBatch.End(); Main.spriteBatch.Begin(SpriteSortMode.Deferred, null, null, null, null, null, Main.UIScaleMatrix); return(false); } return(base.PreDrawTooltipLine(line, ref yOffset)); }
public override bool PreDrawTooltipLine(Item item, DrawableTooltipLine line, ref int yOffset) { if (line.Name != "OneDrop") { return(true); } int colorValue = (int)(Main.mouseTextColor * 1f); Color color = Color.Black; for (int l = 0; l < 5; l++) { int vecX = 0; int vecY = yOffset; switch (l) { case 0: vecX--; break; case 1: vecX++; break; case 2: vecY--; break; case 3: vecY++; break; case 4: color = new Color(colorValue, colorValue, colorValue, colorValue); break; } Main.spriteBatch.Draw(Main.oneDropLogo, new Vector2(vecX + line.X, vecY + line.Y), color); } return(true); }
public override bool PreDrawTooltipLine(Item item, DrawableTooltipLine line, ref int yOffset) { if (line.Name != "OneDrop") { return(true); } float num28 = 1f; int num29 = (int)(Main.mouseTextColor * num28); Color black = Color.Black; for (int l = 0; l < 5; l++) { int num30 = 0; int num31 = yOffset; switch (l) { case 4: black = new Color(num29, num29, num29, num29); break; case 0: num30--; break; case 1: num30++; break; case 2: num31--; break; case 3: num31++; break; } Main.spriteBatch.Draw(Main.oneDropLogo, new Vector2((float)(num30 + line.X), (float)(num31 + line.Y)), null, black, 0f, default(Vector2), 1f, SpriteEffects.None, 0f); } return(true); }
public override bool PreDrawTooltipLine(DrawableTooltipLine line, ref int yOffset) { bool canPlaymaso = FargoSoulsWorld.CanPlayMaso || (Main.LocalPlayer.active && Main.LocalPlayer.GetModPlayer <FargoSoulsPlayer>().Toggler.CanPlayMaso); if (canPlaymaso) { if ((line.Mod == "Terraria" && line.Name == "ItemName") || (line.Mod == Mod.Name && line.Name == "tooltip")) { Main.spriteBatch.End(); //end and begin main.spritebatch to apply a shader Main.spriteBatch.Begin(SpriteSortMode.Immediate, null, null, null, null, null, Main.UIScaleMatrix); var lineshader = GameShaders.Misc["PulseUpwards"].UseColor(new Color(28, 222, 152)).UseSecondaryColor(new Color(168, 245, 228)); lineshader.Apply(); Utils.DrawBorderString(Main.spriteBatch, line.Text, new Vector2(line.X, line.Y), Color.White, 1); //draw the tooltip manually Main.spriteBatch.End(); //then end and begin again to make remaining tooltip lines draw in the default way Main.spriteBatch.Begin(SpriteSortMode.Deferred, null, null, null, null, null, Main.UIScaleMatrix); return(false); } } return(true); }
public override bool PreDrawTooltipLine(DrawableTooltipLine line, ref int yOffset) { if (line.Name.Contains("TLStat") || line.Name == "TLRarity" || (line.Name == "ItemName" && line.mod == "Terraria")) { if (line.Name == "ItemName") { line.X += (innerTooltipBox.Width / 2) - ItemNamePadding - (int)line.font.MeasureString(line.text).X / 2; } else if (line.Name == "TLRarity") { line.X += (int)(statBox.Width * 0.75f); line.baseScale *= 0.75f; //Since the rarity line will be displaced off to the side, don't want it to affect the other lines Y placement yOffset -= (int)line.font.MeasureString(line.text).Y; } else { //Revert possible negative value from the TLRarity line yOffset = 0; string[] splitText = line.text.Split('|'); string statName = splitText.First(); string statValue = splitText.Last(); ChatManager.DrawColorCodedStringWithShadow(Main.spriteBatch, line.font, statName, new Vector2(line.X, line.Y), line.color, line.rotation, line.origin, line.baseScale, line.maxWidth, line.spread); ChatManager.DrawColorCodedStringWithShadow(Main.spriteBatch, line.font, statValue, new Vector2(line.X + (statBox.Width * 0.67f) - ChatManager.GetStringSize(line.font, statValue, line.baseScale).X, line.Y), line.color, line.rotation, line.origin, line.baseScale, line.maxWidth, line.spread); return(false); } } else { Color selectedColor = line.overrideColor != null ? (Color)line.overrideColor : line.color; ChatManager.DrawColorCodedStringWithShadow(Main.spriteBatch, line.font, line.text, new Vector2(line.X, line.Y), selectedColor, line.rotation, line.origin, line.baseScale, outerTooltipBox.Width - ItemNamePadding * 2, line.spread); return(false); } return(true); }
public override bool PreDrawTooltipLine(DrawableTooltipLine line, ref int yOffset) { if (line.Name == "PipetteInfo") { Main.spriteBatch.DrawPanel(new Rectangle(line.X, line.Y, 56, 56)); int offset = 0; Main.spriteBatch.Draw(Utility.PointClampState, () => { icon.animation.Update(); Rectangle rectangle = icon.animation.GetFrame(icon.Texture); float scale = Math.Min(40f / rectangle.Width, 40f / rectangle.Height); Main.spriteBatch.Draw(icon.Texture, new Vector2(line.X + 28, line.Y + 28), rectangle, Color.White, 0f, rectangle.Size() * 0.5f, scale, SpriteEffects.None, 0f); offset += line.Y + 56; }); yOffset += offset; return(false); } return(base.PreDrawTooltipLine(line, ref yOffset)); }
internal abstract TwoColumnLine Create(Item item, DrawableTooltipLine line);
internal override TwoColumnLine Create(Item item, DrawableTooltipLine line) { Player player = Main.LocalPlayer; float knockback = item.knockBack; if (item.summon) { knockback += player.minionKB; } if (player.magicQuiver && item.useAmmo == AmmoID.Arrow || item.useAmmo == AmmoID.Stake) { knockback = (int)(knockback * 1.1f); } if (player.inventory[player.selectedItem].type == 3106 && item.type == 3106) { knockback += knockback * (1f - player.stealth); } ItemLoader.GetWeaponKnockback(item, player, ref knockback); PlayerHooks.GetWeaponKnockback(player, item, ref knockback); string knockbackText; if (knockback <= 0f) { knockbackText = "No"; } else if (knockback <= 1.5f) { knockbackText = "Extremely weak"; } else if (knockback <= 3f) { knockbackText = "Very weak"; } else if (knockback <= 4f) { knockbackText = "Weak"; } else if (knockback <= 6f) { knockbackText = "Average"; } else if (knockback <= 7f) { knockbackText = "Strong"; } else if (knockback <= 9f) { knockbackText = "Very strong"; } else if (knockback <= 11f) { knockbackText = "Extremely strong"; } else { knockbackText = "Insane"; } return(new TwoColumnLine(line) { textLeft = "Knockback", textRight = $"{knockbackText} ({knockback:F1})", colorRight = Utility.DoubleLerp(Color.Red, Color.Yellow, Color.LimeGreen, knockback / GetMaxKnockback(item)) }); }