diff options
author | Jesse Plamondon-Willard <Pathoschild@users.noreply.github.com> | 2021-07-30 00:40:12 -0400 |
---|---|---|
committer | Jesse Plamondon-Willard <Pathoschild@users.noreply.github.com> | 2021-07-30 00:40:12 -0400 |
commit | 4074f697d73f5cac6699836550b144fd0c4e2803 (patch) | |
tree | 022363fa6cf01b947cd39d8a754fb36326898059 /src/SMAPI | |
parent | aa65b2e2f6ae2578f9d1f81d6fc1f4c5a261d90f (diff) | |
download | SMAPI-4074f697d73f5cac6699836550b144fd0c4e2803.tar.gz SMAPI-4074f697d73f5cac6699836550b144fd0c4e2803.tar.bz2 SMAPI-4074f697d73f5cac6699836550b144fd0c4e2803.zip |
rename patch classes for consistency
Diffstat (limited to 'src/SMAPI')
-rw-r--r-- | src/SMAPI/Framework/SCore.cs | 2 | ||||
-rw-r--r-- | src/SMAPI/Patches/Game1Patcher.cs (renamed from src/SMAPI/Patches/LoadContextPatch.cs) | 32 |
2 files changed, 17 insertions, 17 deletions
diff --git a/src/SMAPI/Framework/SCore.cs b/src/SMAPI/Framework/SCore.cs index 419afd4b..35db2da2 100644 --- a/src/SMAPI/Framework/SCore.cs +++ b/src/SMAPI/Framework/SCore.cs @@ -255,7 +255,7 @@ namespace StardewModdingAPI.Framework // apply game patches MiniMonoModHotfix.Apply(); new GamePatcher(this.Monitor).Apply( - new LoadContextPatch(this.Reflection, this.OnLoadStageChanged), + new Game1Patcher(this.Reflection, this.OnLoadStageChanged), new TitleMenuPatcher(this.OnLoadStageChanged) ); diff --git a/src/SMAPI/Patches/LoadContextPatch.cs b/src/SMAPI/Patches/Game1Patcher.cs index c7f7d986..82b13869 100644 --- a/src/SMAPI/Patches/LoadContextPatch.cs +++ b/src/SMAPI/Patches/Game1Patcher.cs @@ -14,7 +14,7 @@ namespace StardewModdingAPI.Patches /// <remarks>Patch methods must be static for Harmony to work correctly. See the Harmony documentation before renaming patch arguments.</remarks> [SuppressMessage("ReSharper", "InconsistentNaming", Justification = "Argument names are defined by Harmony and methods are named for clarity.")] [SuppressMessage("ReSharper", "IdentifierTypo", Justification = "Argument names are defined by Harmony and methods are named for clarity.")] - internal class LoadContextPatch : IHarmonyPatch + internal class Game1Patcher : IHarmonyPatch { /********* ** Fields @@ -35,10 +35,10 @@ namespace StardewModdingAPI.Patches /// <summary>Construct an instance.</summary> /// <param name="reflection">Simplifies access to private code.</param> /// <param name="onStageChanged">A callback to invoke when the load stage changes.</param> - public LoadContextPatch(Reflector reflection, Action<LoadStage> onStageChanged) + public Game1Patcher(Reflector reflection, Action<LoadStage> onStageChanged) { - LoadContextPatch.Reflection = reflection; - LoadContextPatch.OnStageChanged = onStageChanged; + Game1Patcher.Reflection = reflection; + Game1Patcher.OnStageChanged = onStageChanged; } /// <inheritdoc /> @@ -47,20 +47,20 @@ namespace StardewModdingAPI.Patches // detect CreatedInitialLocations and SaveAddedLocations harmony.Patch( original: AccessTools.Method(typeof(Game1), nameof(Game1.AddModNPCs)), - prefix: new HarmonyMethod(this.GetType(), nameof(LoadContextPatch.Before_Game1_AddModNPCs)) + prefix: new HarmonyMethod(this.GetType(), nameof(Game1Patcher.Before_Game1_AddModNPCs)) ); // detect CreatedLocations, and track IsInLoadForNewGame harmony.Patch( original: AccessTools.Method(typeof(Game1), nameof(Game1.loadForNewGame)), - prefix: new HarmonyMethod(this.GetType(), nameof(LoadContextPatch.Before_Game1_LoadForNewGame)), - postfix: new HarmonyMethod(this.GetType(), nameof(LoadContextPatch.After_Game1_LoadForNewGame)) + prefix: new HarmonyMethod(this.GetType(), nameof(Game1Patcher.Before_Game1_LoadForNewGame)), + postfix: new HarmonyMethod(this.GetType(), nameof(Game1Patcher.After_Game1_LoadForNewGame)) ); // detect ReturningToTitle harmony.Patch( original: AccessTools.Method(typeof(Game1), nameof(Game1.CleanupReturningToTitle)), - prefix: new HarmonyMethod(this.GetType(), nameof(LoadContextPatch.Before_Game1_CleanupReturningToTitle)) + prefix: new HarmonyMethod(this.GetType(), nameof(Game1Patcher.Before_Game1_CleanupReturningToTitle)) ); } @@ -75,9 +75,9 @@ namespace StardewModdingAPI.Patches { // When this method is called from Game1.loadForNewGame, it happens right after adding the vanilla // locations but before initializing them. - if (LoadContextPatch.IsInLoadForNewGame) + if (Game1Patcher.IsInLoadForNewGame) { - LoadContextPatch.OnStageChanged(LoadContextPatch.IsCreating() + Game1Patcher.OnStageChanged(Game1Patcher.IsCreating() ? LoadStage.CreatedInitialLocations : LoadStage.SaveAddedLocations ); @@ -91,7 +91,7 @@ namespace StardewModdingAPI.Patches /// <remarks>This method must be static for Harmony to work correctly. See the Harmony documentation before renaming arguments.</remarks> private static bool Before_Game1_CleanupReturningToTitle() { - LoadContextPatch.OnStageChanged(LoadStage.ReturningToTitle); + Game1Patcher.OnStageChanged(LoadStage.ReturningToTitle); return true; } @@ -100,7 +100,7 @@ namespace StardewModdingAPI.Patches /// <remarks>This method must be static for Harmony to work correctly. See the Harmony documentation before renaming arguments.</remarks> private static bool Before_Game1_LoadForNewGame() { - LoadContextPatch.IsInLoadForNewGame = true; + Game1Patcher.IsInLoadForNewGame = true; return true; } @@ -108,10 +108,10 @@ namespace StardewModdingAPI.Patches /// <remarks>This method must be static for Harmony to work correctly. See the Harmony documentation before renaming arguments.</remarks> private static void After_Game1_LoadForNewGame() { - LoadContextPatch.IsInLoadForNewGame = false; + Game1Patcher.IsInLoadForNewGame = false; - if (LoadContextPatch.IsCreating()) - LoadContextPatch.OnStageChanged(LoadStage.CreatedLocations); + if (Game1Patcher.IsCreating()) + Game1Patcher.OnStageChanged(LoadStage.CreatedLocations); } /// <summary>Get whether the save file is currently being created.</summary> @@ -119,7 +119,7 @@ namespace StardewModdingAPI.Patches { return (Game1.currentMinigame is Intro) // creating save with intro - || (Game1.activeClickableMenu is TitleMenu menu && LoadContextPatch.Reflection.GetField<bool>(menu, "transitioningCharacterCreationMenu").GetValue()); // creating save, skipped intro + || (Game1.activeClickableMenu is TitleMenu menu && Game1Patcher.Reflection.GetField<bool>(menu, "transitioningCharacterCreationMenu").GetValue()); // creating save, skipped intro } } } |