diff --git a/stardew-access/CustomCommands.cs b/stardew-access/CustomCommands.cs index 70bef73..d907636 100644 --- a/stardew-access/CustomCommands.cs +++ b/stardew-access/CustomCommands.cs @@ -286,7 +286,7 @@ namespace stardew_access #endregion #region Tile marking - helper.ConsoleCommands.Add("mark", "Marks the player's position for use in building cunstruction in Carpenter Menu.", (string commmand, string[] args) => + helper.ConsoleCommands.Add("mark", "Marks the player's position for use in building construction in Carpenter Menu.", (string commmand, string[] args) => { if (Game1.currentLocation is not Farm) { diff --git a/stardew-access/ModEntry.cs b/stardew-access/ModEntry.cs index 78adf22..0c35bf9 100644 --- a/stardew-access/ModEntry.cs +++ b/stardew-access/ModEntry.cs @@ -82,7 +82,7 @@ namespace stardew_access /// Returns the Screen Reader class for other mods to use. public override object GetApi() { - return new ScreenReaderController().Initialize(); + return new ScreenReaderAPI(); } private void onUpdateTicked(object? sender, UpdateTickedEventArgs? e) diff --git a/stardew-access/Patches/BuildingNAnimalMenuPatches.cs b/stardew-access/Patches/BuildingNAnimalMenuPatches.cs index 513e453..5a3e4ae 100644 --- a/stardew-access/Patches/BuildingNAnimalMenuPatches.cs +++ b/stardew-access/Patches/BuildingNAnimalMenuPatches.cs @@ -209,7 +209,7 @@ namespace stardew_access.Patches if (__instance.okButton != null && __instance.okButton.containsPoint(x, y)) { - string toSpeak = "Cunstruct Building" + (___blueprints[___currentBlueprintIndex].doesFarmerHaveEnoughResourcesToBuild() ? "" : ", cannot cunstrut building, not enough resources to build."); + string toSpeak = "Construct Building" + (___blueprints[___currentBlueprintIndex].doesFarmerHaveEnoughResourcesToBuild() ? "" : ", cannot cunstrut building, not enough resources to build."); if (carpenterMenuQuery != toSpeak) { carpenterMenuQuery = toSpeak; @@ -511,7 +511,7 @@ namespace stardew_access.Patches if ((int)buildingToMove.daysOfConstructionLeft > 0) { buildingToMove = null; - return "Building under cunstruction, cannot move"; + return "Building under construction, cannot move"; } if (!carpenterMenu.hasPermissionsToMove(buildingToMove)) { diff --git a/stardew-access/Patches/MenuPatches.cs b/stardew-access/Patches/MenuPatches.cs index f204cf3..eee71ad 100644 --- a/stardew-access/Patches/MenuPatches.cs +++ b/stardew-access/Patches/MenuPatches.cs @@ -135,13 +135,17 @@ namespace stardew_access.Patches } } - internal static void LevelUpMenuPatch(LevelUpMenu __instance, List ___professionsToChoose, List ___leftProfessionDescription, List ___rightProfessionDescription, List ___extraInfoForLevel, List ___newCraftingRecipes, string ___title) + internal static void LevelUpMenuPatch(LevelUpMenu __instance, List ___professionsToChoose, List ___leftProfessionDescription, List ___rightProfessionDescription, List ___extraInfoForLevel, List ___newCraftingRecipes, string ___title, bool ___isActive, bool ___isProfessionChooser) { try { int x = Game1.getMouseX(), y = Game1.getMouseY(); string leftProfession = " ", rightProfession = " ", extraInfo = " ", newCraftingRecipe = " ", toSpeak = " "; + bool isOpenBracketPressed = Game1.input.GetKeyboardState().IsKeyDown(Microsoft.Xna.Framework.Input.Keys.OemOpenBrackets); // for left click + bool isLeftCtrlPressed = Game1.input.GetKeyboardState().IsKeyDown(Microsoft.Xna.Framework.Input.Keys.LeftControl); + bool isEnterPressed = Game1.input.GetKeyboardState().IsKeyDown(Microsoft.Xna.Framework.Input.Keys.Enter); + if (!__instance.informationUp) { return; @@ -162,10 +166,38 @@ namespace stardew_access.Patches } if (__instance.leftProfession.containsPoint(x, y)) + { + if (isOpenBracketPressed || (isLeftCtrlPressed && isEnterPressed && __instance.readyToClose())) + { + Game1.player.professions.Add(___professionsToChoose[0]); + __instance.getImmediateProfessionPerk(___professionsToChoose[0]); + ___isActive = false; + __instance.informationUp = false; + ___isProfessionChooser = false; + __instance.RemoveLevelFromLevelList(); + __instance.exitThisMenu(); + return; + } + toSpeak = $"Selected: {leftProfession} Left click to choose."; + } if (__instance.rightProfession.containsPoint(x, y)) + { + if (isOpenBracketPressed || (isLeftCtrlPressed && isEnterPressed && __instance.readyToClose())) + { + Game1.player.professions.Add(___professionsToChoose[1]); + __instance.getImmediateProfessionPerk(___professionsToChoose[1]); + ___isActive = false; + __instance.informationUp = false; + ___isProfessionChooser = false; + __instance.RemoveLevelFromLevelList(); + __instance.exitThisMenu(); + return; + } + toSpeak = $"Selected: {rightProfession} Left click to choose."; + } } else { @@ -180,11 +212,14 @@ namespace stardew_access.Patches newCraftingRecipe += $"{message}, "; } + } - if (__instance.okButton.containsPoint(x, y)) - { - toSpeak = $"{___title} {extraInfo} {newCraftingRecipe}. Left click to close."; - } + if (__instance.okButton.containsPoint(x, y)) + { + if (isOpenBracketPressed || (isLeftCtrlPressed && isEnterPressed)) + __instance.okButtonClicked(); + + toSpeak = $"{___title} {extraInfo} {newCraftingRecipe}. Left click to close."; } if (toSpeak != " ") @@ -205,12 +240,21 @@ namespace stardew_access.Patches { try { + bool isLeftControlPressed = Game1.input.GetKeyboardState().IsKeyDown(Microsoft.Xna.Framework.Input.Keys.LeftControl); + bool isOpenBracketPressed = Game1.input.GetKeyboardState().IsKeyDown(Microsoft.Xna.Framework.Input.Keys.OemOpenBrackets); // for left click + bool isEnterPressed = Game1.input.GetKeyboardState().IsKeyDown(Microsoft.Xna.Framework.Input.Keys.Enter); + if (__instance.currentPage == -1) { int total = ___categoryTotals[5]; string toSpeak; if (__instance.okButton.containsPoint(Game1.getMouseX(), Game1.getMouseY())) { + // Perform Left Click + if (isOpenBracketPressed || (isLeftControlPressed && isEnterPressed)) + { + Game1.activeClickableMenu.receiveLeftClick(Game1.getMouseX(true), Game1.getMouseY(true)); + } toSpeak = $"{total}g in total. Press left mouse button to save."; MainClass.ScreenReader.SayWithChecker(toSpeak, true); } diff --git a/stardew-access/ScreenReader/ScreenReaderAPI.cs b/stardew-access/ScreenReader/ScreenReaderAPI.cs new file mode 100644 index 0000000..b0841e2 --- /dev/null +++ b/stardew-access/ScreenReader/ScreenReaderAPI.cs @@ -0,0 +1,59 @@ +namespace stardew_access.ScreenReader +{ + public class ScreenReaderAPI + { + + public ScreenReaderAPI() + { + } + + public void CloseScreenReader() + { + if (MainClass.ScreenReader == null) + return; + + MainClass.ScreenReader.CloseScreenReader(); + } + + public void Say(String text, Boolean interrupt) + { + if (MainClass.ScreenReader == null) + return; + + MainClass.ScreenReader.Say(text, interrupt); + } + + public void SayWithChecker(String text, Boolean interrupt) + { + if (MainClass.ScreenReader == null) + return; + + MainClass.ScreenReader.SayWithChecker(text, interrupt); + } + + public void SayWithMenuChecker(String text, Boolean interrupt) + { + if (MainClass.ScreenReader == null) + return; + + MainClass.ScreenReader.SayWithMenuChecker(text, interrupt); + } + + public void SayWithChatChecker(String text, Boolean interrupt) + { + if (MainClass.ScreenReader == null) + return; + + MainClass.ScreenReader.SayWithChatChecker(text, interrupt); + } + + public void SayWithTileQuery(String text, int x, int y, Boolean interrupt) + { + if (MainClass.ScreenReader == null) + return; + + MainClass.ScreenReader.SayWithTileQuery(text, x, y, interrupt); + } + + } +} \ No newline at end of file diff --git a/stardew-access/manifest.json b/stardew-access/manifest.json index 8eada81..ba7bd79 100644 --- a/stardew-access/manifest.json +++ b/stardew-access/manifest.json @@ -1,7 +1,7 @@ { "Name": "Stardew Access", "Author": "Mohammad Shoaib", - "Version": "1.0.22-beta", + "Version": "1.0.23-beta", "Description": "An accessibility mod with screen reader support!", "UniqueID": "shoaib.stardewaccess", "EntryDll": "stardew-access.dll",