internal static void InitializeGlyphLookup() { Type glyphBase = typeof(GlyphBase); foreach (Type type in SpiritMod.instance.Code.GetTypes()) { if (type.IsAbstract) { continue; } if (!type.IsSubclassOf(glyphBase)) { continue; } Item item = new Item(); item.SetDefaults(SpiritMod.instance.ItemType(type.Name), true); GlyphBase glyph = (GlyphBase)item.modItem; _lookup[(byte)glyph.Glyph] = glyph; } GlyphBase zero = _lookup[0]; for (int i = 1; i < _lookup.Length; i++) { if (_lookup[i] == null) { _lookup[i] = zero; } } }
public override void ModifyTooltips(List <TooltipLine> tooltips) { int index = tooltips.FindIndex(x => x.Name == "Tooltip0"); if (index < 0) { return; } Player player = Main.player[Main.myPlayer]; TooltipLine line; if (CanRightClick()) { Item held = player.HeldItem; GlyphBase glyph = FromType(held.GetGlobalItem <GItem>().Glyph); Color color = glyph.Color; color *= Main.mouseTextColor / 255f; Color itemColor = held.RarityColor(Main.mouseTextColor / 255f); line = new TooltipLine(mod, "GlyphHint", "Right-click to wipe the [c/" + string.Format("{0:X2}{1:X2}{2:X2}:", color.R, color.G, color.B) + glyph.item.Name + "] of [i:" + player.HeldItem.type + "] [c/" + string.Format("{0:X2}{1:X2}{2:X2}:", itemColor.R, itemColor.G, itemColor.B) + held.Name + "]"); } else { line = new TooltipLine(mod, "GlyphHint", "Hold the item which' glyph you want to remove and right-click this glyph"); } line.overrideColor = new Color(120, 190, 120); tooltips.Insert(index + 1, line); }