internal void UpdateNPCGrid() { if (!updateNeededNPC) { return; } updateNeededNPC = false; npcGrid.Clear(); for (int i = 0; i < Main.npcTexture.Length; i++) // TODO, right? { //if (Main.projName[i].ToLower().IndexOf(searchFilter.Text, StringComparison.OrdinalIgnoreCase) != -1) { NPC npc = new NPC(); npc.SetDefaults(i); var box = new UINPCSlot(npc); box.OnClick += Box_OnClick; npcGrid._items.Add(box); npcGrid._innerList.Append(box); } } npcGrid.UpdateOrder(); npcGrid._innerList.Recalculate(); }
internal void SetNPC(UINPCSlot slot) { foreach (var npc in npcSlots) { npc.selected = false; } slot.selected = true; }
internal void Update() { if (NPCLoader.NPCCount - 1 != npcSlots.Count) { // should only happen once npcSlots.Clear(); for (int type = 1; type < NPCLoader.NPCCount; type++) { NPC npc = new NPC(); npc.SetDefaults(type); var slot = new UINPCSlot(npc); npcSlots.Add(slot); } } if (!updateNeeded) { return; } updateNeeded = false; npcGrid.Clear(); for (int type = 1; type < NPCLoader.NPCCount; type++) { var slot = npcSlots[type - 1]; if (PassNPCFilters(slot)) { npcGrid._items.Add(slot); npcGrid._innerList.Append(slot); } } npcGrid.UpdateOrder(); npcGrid._innerList.Recalculate(); lootGrid.Clear(); if (queryLootNPC != null) { var drops = queryLootNPC.GetDrops(); if (NewLootOnlyRadioButton.Selected && RecipeBrowserUI.instance.foundItems != null) { drops.RemoveWhere(x => RecipeBrowserUI.instance.foundItems[x]); } foreach (var dropitem in drops) { Item item = new Item(); item.SetDefaults(dropitem, false); var slot = new UIBestiaryItemSlot(item); lootGrid._items.Add(slot); lootGrid._innerList.Append(slot); } } lootGrid.UpdateOrder(); lootGrid._innerList.Recalculate(); }
private void UpdateGrid() { if (Recipe.numRecipes != recipeSlots.Count) { recipeSlots.Clear(); for (int i = 0; i < Recipe.numRecipes; i++) { recipeSlots.Add(new UIRecipeSlot(i)); } tileChooserGrid.Clear(); var tileUsageCounts = new Dictionary <int, int>(); int currentCount; for (int i = 0; i < Recipe.numRecipes; i++) { for (int j = 0; j < 15; j++) { if (Main.recipe[i].requiredTile[j] == -1) { break; } tileUsageCounts.TryGetValue(Main.recipe[i].requiredTile[j], out currentCount); tileUsageCounts[Main.recipe[i].requiredTile[j]] = currentCount + 1; } } // sort var sorted = tileUsageCounts.OrderBy(kvp => kvp.Value); foreach (var tileUsage in sorted) { var tileSlot = new UITileSlot(tileUsage.Key, tileUsage.Value); tileChooserGrid.Add(tileSlot); tileSlots.Add(tileSlot); } craftingTiles = tileUsageCounts.Select(x => x.Key).ToList(); RecipeBrowserUI.instance.UpdateFavoritedPanel(); } if (!updateNeeded) { return; } updateNeeded = false; List <int> groups = new List <int>(); if (queryItem.item.stack > 0) { int type = queryItem.item.type; foreach (var group in RecipeGroup.recipeGroups) { if (group.Value.ValidItems.Contains(type)) { groups.Add(group.Key); } } } lootSourceGrid.Clear(); if (queryLootItem != null) { //var jsonitem = new JSONItem(queryLootItem.modItem?.mod.Name ?? "Terraria", Lang.GetItemNameValue(queryLootItem.type), queryLootItem.modItem != null ? 0 : queryLootItem.type); var jsonitem = new JSONItem(queryLootItem.modItem?.mod.Name ?? "Terraria", queryLootItem.modItem?.Name ?? Lang.GetItemNameValue(queryLootItem.type), queryLootItem.modItem != null ? 0 : queryLootItem.type); List <JSONNPC> npcsthatdropme; if (LootCache.instance.lootInfos.TryGetValue(jsonitem, out npcsthatdropme)) { foreach (var dropper in npcsthatdropme) { int id = dropper.GetID(); if (id == 0) { continue; } /*int id = dropper.id; * if (id == 0) * { * //it's a * Mod m = ModLoader.GetMod(dropper.mod); * if (m == null) continue; * id = m.NPCType(dropper.name); * }*/ NPC npc = new NPC(); npc.SetDefaults(id); var slot = new UINPCSlot(npc); //lootSourceGrid.Add(slot); lootSourceGrid._items.Add(slot); lootSourceGrid._innerList.Append(slot); } } } lootSourceGrid.UpdateOrder(); lootSourceGrid._innerList.Recalculate(); recipeGrid.Clear(); for (int i = 0; i < Recipe.numRecipes; i++) { if (PassRecipeFilters(Main.recipe[i], groups)) // all the filters //if (Main.projName[i].ToLower().IndexOf(searchFilter.Text, StringComparison.OrdinalIgnoreCase) != -1) { var box = recipeSlots[i]; // if (newestItem > 0) { Recipe recipe = Main.recipe[i]; box.recentlyDiscovered = false; if (recipe.requiredItem.Any(x => x.type == newestItem)) { box.recentlyDiscovered = true; } } recipeGrid._items.Add(box); recipeGrid._innerList.Append(box); } } recipeGrid.UpdateOrder(); recipeGrid._innerList.Recalculate(); }
private bool PassNPCFilters(UINPCSlot slot) { if (EncounteredRadioButton.Selected) { int bannerID = Item.NPCtoBanner(slot.npc.BannerID()); if (bannerID > 0) { if (NPC.killCount[bannerID] <= 0) { return(false); } } else { return(false); } } if (HasLootRadioButton.Selected) { // Slow, AnyDrops or Cache results. if (slot.GetDrops().Count == 0) { return(false); } } if (NewLootOnlyRadioButton.Selected) { // Item Checklist integration if (RecipeBrowserUI.instance.foundItems != null) { bool hasNewItem = false; var drops = slot.GetDrops(); foreach (var item in drops) { if (!RecipeBrowserUI.instance.foundItems[item]) { hasNewItem = true; break; } } if (!hasNewItem) { return(false); } } else { Main.NewText("How is this happening?"); } } if (RecipeBrowserUI.modIndex != 0) { if (slot.npc.modNPC == null) { return(false); } if (slot.npc.modNPC.mod.Name != RecipeBrowserUI.instance.mods[RecipeBrowserUI.modIndex]) { return(false); } } if (!queryItem.item.IsAir) { if (!slot.GetDrops().Contains(queryItem.item.type)) { return(false); } } if (Lang.GetNPCNameValue(slot.npcType).IndexOf(npcNameFilter.currentString, StringComparison.OrdinalIgnoreCase) == -1) { return(false); } return(true); }
private void UpdateGrid() { if (Recipe.numRecipes != recipeSlots.Count) { recipeSlots.Clear(); for (int i = 0; i < Recipe.numRecipes; i++) { recipeSlots.Add(new UIRecipeSlot(i)); } } if (!updateNeeded) { return; } updateNeeded = false; List <int> groups = new List <int>(); if (queryItem.item.stack > 0 && !TileLookupRadioButton.Selected) { int type = queryItem.item.type; foreach (var group in RecipeGroup.recipeGroups) { if (group.Value.ValidItems.Contains(type)) { groups.Add(group.Key); } } } lootSourceGrid.Clear(); if (queryLootItem != null) { //var jsonitem = new JSONItem(queryLootItem.modItem?.mod.Name ?? "Terraria", Lang.GetItemNameValue(queryLootItem.type), queryLootItem.modItem != null ? 0 : queryLootItem.type); var jsonitem = new JSONItem(queryLootItem.modItem?.mod.Name ?? "Terraria", queryLootItem.modItem?.Name ?? Lang.GetItemNameValue(queryLootItem.type), queryLootItem.modItem != null ? 0 : queryLootItem.type); List <JSONNPC> npcsthatdropme; if (LootCache.instance.lootInfos.TryGetValue(jsonitem, out npcsthatdropme)) { foreach (var dropper in npcsthatdropme) { int id = dropper.GetID(); if (id == 0) { continue; } /*int id = dropper.id; * if (id == 0) * { * //it's a * Mod m = ModLoader.GetMod(dropper.mod); * if (m == null) continue; * id = m.NPCType(dropper.name); * }*/ NPC npc = new NPC(); npc.SetDefaults(id); var slot = new UINPCSlot(npc); //lootSourceGrid.Add(slot); lootSourceGrid._items.Add(slot); lootSourceGrid._innerList.Append(slot); } } } lootSourceGrid.UpdateOrder(); lootSourceGrid._innerList.Recalculate(); recipeGrid.Clear(); for (int i = 0; i < Recipe.numRecipes; i++) { if (PassRecipeFilters(Main.recipe[i], groups)) // all the filters //if (Main.projName[i].ToLower().IndexOf(searchFilter.Text, StringComparison.OrdinalIgnoreCase) != -1) { var box = recipeSlots[i]; // if (newestItem > 0) { Recipe recipe = Main.recipe[i]; box.recentlyDiscovered = false; if (recipe.requiredItem.Any(x => x.type == newestItem)) { box.recentlyDiscovered = true; } } recipeGrid._items.Add(box); recipeGrid._innerList.Append(box); } } recipeGrid.UpdateOrder(); recipeGrid._innerList.Recalculate(); }