public override void ProcessTriggers(TriggersSet triggersSet) { if (IMPCN.instance.ShowTextKey.JustPressed) { Item item = Main.HoverItem; int id; if (item == null) { Tile tile = Main.tile[Main.mouseX, Main.mouseY]; if (tile == null || tile.type == 0) { return; } id = tile.blockType(); } else { id = item.type; } ItemWithName info = IMPCNExtension.GetItem(id); if (info == null) { ModItem modItem = ItemLoader.GetItem(id); item = modItem.item; info = new ItemWithName( id: id, clazz: item.GetType().Name, english: modItem.DisplayName.GetDefault(), original: modItem.DisplayName.GetTranslation(GameCulture.Chinese) ); } QueryItemNameCommand.WriteItem(info); } }
public static HashSet <ItemWithName> GetExactItem(string name) { HashSet <ItemWithName> resultSet = new HashSet <ItemWithName>(); if (int.TryParse(name, out int res)) { ItemWithName i = GetItem(res); if (i != null) { resultSet.Add(i); return(resultSet); } return(null); } if (!name.Contains(' ')) { ItemWithName i = GetItem(name); if (i != null) { resultSet.Add(i); return(resultSet); } } if (Regex.IsMatch(name, "^[0-9a-zA-Z_ ]+$")) { foreach (KeyValuePair <string, string> v in englishDict) { if (v.Value.ToLower() == name.ToLower()) { string className = v.Key; resultSet.Add(GetItem(className)); } } return(resultSet); } foreach (KeyValuePair <string, string> v in originalDict) { if (v.Value == name) { string className = v.Key; resultSet.Add(GetItem(className)); } } foreach (KeyValuePair <string, string> v in improvedDict) { if (v.Value == name) { string className = v.Key; resultSet.Add(GetItem(className)); } } return(resultSet); }
public static void WriteItem(ItemWithName item) { byte[] color = new byte[3]; IMPCN.random.NextBytes(color); Main.NewText("ID: " + item.ID, color[0], color[1], color[2]); Main.NewText("改良:" + item.ImprovedName, color[0], color[1], color[2]); Main.NewText("旧版(v1.3.5.1):" + item.OldImproved1351Name, color[0], color[1], color[2]); Main.NewText("旧版(v1.3.4.4):" + item.OldImproved1344Name, color[0], color[1], color[2]); Main.NewText("原版(官方中文):" + item.OriginalName, color[0], color[1], color[2]); Main.NewText("英文:" + item.EnglishName, color[0], color[1], color[2]); Main.NewText("类名:" + item.ClassName, color[0], color[1], color[2]); }
public static HashSet <ItemWithName> GetItems(string text) { HashSet <ItemWithName> resultSet = new HashSet <ItemWithName>(); if (int.TryParse(text, out int res)) { ItemWithName i = GetItem(res); if (i != null) { resultSet.Add(i); return(resultSet); } return(null); } if (!text.Contains(' ')) { ItemWithName i = GetItem(text); if (i != null) { resultSet.Add(i); return(resultSet); } } if (Regex.IsMatch(text, "^[0-9a-zA-Z_ ]+$")) { Internal_SearchAndAddEnglish(text, englishDict, resultSet); return(resultSet); } Internal_SearchAndAdd(text, improvedDict, resultSet); Internal_SearchAndAdd(text, originalDict, resultSet); return(resultSet); }