public static int NewText(PopupTextContext context, Item bag, Item newItem, int stack, bool noStack = false, bool longText = false) { if (!Main.showItemText || newItem.Name is null || !newItem.active || Main.netMode == NetmodeID.Server) { return(-1); } bool isCoin = newItem.IsACoin; for (int i = 0; i < 20; i++) { PopupText popupText = Main.popupText[i]; if (!popupText.active || popupText.notActuallyAnItem || ItemTextBags[i] != bag || (popupText.name != newItem.AffixName() && (!isCoin || !popupText.coinText)) || popupText.NoStack || noStack) { continue; } string text = $"{newItem.Name} ({popupText.stack + stack})"; Vector2 size = FontAssets.MouseText.Value.MeasureString(text) + new Vector2(24f, 0f); if (popupText.lifeTime < 0) { popupText.scale = 1f; } if (popupText.lifeTime < 60) { popupText.lifeTime = 60; } if (isCoin && popupText.coinText) { int num = 0; if (newItem.type == ItemID.CopperCoin) { num += stack; } else if (newItem.type == ItemID.SilverCoin) { num += 100 * stack; } else if (newItem.type == ItemID.GoldCoin) { num += 10000 * stack; } else if (newItem.type == ItemID.PlatinumCoin) { num += 1000000 * stack; } popupText.coinValue += num; text = PopupText.ValueToName(popupText.coinValue); size = FontAssets.MouseText.Value.MeasureString(text) + new Vector2(24f, 0f); popupText.name = text; if (popupText.coinValue >= 1000000) { if (popupText.lifeTime < 300) { popupText.lifeTime = 300; } popupText.color = new Color(220, 220, 198); } else if (popupText.coinValue >= 10000) { if (popupText.lifeTime < 240) { popupText.lifeTime = 240; } popupText.color = new Color(224, 201, 92); } else if (popupText.coinValue >= 100) { if (popupText.lifeTime < 180) { popupText.lifeTime = 180; } popupText.color = new Color(181, 192, 193); } else if (popupText.coinValue >= 1) { if (popupText.lifeTime < 120) { popupText.lifeTime = 120; } popupText.color = new Color(246, 138, 96); } } popupText.stack += stack; popupText.scale = 0f; popupText.rotation = 0f; popupText.position.X = newItem.position.X + newItem.width * 0.5f - size.X * 0.5f; popupText.position.Y = newItem.position.Y + newItem.height * 0.25f - size.Y * 0.5f; popupText.velocity.Y = -7f; popupText.context = context; popupText.npcNetID = 0; if (popupText.coinText) { popupText.stack = 1; } return(i); } int slotIndex = FindNextItemTextSlot.InvokeStatic <int>(); if (slotIndex >= 0) { string text3 = newItem.AffixName(); if (stack > 1) { text3 = text3 + " (" + stack + ")"; } Vector2 size = FontAssets.MouseText.Value.MeasureString(text3) + new Vector2(24f, 0f); PopupText popupText = Main.popupText[slotIndex]; PopupText.ResetText(popupText); popupText.active = true; popupText.position.X = newItem.position.X + newItem.width * 0.5f - size.X * 0.5f; popupText.position.Y = newItem.position.Y + newItem.height * 0.25f - size.Y * 0.5f; popupText.color = Color.White; if (newItem.rare == ItemRarityID.Blue) { popupText.color = new Color(150, 150, 255); } else if (newItem.rare == ItemRarityID.Green) { popupText.color = new Color(150, 255, 150); } else if (newItem.rare == ItemRarityID.Orange) { popupText.color = new Color(255, 200, 150); } else if (newItem.rare == ItemRarityID.LightRed) { popupText.color = new Color(255, 150, 150); } else if (newItem.rare == ItemRarityID.Pink) { popupText.color = new Color(255, 150, 255); } else if (newItem.rare == ItemRarityID.Master) { popupText.master = true; } else if (newItem.rare == ItemRarityID.Quest) { popupText.color = new Color(255, 175, 0); } else if (newItem.rare == ItemRarityID.Gray) { popupText.color = new Color(130, 130, 130); } else if (newItem.rare == ItemRarityID.LightPurple) { popupText.color = new Color(210, 160, 255); } else if (newItem.rare == ItemRarityID.Lime) { popupText.color = new Color(150, 255, 10); } else if (newItem.rare == ItemRarityID.Yellow) { popupText.color = new Color(255, 255, 10); } else if (newItem.rare == ItemRarityID.Cyan) { popupText.color = new Color(5, 200, 255); } else if (newItem.rare == ItemRarityID.Red) { popupText.color = new Color(255, 40, 100); } else if (newItem.rare == ItemRarityID.Purple) { popupText.color = new Color(180, 40, 255); } else if (newItem.rare >= ItemRarityID.Count) { popupText.color = GetRarity.InvokeStatic <ModRarity>(newItem.rare).RarityColor; } ItemTextBags[slotIndex] = bag; popupText.rarity = newItem.rare; popupText.expert = newItem.expert; popupText.master = newItem.master; popupText.name = newItem.AffixName(); popupText.stack = stack; popupText.velocity.Y = -7f; popupText.lifeTime = 60; popupText.context = context; if (longText) { popupText.lifeTime *= 5; } popupText.coinValue = 0; popupText.coinText = newItem.type is >= ItemID.CopperCoin and <= ItemID.PlatinumCoin; if (popupText.coinText) { if (newItem.type == ItemID.CopperCoin) { popupText.coinValue += popupText.stack; } else if (newItem.type == ItemID.SilverCoin) { popupText.coinValue += 100 * popupText.stack; } else if (newItem.type == ItemID.GoldCoin) { popupText.coinValue += 10000 * popupText.stack; } else if (newItem.type == ItemID.PlatinumCoin) { popupText.coinValue += 1000000 * popupText.stack; } popupText.stack = 1; if (popupText.coinValue >= 1000000) { if (popupText.lifeTime < 300) { popupText.lifeTime = 300; } popupText.color = new Color(220, 220, 198); } else if (popupText.coinValue >= 10000) { if (popupText.lifeTime < 240) { popupText.lifeTime = 240; } popupText.color = new Color(224, 201, 92); } else if (popupText.coinValue >= 100) { if (popupText.lifeTime < 180) { popupText.lifeTime = 180; } popupText.color = new Color(181, 192, 193); } else if (popupText.coinValue >= 1) { if (popupText.lifeTime < 120) { popupText.lifeTime = 120; } popupText.color = new Color(246, 138, 96); } } } return(slotIndex); }