diff --git a/stardew-access/Patches/GameMenuPatches.cs b/stardew-access/Patches/GameMenuPatches.cs index 44e7378..35abdec 100644 --- a/stardew-access/Patches/GameMenuPatches.cs +++ b/stardew-access/Patches/GameMenuPatches.cs @@ -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 getContainerContents(List materialContainers) + { + if (materialContainers == null) + { + return null; + } + List items = new List(); + for (int i = 0; i < materialContainers.Count; i++) + { + items.AddRange(materialContainers[i].items); + } + return items; + } + internal static void InventoryPagePatch(InventoryPage __instance) { try