/******************** ** Method Patches ** ********************/ /// <summary>After setUpBundleSpecificPage runs, define hover text for ingredients and blank out the originals.</summary> /// <param name="__instance">The instance of the bundle menu.</param> /// <param name="b">The bundle object.</param> public static void Postfix_setUpBundleSpecificPage(JunimoNoteMenu __instance, Bundle b) { try { if (__instance.ingredientList == null) { return; } if (debugClearCompletedBundles) { debugTempClearBundles(__instance); } if (debugUnlockMissingBundle) { debugUnlockMissing(); } ingredientHoverTitle = new string[__instance.ingredientList.Count]; ingredientHoverText = new string[__instance.ingredientList.Count]; for (int i = 0; i < __instance.ingredientList.Count; i++) { try { BundleIngredientDescription ingredient = b.ingredients[i]; string hintText = ItemHints.getHintText(ingredient.index, ingredient.quality); if (hintText != "") { ingredientHoverTitle[i] = __instance.ingredientList[i].hoverText; ingredientHoverText[i] = hintText; __instance.ingredientList[i].hoverText = ""; } else { ingredientHoverTitle[i] = ""; ingredientHoverText[i] = ""; } } catch (Exception e) { Log("Error defining hint text: " + e.Message + Environment.NewLine + e.StackTrace); } } } catch (Exception e) { Log("Error in setUpBundleSpecificPage: " + e.Message + Environment.NewLine + e.StackTrace); } }
private static void JunimoNoteCustomButtons(JunimoNoteMenu __instance, Bundle ___currentPageBundle, int signal, bool isLeftShiftPressed = false) { try { switch (signal) { case 0: // For ingredient list { if (___currentPageBundle.ingredients.Count >= 0) { currentIngredientListItem = currentIngredientListItem + (isLeftShiftPressed ? -1 : 1); if (currentIngredientListItem >= ___currentPageBundle.ingredients.Count) { if (isLeftShiftPressed) { currentIngredientListItem = ___currentPageBundle.ingredients.Count - 1; } else { currentIngredientListItem = 0; } } if (currentIngredientListItem < 0) { if (isLeftShiftPressed) { currentIngredientListItem = ___currentPageBundle.ingredients.Count - 1; } else { currentIngredientListItem = 0; } } ClickableTextureComponent c = __instance.ingredientList[currentIngredientListItem]; BundleIngredientDescription ingredient = ___currentPageBundle.ingredients[currentIngredientListItem]; Item item = new StardewValley.Object(ingredient.index, ingredient.stack, isRecipe: false, -1, ingredient.quality); bool completed = false; if (___currentPageBundle != null && ___currentPageBundle.ingredients != null && currentIngredientListItem < ___currentPageBundle.ingredients.Count && ___currentPageBundle.ingredients[currentIngredientListItem].completed) { completed = true; } string toSpeak = item.DisplayName; if (!completed) { int quality = ingredient.quality; if (quality == 1) { toSpeak = $"Silver quality {toSpeak}"; } else if (quality == 2 || quality == 3) { toSpeak = $"Gold quality {toSpeak}"; } else if (quality >= 4) { toSpeak = $"Iridium quality {toSpeak}"; } toSpeak = $"{ingredient.stack} {toSpeak}"; } if (completed) { toSpeak = $"Completed {toSpeak}"; } c.snapMouseCursorToCenter(); MainClass.ScreenReader.Say(toSpeak, true); } } break; case 1: // For input slot list { if (__instance.ingredientSlots.Count >= 0) { currentIngredientInputSlot = currentIngredientInputSlot + (isLeftShiftPressed ? -1 : 1); if (currentIngredientInputSlot >= __instance.ingredientSlots.Count) { if (isLeftShiftPressed) { currentIngredientInputSlot = __instance.ingredientSlots.Count - 1; } else { currentIngredientInputSlot = 0; } } if (currentIngredientInputSlot < 0) { if (isLeftShiftPressed) { currentIngredientInputSlot = __instance.ingredientSlots.Count - 1; } else { currentIngredientInputSlot = 0; } } ClickableTextureComponent c = __instance.ingredientSlots[currentIngredientInputSlot]; Item item = c.item; string toSpeak; if (item == null) { toSpeak = $"Input Slot {currentIngredientInputSlot + 1}"; } else { toSpeak = item.DisplayName; } c.snapMouseCursorToCenter(); MainClass.ScreenReader.Say(toSpeak, true); } } break; case 2: // For inventory slots { if (__instance.inventory != null && __instance.inventory.actualInventory.Count >= 0) { int prevSlotIndex = currentInventorySlot; currentInventorySlot = currentInventorySlot + (isLeftShiftPressed ? -1 : 1); if (currentInventorySlot >= __instance.inventory.actualInventory.Count) { if (isLeftShiftPressed) { currentInventorySlot = __instance.inventory.actualInventory.Count - 1; } else { currentInventorySlot = 0; } } if (currentInventorySlot < 0) { if (isLeftShiftPressed) { currentInventorySlot = __instance.inventory.actualInventory.Count - 1; } else { currentInventorySlot = 0; } } Item item = __instance.inventory.actualInventory[currentInventorySlot]; ClickableComponent c = __instance.inventory.inventory[currentInventorySlot]; string toSpeak; if (item != null) { toSpeak = item.DisplayName; if ((item as StardewValley.Object) != null) { int quality = ((StardewValley.Object)item).Quality; if (quality == 1) { toSpeak = $"Silver quality {toSpeak}"; } else if (quality == 2 || quality == 3) { toSpeak = $"Gold quality {toSpeak}"; } else if (quality >= 4) { toSpeak = $"Iridium quality {toSpeak}"; } } toSpeak = $"{item.Stack} {toSpeak}"; } else { toSpeak = "Empty Slot"; } c.snapMouseCursorToCenter(); MainClass.ScreenReader.Say(toSpeak, true); } } break; } } catch (Exception e) { MainClass.ErrorLog($"Unable to narrate Text:\n{e.Message}\n{e.StackTrace}"); } }