diff --git a/stardew-access/Game/CurrentPlayer.cs b/stardew-access/Game/CurrentPlayer.cs index 5492c9f..50e50af 100644 --- a/stardew-access/Game/CurrentPlayer.cs +++ b/stardew-access/Game/CurrentPlayer.cs @@ -58,5 +58,23 @@ namespace stardew_access.Game int y = (int)player.getTileLocation().Y; return y; } + + internal static int getToolHItPositionX() + { + if (player == null) + initPlayer(); + + int x = (int)player.GetGrabTile().X; + return x; + } + + internal static int getToolHItPositionY() + { + if (player == null) + initPlayer(); + + int y = (int)player.GetGrabTile().Y; + return y; + } } } diff --git a/stardew-access/ModEntry.cs b/stardew-access/ModEntry.cs index 6de2c27..dec2990 100644 --- a/stardew-access/ModEntry.cs +++ b/stardew-access/ModEntry.cs @@ -7,6 +7,7 @@ using StardewValley.Menus; using Microsoft.Xna.Framework.Graphics; using stardew_access.Patches; using AutoHotkey.Interop; +using Microsoft.Xna.Framework; namespace stardew_access { @@ -85,9 +86,30 @@ namespace stardew_access postfix: new HarmonyMethod(typeof(MenuPatch), nameof(MenuPatch.NewGameMenuPatch)) ); + harmony.Patch( + original: AccessTools.Method(typeof(LetterViewerMenu), nameof(LetterViewerMenu.draw), new Type[] { typeof(SpriteBatch) }), + postfix: new HarmonyMethod(typeof(MenuPatch), nameof(MenuPatch.LetterViewerMenuPatch)) + ); + #endregion helper.Events.Input.ButtonPressed += this.OnButtonPressed; + helper.Events.GameLoop.UpdateTicked += this.onUpdateTicked; + } + + private void onUpdateTicked(object sender, UpdateTickedEventArgs e) + { + if (!Context.IsPlayerFree) + return; + + + } + + private void On1SecUpdateTicked(object sender, OneSecondUpdateTickedEventArgs e) + { + + + } private void OnButtonPressed(object sender, ButtonPressedEventArgs e) @@ -104,7 +126,7 @@ namespace stardew_access // Narrate Position if (Equals(e.Button, SButton.K)) { - string toSpeak = $"X: {CurrentPlayer.getPositionX()} , Y: {CurrentPlayer.getPositionX()}"; + string toSpeak = $"X: {CurrentPlayer.getPositionX()} , Y: {CurrentPlayer.getPositionY()}"; ScreenReader.say(toSpeak, true); } diff --git a/stardew-access/Patches/MenuPatch.cs b/stardew-access/Patches/MenuPatch.cs index 3ba5957..8b83f9c 100644 --- a/stardew-access/Patches/MenuPatch.cs +++ b/stardew-access/Patches/MenuPatch.cs @@ -9,6 +9,67 @@ namespace stardew_access.Patches { private static int saveGameIndex = -1; private static bool isRunning = false; + private static string currentLetterText = " "; + + internal static void LetterViewerMenuPatch(LetterViewerMenu __instance) + { + try + { + if (!__instance.IsActive()) + return; + + #region Texts in the letter + string title = __instance.mailTitle; + string message = __instance.mailMessage[__instance.page]; + + string toSpeak = $"{title} \t\n\t {message}."; + + if (__instance.ShouldShowInteractable()) + { + if (__instance.moneyIncluded > 0) + { + string moneyText = Game1.content.LoadString("Strings\\UI:LetterViewer_MoneyIncluded", __instance.moneyIncluded); + toSpeak += $"\t\n\t ,Included money: {moneyText}"; + } + else if (__instance.learnedRecipe != null && __instance.learnedRecipe.Length > 0) + { + string recipeText = Game1.content.LoadString("Strings\\UI:LetterViewer_LearnedRecipe", __instance.cookingOrCrafting); + toSpeak += $"\t\n\t ,Learned Recipe: {recipeText}"; + } + } + + if (__instance.ShouldShowInteractable() && __instance.questID != -1) + { + toSpeak += "\t\n\t ,Close this menu to accept or press left click button"; + } + + if (currentLetterText != toSpeak) + { + currentLetterText = toSpeak; + ScreenReader.say(toSpeak, false); + } + #endregion + + #region Narrate items given in the mail + if (__instance.ShouldShowInteractable()) + { + foreach (ClickableComponent c in __instance.itemsToGrab) + { + string name = c.name; + string label = c.label; + + if (c.containsPoint(Game1.getMousePosition().X, Game1.getMousePosition().Y)) + ScreenReader.sayWithChecker($"Grab: {name} \t\n {label}", false); + } + } + #endregion + } + catch (Exception e) + { + + MainClass.monitor.Log($"Unable to narrate Text:\n{e.Message}\n{e.StackTrace}", LogLevel.Error); + } + } internal static void TitleMenuPatch(TitleMenu __instance) { diff --git a/stardew-access/ScreenReader.cs b/stardew-access/ScreenReader.cs index 8e53ff4..5fc977f 100644 --- a/stardew-access/ScreenReader.cs +++ b/stardew-access/ScreenReader.cs @@ -21,7 +21,7 @@ namespace stardew_access } catch (Exception ex) { - MainClass.monitor.Log($"Error initializing NVDA:\n{ex.StackTrace}", LogLevel.Error); + MainClass.monitor.Log($"Error initializing NVDA:\n{ex.StackTrace}", LogLevel.Info); } // Initialize JAWS @@ -31,7 +31,7 @@ namespace stardew_access } catch (Exception ex) { - MainClass.monitor.Log($"Error initializing JAWS:\n{ex.StackTrace}", LogLevel.Error); + MainClass.monitor.Log($"Error initializing JAWS:\n{ex.StackTrace}", LogLevel.Info); } // Initialize SAPI @@ -41,7 +41,7 @@ namespace stardew_access } catch (Exception ex) { - MainClass.monitor.Log($"Error initializing SAPI:\n{ex.StackTrace}", LogLevel.Error); + MainClass.monitor.Log($"Error initializing SAPI:\n{ex.StackTrace}", LogLevel.Info); } if (nvdaOutput != null && nvdaOutput.IsAvailable())