From d3d7e1c2aa4ba63757f99b6095b84f19bc1b7b5c Mon Sep 17 00:00:00 2001 From: Mohammad Shoaib Date: Tue, 1 Feb 2022 12:50:40 +0530 Subject: [PATCH] Added social page accessibility --- stardew-access/Features/Radar.cs | 38 ++-- stardew-access/HarmonyPatches.cs | 5 + stardew-access/ModEntry.cs | 2 +- stardew-access/Patches/GameMenuPatches.cs | 193 ++++++++++++++++++--- stardew-access/Patches/MenuPatches.cs | 37 ++-- stardew-access/Patches/QuestPatches.cs | 4 +- stardew-access/Patches/TitleMenuPatches.cs | 20 +-- 7 files changed, 218 insertions(+), 81 deletions(-) diff --git a/stardew-access/Features/Radar.cs b/stardew-access/Features/Radar.cs index efac4c2..0a39466 100644 --- a/stardew-access/Features/Radar.cs +++ b/stardew-access/Features/Radar.cs @@ -2,7 +2,6 @@ using StardewValley; using StardewValley.Objects; using StardewValley.TerrainFeatures; -using System.Diagnostics; namespace stardew_access.Game { @@ -31,7 +30,7 @@ namespace stardew_access.Game public static CATEGORY Flooring = new CATEGORY("flooring"); public static CATEGORY Grass = new CATEGORY("grass"); public static CATEGORY Crops = new CATEGORY("crop"); - public static CATEGORY Trees = new CATEGORY("tree") ; + public static CATEGORY Trees = new CATEGORY("tree"); public static CATEGORY Buildings = new CATEGORY("building"); public static CATEGORY MineItems = new CATEGORY("mine item"); public static CATEGORY Chests = new CATEGORY("chest"); @@ -95,10 +94,7 @@ namespace stardew_access.Game public async void Run() { - Stopwatch sw = new Stopwatch(); - sw.Start(); - - if(MainClass.radarDebug) + if (MainClass.radarDebug) MainClass.monitor.Log($"\n\nRead Tile started", StardewModdingAPI.LogLevel.Debug); isRunning = true; @@ -110,11 +106,9 @@ namespace stardew_access.Game BFS(currPosition, range); - if(MainClass.radarDebug) + if (MainClass.radarDebug) MainClass.monitor.Log($"\nRead Tile stopped\n\n", StardewModdingAPI.LogLevel.Debug); - sw.Stop(); - MainClass.monitor.Log($"Time:{sw.ElapsedMilliseconds}ms", StardewModdingAPI.LogLevel.Debug); await Task.Delay(delay); isRunning = false; } @@ -128,8 +122,8 @@ namespace stardew_access.Game { Queue toSearch = new Queue(); List searched = new List(); - int []dirX = { -1, 0, 1, 0 }; - int []dirY = { 0, 1, 0, -1 }; + int[] dirX = { -1, 0, 1, 0 }; + int[] dirY = { 0, 1, 0, -1 }; int count = 0; toSearch.Enqueue(center); @@ -141,9 +135,9 @@ namespace stardew_access.Game CheckTile(item); count++; - for(int i = 0; i < 4; i++) + for (int i = 0; i < 4; i++) { - Vector2 dir = new Vector2(item.X+dirX[i], item.Y+dirY[i]); + Vector2 dir = new Vector2(item.X + dirX[i], item.Y + dirY[i]); if (isValid(dir, center, searched, limit)) { @@ -170,7 +164,7 @@ namespace stardew_access.Game if (Math.Abs(item.Y - center.Y) > limit) return false; - if(searched.Contains(item)) + if (searched.Contains(item)) return false; return true; @@ -223,7 +217,7 @@ namespace stardew_access.Game PlaySoundAt(position, objectName, CATEGORY.Furnitures); } } - else if(obj is Chest) + else if (obj is Chest) { PlaySoundAt(position, objectName, CATEGORY.Chests); } @@ -231,7 +225,7 @@ namespace stardew_access.Game { bool isMineItem = false; - if(objectName.Contains("node") || objectName.Contains("mystic stone") || objectName.Contains("jade stone")) + if (objectName.Contains("node") || objectName.Contains("mystic stone") || objectName.Contains("jade stone")) isMineItem = true; else if (objectName.Contains("geode") || objectName.Contains("mine stone") || objectName.Contains("barrel") || objectName.Contains("item box")) isMineItem = true; @@ -338,7 +332,7 @@ namespace stardew_access.Game if (!radarFocus && (exclusions.Contains(category.ToString().ToLower().Trim()) || exclusions.Contains(searchQuery.ToLower().Trim()))) return; - if (radarFocus && !(focus.Contains(category.ToString().ToLower().Trim()) || focus.Contains(searchQuery.ToLower().Trim())) ) + if (radarFocus && !(focus.Contains(category.ToString().ToLower().Trim()) || focus.Contains(searchQuery.ToLower().Trim()))) return; if (MainClass.radarDebug) @@ -376,18 +370,18 @@ namespace stardew_access.Game { string soundName = $"_{post}"; - if(!MainClass.radarStereoSound) + if (!MainClass.radarStereoSound) soundName = $"_mono{soundName}"; - if(category == CATEGORY.Farmers) // Villagers and farmers + if (category == CATEGORY.Farmers) // Villagers and farmers soundName = $"npc{soundName}"; else if (category == CATEGORY.FarmAnimals) // Farm Animals soundName = $"npc{soundName}"; - else if(category == CATEGORY.NPCs) // Other npcs, also includes enemies + else if (category == CATEGORY.NPCs) // Other npcs, also includes enemies soundName = $"npc{soundName}"; - else if(category == CATEGORY.WaterTiles) // Water tiles + else if (category == CATEGORY.WaterTiles) // Water tiles soundName = $"obj{soundName}"; - else if(category == CATEGORY.Furnitures) // Furnitures + else if (category == CATEGORY.Furnitures) // Furnitures soundName = $"obj{soundName}"; else if (category == CATEGORY.Others) // Other Objects soundName = $"obj{soundName}"; diff --git a/stardew-access/HarmonyPatches.cs b/stardew-access/HarmonyPatches.cs index 96fddaa..0f0633f 100644 --- a/stardew-access/HarmonyPatches.cs +++ b/stardew-access/HarmonyPatches.cs @@ -90,6 +90,11 @@ namespace stardew_access original: AccessTools.Method(typeof(ShopMenu), nameof(ShopMenu.draw), new Type[] { typeof(SpriteBatch) }), postfix: new HarmonyMethod(typeof(GameMenuPatches), nameof(GameMenuPatches.ShopMenuPatch)) ); + + harmony.Patch( + original: AccessTools.Method(typeof(SocialPage), nameof(SocialPage.draw), new Type[] { typeof(SpriteBatch) }), + postfix: new HarmonyMethod(typeof(GameMenuPatches), nameof(GameMenuPatches.SocialPagePatch)) + ); #endregion #region Menu Patches diff --git a/stardew-access/ModEntry.cs b/stardew-access/ModEntry.cs index 16fcba2..d578003 100644 --- a/stardew-access/ModEntry.cs +++ b/stardew-access/ModEntry.cs @@ -20,7 +20,7 @@ namespace stardew_access public static bool radarDebug = false; public static bool radarStereoSound = true; public static IMonitor monitor; - private AutoHotkeyEngine? ahk; + private AutoHotkeyEngine ahk; public static string hudMessageQueryKey = ""; public static Radar radarFeature; public static ScreenReaderInterface screenReader; diff --git a/stardew-access/Patches/GameMenuPatches.cs b/stardew-access/Patches/GameMenuPatches.cs index 176afbb..6f9eca8 100644 --- a/stardew-access/Patches/GameMenuPatches.cs +++ b/stardew-access/Patches/GameMenuPatches.cs @@ -17,23 +17,160 @@ namespace stardew_access.Patches internal static string exitPageQueryKey = ""; internal static string optionsPageQueryKey = ""; internal static string shopMenuQueryKey = ""; + internal static string socialPageQuery = ""; internal static int currentSelectedCraftingRecipe = -1; internal static bool isSelectingRecipe = false; + internal static void SocialPagePatch(SocialPage __instance, List ___sprites, int ___slotPosition, List ___kidsNames) + { + try + { + int x = Game1.getMouseX(), y = Game1.getMouseY(); // Mouse x and y position + for (int i = ___slotPosition; i < ___slotPosition + 5; i++) + { + if (i < ___sprites.Count) + { + if (__instance.names[i] is string) + { + #region For NPCs + if (__instance.characterSlots[i].bounds.Contains(Game1.getMouseX(), Game1.getMouseY())) + { + string name = $"{__instance.names[i] as string}"; + int heartLevel = Game1.player.getFriendshipHeartLevelForNPC(name); + bool datable = SocialPage.isDatable(name); + Friendship friendship = __instance.getFriendship(name); + int giftsThisWeek = friendship.GiftsThisWeek; + bool hasTalked = Game1.player.hasPlayerTalkedToNPC(name); + bool spouse = friendship.IsMarried(); + bool housemate = spouse && SocialPage.isRoommateOfAnyone(name); + + string toSpeak = $"{name}"; + + if (!hasTalked) + { + toSpeak = $"{toSpeak}, not talked yet"; + } + else + { + if (datable | housemate) + { + string text2 = (LocalizedContentManager.CurrentLanguageCode != LocalizedContentManager.LanguageCode.pt) ? Game1.content.LoadString("Strings\\StringsFromCSFiles:SocialPage.cs.11635") : ((__instance.getGender(name) == 0) ? Game1.content.LoadString("Strings\\StringsFromCSFiles:SocialPage.cs.11635").Split('/').First() : Game1.content.LoadString("Strings\\StringsFromCSFiles:SocialPage.cs.11635").Split('/').Last()); + if (housemate) + { + text2 = Game1.content.LoadString("Strings\\StringsFromCSFiles:Housemate"); + } + else if (spouse) + { + text2 = ((__instance.getGender(name) == 0) ? Game1.content.LoadString("Strings\\StringsFromCSFiles:SocialPage.cs.11636") : Game1.content.LoadString("Strings\\StringsFromCSFiles:SocialPage.cs.11637")); + } + else if (__instance.isMarriedToAnyone(name)) + { + text2 = ((__instance.getGender(name) == 0) ? Game1.content.LoadString("Strings\\UI:SocialPage_MarriedToOtherPlayer_MaleNPC") : Game1.content.LoadString("Strings\\UI:SocialPage_MarriedToOtherPlayer_FemaleNPC")); + } + else if (!Game1.player.isMarried() && friendship.IsDating()) + { + text2 = ((__instance.getGender(name) == 0) ? Game1.content.LoadString("Strings\\StringsFromCSFiles:SocialPage.cs.11639") : Game1.content.LoadString("Strings\\StringsFromCSFiles:SocialPage.cs.11640")); + } + else if (__instance.getFriendship(name).IsDivorced()) + { + text2 = ((__instance.getGender(name) == 0) ? Game1.content.LoadString("Strings\\StringsFromCSFiles:SocialPage.cs.11642") : Game1.content.LoadString("Strings\\StringsFromCSFiles:SocialPage.cs.11643")); + } + + toSpeak = $"{toSpeak}, {text2}"; + } + if (!__instance.getFriendship(name).IsMarried() && !___kidsNames.Contains(name)) + { + toSpeak = $"{toSpeak}, married"; + } + if (spouse) + { + toSpeak = $"{toSpeak}, spouse"; + } + else if (friendship.IsDating()) + { + toSpeak = $"{toSpeak}, dating"; + } + + toSpeak = $"{toSpeak}, {heartLevel} hearts, {giftsThisWeek} gifts given this week."; + } + + if (socialPageQuery != toSpeak) + { + socialPageQuery = toSpeak; + MainClass.screenReader.Say(toSpeak, true); + } + } + #endregion + } + else if (__instance.names[i] is long) + { + #region For Farmers + + long farmerID = (long)__instance.names[i]; + Farmer farmer = Game1.getFarmerMaybeOffline(farmerID); + if (farmer != null) + { + int gender = (!farmer.IsMale) ? 1 : 0; + ClickableTextureComponent clickableTextureComponent = ___sprites[i]; + if (clickableTextureComponent.containsPoint(x, y)) + { + Friendship friendship = Game1.player.team.GetFriendship(Game1.player.UniqueMultiplayerID, farmerID); + bool spouse = friendship.IsMarried(); + string toSpeak = ""; + + string text2 = (LocalizedContentManager.CurrentLanguageCode != LocalizedContentManager.LanguageCode.pt) ? Game1.content.LoadString("Strings\\StringsFromCSFiles:SocialPage.cs.11635") : ((gender == 0) ? Game1.content.LoadString("Strings\\StringsFromCSFiles:SocialPage.cs.11635").Split('/').First() : Game1.content.LoadString("Strings\\StringsFromCSFiles:SocialPage.cs.11635").Split('/').Last()); + if (spouse) + { + text2 = ((gender == 0) ? Game1.content.LoadString("Strings\\StringsFromCSFiles:SocialPage.cs.11636") : Game1.content.LoadString("Strings\\StringsFromCSFiles:SocialPage.cs.11637")); + } + else if (farmer.isMarried() && !farmer.hasRoommate()) + { + text2 = ((gender == 0) ? Game1.content.LoadString("Strings\\UI:SocialPage_MarriedToOtherPlayer_MaleNPC") : Game1.content.LoadString("Strings\\UI:SocialPage_MarriedToOtherPlayer_FemaleNPC")); + } + else if (!Game1.player.isMarried() && friendship.IsDating()) + { + text2 = ((gender == 0) ? Game1.content.LoadString("Strings\\StringsFromCSFiles:SocialPage.cs.11639") : Game1.content.LoadString("Strings\\StringsFromCSFiles:SocialPage.cs.11640")); + } + else if (friendship.IsDivorced()) + { + text2 = ((gender == 0) ? Game1.content.LoadString("Strings\\StringsFromCSFiles:SocialPage.cs.11642") : Game1.content.LoadString("Strings\\StringsFromCSFiles:SocialPage.cs.11643")); + } + + toSpeak = $"{farmer.displayName}, {text2}"; + + if (socialPageQuery != toSpeak) + { + socialPageQuery = toSpeak; + MainClass.screenReader.Say(toSpeak, true); + } + } + } + + #endregion + } + } + } + } + catch (Exception e) + { + MainClass.monitor.Log($"Unable to narrate Text:\n{e.Message}\n{e.StackTrace}", LogLevel.Error); + } + } + internal static void ShopMenuPatch(ShopMenu __instance) { try { - int x = Game1.getMousePosition(true).X, y = Game1.getMousePosition(true).Y; // Mouse x and y position + int x = Game1.getMouseX(), y = Game1.getMouseY(); // Mouse x and y position bool isIPressed = Game1.input.GetKeyboardState().IsKeyDown(Microsoft.Xna.Framework.Input.Keys.I); bool isLeftShiftPressed = Game1.input.GetKeyboardState().IsKeyDown(Microsoft.Xna.Framework.Input.Keys.LeftShift); - if (isLeftShiftPressed && isIPressed && __instance.inventory.inventory.Count>0) + if (isLeftShiftPressed && isIPressed && __instance.inventory.inventory.Count > 0) { __instance.inventory.inventory[0].snapMouseCursorToCenter(); __instance.setCurrentlySnappedComponentTo(__instance.inventory.inventory[0].myID); } - else if (!isLeftShiftPressed && isIPressed && __instance.forSaleButtons.Count>0) + else if (!isLeftShiftPressed && isIPressed && __instance.forSaleButtons.Count > 0) { __instance.forSaleButtons[0].snapMouseCursorToCenter(); __instance.setCurrentlySnappedComponentTo(__instance.forSaleButtons[0].myID); @@ -109,7 +246,7 @@ namespace stardew_access.Patches requirements = $"Required: {itemAmount} {itemName}"; else requirements = $"Required: {itemName}"; - } + } #endregion string toSpeak = $"{name}, {requirements}, {price}, \n\t{description}"; @@ -136,11 +273,11 @@ namespace stardew_access.Patches if (__instance.currentTab != 0 && __instance.currentTab != 4 && __instance.currentTab != 6 && __instance.currentTab != 7) return; - int x = Game1.getMousePosition(true).X, y = Game1.getMousePosition(true).Y; // Mouse x and y position + int x = Game1.getMouseX(), y = Game1.getMouseY(); // Mouse x and y position - for(int i=0; i<__instance.tabs.Count; i++) + for (int i = 0; i < __instance.tabs.Count; i++) { - if(__instance.tabs[i].containsPoint(x, y)) + if (__instance.tabs[i].containsPoint(x, y)) { string toSpeak = $"{GameMenu.getLabelOfTabFromIndex(i)} Tab"; if (gameMenuQueryKey != toSpeak) @@ -162,7 +299,7 @@ namespace stardew_access.Patches { try { - int x = Game1.getMousePosition(true).X, y = Game1.getMousePosition(true).Y; // Mouse x and y position + int x = Game1.getMouseX(), y = Game1.getMouseY(); // Mouse x and y position #region Narrate the treasure recieved on breaking the geode if (__instance.geodeTreasure != null) @@ -178,7 +315,7 @@ namespace stardew_access.Patches MainClass.screenReader.Say(toSpeak, true); } return; - } + } #endregion #region Narrate hovered buttons in the menu @@ -232,7 +369,7 @@ namespace stardew_access.Patches #endregion #region Narrate hovered item - if(narrateHoveredItemInInventory(__instance.inventory.inventory, __instance.inventory.actualInventory, x, y)) + if (narrateHoveredItemInInventory(__instance.inventory.inventory, __instance.inventory.actualInventory, x, y)) geodeMenuQueryKey = ""; #endregion } @@ -246,16 +383,16 @@ namespace stardew_access.Patches { try { - int x = Game1.getMousePosition(true).X, y = Game1.getMousePosition(true).Y; // Mouse x and y position + int x = Game1.getMouseX(), y = Game1.getMouseY(); // Mouse x and y position bool isIPressed = Game1.input.GetKeyboardState().IsKeyDown(Microsoft.Xna.Framework.Input.Keys.I); bool isLeftShiftPressed = Game1.input.GetKeyboardState().IsKeyDown(Microsoft.Xna.Framework.Input.Keys.LeftShift); - if(isLeftShiftPressed && isIPressed && __instance.inventory.inventory.Count > 0) + if (isLeftShiftPressed && isIPressed && __instance.inventory.inventory.Count > 0) { __instance.setCurrentlySnappedComponentTo(__instance.inventory.inventory[0].myID); __instance.inventory.inventory[0].snapMouseCursorToCenter(); } - else if(!isLeftShiftPressed && isIPressed && __instance.ItemsToGrabMenu.inventory.Count > 0 && !__instance.shippingBin) + else if (!isLeftShiftPressed && isIPressed && __instance.ItemsToGrabMenu.inventory.Count > 0 && !__instance.shippingBin) { __instance.setCurrentlySnappedComponentTo(__instance.ItemsToGrabMenu.inventory[0].myID); __instance.ItemsToGrabMenu.inventory[0].snapMouseCursorToCenter(); @@ -265,7 +402,7 @@ namespace stardew_access.Patches if (__instance.okButton != null && __instance.okButton.containsPoint(x, y)) { string toSpeak = "Ok Button"; - if(itemGrabMenuQueryKey != toSpeak) + if (itemGrabMenuQueryKey != toSpeak) { itemGrabMenuQueryKey = toSpeak; hoveredItemQueryKey = ""; @@ -329,7 +466,7 @@ namespace stardew_access.Patches if (__instance.colorPickerToggleButton != null && __instance.colorPickerToggleButton.containsPoint(x, y)) { - string toSpeak = "Color Picker: " + (__instance.chestColorPicker.visible?"Enabled":"Disabled"); + string toSpeak = "Color Picker: " + (__instance.chestColorPicker.visible ? "Enabled" : "Disabled"); if (itemGrabMenuQueryKey != toSpeak) { itemGrabMenuQueryKey = toSpeak; @@ -407,11 +544,11 @@ namespace stardew_access.Patches MainClass.screenReader.Say(toSpeak, true); } return; - } + } #endregion #region Narrate hovered item - if(narrateHoveredItemInInventory(__instance.inventory.inventory, __instance.inventory.actualInventory, x, y, true)) + if (narrateHoveredItemInInventory(__instance.inventory.inventory, __instance.inventory.actualInventory, x, y, true)) { gameMenuQueryKey = ""; itemGrabMenuQueryKey = ""; @@ -510,7 +647,7 @@ namespace stardew_access.Patches { try { - int x = Game1.getMousePosition(true).X, y = Game1.getMousePosition(true).Y; // Mouse x and y position + int x = Game1.getMouseX(), y = Game1.getMouseY(); // Mouse x and y position bool isIPressed = Game1.input.GetKeyboardState().IsKeyDown(Microsoft.Xna.Framework.Input.Keys.I); bool isCPressed = Game1.input.GetKeyboardState().IsKeyDown(Microsoft.Xna.Framework.Input.Keys.C); bool isLeftShiftPressed = Game1.input.GetKeyboardState().IsKeyDown(Microsoft.Xna.Framework.Input.Keys.LeftShift); @@ -522,13 +659,13 @@ namespace stardew_access.Patches __instance.inventory.inventory[0].snapMouseCursorToCenter(); currentSelectedCraftingRecipe = -1; } - else if (!isLeftShiftPressed && isIPressed && __instance.pagesOfCraftingRecipes[___currentCraftingPage].Count>0) + else if (!isLeftShiftPressed && isIPressed && __instance.pagesOfCraftingRecipes[___currentCraftingPage].Count > 0) { // snap to first crafting recipe __instance.setCurrentlySnappedComponentTo(__instance.pagesOfCraftingRecipes[___currentCraftingPage].ElementAt(0).Key.myID); __instance.pagesOfCraftingRecipes[___currentCraftingPage].ElementAt(0).Key.snapMouseCursorToCenter(); currentSelectedCraftingRecipe = 0; - } + } else if (isCPressed && !isSelectingRecipe) { _ = CycleThroughRecipies(__instance.pagesOfCraftingRecipes, ___currentCraftingPage, __instance); @@ -711,7 +848,7 @@ namespace stardew_access.Patches { try { - int x = Game1.getMousePosition(true).X, y = Game1.getMousePosition(true).Y; // Mouse x and y position + int x = Game1.getMouseX(), y = Game1.getMouseY(); // Mouse x and y position #region Narrate buttons in the menu if (__instance.inventory.dropItemInvisibleButton != null && __instance.inventory.dropItemInvisibleButton.containsPoint(x, y)) @@ -783,7 +920,7 @@ namespace stardew_access.Patches #endregion #region Narrate equipment slots - for (int i=0; i<__instance.equipmentIcons.Count; i++) + for (int i = 0; i < __instance.equipmentIcons.Count; i++) { if (__instance.equipmentIcons[i].containsPoint(x, y)) { @@ -864,7 +1001,7 @@ namespace stardew_access.Patches } } break; - } + } #endregion if (inventoryPageQueryKey != toSpeak) @@ -899,7 +1036,7 @@ namespace stardew_access.Patches try { int currentItemIndex = Math.Max(0, Math.Min(__instance.options.Count - 7, __instance.currentItemIndex)); - int x = Game1.getMousePosition(true).X, y = Game1.getMousePosition(true).Y; + int x = Game1.getMouseX(), y = Game1.getMouseY(); for (int i = 0; i < __instance.optionSlots.Count; i++) { if (__instance.optionSlots[i].bounds.Contains(x, y) && currentItemIndex + i < __instance.options.Count && __instance.options[currentItemIndex + i].bounds.Contains(x - __instance.optionSlots[i].bounds.X, y - __instance.optionSlots[i].bounds.Y)) @@ -952,7 +1089,7 @@ namespace stardew_access.Patches try { if (__instance.exitToTitle.visible && - __instance.exitToTitle.containsPoint(Game1.getMousePosition(true).X, Game1.getMousePosition(true).Y)) + __instance.exitToTitle.containsPoint(Game1.getMouseX(), Game1.getMouseY())) { string toSpeak = "Exit to Title Button"; if (exitPageQueryKey != toSpeak) @@ -964,7 +1101,7 @@ namespace stardew_access.Patches return; } if (__instance.exitToDesktop.visible && - __instance.exitToDesktop.containsPoint(Game1.getMousePosition(true).X, Game1.getMousePosition(true).Y)) + __instance.exitToDesktop.containsPoint(Game1.getMouseX(), Game1.getMouseY())) { string toSpeak = "Exit to Desktop Button"; if (exitPageQueryKey != toSpeak) @@ -1068,7 +1205,7 @@ namespace stardew_access.Patches { string itemName = Game1.objectInformation[extraItemToShowIndex].Split('/')[0]; - if(extraItemToShowAmount != -1) + if (extraItemToShowAmount != -1) requirements = $"Required: {extraItemToShowAmount} {itemName}"; else requirements = $"Required: {itemName}"; @@ -1085,7 +1222,7 @@ namespace stardew_access.Patches if (stack > 1) toSpeak = $"{stack} {name} {quality}, \n{requirements}, \n{price}, \n{description}, \n{healthNStamine}, \n{buffs}"; else - toSpeak = $"{name} {quality}, \n{requirements}, \n{price}, \n{description}, \n{healthNStamine}, \n{buffs}"; + toSpeak = $"{name} {quality}, \n{requirements}, \n{price}, \n{description}, \n{healthNStamine}, \n{buffs}"; } else { diff --git a/stardew-access/Patches/MenuPatches.cs b/stardew-access/Patches/MenuPatches.cs index f483152..e84f01c 100644 --- a/stardew-access/Patches/MenuPatches.cs +++ b/stardew-access/Patches/MenuPatches.cs @@ -19,10 +19,10 @@ namespace stardew_access.Patches if (!Context.IsPlayerFree) return true; - if(!Game1.player.isMoving()) + if (!Game1.player.isMoving()) return true; - if(cueName == "grassyStep" || cueName == "sandyStep" || cueName == "snowyStep" || cueName == "stoneStep" || cueName == "thudStep" || cueName == "woodyStep") + if (cueName == "grassyStep" || cueName == "sandyStep" || cueName == "snowyStep" || cueName == "stoneStep" || cueName == "thudStep" || cueName == "woodyStep") { Vector2 nextTile = CurrentPlayer.getNextTile(); if (ReadTile.isCollidingAtTile((int)nextTile.X, (int)nextTile.Y)) @@ -48,9 +48,9 @@ namespace stardew_access.Patches { try { - int x = Game1.getMousePosition(true).X, y = Game1.getMousePosition(true).Y; // Mouse x and y position + int x = Game1.getMouseX(), y = Game1.getMouseY(); // Mouse x and y position - if(__instance.nextPageButton != null && __instance.nextPageButton.containsPoint(x, y)) + if (__instance.nextPageButton != null && __instance.nextPageButton.containsPoint(x, y)) { MainClass.screenReader.SayWithMenuChecker($"Next Page Button", true); return; @@ -62,9 +62,9 @@ namespace stardew_access.Patches return; } - for(int i=0; i<__instance.languages.Count; i++) + for (int i = 0; i < __instance.languages.Count; i++) { - if(__instance.languages[i].containsPoint(x, y)) + if (__instance.languages[i].containsPoint(x, y)) { MainClass.screenReader.SayWithMenuChecker($"{__instance.languageList[i]} Button", true); break; @@ -81,10 +81,10 @@ namespace stardew_access.Patches { try { - int x = Game1.getMousePosition(true).X, y = Game1.getMousePosition(true).Y; // Mouse x and y position - for (int i=0; i<___elevators.Count; i++) + int x = Game1.getMouseX(), y = Game1.getMouseY(); // Mouse x and y position + for (int i = 0; i < ___elevators.Count; i++) { - if(___elevators[i].containsPoint(x, y)) + if (___elevators[i].containsPoint(x, y)) { MainClass.screenReader.SayWithMenuChecker($"{___elevators[i].name} level", true); break; @@ -117,13 +117,14 @@ namespace stardew_access.Patches { try { - int x = Game1.getMousePosition(true).X, y = Game1.getMousePosition(true).Y; + int x = Game1.getMouseX(), y = Game1.getMouseY(); MainClass.screenReader.SayWithMenuChecker(___message, true); - if(__instance.okButton.containsPoint(x, y)) + if (__instance.okButton.containsPoint(x, y)) { MainClass.screenReader.SayWithMenuChecker("Ok Button", false); - } else if (__instance.cancelButton.containsPoint(x, y)) + } + else if (__instance.cancelButton.containsPoint(x, y)) { MainClass.screenReader.SayWithMenuChecker("Cancel Button", false); } @@ -138,7 +139,7 @@ namespace stardew_access.Patches { try { - int x = Game1.getMousePosition(true).X, y = Game1.getMousePosition(true).Y; + int x = Game1.getMouseX(), y = Game1.getMouseY(); string leftProfession = " ", rightProfession = " ", extraInfo = " ", newCraftingRecipe = " ", toSpeak = " "; if (!__instance.informationUp) @@ -208,14 +209,14 @@ namespace stardew_access.Patches { int total = ___categoryTotals[5]; string toSpeak; - if (__instance.okButton.containsPoint(Game1.getMousePosition(true).X, Game1.getMousePosition(true).Y)) + if (__instance.okButton.containsPoint(Game1.getMouseX(), Game1.getMouseY())) { toSpeak = $"{total}g in total. Press left mouse button to save."; MainClass.screenReader.SayWithChecker(toSpeak, true); } for (int i = 0; i < __instance.categories.Count; i++) { - if (__instance.categories[i].containsPoint(Game1.getMousePosition(true).X, Game1.getMousePosition(true).Y)) + if (__instance.categories[i].containsPoint(Game1.getMouseX(), Game1.getMouseY())) { toSpeak = $"Money recieved from {__instance.getCategoryName(i)}: {___categoryTotals[i]}g."; MainClass.screenReader.SayWithChecker(toSpeak, true); @@ -260,7 +261,7 @@ namespace stardew_access.Patches currentLetterText = toSpeak; // snap mouse to accept quest button - if (__instance.acceptQuestButton!=null && __instance.acceptQuestButton.visible) + if (__instance.acceptQuestButton != null && __instance.acceptQuestButton.visible) { toSpeak += "\t\n Left click to accept quest."; __instance.acceptQuestButton.snapMouseCursorToCenter(); @@ -315,7 +316,7 @@ namespace stardew_access.Patches { try { - if(__instance is GeodeMenu) + if (__instance is GeodeMenu) { GameMenuPatches.geodeMenuQueryKey = ""; } @@ -340,7 +341,7 @@ namespace stardew_access.Patches internal static void ExitEventPatch() { - if(MainClass.screenReader!=null) + if (MainClass.screenReader != null) MainClass.screenReader.CloseScreenReader(); } internal static void resetGlobalVars() diff --git a/stardew-access/Patches/QuestPatches.cs b/stardew-access/Patches/QuestPatches.cs index cd956ea..7c02d77 100644 --- a/stardew-access/Patches/QuestPatches.cs +++ b/stardew-access/Patches/QuestPatches.cs @@ -15,7 +15,7 @@ namespace stardew_access.Patches { try { - int x = Game1.getMousePosition(true).X, y = Game1.getMousePosition(true).Y; // Mouse x and y position + int x = Game1.getMouseX(), y = Game1.getMouseY(); // Mouse x and y position if (__instance.acceptLeftQuestButton.visible && __instance.acceptLeftQuestButton.containsPoint(x, y)) { @@ -83,7 +83,7 @@ namespace stardew_access.Patches #region Callender for (int i = 0; i < __instance.calendarDays.Count; i++) { - if (__instance.calendarDays[i].containsPoint(Game1.getMousePosition(true).X, Game1.getMousePosition(true).Y)) + if (__instance.calendarDays[i].containsPoint(Game1.getMouseX(), Game1.getMouseY())) { string toSpeak = $"Day {i + 1}"; diff --git a/stardew-access/Patches/TitleMenuPatches.cs b/stardew-access/Patches/TitleMenuPatches.cs index 5664a74..ea03189 100644 --- a/stardew-access/Patches/TitleMenuPatches.cs +++ b/stardew-access/Patches/TitleMenuPatches.cs @@ -16,7 +16,7 @@ namespace stardew_access.Patches { try { - int x = Game1.getMousePosition(true).X, y = Game1.getMousePosition(true).Y; + int x = Game1.getMouseX(), y = Game1.getMouseY(); string toSpeak = " "; #region Join/Host Button (Important! This should be checked before checking other buttons) @@ -64,7 +64,7 @@ namespace stardew_access.Patches __instance.buttons.ForEach(component => { - if (component.containsPoint(Game1.getMousePosition(true).X, Game1.getMousePosition(true).Y)) + if (component.containsPoint(Game1.getMouseX(), Game1.getMouseY())) { string name = component.name; string label = component.label; @@ -72,27 +72,27 @@ namespace stardew_access.Patches } }); - if (__instance.muteMusicButton.containsPoint(Game1.getMousePosition(true).X, Game1.getMousePosition(true).Y)) + if (__instance.muteMusicButton.containsPoint(Game1.getMouseX(), Game1.getMouseY())) { toSpeak = "Mute Music Button"; } - if (__instance.aboutButton.containsPoint(Game1.getMousePosition(true).X, Game1.getMousePosition(true).Y)) + if (__instance.aboutButton.containsPoint(Game1.getMouseX(), Game1.getMouseY())) { toSpeak = "About Button"; } - if (__instance.languageButton.containsPoint(Game1.getMousePosition(true).X, Game1.getMousePosition(true).Y)) + if (__instance.languageButton.containsPoint(Game1.getMouseX(), Game1.getMouseY())) { toSpeak = "Language Button"; } - if (__instance.windowedButton.containsPoint(Game1.getMousePosition(true).X, Game1.getMousePosition(true).Y)) + if (__instance.windowedButton.containsPoint(Game1.getMouseX(), Game1.getMouseY())) { toSpeak = "Fullscreen toggle Button"; } - if (TitleMenu.subMenu != null && __instance.backButton.containsPoint(Game1.getMousePosition(true).X, Game1.getMousePosition(true).Y)) + if (TitleMenu.subMenu != null && __instance.backButton.containsPoint(Game1.getMouseX(), Game1.getMouseY())) { string text = "Back Button"; MainClass.screenReader.SayWithChecker(text, true); @@ -111,7 +111,7 @@ namespace stardew_access.Patches { try { - int x = Game1.getMousePosition(true).X, y = Game1.getMousePosition(true).Y; + int x = Game1.getMouseX(), y = Game1.getMouseY(); if (___menu.slotButtons[i].containsPoint(x, y)) { if (__instance.Farmer != null) @@ -290,7 +290,7 @@ namespace stardew_access.Patches #endregion __instance.skipIntroButton.snapMouseCursor(); - toSpeak = (___skipIntro?"Enabled":"Disabled") + " Skip Intro Button"; + toSpeak = (___skipIntro ? "Enabled" : "Disabled") + " Skip Intro Button"; } break; case 5: @@ -638,7 +638,7 @@ namespace stardew_access.Patches break; } - if(toSpeak!=" ") + if (toSpeak != " ") { MainClass.screenReader.Say(toSpeak, true); }