Organised code for purchase animal menu patch
parent
80963c4dc6
commit
6822bd4840
|
@ -273,9 +273,7 @@ namespace stardew_access.Patches
|
|||
}
|
||||
else if (menu is PurchaseAnimalsMenu)
|
||||
{
|
||||
PurchaseAnimalsMenuPatch.purchaseAnimalMenuQuery = "";
|
||||
PurchaseAnimalsMenuPatch.firstTimeInNamingMenu = true;
|
||||
PurchaseAnimalsMenuPatch.purchaseAnimalsMenu = null;
|
||||
PurchaseAnimalsMenuPatch.Cleanup();
|
||||
}
|
||||
else if (menu is AnimalQueryMenu)
|
||||
{
|
||||
|
|
|
@ -24,39 +24,7 @@ namespace stardew_access.Patches
|
|||
|
||||
if (___onFarm && ___namingAnimal)
|
||||
{
|
||||
string toSpeak = "";
|
||||
if (__instance.okButton != null && __instance.okButton.containsPoint(x, y))
|
||||
{
|
||||
toSpeak = "Cancel Button";
|
||||
}
|
||||
else if (__instance.doneNamingButton != null && __instance.doneNamingButton.containsPoint(x, y))
|
||||
{
|
||||
toSpeak = "OK Button";
|
||||
}
|
||||
else if (__instance.randomButton != null && __instance.randomButton.containsPoint(x, y))
|
||||
{
|
||||
toSpeak = "Random Name Button";
|
||||
}
|
||||
else if (__instance.textBoxCC != null && __instance.textBoxCC.containsPoint(x, y))
|
||||
{
|
||||
toSpeak = "Name Text Box";
|
||||
// string? value = ___textBox.Text;
|
||||
// if (value != "" && value != null && value != "null")
|
||||
// toSpeak = $"{toSpeak}, Value: {value}";
|
||||
}
|
||||
|
||||
if (purchaseAnimalMenuQuery != toSpeak)
|
||||
{
|
||||
purchaseAnimalMenuQuery = toSpeak;
|
||||
|
||||
if (firstTimeInNamingMenu)
|
||||
{
|
||||
toSpeak = $"Enter the name of animal in the name text box. {toSpeak}";
|
||||
firstTimeInNamingMenu = false;
|
||||
}
|
||||
|
||||
MainClass.ScreenReader.Say(toSpeak, true);
|
||||
}
|
||||
narrateNamingMenu(__instance, x, y);
|
||||
}
|
||||
else if (___onFarm && !___namingAnimal)
|
||||
{
|
||||
|
@ -65,29 +33,7 @@ namespace stardew_access.Patches
|
|||
else if (!___onFarm && !___namingAnimal)
|
||||
{
|
||||
firstTimeInNamingMenu = true;
|
||||
if (__instance.hovered != null)
|
||||
{
|
||||
string toSpeak = "";
|
||||
if (((StardewValley.Object)__instance.hovered.item).Type != null)
|
||||
{
|
||||
toSpeak = ((StardewValley.Object)__instance.hovered.item).Type;
|
||||
}
|
||||
else
|
||||
{
|
||||
string displayName = PurchaseAnimalsMenu.getAnimalTitle(__instance.hovered.hoverText);
|
||||
int price = __instance.hovered.item.salePrice();
|
||||
string description = PurchaseAnimalsMenu.getAnimalDescription(__instance.hovered.hoverText);
|
||||
|
||||
toSpeak = $"{displayName}, Price: {price}g, Description: {description}";
|
||||
}
|
||||
|
||||
if (purchaseAnimalMenuQuery != toSpeak)
|
||||
{
|
||||
purchaseAnimalMenuQuery = toSpeak;
|
||||
MainClass.ScreenReader.Say(toSpeak, true);
|
||||
}
|
||||
return;
|
||||
}
|
||||
narratePurchasingMenu(__instance);
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
|
@ -96,6 +42,72 @@ namespace stardew_access.Patches
|
|||
}
|
||||
}
|
||||
|
||||
private static void narrateNamingMenu(PurchaseAnimalsMenu __instance, int x, int y)
|
||||
{
|
||||
string toSpeak = "";
|
||||
if (__instance.okButton != null && __instance.okButton.containsPoint(x, y))
|
||||
{
|
||||
toSpeak = "Cancel Button";
|
||||
}
|
||||
else if (__instance.doneNamingButton != null && __instance.doneNamingButton.containsPoint(x, y))
|
||||
{
|
||||
toSpeak = "OK Button";
|
||||
}
|
||||
else if (__instance.randomButton != null && __instance.randomButton.containsPoint(x, y))
|
||||
{
|
||||
toSpeak = "Random Name Button";
|
||||
}
|
||||
else if (__instance.textBoxCC != null && __instance.textBoxCC.containsPoint(x, y))
|
||||
{
|
||||
toSpeak = "Name Text Box";
|
||||
// string? value = ___textBox.Text;
|
||||
// if (value != "" && value != null && value != "null")
|
||||
// toSpeak = $"{toSpeak}, Value: {value}";
|
||||
}
|
||||
|
||||
if (purchaseAnimalMenuQuery == toSpeak) return;
|
||||
|
||||
purchaseAnimalMenuQuery = toSpeak;
|
||||
|
||||
if (firstTimeInNamingMenu)
|
||||
{
|
||||
toSpeak = $"Enter the name of animal in the name text box. {toSpeak}";
|
||||
firstTimeInNamingMenu = false;
|
||||
}
|
||||
|
||||
MainClass.ScreenReader.Say(toSpeak, true);
|
||||
}
|
||||
|
||||
private static void narratePurchasingMenu(PurchaseAnimalsMenu __instance)
|
||||
{
|
||||
if (__instance.hovered == null)
|
||||
return;
|
||||
|
||||
string toSpeak = "";
|
||||
if (((StardewValley.Object)__instance.hovered.item).Type != null)
|
||||
{
|
||||
toSpeak = ((StardewValley.Object)__instance.hovered.item).Type;
|
||||
}
|
||||
else
|
||||
{
|
||||
string displayName = PurchaseAnimalsMenu.getAnimalTitle(__instance.hovered.hoverText);
|
||||
int price = __instance.hovered.item.salePrice();
|
||||
string description = PurchaseAnimalsMenu.getAnimalDescription(__instance.hovered.hoverText);
|
||||
|
||||
toSpeak = $"{displayName}, Price: {price}g, Description: {description}";
|
||||
}
|
||||
|
||||
if (purchaseAnimalMenuQuery == toSpeak) return;
|
||||
|
||||
purchaseAnimalMenuQuery = toSpeak;
|
||||
MainClass.ScreenReader.Say(toSpeak, true);
|
||||
}
|
||||
|
||||
internal static void Cleanup()
|
||||
{
|
||||
purchaseAnimalMenuQuery = "";
|
||||
firstTimeInNamingMenu = true;
|
||||
purchaseAnimalsMenu = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue