From dda69f6b19c9345dcf7395ac6438f9bf3df928d7 Mon Sep 17 00:00:00 2001 From: shoaib11120 Date: Mon, 3 Jan 2022 19:47:58 +0530 Subject: [PATCH] Mine elevator menu is accessible. Use wasd! --- stardew-access/ModEntry.cs | 15 ++++++++----- stardew-access/Patches/DialoguePatcher.cs | 16 ++++++++----- stardew-access/Patches/MenuPatch.cs | 26 +++++++++++++++++----- stardew-access/Patches/TitleMenuPatches.cs | 3 +-- 4 files changed, 42 insertions(+), 18 deletions(-) diff --git a/stardew-access/ModEntry.cs b/stardew-access/ModEntry.cs index 49baf31..940919d 100644 --- a/stardew-access/ModEntry.cs +++ b/stardew-access/ModEntry.cs @@ -74,12 +74,12 @@ namespace stardew_access harmony.Patch( original: AccessTools.Method(typeof(TitleMenu), nameof(TitleMenu.draw), new Type[] { typeof(SpriteBatch) }), - postfix: new HarmonyMethod(typeof(MenuPatch), nameof(TitleMenuPatches.TitleMenuPatch)) + postfix: new HarmonyMethod(typeof(TitleMenuPatches), nameof(TitleMenuPatches.TitleMenuPatch)) ); harmony.Patch( original: AccessTools.Method(typeof(LoadGameMenu.SaveFileSlot), nameof(LoadGameMenu.SaveFileSlot.Draw), new Type[] { typeof(SpriteBatch), typeof(int) }), - postfix: new HarmonyMethod(typeof(MenuPatch), nameof(TitleMenuPatches.LoadGameMenuPatch)) + postfix: new HarmonyMethod(typeof(TitleMenuPatches), nameof(TitleMenuPatches.LoadGameMenuPatch)) ); harmony.Patch( @@ -89,7 +89,7 @@ namespace stardew_access harmony.Patch( original: AccessTools.Method(typeof(CharacterCustomization), nameof(CharacterCustomization.draw), new Type[] { typeof(SpriteBatch) }), - postfix: new HarmonyMethod(typeof(MenuPatch), nameof(TitleMenuPatches.NewGameMenuPatch)) + postfix: new HarmonyMethod(typeof(TitleMenuPatches), nameof(TitleMenuPatches.NewGameMenuPatch)) ); harmony.Patch( @@ -119,12 +119,12 @@ namespace stardew_access harmony.Patch( original: AccessTools.Method(typeof(CoopMenu), nameof(CoopMenu.update), new Type[] { typeof(GameTime) }), - postfix: new HarmonyMethod(typeof(MenuPatch), nameof(TitleMenuPatches.CoopMenuPatch)) + postfix: new HarmonyMethod(typeof(TitleMenuPatches), nameof(TitleMenuPatches.CoopMenuPatch)) ); harmony.Patch( original: AccessTools.Method(typeof(ChatBox), nameof(ChatBox.update), new Type[] { typeof(GameTime) }), - postfix: new HarmonyMethod(typeof(MenuPatch), nameof(ChatManuPatches.ChatBoxPatch)) + postfix: new HarmonyMethod(typeof(ChatManuPatches), nameof(ChatManuPatches.ChatBoxPatch)) ); harmony.Patch( @@ -142,6 +142,11 @@ namespace stardew_access postfix: new HarmonyMethod(typeof(MenuPatch), nameof(MenuPatch.NamingMenuPatch)) ); + harmony.Patch( + original: AccessTools.Method(typeof(MineElevatorMenu), nameof(MineElevatorMenu.draw), new Type[] { typeof(SpriteBatch) }), + postfix: new HarmonyMethod(typeof(MenuPatch), nameof(MenuPatch.MineElevatorMenuPatch)) + ); + #endregion #region Custom Commands diff --git a/stardew-access/Patches/DialoguePatcher.cs b/stardew-access/Patches/DialoguePatcher.cs index fbca916..5826900 100644 --- a/stardew-access/Patches/DialoguePatcher.cs +++ b/stardew-access/Patches/DialoguePatcher.cs @@ -113,7 +113,7 @@ namespace stardew_access.Patches try { // Fix for delete button hover text not narrating - if (Game1.activeClickableMenu is TitleMenuPatches && !((Game1.activeClickableMenu as TitleMenuPatches).GetChildMenu() is CharacterCustomization)) + if (Game1.activeClickableMenu is TitleMenuPatches && !((Game1.activeClickableMenu as TitleMenu).GetChildMenu() is CharacterCustomization)) return; if (Game1.activeClickableMenu is LetterViewerMenu || Game1.activeClickableMenu is QuestLog) @@ -122,7 +122,7 @@ namespace stardew_access.Patches if (Game1.activeClickableMenu is Billboard) return; - StringBuilder toSpeak = new StringBuilder(); + StringBuilder toSpeak = new StringBuilder(" "); #region Add item count before title if(hoveredItem != null && hoveredItem.HasBeenInInventory) @@ -201,10 +201,14 @@ namespace stardew_access.Patches #region Narrate toSpeak // To prevent it from getting conflicted by two hover texts at the same time, two seperate methods are used. // For example, sometimes `Welcome to Pierre's` and the items in seeds shop get conflicted causing it to speak infinitely. - if(Context.IsPlayerFree) - ScreenReader.sayWithChecker(toSpeak.ToString(), true); // Normal Checker - else - ScreenReader.sayWithMenuChecker(toSpeak.ToString(), true); // Normal Checker + + if (toSpeak.ToString() != " ") + { + if (Context.IsPlayerFree) + ScreenReader.sayWithChecker(toSpeak.ToString(), true); // Normal Checker + else + ScreenReader.sayWithMenuChecker(toSpeak.ToString(), true); // Normal Checker + } #endregion } catch (Exception e) diff --git a/stardew-access/Patches/MenuPatch.cs b/stardew-access/Patches/MenuPatch.cs index 70fe20d..3c12fd9 100644 --- a/stardew-access/Patches/MenuPatch.cs +++ b/stardew-access/Patches/MenuPatch.cs @@ -1,10 +1,8 @@ -using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; +using Microsoft.Xna.Framework.Graphics; using StardewModdingAPI; using StardewValley; using StardewValley.Menus; using StardewValley.Quests; -using static StardewValley.Menus.LoadGameMenu; namespace stardew_access.Patches { @@ -14,6 +12,26 @@ namespace stardew_access.Patches private static string currentDailyQuestText = " "; private static string currentLevelUpTitle = " "; + internal static void MineElevatorMenuPatch(List ___elevators) + { + 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++) + { + if(___elevators[i].containsPoint(x, y)) + { + ScreenReader.sayWithMenuChecker($"{___elevators[i].name} level", true); + break; + } + } + } + catch (Exception e) + { + MainClass.monitor.Log($"Unable to narrate Text:\n{e.Message}\n{e.StackTrace}", LogLevel.Error); + } + } + internal static void NamingMenuPatch(NamingMenu __instance, string title, TextBox ___textBox) { try @@ -51,8 +69,6 @@ namespace stardew_access.Patches } } - - internal static void OptionsPagePatch(OptionsPage __instance) { try diff --git a/stardew-access/Patches/TitleMenuPatches.cs b/stardew-access/Patches/TitleMenuPatches.cs index 0b00e15..5602cfd 100644 --- a/stardew-access/Patches/TitleMenuPatches.cs +++ b/stardew-access/Patches/TitleMenuPatches.cs @@ -1,5 +1,4 @@ - -using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework; using StardewModdingAPI; using StardewValley; using StardewValley.Menus;