Moved patches related to Game1 and InstanceGame to their own class
This commit is contained in:
		| @@ -222,9 +222,10 @@ namespace stardew_access | |||||||
|                     original: AccessTools.Method(typeof(IClickableMenu), nameof(IClickableMenu.exitThisMenu)), |                     original: AccessTools.Method(typeof(IClickableMenu), nameof(IClickableMenu.exitThisMenu)), | ||||||
|                     postfix: new HarmonyMethod(typeof(IClickableMenuPatch), nameof(IClickableMenuPatch.ExitThisMenuPatch)) |                     postfix: new HarmonyMethod(typeof(IClickableMenuPatch), nameof(IClickableMenuPatch.ExitThisMenuPatch)) | ||||||
|                 ); |                 ); | ||||||
|  |  | ||||||
|             harmony.Patch( |             harmony.Patch( | ||||||
|                     original: AccessTools.Method(typeof(Game1), nameof(Game1.exitActiveMenu)), |                     original: AccessTools.Method(typeof(Game1), nameof(Game1.exitActiveMenu)), | ||||||
|                     prefix: new HarmonyMethod(typeof(MenuPatches), nameof(MenuPatches.Game1ExitActiveMenuPatch)) |                     prefix: new HarmonyMethod(typeof(Game1Patch), nameof(Game1Patch.ExitActiveMenuPatch)) | ||||||
|                 ); |                 ); | ||||||
|             #endregion |             #endregion | ||||||
|  |  | ||||||
| @@ -278,12 +279,12 @@ namespace stardew_access | |||||||
|  |  | ||||||
|             harmony.Patch( |             harmony.Patch( | ||||||
|                     original: AccessTools.Method(typeof(Game1), nameof(Game1.playSound)), |                     original: AccessTools.Method(typeof(Game1), nameof(Game1.playSound)), | ||||||
|                     prefix: new HarmonyMethod(typeof(MenuPatches), nameof(MenuPatches.PlaySoundPatch)) |                     prefix: new HarmonyMethod(typeof(Game1Patch), nameof(Game1Patch.PlaySoundPatch)) | ||||||
|                 ); |                 ); | ||||||
|  |  | ||||||
|             harmony.Patch( |             harmony.Patch( | ||||||
|                     original: AccessTools.Method(typeof(InstanceGame), nameof(InstanceGame.Exit)), |                     original: AccessTools.Method(typeof(InstanceGame), nameof(InstanceGame.Exit)), | ||||||
|                     prefix: new HarmonyMethod(typeof(MenuPatches), nameof(MenuPatches.ExitEventPatch)) |                     prefix: new HarmonyMethod(typeof(InstanceGamePatch), nameof(InstanceGamePatch.ExitPatch)) | ||||||
|                 ); |                 ); | ||||||
|  |  | ||||||
|             harmony.Patch( |             harmony.Patch( | ||||||
|   | |||||||
							
								
								
									
										56
									
								
								stardew-access/Patches/Game1Patch.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										56
									
								
								stardew-access/Patches/Game1Patch.cs
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,56 @@ | |||||||
|  | using Microsoft.Xna.Framework; | ||||||
|  | using stardew_access.Features; | ||||||
|  | using StardewModdingAPI; | ||||||
|  | using StardewValley; | ||||||
|  |  | ||||||
|  | namespace stardew_access.Patches | ||||||
|  | { | ||||||
|  |     internal class Game1Patch | ||||||
|  |     { | ||||||
|  |         private static Vector2? prevTile = null; | ||||||
|  |  | ||||||
|  |         internal static void ExitActiveMenuPatch() | ||||||
|  |         { | ||||||
|  |             try | ||||||
|  |             { | ||||||
|  |                 IClickableMenuPatch.Cleanup(Game1.activeClickableMenu); | ||||||
|  |             } | ||||||
|  |             catch (Exception e) | ||||||
|  |             { | ||||||
|  |                 MainClass.ErrorLog($"Unable to narrate Text:\n{e.Message}\n{e.StackTrace}"); | ||||||
|  |             } | ||||||
|  |         } | ||||||
|  |  | ||||||
|  |         internal static bool PlaySoundPatch(string cueName) | ||||||
|  |         { | ||||||
|  |             try | ||||||
|  |             { | ||||||
|  |                 if (!Context.IsPlayerFree) | ||||||
|  |                     return true; | ||||||
|  |  | ||||||
|  |                 if (!Game1.player.isMoving()) | ||||||
|  |                     return true; | ||||||
|  |  | ||||||
|  |                 if (cueName == "grassyStep" || cueName == "sandyStep" || cueName == "snowyStep" || cueName == "stoneStep" || cueName == "thudStep" || cueName == "woodyStep") | ||||||
|  |                 { | ||||||
|  |                     Vector2 nextTile = CurrentPlayer.FacingTile; | ||||||
|  |                     if (TileInfo.isCollidingAtTile((int)nextTile.X, (int)nextTile.Y)) | ||||||
|  |                     { | ||||||
|  |                         if (prevTile != nextTile) | ||||||
|  |                         { | ||||||
|  |                             prevTile = nextTile; | ||||||
|  |                             //Game1.playSound("colliding"); | ||||||
|  |                         } | ||||||
|  |                         return false; | ||||||
|  |                     } | ||||||
|  |                 } | ||||||
|  |             } | ||||||
|  |             catch (Exception e) | ||||||
|  |             { | ||||||
|  |                 MainClass.ErrorLog($"Unable to narrate Text:\n{e.Message}\n{e.StackTrace}"); | ||||||
|  |             } | ||||||
|  |  | ||||||
|  |             return true; | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  | } | ||||||
							
								
								
									
										11
									
								
								stardew-access/Patches/InstanceGamePatch.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										11
									
								
								stardew-access/Patches/InstanceGamePatch.cs
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,11 @@ | |||||||
|  | namespace stardew_access.Patches | ||||||
|  | { | ||||||
|  |     internal class InstanceGamePatch | ||||||
|  |     { | ||||||
|  |         internal static void ExitPatch() | ||||||
|  |         { | ||||||
|  |             if (MainClass.ScreenReader != null) | ||||||
|  |                 MainClass.ScreenReader.CloseScreenReader(); | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  | } | ||||||
| @@ -17,7 +17,6 @@ namespace stardew_access.Patches | |||||||
|         internal static string forgeMenuQuery = " "; |         internal static string forgeMenuQuery = " "; | ||||||
|         internal static string itemListMenuQuery = " "; |         internal static string itemListMenuQuery = " "; | ||||||
|         internal static int prevSlotIndex = -999; |         internal static int prevSlotIndex = -999; | ||||||
|         public static Vector2? prevTile = null; |  | ||||||
|  |  | ||||||
|         internal static void ItemListMenuPatch(ItemListMenu __instance, string ___title, int ___currentTab, int ___totalValueOfItems, List<Item> ___itemsToList) |         internal static void ItemListMenuPatch(ItemListMenu __instance, string ___title, int ___currentTab, int ___totalValueOfItems, List<Item> ___itemsToList) | ||||||
|         { |         { | ||||||
| @@ -312,37 +311,6 @@ namespace stardew_access.Patches | |||||||
|             } |             } | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         internal static bool PlaySoundPatch(string cueName) |  | ||||||
|         { |  | ||||||
|             try |  | ||||||
|             { |  | ||||||
|                 if (!Context.IsPlayerFree) |  | ||||||
|                     return true; |  | ||||||
|  |  | ||||||
|                 if (!Game1.player.isMoving()) |  | ||||||
|                     return true; |  | ||||||
|  |  | ||||||
|                 if (cueName == "grassyStep" || cueName == "sandyStep" || cueName == "snowyStep" || cueName == "stoneStep" || cueName == "thudStep" || cueName == "woodyStep") |  | ||||||
|                 { |  | ||||||
|                     Vector2 nextTile = CurrentPlayer.FacingTile; |  | ||||||
|                     if (TileInfo.isCollidingAtTile((int)nextTile.X, (int)nextTile.Y)) |  | ||||||
|                     { |  | ||||||
|                         if (prevTile != nextTile) |  | ||||||
|                         { |  | ||||||
|                             prevTile = nextTile; |  | ||||||
|                             //Game1.playSound("colliding"); |  | ||||||
|                         } |  | ||||||
|                         return false; |  | ||||||
|                     } |  | ||||||
|                 } |  | ||||||
|             } |  | ||||||
|             catch (Exception e) |  | ||||||
|             { |  | ||||||
|                 MainClass.ErrorLog($"Unable to narrate Text:\n{e.Message}\n{e.StackTrace}"); |  | ||||||
|             } |  | ||||||
|  |  | ||||||
|             return true; |  | ||||||
|         } |  | ||||||
|  |  | ||||||
|         internal static void LanguageSelectionMenuPatch(LanguageSelectionMenu __instance) |         internal static void LanguageSelectionMenuPatch(LanguageSelectionMenu __instance) | ||||||
|         { |         { | ||||||
| @@ -604,22 +572,6 @@ namespace stardew_access.Patches | |||||||
|             } |             } | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         internal static void Game1ExitActiveMenuPatch() |  | ||||||
|         { |  | ||||||
|             try |  | ||||||
|             { |  | ||||||
|                 IClickableMenuPatch.Cleanup(Game1.activeClickableMenu); |  | ||||||
|             } |  | ||||||
|             catch (Exception e) |  | ||||||
|             { |  | ||||||
|                 MainClass.ErrorLog($"Unable to narrate Text:\n{e.Message}\n{e.StackTrace}"); |  | ||||||
|             } |  | ||||||
|         } |  | ||||||
|  |  | ||||||
|         internal static void ExitEventPatch() |  | ||||||
|         { |  | ||||||
|             if (MainClass.ScreenReader != null) |  | ||||||
|                 MainClass.ScreenReader.CloseScreenReader(); |  | ||||||
|         } |  | ||||||
|     } |     } | ||||||
| } | } | ||||||
|   | |||||||
| @@ -1,11 +0,0 @@ | |||||||
| using Microsoft.Xna.Framework.Graphics; |  | ||||||
| using StardewValley; |  | ||||||
| using StardewValley.Menus; |  | ||||||
| using StardewValley.Quests; |  | ||||||
|  |  | ||||||
| namespace stardew_access.Patches |  | ||||||
| { |  | ||||||
|     internal class QuestPatches |  | ||||||
|     { |  | ||||||
|     } |  | ||||||
| } |  | ||||||
		Reference in New Issue
	
	Block a user