Organised code for purchase animal menu patch
parent
80963c4dc6
commit
6822bd4840
|
@ -273,9 +273,7 @@ namespace stardew_access.Patches
|
||||||
}
|
}
|
||||||
else if (menu is PurchaseAnimalsMenu)
|
else if (menu is PurchaseAnimalsMenu)
|
||||||
{
|
{
|
||||||
PurchaseAnimalsMenuPatch.purchaseAnimalMenuQuery = "";
|
PurchaseAnimalsMenuPatch.Cleanup();
|
||||||
PurchaseAnimalsMenuPatch.firstTimeInNamingMenu = true;
|
|
||||||
PurchaseAnimalsMenuPatch.purchaseAnimalsMenu = null;
|
|
||||||
}
|
}
|
||||||
else if (menu is AnimalQueryMenu)
|
else if (menu is AnimalQueryMenu)
|
||||||
{
|
{
|
||||||
|
|
|
@ -23,6 +23,26 @@ namespace stardew_access.Patches
|
||||||
animalBeingPurchased = ___animalBeingPurchased;
|
animalBeingPurchased = ___animalBeingPurchased;
|
||||||
|
|
||||||
if (___onFarm && ___namingAnimal)
|
if (___onFarm && ___namingAnimal)
|
||||||
|
{
|
||||||
|
narrateNamingMenu(__instance, x, y);
|
||||||
|
}
|
||||||
|
else if (___onFarm && !___namingAnimal)
|
||||||
|
{
|
||||||
|
firstTimeInNamingMenu = true;
|
||||||
|
}
|
||||||
|
else if (!___onFarm && !___namingAnimal)
|
||||||
|
{
|
||||||
|
firstTimeInNamingMenu = true;
|
||||||
|
narratePurchasingMenu(__instance);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
MainClass.ErrorLog($"Unable to narrate Text:\n{e.Message}\n{e.StackTrace}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void narrateNamingMenu(PurchaseAnimalsMenu __instance, int x, int y)
|
||||||
{
|
{
|
||||||
string toSpeak = "";
|
string toSpeak = "";
|
||||||
if (__instance.okButton != null && __instance.okButton.containsPoint(x, y))
|
if (__instance.okButton != null && __instance.okButton.containsPoint(x, y))
|
||||||
|
@ -45,8 +65,8 @@ namespace stardew_access.Patches
|
||||||
// toSpeak = $"{toSpeak}, Value: {value}";
|
// toSpeak = $"{toSpeak}, Value: {value}";
|
||||||
}
|
}
|
||||||
|
|
||||||
if (purchaseAnimalMenuQuery != toSpeak)
|
if (purchaseAnimalMenuQuery == toSpeak) return;
|
||||||
{
|
|
||||||
purchaseAnimalMenuQuery = toSpeak;
|
purchaseAnimalMenuQuery = toSpeak;
|
||||||
|
|
||||||
if (firstTimeInNamingMenu)
|
if (firstTimeInNamingMenu)
|
||||||
|
@ -57,16 +77,12 @@ namespace stardew_access.Patches
|
||||||
|
|
||||||
MainClass.ScreenReader.Say(toSpeak, true);
|
MainClass.ScreenReader.Say(toSpeak, true);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
else if (___onFarm && !___namingAnimal)
|
private static void narratePurchasingMenu(PurchaseAnimalsMenu __instance)
|
||||||
{
|
|
||||||
firstTimeInNamingMenu = true;
|
|
||||||
}
|
|
||||||
else if (!___onFarm && !___namingAnimal)
|
|
||||||
{
|
|
||||||
firstTimeInNamingMenu = true;
|
|
||||||
if (__instance.hovered != null)
|
|
||||||
{
|
{
|
||||||
|
if (__instance.hovered == null)
|
||||||
|
return;
|
||||||
|
|
||||||
string toSpeak = "";
|
string toSpeak = "";
|
||||||
if (((StardewValley.Object)__instance.hovered.item).Type != null)
|
if (((StardewValley.Object)__instance.hovered.item).Type != null)
|
||||||
{
|
{
|
||||||
|
@ -81,21 +97,17 @@ namespace stardew_access.Patches
|
||||||
toSpeak = $"{displayName}, Price: {price}g, Description: {description}";
|
toSpeak = $"{displayName}, Price: {price}g, Description: {description}";
|
||||||
}
|
}
|
||||||
|
|
||||||
if (purchaseAnimalMenuQuery != toSpeak)
|
if (purchaseAnimalMenuQuery == toSpeak) return;
|
||||||
{
|
|
||||||
purchaseAnimalMenuQuery = toSpeak;
|
purchaseAnimalMenuQuery = toSpeak;
|
||||||
MainClass.ScreenReader.Say(toSpeak, true);
|
MainClass.ScreenReader.Say(toSpeak, true);
|
||||||
}
|
}
|
||||||
return;
|
|
||||||
}
|
internal static void Cleanup()
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
{
|
||||||
MainClass.ErrorLog($"Unable to narrate Text:\n{e.Message}\n{e.StackTrace}");
|
purchaseAnimalMenuQuery = "";
|
||||||
|
firstTimeInNamingMenu = true;
|
||||||
|
purchaseAnimalsMenu = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue