From ec08f2c0191a55d93c8c49a92a35fb3dc101086f Mon Sep 17 00:00:00 2001 From: Mohammad Shoaib Date: Thu, 3 Feb 2022 16:42:58 +0530 Subject: [PATCH] Added buildlist command --- stardew-access/CustomCommands.cs | 11 +++++++++-- stardew-access/Features/ReadTile.cs | 2 +- stardew-access/Patches/BuildingNAnimalMenuPatches.cs | 2 ++ stardew-access/Patches/ChatManuPatches.cs | 8 ++++---- 4 files changed, 16 insertions(+), 7 deletions(-) diff --git a/stardew-access/CustomCommands.cs b/stardew-access/CustomCommands.cs index 229a12c..16761af 100644 --- a/stardew-access/CustomCommands.cs +++ b/stardew-access/CustomCommands.cs @@ -342,9 +342,16 @@ namespace stardew_access string toPrint = ""; Farm farm = (Farm)Game1.getLocationFromName("Farm"); Netcode.NetCollection buildings = farm.buildings; + int buildingIndex = 0; + for (int i = 0; i < buildings.Count; i++) { - toPrint = $"{toPrint},\t{buildings[i].nameOfIndoorsWithoutUnique}: At {buildings[i].tileX}x and {buildings[i].tileY}y"; + string? name = buildings[i].nameOfIndoorsWithoutUnique; + name = (name == "null") ? buildings[i].buildingType.Value : name; + + BuildingNAnimalMenuPatches.availableBuildings[buildingIndex] = buildings[i]; + toPrint = $"{toPrint}\nIndex {buildingIndex}: {name}: At {buildings[i].tileX}x and {buildings[i].tileY}y"; + ++buildingIndex; } if (toPrint == "") @@ -353,7 +360,7 @@ namespace stardew_access } else { - MainClass.monitor.Log($"Available buildings: {toPrint}", LogLevel.Info); + MainClass.monitor.Log($"Available buildings:{toPrint}\nOpen the command menu and use pageup and pagedown to check the list", LogLevel.Info); } }); #endregion diff --git a/stardew-access/Features/ReadTile.cs b/stardew-access/Features/ReadTile.cs index 5e8ed34..09526a1 100644 --- a/stardew-access/Features/ReadTile.cs +++ b/stardew-access/Features/ReadTile.cs @@ -268,7 +268,7 @@ namespace stardew_access.Game if (Game1.currentLocation is Farm) { - Building building = (Game1.currentLocation as Farm).getBuildingAt(new Vector2(x, y)); + Building building = ((Farm)Game1.currentLocation).getBuildingAt(new Vector2(x, y)); if (building != null) { return (CATEGORY.Buildings, building.buildingType.Value); diff --git a/stardew-access/Patches/BuildingNAnimalMenuPatches.cs b/stardew-access/Patches/BuildingNAnimalMenuPatches.cs index f629900..268e573 100644 --- a/stardew-access/Patches/BuildingNAnimalMenuPatches.cs +++ b/stardew-access/Patches/BuildingNAnimalMenuPatches.cs @@ -1,6 +1,7 @@ using Microsoft.Xna.Framework; using StardewModdingAPI; using StardewValley; +using StardewValley.Buildings; using StardewValley.Menus; namespace stardew_access.Patches @@ -8,6 +9,7 @@ namespace stardew_access.Patches internal class BuildingNAnimalMenuPatches { internal static Vector2[] marked = new Vector2[10]; + internal static Building[] availableBuildings = new Building[100]; internal static string carpenterMenuQuery = ""; internal static bool isSayingBlueprintInfo = false; internal static string prevBlueprintInfo = ""; diff --git a/stardew-access/Patches/ChatManuPatches.cs b/stardew-access/Patches/ChatManuPatches.cs index adec1ba..fb15a2b 100644 --- a/stardew-access/Patches/ChatManuPatches.cs +++ b/stardew-access/Patches/ChatManuPatches.cs @@ -25,11 +25,11 @@ namespace stardew_access.Patches #region To narrate previous and next chat messages if (isNextArrowPressed && !isChatRunning) { - _ = CycleThroughChatMessages(true, ___messages); + CycleThroughChatMessages(true, ___messages); } else if (isPrevArrowPressed && !isChatRunning) { - _ = CycleThroughChatMessages(false, ___messages); + CycleThroughChatMessages(false, ___messages); } #endregion } @@ -52,10 +52,9 @@ namespace stardew_access.Patches } } - private static async Task CycleThroughChatMessages(bool increase, List ___messages) + private static async void CycleThroughChatMessages(bool increase, List ___messages) { isChatRunning = true; - await Task.Delay(200); string toSpeak = " "; if (increase) { @@ -79,6 +78,7 @@ namespace stardew_access.Patches }); MainClass.screenReader.Say(toSpeak, true); + await Task.Delay(200); isChatRunning = false; } }