Added craftable or not craftable text for recipies in the crafting page

master
shoaib11120 2022-01-07 14:17:00 +05:30
parent deebc26a2a
commit ac6247c70d
1 changed files with 20 additions and 1 deletions

View File

@ -2,6 +2,7 @@
using StardewModdingAPI;
using StardewValley;
using StardewValley.Menus;
using StardewValley.Objects;
namespace stardew_access.Patches
{
@ -256,8 +257,10 @@ namespace stardew_access.Patches
string description = "";
string ingredients = "";
string buffs = "";
string craftable = "";
description = $"Description:\n{___hoverRecipe.description}";
craftable = ___hoverRecipe.doesFarmerHaveIngredientsInInventory(getContainerContents(__instance._materialContainers)) ? "Craftable" : "Not Craftable";
#region Crafting ingredients
ingredients = "Ingredients:\n";
@ -309,7 +312,7 @@ namespace stardew_access.Patches
#endregion
string toSpeak = $"{numberOfProduce} {name}, \n\t{ingredients}, \n\t{description}, \n\t{buffs}";
string toSpeak = $"{numberOfProduce} {name}, {craftable}, \n\t{ingredients}, \n\t{description} \n\t{buffs}";
if (craftingPageQueryKey != toSpeak)
{
@ -335,6 +338,22 @@ namespace stardew_access.Patches
}
}
// This method is used to get the inventory items to check if the player has enough ingredients for a recipe
// Taken from CraftingPage.cs -> 169 line
internal static IList<Item> getContainerContents(List<Chest> materialContainers)
{
if (materialContainers == null)
{
return null;
}
List<Item> items = new List<Item>();
for (int i = 0; i < materialContainers.Count; i++)
{
items.AddRange(materialContainers[i].items);
}
return items;
}
internal static void InventoryPagePatch(InventoryPage __instance)
{
try