Added crafting ingredients, buff items, etc to the hovered text narration
parent
09fdbd59aa
commit
21c2a3309e
|
@ -57,16 +57,80 @@ namespace stardew_access
|
||||||
{
|
{
|
||||||
StringBuilder toSpeak = new StringBuilder();
|
StringBuilder toSpeak = new StringBuilder();
|
||||||
|
|
||||||
if (hoveredItem != null)
|
#region Add title if any
|
||||||
toSpeak.AppendLine(hoveredItem.DisplayName);
|
if (boldTitleText != null)
|
||||||
|
toSpeak.Append($"{boldTitleText}.\n");
|
||||||
|
#endregion
|
||||||
|
|
||||||
toSpeak.AppendLine(text);
|
#region Add the base text
|
||||||
|
toSpeak.Append(text);
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Add crafting ingredients
|
||||||
|
if (craftingIngredients != null)
|
||||||
|
{
|
||||||
|
|
||||||
|
toSpeak.Append($"\n{craftingIngredients.description}");
|
||||||
|
toSpeak.Append("\nIngredients\n");
|
||||||
|
|
||||||
|
craftingIngredients.recipeList.ToList().ForEach(recipe =>
|
||||||
|
{
|
||||||
|
int count = recipe.Value;
|
||||||
|
int item = recipe.Key;
|
||||||
|
string name = craftingIngredients.getNameFromIndex(item);
|
||||||
|
|
||||||
|
toSpeak.Append($" ,{count} {name}");
|
||||||
|
});
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Add health & stamina
|
||||||
|
if (hoveredItem is StardewValley.Object && (hoveredItem as StardewValley.Object).Edibility != -300)
|
||||||
|
{
|
||||||
|
int stamina_recovery = (hoveredItem as StardewValley.Object).staminaRecoveredOnConsumption();
|
||||||
|
toSpeak.Append($"{stamina_recovery} Energy\n");
|
||||||
|
if (stamina_recovery >= 0)
|
||||||
|
{
|
||||||
|
int health_recovery = (hoveredItem as StardewValley.Object).healthRecoveredOnConsumption();
|
||||||
|
toSpeak.Append($"{health_recovery} Health");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Add buff items (effects like +1 walking speed)
|
||||||
|
if (buffIconsToDisplay != null)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < buffIconsToDisplay.Length; i++)
|
||||||
|
{
|
||||||
|
string buffName = ((Convert.ToInt32(buffIconsToDisplay[i]) > 0) ? "+" : "") + buffIconsToDisplay[i] + " ";
|
||||||
|
if (i <= 11)
|
||||||
|
{
|
||||||
|
buffName = Game1.content.LoadString("Strings\\UI:ItemHover_Buff" + i, buffName);
|
||||||
|
}
|
||||||
|
try
|
||||||
|
{
|
||||||
|
int count = int.Parse(buffName.Substring(0, buffName.IndexOf(' ')));
|
||||||
|
monitor.Log("" + count);
|
||||||
|
if (count != 0)
|
||||||
|
toSpeak.Append($"{buffName}\n");
|
||||||
|
}
|
||||||
|
catch (Exception) { }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Add money
|
||||||
|
if (moneyAmountToDisplayAtBottom != -1)
|
||||||
|
toSpeak.Append($"\nValue: {moneyAmountToDisplayAtBottom} coins\n");
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Narrate toSpeak
|
||||||
if (prevText != toSpeak.ToString())
|
if (prevText != toSpeak.ToString())
|
||||||
{
|
{
|
||||||
prevText = toSpeak.ToString();
|
prevText = toSpeak.ToString();
|
||||||
screenReader.Speak(toSpeak.ToString(), true);
|
screenReader.Speak(toSpeak.ToString(), true);
|
||||||
}
|
}
|
||||||
|
#endregion
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
|
@ -74,24 +138,6 @@ namespace stardew_access
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void dialogBoxRecieveLeftClickPostfix(DialogueBox dialogueBox)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
if(!dialogueBox.transitioning && dialogueBox.characterDialogue!=null)
|
|
||||||
{
|
|
||||||
string speakerName = dialogueBox.characterDialogue.speaker.Name;
|
|
||||||
List<string> dialogues = dialogueBox.characterDialogue.dialogues;
|
|
||||||
int dialogueIndex = dialogueBox.characterDialogue.currentDialogueIndex;
|
|
||||||
|
|
||||||
screenReader.Speak($"{speakerName} said, {dialogues[dialogueIndex]}", false);
|
|
||||||
}
|
|
||||||
} catch (Exception e)
|
|
||||||
{
|
|
||||||
monitor.Log($"Unable to narrate dialog:\n{e.StackTrace}", LogLevel.Error);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void dialogBoxPostfix(Dialogue dialogue)
|
private static void dialogBoxPostfix(Dialogue dialogue)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
|
|
Loading…
Reference in New Issue