private int ItemGridSort(UIElement x, UIElement y) { UIRecipeSlot a = x as UIRecipeSlot; UIRecipeSlot b = y as UIRecipeSlot; if (a.CompareToIgnoreIndex(b) == 0 && SharedUI.instance.SelectedSort != null) { return(SharedUI.instance.SelectedSort.sort(a.item, b.item)); } return(a.CompareTo(b)); }
internal void FavoriteChange(UIRecipeSlot slot) { if (favoritedRecipes.Contains(slot)) { favoritedRecipes.Remove(slot); } if (slot.favorited) { favoritedRecipes.Add(slot); } UpdateFavoritedPanel(); }
public override void CreateSlot() { listCount = Inventory.GetRecipeList().Count; for (int t = 0; t < listCount; t++) { if (t >= slotList.Count) { UIRecipeSlot s = Instantiate(slotPrefab, viewTransform).GetComponent <UIRecipeSlot>(); slotList.Add(s); } } UpdateSlot(); }
private bool PassItemFilters(UIItemCatalogueItemSlot slot) { if (RecipeBrowserUI.modIndex != 0) { if (slot.item.modItem == null) { return(false); } if (slot.item.modItem.mod.Name != RecipeBrowserUI.instance.mods[RecipeBrowserUI.modIndex]) { return(false); } } if (CraftedRadioButton.Selected) { if (!craftResults[slot.item.type]) { return(false); } } if (LootRadioButton.Selected) { if (!isLoot[slot.item.type]) { return(false); } } if (UnobtainedRadioButton.Selected && RecipeBrowserUI.instance.foundItems != null) { if (RecipeBrowserUI.instance.foundItems[slot.item.type]) { return(false); } } if (SharedUI.instance.SelectedCategory != null) { if (!SharedUI.instance.SelectedCategory.belongs(slot.item) && !SharedUI.instance.SelectedCategory.subCategories.Any(x => x.belongs(slot.item))) { return(false); } } foreach (var filter in SharedUI.instance.availableFilters) { if (filter.button.selected) { if (!filter.belongs(slot.item)) { return(false); } if (filter == SharedUI.instance.ObtainableFilter) { bool ableToCraft = false; for (int i = 0; i < Recipe.numRecipes; i++) // Optimize with non-trimmed RecipePath.recipeDictionary { Recipe recipe = Main.recipe[i]; if (recipe.createItem.type == slot.item.type) { UIRecipeSlot recipeSlot = RecipeCatalogueUI.instance.recipeSlots[i]; recipeSlot.CraftPathNeeded(); //recipeSlot.CraftPathsImmediatelyNeeded(); if ((recipeSlot.craftPathCalculated || recipeSlot.craftPathsCalculated) && recipeSlot.craftPaths.Count > 0) { ableToCraft = true; break; } } } if (!ableToCraft) { return(false); } } if (filter == SharedUI.instance.CraftableFilter) { bool ableToCraft = false; for (int n = 0; n < Main.numAvailableRecipes; n++) { if (Main.recipe[Main.availableRecipe[n]].createItem.type == slot.item.type) { ableToCraft = true; break; } } if (!ableToCraft) { return(false); } } } } if (slot.item.Name.IndexOf(itemNameFilter.currentString, StringComparison.OrdinalIgnoreCase) == -1) { return(false); } if (itemDescriptionFilter.currentString.Length > 0) { if (SharedUI.instance.SelectedCategory.name == ArmorSetFeatureHelper.ArmorSetsHoverTest) { if (slot is UIArmorSetCatalogueItemSlot setCatalogueItemSlot) { return(setCatalogueItemSlot.set.Item4.IndexOf(itemDescriptionFilter.currentString, StringComparison.OrdinalIgnoreCase) != -1); } } if ((slot.item.ToolTip != null && GetTooltipsAsString(slot.item.ToolTip).IndexOf(itemDescriptionFilter.currentString, StringComparison.OrdinalIgnoreCase) != -1) /*|| (recipe.createItem.toolTip2 != null && recipe.createItem.toolTip2.ToLower().IndexOf(itemDescriptionFilter.Text, StringComparison.OrdinalIgnoreCase) != -1)*/) { return(true); } else { return(false); } } return(true); }
private bool PassRecipeFilters(UIRecipeSlot recipeSlot, Recipe recipe, List <int> groups) { // TODO: Option to filter by source of Recipe rather than by createItem maybe? if (RecipeBrowserUI.modIndex != 0) { if (recipe.createItem.modItem == null) { return(false); } if (recipe.createItem.modItem.mod.Name != RecipeBrowserUI.instance.mods[RecipeBrowserUI.modIndex]) { return(false); } } if (NearbyIngredientsRadioBitton.Selected) { if (!PassNearbyChestFilter(recipe)) { return(false); } } // Item Checklist integration if (ItemChecklistRadioButton.Selected) { if (RecipeBrowserUI.instance.foundItems != null) { for (int i = 0; i < Recipe.maxRequirements; i++) { if (recipe.requiredItem[i].type > 0) { if (!RecipeBrowserUI.instance.foundItems[recipe.requiredItem[i].type]) { return(false); } } } // filter out recipes that make things I've already obtained if (RecipeBrowserUI.instance.foundItems[recipe.createItem.type]) { return(false); } } else { Main.NewText("How is this happening??"); } } // Filter out recipes that don't use selected Tile if (Tile > -1) { List <int> adjTiles = new List <int>(); adjTiles.Add(Tile); if (uniqueCheckbox.CurrentState == 0) { Terraria.ModLoader.ModTile modTile = Terraria.ModLoader.TileLoader.GetTile(Tile); if (modTile != null) { adjTiles.AddRange(modTile.adjTiles); } if (Tile == 302) { adjTiles.Add(17); } if (Tile == 77) { adjTiles.Add(17); } if (Tile == 133) { adjTiles.Add(17); adjTiles.Add(77); } if (Tile == 134) { adjTiles.Add(16); } if (Tile == 354) { adjTiles.Add(14); } if (Tile == 469) { adjTiles.Add(14); } if (Tile == 355) { adjTiles.Add(13); adjTiles.Add(14); } // TODO: GlobalTile.AdjTiles support (no player object, reflection needed since private) } if (!recipe.requiredTile.Any(t => adjTiles.Contains(t))) { return(false); } } if (!queryItem.item.IsAir) { int type = queryItem.item.type; bool inGroup = recipe.acceptedGroups.Intersect(groups).Any(); inGroup |= recipe.useWood(type, type) || recipe.useSand(type, type) || recipe.useFragment(type, type) || recipe.useIronBar(type, type) || recipe.usePressurePlate(type, type); if (!inGroup) { if (!(recipe.createItem.type == type || recipe.requiredItem.Any(ing => ing.type == type))) { return(false); } } } var SelectedCategory = SharedUI.instance.SelectedCategory; if (SelectedCategory != null) { if (!SelectedCategory.belongs(recipe.createItem) && !SelectedCategory.subCategories.Any(x => x.belongs(recipe.createItem))) { return(false); } } var availableFilters = SharedUI.instance.availableFilters; if (availableFilters != null) { foreach (var filter in SharedUI.instance.availableFilters) { if (filter.button.selected) { // Extended craft problem. if (!filter.belongs(recipe.createItem)) { return(false); } if (filter == SharedUI.instance.ObtainableFilter) { recipeSlot.CraftPathNeeded(); if (!((recipeSlot.craftPathCalculated || recipeSlot.craftPathsCalculated) && recipeSlot.craftPaths.Count > 0)) { return(false); } } if (filter == SharedUI.instance.CraftableFilter) { int index = recipeSlot.index; bool ableToCraft = false; for (int n = 0; n < Main.numAvailableRecipes; n++) { if (index == Main.availableRecipe[n]) { ableToCraft = true; break; } } if (!ableToCraft) { return(false); } } } } } if (recipe.createItem.Name.ToLower().IndexOf(itemNameFilter.currentString, StringComparison.OrdinalIgnoreCase) == -1) { return(false); } if (itemDescriptionFilter.currentString.Length > 0) { if ((recipe.createItem.ToolTip != null && GetTooltipsAsString(recipe.createItem.ToolTip).IndexOf(itemDescriptionFilter.currentString, StringComparison.OrdinalIgnoreCase) != -1) /*|| (recipe.createItem.toolTip2 != null && recipe.createItem.toolTip2.ToLower().IndexOf(itemDescriptionFilter.Text, StringComparison.OrdinalIgnoreCase) != -1)*/) { return(true); } else { return(false); } } return(true); }