From 9d1c6f95dd3a44efaa8d34dca6228d55c8f9dd2d Mon Sep 17 00:00:00 2001 From: Mohammad Shoaib Khan Date: Sun, 23 Oct 2022 11:14:58 +0530 Subject: [PATCH] Issue#52 Patched speech bubbles --- stardew-access/Features/StaticTiles.cs | 2 +- stardew-access/Features/TileInfo.cs | 12 ++++++------ stardew-access/HarmonyPatches.cs | 5 +++++ stardew-access/Patches/DialoguePatches.cs | 16 +++++++++++++++- 4 files changed, 27 insertions(+), 8 deletions(-) diff --git a/stardew-access/Features/StaticTiles.cs b/stardew-access/Features/StaticTiles.cs index c0bb806..4ce596d 100644 --- a/stardew-access/Features/StaticTiles.cs +++ b/stardew-access/Features/StaticTiles.cs @@ -45,7 +45,7 @@ namespace stardew_access.Features foreach (var location in data) { - if (!Game1.currentLocation.name.Value.ToLower().Equals(location.Key.ToLower())) + if (!Game1.currentLocation.Name.ToLower().Equals(location.Key.ToLower())) continue; if (location.Value != null) diff --git a/stardew-access/Features/TileInfo.cs b/stardew-access/Features/TileInfo.cs index 1e15d45..5f20015 100644 --- a/stardew-access/Features/TileInfo.cs +++ b/stardew-access/Features/TileInfo.cs @@ -478,7 +478,7 @@ namespace stardew_access.Features return (CATEGORY.Interactables, "Island Trader"); } } - else if (Game1.currentLocation.name.Value.ToLower().Equals("coop")) + else if (Game1.currentLocation.Name.ToLower().Equals("coop")) { if (x >= 6 && x <= 9 && y == 3) { @@ -489,7 +489,7 @@ namespace stardew_access.Features return (CATEGORY.Others, "Empty Feeding Bench"); } } - else if (Game1.currentLocation.name.Value.ToLower().Equals("big coop") || Game1.currentLocation.name.Value.ToLower().Equals("coop2")) + else if (Game1.currentLocation.Name.ToLower().Equals("big coop") || Game1.currentLocation.Name.ToLower().Equals("coop2")) { if (x >= 6 && x <= 13 && y == 3) { @@ -500,7 +500,7 @@ namespace stardew_access.Features return (CATEGORY.Others, "Empty Feeding Bench"); } } - else if (Game1.currentLocation.name.Value.ToLower().Equals("deluxe coop") || Game1.currentLocation.name.Value.ToLower().Equals("coop3")) + else if (Game1.currentLocation.Name.ToLower().Equals("deluxe coop") || Game1.currentLocation.Name.ToLower().Equals("coop3")) { if (x >= 6 && x <= 17 && y == 3) { @@ -511,7 +511,7 @@ namespace stardew_access.Features return (CATEGORY.Others, "Empty Feeding Bench"); } } - else if (Game1.currentLocation.name.Value.ToLower().Equals("barn")) + else if (Game1.currentLocation.Name.ToLower().Equals("barn")) { if (x >= 8 && x <= 11 && y == 3) { @@ -522,7 +522,7 @@ namespace stardew_access.Features return (CATEGORY.Others, "Empty Feeding Bench"); } } - else if (Game1.currentLocation.name.Value.ToLower().Equals("big barn") || Game1.currentLocation.name.Value.ToLower().Equals("barn2")) + else if (Game1.currentLocation.Name.ToLower().Equals("big barn") || Game1.currentLocation.Name.ToLower().Equals("barn2")) { if (x >= 8 && x <= 15 && y == 3) { @@ -533,7 +533,7 @@ namespace stardew_access.Features return (CATEGORY.Others, "Empty Feeding Bench"); } } - else if (Game1.currentLocation.name.Value.ToLower().Equals("deluxe barn") || Game1.currentLocation.name.Value.ToLower().Equals("barn3")) + else if (Game1.currentLocation.Name.ToLower().Equals("deluxe barn") || Game1.currentLocation.Name.ToLower().Equals("barn3")) { if (x >= 8 && x <= 19 && y == 3) { diff --git a/stardew-access/HarmonyPatches.cs b/stardew-access/HarmonyPatches.cs index ec74193..fbd1d92 100644 --- a/stardew-access/HarmonyPatches.cs +++ b/stardew-access/HarmonyPatches.cs @@ -28,6 +28,11 @@ namespace stardew_access original: AccessTools.Method(typeof(IClickableMenu), nameof(IClickableMenu.drawHoverText), new Type[] { typeof(SpriteBatch), typeof(string), typeof(SpriteFont), typeof(int), typeof(int), typeof(int), typeof(string), typeof(int), typeof(string[]), typeof(Item), typeof(int), typeof(int), typeof(int), typeof(int), typeof(int), typeof(float), typeof(CraftingRecipe), typeof(IList) }), postfix: new HarmonyMethod(typeof(DialoguePatches), nameof(DialoguePatches.HoverTextPatch)) ); + + harmony.Patch( + original: AccessTools.Method(typeof(NPC), nameof(NPC.drawAboveAlwaysFrontLayer)), + postfix: new HarmonyMethod(typeof(DialoguePatches), nameof(DialoguePatches.drawAboveAlwaysFrontLayerPatch)) + ); #endregion #region Title Menu Patches diff --git a/stardew-access/Patches/DialoguePatches.cs b/stardew-access/Patches/DialoguePatches.cs index b59bbef..e131952 100644 --- a/stardew-access/Patches/DialoguePatches.cs +++ b/stardew-access/Patches/DialoguePatches.cs @@ -340,7 +340,6 @@ namespace stardew_access.Patches } catch (Exception e) { - MainClass.ErrorLog($"Unable to narrate Text:\n{e.Message}\n{e.StackTrace}"); } } @@ -409,5 +408,20 @@ namespace stardew_access.Patches #endregion } + + internal static void drawAboveAlwaysFrontLayerPatch(NPC __instance, string ___textAboveHead, int ___textAboveHeadTimer) + { + try + { + if (___textAboveHeadTimer > 2900 && ___textAboveHead != null) + { + MainClass.ScreenReader.SayWithChecker($"{__instance.displayName} says {___textAboveHead}", true); + } + } + catch (Exception e) + { + MainClass.ErrorLog($"Error in patch:NPCShowTextAboveHeadPatch \n{e.Message}\n{e.StackTrace}"); + } + } } }