Fixed move animal to different building
parent
9c1a185047
commit
e534a6aed9
|
@ -347,7 +347,7 @@ namespace stardew_access
|
||||||
|
|
||||||
helper.ConsoleCommands.Add("buildlist", "List all buildings for selection for upgrading/demolishing/painting", (string commmand, string[] args) =>
|
helper.ConsoleCommands.Add("buildlist", "List all buildings for selection for upgrading/demolishing/painting", (string commmand, string[] args) =>
|
||||||
{
|
{
|
||||||
if ((Game1.activeClickableMenu is not CarpenterMenu && Game1.activeClickableMenu is not PurchaseAnimalsMenu) || !BuildingNAnimalMenuPatches.isOnFarm)
|
if ((Game1.activeClickableMenu is not CarpenterMenu && Game1.activeClickableMenu is not PurchaseAnimalsMenu && Game1.activeClickableMenu is not AnimalQueryMenu) || !BuildingNAnimalMenuPatches.isOnFarm)
|
||||||
{
|
{
|
||||||
MainClass.DebugLog($"Cannot list buildings.");
|
MainClass.DebugLog($"Cannot list buildings.");
|
||||||
return;
|
return;
|
||||||
|
@ -380,7 +380,7 @@ namespace stardew_access
|
||||||
|
|
||||||
helper.ConsoleCommands.Add("buildsel", "Select the building index which you want to upgrade/demolish/paint", (string commmand, string[] args) =>
|
helper.ConsoleCommands.Add("buildsel", "Select the building index which you want to upgrade/demolish/paint", (string commmand, string[] args) =>
|
||||||
{
|
{
|
||||||
if ((Game1.activeClickableMenu is not CarpenterMenu && Game1.activeClickableMenu is not PurchaseAnimalsMenu) || !BuildingNAnimalMenuPatches.isOnFarm)
|
if ((Game1.activeClickableMenu is not CarpenterMenu && Game1.activeClickableMenu is not PurchaseAnimalsMenu && Game1.activeClickableMenu is not AnimalQueryMenu) || !BuildingNAnimalMenuPatches.isOnFarm)
|
||||||
{
|
{
|
||||||
MainClass.DebugLog($"Cannot select building.");
|
MainClass.DebugLog($"Cannot select building.");
|
||||||
return;
|
return;
|
||||||
|
@ -450,7 +450,14 @@ namespace stardew_access
|
||||||
|
|
||||||
string? response = null;
|
string? response = null;
|
||||||
|
|
||||||
if (Game1.activeClickableMenu is PurchaseAnimalsMenu) { BuildingNAnimalMenuPatches.PurchaseAnimal(BuildingNAnimalMenuPatches.availableBuildings[index]); }
|
if (Game1.activeClickableMenu is PurchaseAnimalsMenu)
|
||||||
|
{
|
||||||
|
BuildingNAnimalMenuPatches.PurchaseOrMoveAnimal(BuildingNAnimalMenuPatches.availableBuildings[index]);
|
||||||
|
}
|
||||||
|
else if (Game1.activeClickableMenu is AnimalQueryMenu)
|
||||||
|
{
|
||||||
|
BuildingNAnimalMenuPatches.PurchaseOrMoveAnimal(BuildingNAnimalMenuPatches.availableBuildings[index]);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (BuildingNAnimalMenuPatches.isConstructing && !BuildingNAnimalMenuPatches.isUpgrading) { response = BuildingNAnimalMenuPatches.Contstruct(BuildingNAnimalMenuPatches.marked[index]); }
|
if (BuildingNAnimalMenuPatches.isConstructing && !BuildingNAnimalMenuPatches.isUpgrading) { response = BuildingNAnimalMenuPatches.Contstruct(BuildingNAnimalMenuPatches.marked[index]); }
|
||||||
|
|
|
@ -162,11 +162,6 @@ namespace stardew_access
|
||||||
prefix: new HarmonyMethod(typeof(DonationMenuPatches), nameof(DonationMenuPatches.MuseumMenuKeyPressPatch))
|
prefix: new HarmonyMethod(typeof(DonationMenuPatches), nameof(DonationMenuPatches.MuseumMenuKeyPressPatch))
|
||||||
);
|
);
|
||||||
|
|
||||||
harmony.Patch(
|
|
||||||
original: AccessTools.Method(typeof(AnimalQueryMenu), nameof(AnimalQueryMenu.draw), new Type[] { typeof(SpriteBatch) }),
|
|
||||||
postfix: new HarmonyMethod(typeof(MenuPatches), nameof(MenuPatches.AnimalQueryMenuPatch))
|
|
||||||
);
|
|
||||||
|
|
||||||
harmony.Patch(
|
harmony.Patch(
|
||||||
original: AccessTools.Method(typeof(ChooseFromListMenu), nameof(ChooseFromListMenu.draw), new Type[] { typeof(SpriteBatch) }),
|
original: AccessTools.Method(typeof(ChooseFromListMenu), nameof(ChooseFromListMenu.draw), new Type[] { typeof(SpriteBatch) }),
|
||||||
postfix: new HarmonyMethod(typeof(MenuPatches), nameof(MenuPatches.ChooseFromListMenuPatch))
|
postfix: new HarmonyMethod(typeof(MenuPatches), nameof(MenuPatches.ChooseFromListMenuPatch))
|
||||||
|
@ -240,6 +235,11 @@ namespace stardew_access
|
||||||
prefix: new HarmonyMethod(typeof(BuildingNAnimalMenuPatches), nameof(BuildingNAnimalMenuPatches.PurchaseAnimalsMenuPatch))
|
prefix: new HarmonyMethod(typeof(BuildingNAnimalMenuPatches), nameof(BuildingNAnimalMenuPatches.PurchaseAnimalsMenuPatch))
|
||||||
);
|
);
|
||||||
|
|
||||||
|
harmony.Patch(
|
||||||
|
original: AccessTools.Method(typeof(AnimalQueryMenu), nameof(AnimalQueryMenu.draw), new Type[] { typeof(SpriteBatch) }),
|
||||||
|
postfix: new HarmonyMethod(typeof(BuildingNAnimalMenuPatches), nameof(BuildingNAnimalMenuPatches.AnimalQueryMenuPatch))
|
||||||
|
);
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Donation Menus
|
#region Donation Menus
|
||||||
|
|
|
@ -12,20 +12,100 @@ namespace stardew_access.Patches
|
||||||
internal static Vector2[] marked = new Vector2[10];
|
internal static Vector2[] marked = new Vector2[10];
|
||||||
internal static Building?[] availableBuildings = new Building[100];
|
internal static Building?[] availableBuildings = new Building[100];
|
||||||
internal static CarpenterMenu? carpenterMenu = null;
|
internal static CarpenterMenu? carpenterMenu = null;
|
||||||
|
internal static bool isNarratingAnimalInfo = false;
|
||||||
|
internal static string animalQueryMenuQuery = " ";
|
||||||
internal static string carpenterMenuQuery = "", purchaseAnimalMenuQuery = "";
|
internal static string carpenterMenuQuery = "", purchaseAnimalMenuQuery = "";
|
||||||
internal static bool isSayingBlueprintInfo = false;
|
internal static bool isSayingBlueprintInfo = false;
|
||||||
internal static string prevBlueprintInfo = "";
|
internal static string prevBlueprintInfo = "";
|
||||||
internal static bool isOnFarm = false, isUpgrading = false, isDemolishing = false, isPainting = false, isConstructing = false, isMoving = false, isMagicalConstruction = false;
|
internal static bool isOnFarm = false, isUpgrading = false, isDemolishing = false, isPainting = false, isConstructing = false, isMoving = false, isMagicalConstruction = false;
|
||||||
internal static bool firstTimeInNamingMenu = true;
|
internal static bool firstTimeInNamingMenu = true;
|
||||||
internal static PurchaseAnimalsMenu? purchaseAnimalsMenu;
|
internal static PurchaseAnimalsMenu? purchaseAnimalsMenu;
|
||||||
|
internal static AnimalQueryMenu? animalQueryMenu;
|
||||||
|
private static FarmAnimal? animalBeingPurchasedOrMoved = null;
|
||||||
|
|
||||||
internal static void PurchaseAnimalsMenuPatch(PurchaseAnimalsMenu __instance, bool ___onFarm, bool ___namingAnimal, TextBox ___textBox)
|
internal static void AnimalQueryMenuPatch(AnimalQueryMenu __instance, bool ___confirmingSell, FarmAnimal ___animal, TextBox ___textBox, string ___parentName, bool ___movingAnimal)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
int x = Game1.getMouseX(true), y = Game1.getMouseY(true); // Mouse x and y position
|
||||||
|
bool isCPressed = MainClass.Config.PrimaryInfoKey.JustPressed(); // For narrating animal details
|
||||||
|
bool isEscPressed = Game1.input.GetKeyboardState().IsKeyDown(Microsoft.Xna.Framework.Input.Keys.Escape); // For escaping/unselecting from the animal name text box
|
||||||
|
string toSpeak = " ", details = " ";
|
||||||
|
|
||||||
|
isOnFarm = ___movingAnimal;
|
||||||
|
animalQueryMenu = __instance;
|
||||||
|
animalBeingPurchasedOrMoved = ___animal;
|
||||||
|
|
||||||
|
if (___textBox.Selected)
|
||||||
|
{
|
||||||
|
toSpeak = ___textBox.Text;
|
||||||
|
|
||||||
|
if (isEscPressed)
|
||||||
|
{
|
||||||
|
___textBox.Selected = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (isCPressed & !isNarratingAnimalInfo)
|
||||||
|
{
|
||||||
|
string name = ___animal.displayName;
|
||||||
|
string type = ___animal.displayType;
|
||||||
|
int age = (___animal.GetDaysOwned() + 1) / 28 + 1;
|
||||||
|
string ageText = (age <= 1) ? Game1.content.LoadString("Strings\\UI:AnimalQuery_Age1") : Game1.content.LoadString("Strings\\UI:AnimalQuery_AgeN", age);
|
||||||
|
string parent = "";
|
||||||
|
if ((int)___animal.age.Value < (byte)___animal.ageWhenMature.Value)
|
||||||
|
{
|
||||||
|
ageText += Game1.content.LoadString("Strings\\UI:AnimalQuery_AgeBaby");
|
||||||
|
}
|
||||||
|
if (___parentName != null)
|
||||||
|
{
|
||||||
|
parent = Game1.content.LoadString("Strings\\UI:AnimalQuery_Parent", ___parentName);
|
||||||
|
}
|
||||||
|
|
||||||
|
details = $"Name: {name} Type: {type} \n\t Age: {ageText} {parent}";
|
||||||
|
animalQueryMenuQuery = " ";
|
||||||
|
|
||||||
|
isNarratingAnimalInfo = true;
|
||||||
|
Task.Delay(200).ContinueWith(_ => { isNarratingAnimalInfo = false; });
|
||||||
|
}
|
||||||
|
|
||||||
|
if (__instance.okButton != null && __instance.okButton.containsPoint(x, y))
|
||||||
|
toSpeak = "OK button";
|
||||||
|
else if (__instance.sellButton != null && __instance.sellButton.containsPoint(x, y))
|
||||||
|
toSpeak = $"Sell for {___animal.getSellPrice()}g button";
|
||||||
|
else if (___confirmingSell && __instance.yesButton != null && __instance.yesButton.containsPoint(x, y))
|
||||||
|
toSpeak = "Confirm selling animal";
|
||||||
|
else if (___confirmingSell && __instance.noButton != null && __instance.noButton.containsPoint(x, y))
|
||||||
|
toSpeak = "Cancel selling animal";
|
||||||
|
else if (__instance.moveHomeButton != null && __instance.moveHomeButton.containsPoint(x, y))
|
||||||
|
toSpeak = "Change home building button";
|
||||||
|
else if (__instance.allowReproductionButton != null && __instance.allowReproductionButton.containsPoint(x, y))
|
||||||
|
toSpeak = ((___animal.allowReproduction.Value) ? "Enabled" : "Disabled") + " allow reproduction button";
|
||||||
|
else if (__instance.textBoxCC != null && __instance.textBoxCC.containsPoint(x, y))
|
||||||
|
toSpeak = "Animal name text box";
|
||||||
|
}
|
||||||
|
|
||||||
|
if (animalQueryMenuQuery != toSpeak)
|
||||||
|
{
|
||||||
|
animalQueryMenuQuery = toSpeak;
|
||||||
|
MainClass.ScreenReader.Say($"{details} {toSpeak}", true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (System.Exception e)
|
||||||
|
{
|
||||||
|
MainClass.ErrorLog($"Unable to narrate Text:\n{e.Message}\n{e.StackTrace}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
internal static void PurchaseAnimalsMenuPatch(PurchaseAnimalsMenu __instance, bool ___onFarm, bool ___namingAnimal, TextBox ___textBox, FarmAnimal ___animalBeingPurchased)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
int x = Game1.getMouseX(true), y = Game1.getMouseY(true); // Mouse x and y position
|
int x = Game1.getMouseX(true), y = Game1.getMouseY(true); // Mouse x and y position
|
||||||
purchaseAnimalsMenu = __instance;
|
purchaseAnimalsMenu = __instance;
|
||||||
isOnFarm = ___onFarm;
|
isOnFarm = ___onFarm;
|
||||||
|
animalBeingPurchasedOrMoved = ___animalBeingPurchased;
|
||||||
|
|
||||||
if (___onFarm && ___namingAnimal)
|
if (___onFarm && ___namingAnimal)
|
||||||
{
|
{
|
||||||
|
@ -557,17 +637,59 @@ namespace stardew_access.Patches
|
||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void PurchaseAnimal(Building? selection)
|
public static void PurchaseOrMoveAnimal(Building? selection)
|
||||||
{
|
{
|
||||||
if (selection == null)
|
if (selection == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (purchaseAnimalsMenu == null)
|
if (purchaseAnimalsMenu == null && animalQueryMenu == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
int x = (selection.tileX.Value * Game1.tileSize) - Game1.viewport.X;
|
int x = (selection.tileX.Value * Game1.tileSize) - Game1.viewport.X;
|
||||||
int y = (selection.tileY.Value * Game1.tileSize) - Game1.viewport.Y;
|
int y = (selection.tileY.Value * Game1.tileSize) - Game1.viewport.Y;
|
||||||
purchaseAnimalsMenu.receiveLeftClick(x, y);
|
|
||||||
|
if (purchaseAnimalsMenu != null)
|
||||||
|
{
|
||||||
|
if (animalBeingPurchasedOrMoved != null && !selection.buildingType.Value.Contains(animalBeingPurchasedOrMoved.buildingTypeILiveIn.Value))
|
||||||
|
{
|
||||||
|
string warn = Game1.content.LoadString("Strings\\StringsFromCSFiles:PurchaseAnimalsMenu.cs.11326", animalBeingPurchasedOrMoved.displayType);
|
||||||
|
MainClass.ScreenReader.Say(warn, true);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (((AnimalHouse)selection.indoors.Value).isFull())
|
||||||
|
{
|
||||||
|
string warn = Game1.content.LoadString("Strings\\StringsFromCSFiles:PurchaseAnimalsMenu.cs.11321");
|
||||||
|
MainClass.ScreenReader.Say(warn, true);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
purchaseAnimalsMenu.receiveLeftClick(x, y);
|
||||||
|
}
|
||||||
|
else if (animalQueryMenu != null)
|
||||||
|
{
|
||||||
|
if (animalBeingPurchasedOrMoved != null && !selection.buildingType.Value.Contains(animalBeingPurchasedOrMoved.buildingTypeILiveIn.Value))
|
||||||
|
{
|
||||||
|
string warn = Game1.content.LoadString("Strings\\UI:AnimalQuery_Moving_CantLiveThere", animalBeingPurchasedOrMoved.shortDisplayType());
|
||||||
|
MainClass.ScreenReader.Say(warn, true);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (((AnimalHouse)selection.indoors.Value).isFull())
|
||||||
|
{
|
||||||
|
string warn = Game1.content.LoadString("Strings\\UI:AnimalQuery_Moving_BuildingFull");
|
||||||
|
MainClass.ScreenReader.Say(warn, true);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (animalBeingPurchasedOrMoved != null && selection.Equals(animalBeingPurchasedOrMoved.home))
|
||||||
|
{
|
||||||
|
string warn = Game1.content.LoadString("Strings\\UI:AnimalQuery_Moving_AlreadyHome");
|
||||||
|
MainClass.ScreenReader.Say(warn, true);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
animalQueryMenu.receiveLeftClick(x, y);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -12,8 +12,6 @@ namespace stardew_access.Patches
|
||||||
internal static string currentLevelUpTitle = " ";
|
internal static string currentLevelUpTitle = " ";
|
||||||
internal static bool firstTimeInNamingMenu = true;
|
internal static bool firstTimeInNamingMenu = true;
|
||||||
internal static bool isNarratingPondInfo = false;
|
internal static bool isNarratingPondInfo = false;
|
||||||
internal static bool isNarratingAnimalInfo = false;
|
|
||||||
internal static string animalQueryMenuQuery = " ";
|
|
||||||
internal static string tailoringMenuQuery = " ";
|
internal static string tailoringMenuQuery = " ";
|
||||||
internal static string pondQueryMenuQuery = " ";
|
internal static string pondQueryMenuQuery = " ";
|
||||||
internal static string forgeMenuQuery = " ";
|
internal static string forgeMenuQuery = " ";
|
||||||
|
@ -350,77 +348,6 @@ namespace stardew_access.Patches
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
internal static void AnimalQueryMenuPatch(AnimalQueryMenu __instance, bool ___confirmingSell, FarmAnimal ___animal, TextBox ___textBox, string ___parentName)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
int x = Game1.getMouseX(true), y = Game1.getMouseY(true); // Mouse x and y position
|
|
||||||
bool isCPressed = MainClass.Config.PrimaryInfoKey.JustPressed(); // For narrating animal details
|
|
||||||
bool isEscPressed = Game1.input.GetKeyboardState().IsKeyDown(Microsoft.Xna.Framework.Input.Keys.Escape); // For escaping/unselecting from the animal name text box
|
|
||||||
string toSpeak = " ", details = " ";
|
|
||||||
|
|
||||||
if (___textBox.Selected)
|
|
||||||
{
|
|
||||||
toSpeak = ___textBox.Text;
|
|
||||||
|
|
||||||
if (isEscPressed)
|
|
||||||
{
|
|
||||||
___textBox.Selected = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (isCPressed & !isNarratingAnimalInfo)
|
|
||||||
{
|
|
||||||
string name = ___animal.displayName;
|
|
||||||
string type = ___animal.displayType;
|
|
||||||
int age = (___animal.GetDaysOwned() + 1) / 28 + 1;
|
|
||||||
string ageText = (age <= 1) ? Game1.content.LoadString("Strings\\UI:AnimalQuery_Age1") : Game1.content.LoadString("Strings\\UI:AnimalQuery_AgeN", age);
|
|
||||||
string parent = "";
|
|
||||||
if ((int)___animal.age.Value < (byte)___animal.ageWhenMature.Value)
|
|
||||||
{
|
|
||||||
ageText += Game1.content.LoadString("Strings\\UI:AnimalQuery_AgeBaby");
|
|
||||||
}
|
|
||||||
if (___parentName != null)
|
|
||||||
{
|
|
||||||
parent = Game1.content.LoadString("Strings\\UI:AnimalQuery_Parent", ___parentName);
|
|
||||||
}
|
|
||||||
|
|
||||||
details = $"Name: {name} Type: {type} \n\t Age: {ageText} {parent}";
|
|
||||||
animalQueryMenuQuery = " ";
|
|
||||||
|
|
||||||
isNarratingAnimalInfo = true;
|
|
||||||
Task.Delay(200).ContinueWith(_ => { isNarratingAnimalInfo = false; });
|
|
||||||
}
|
|
||||||
|
|
||||||
if (__instance.okButton != null && __instance.okButton.containsPoint(x, y))
|
|
||||||
toSpeak = "OK button";
|
|
||||||
else if (__instance.sellButton != null && __instance.sellButton.containsPoint(x, y))
|
|
||||||
toSpeak = $"Sell for {___animal.getSellPrice()}g button";
|
|
||||||
else if (___confirmingSell && __instance.yesButton != null && __instance.yesButton.containsPoint(x, y))
|
|
||||||
toSpeak = "Confirm selling animal";
|
|
||||||
else if (___confirmingSell && __instance.noButton != null && __instance.noButton.containsPoint(x, y))
|
|
||||||
toSpeak = "Cancel selling animal";
|
|
||||||
else if (__instance.moveHomeButton != null && __instance.moveHomeButton.containsPoint(x, y))
|
|
||||||
toSpeak = "Change home building button";
|
|
||||||
else if (__instance.allowReproductionButton != null && __instance.allowReproductionButton.containsPoint(x, y))
|
|
||||||
toSpeak = ((___animal.allowReproduction.Value) ? "Enabled" : "Disabled") + " allow reproduction button";
|
|
||||||
else if (__instance.textBoxCC != null && __instance.textBoxCC.containsPoint(x, y))
|
|
||||||
toSpeak = "Animal name text box";
|
|
||||||
}
|
|
||||||
|
|
||||||
if (animalQueryMenuQuery != toSpeak)
|
|
||||||
{
|
|
||||||
animalQueryMenuQuery = toSpeak;
|
|
||||||
MainClass.ScreenReader.Say($"{details} {toSpeak}", true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (System.Exception e)
|
|
||||||
{
|
|
||||||
MainClass.ErrorLog($"Unable to narrate Text:\n{e.Message}\n{e.StackTrace}");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
internal static bool PlaySoundPatch(string cueName)
|
internal static bool PlaySoundPatch(string cueName)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
|
|
Loading…
Reference in New Issue