private static void PostloadHandler(HarmonyInstance instance) { if (DebugNotIncludedOptions.Instance?.PowerUserMode ?? false) { instance.Patch(typeof(ModsScreen), "BuildDisplay", new HarmonyMethod(typeof(DebugNotIncludedPatches), nameof(HidePopups)), new HarmonyMethod(typeof(DebugNotIncludedPatches), nameof(BuildDisplay))); } KInputHandler.Add(Global.Instance.GetInputManager().GetDefaultController(), new UISnapshotHandler(), 1024); // New postload architecture requires going back a little ways var st = new System.Diagnostics.StackTrace(6); Assembly assembly = null; if (st.FrameCount > 0) { assembly = st.GetFrame(0).GetMethod()?.DeclaringType?.Assembly; } PUtil.LogDebug(assembly?.FullName ?? "none"); RunningPLibAssembly = assembly ?? Assembly.GetCallingAssembly(); // Log which mod is running PLib var latest = ModDebugRegistry.Instance.OwnerOfAssembly(RunningPLibAssembly); if (latest != null) { DebugLogger.LogDebug("Executing version of PLib is from: " + latest.ModName); } HarmonyPatchInspector.Check(); }
/// <summary> /// Applied after GetOriginalMethod runs. /// </summary> internal static void Postfix(HarmonyMethod ___containerAttributes, Type ___container, MethodBase __result) { if (__result != null && ___containerAttributes != null) { HarmonyPatchInspector.CheckHarmonyMethod(___containerAttributes, ___container); } }
/// <summary> /// Runs the required postload patches after all other mods load. /// </summary> /// <param name="instance">The Harmony instance to execute patches.</param> public override void OnAllModsLoaded(Harmony harmony, IReadOnlyList <Mod> mods) { var options = DebugNotIncludedOptions.Instance; if (options?.PowerUserMode == true) { harmony.Patch(typeof(ModsScreen), "BuildDisplay", new HarmonyMethod(typeof(DebugNotIncludedPatches), nameof(HidePopups)), new HarmonyMethod(typeof(DebugNotIncludedPatches), nameof(BuildDisplay))); } if (mods != null) { ModDebugRegistry.Instance.Populate(mods); } else { DebugLogger.LogWarning("Mods list is empty! Attribution will not work"); } var runningCore = PRegistry.Instance.GetLatestVersion( "PeterHan.PLib.Core.PLibCorePatches")?.GetOwningAssembly(); if (runningCore != null) { RunningPLibAssembly = runningCore; } // Log which mod is running PLib var latest = ModDebugRegistry.Instance.OwnerOfAssembly(RunningPLibAssembly); if (latest != null) { DebugLogger.LogDebug("Executing version of PLib is from: " + latest.ModName); } HarmonyPatchInspector.Check(); #if DEBUG harmony.ProfileMethod(typeof(SaveLoader).GetMethodSafe("Load", false, typeof( IReader))); harmony.ProfileMethod(typeof(SaveLoader).GetMethodSafe("Save", false, typeof( BinaryWriter))); harmony.ProfileMethod(typeof(SaveManager).GetMethodSafe("Load", false, PPatchTools.AnyArguments)); harmony.ProfileMethod(typeof(SaveManager).GetMethodSafe("Save", false, PPatchTools.AnyArguments)); #endif if (options?.LocalizeMods == true) { typeof(PLocalization).GetMethodSafe("DumpAll", false)?.Invoke(loc, null); } }
private static void PostloadHandler(HarmonyInstance instance) { if (DebugNotIncludedOptions.Instance?.PowerUserMode ?? false) { instance.Patch(typeof(ModsScreen), "BuildDisplay", new HarmonyMethod(typeof(DebugNotIncludedPatches), nameof(HidePopups)), new HarmonyMethod(typeof(DebugNotIncludedPatches), nameof(BuildDisplay))); } KInputHandler.Add(Global.Instance.GetInputManager().GetDefaultController(), new UISnapshotHandler(), 1024); // New postload architecture requires going back a little ways var st = new StackTrace(6); Assembly assembly = null; if (st.FrameCount > 0) { assembly = st.GetFrame(0).GetMethod()?.DeclaringType?.Assembly; } RunningPLibAssembly = assembly ?? Assembly.GetCallingAssembly(); // Log which mod is running PLib var latest = ModDebugRegistry.Instance.OwnerOfAssembly(RunningPLibAssembly); if (latest != null) { DebugLogger.LogDebug("Executing version of PLib is from: " + latest.ModName); } HarmonyPatchInspector.Check(); #if DEBUG // SaveManager.Load:: 13831 ms instance.ProfileMethod(typeof(SaveLoader).GetMethodSafe("Load", false, typeof( IReader))); instance.ProfileMethod(typeof(SaveLoader).GetMethodSafe("Save", false, typeof( BinaryWriter))); instance.ProfileMethod(typeof(SaveManager).GetMethodSafe("Load", false, PPatchTools.AnyArguments)); instance.ProfileMethod(typeof(SaveManager).GetMethodSafe("Save", false, PPatchTools.AnyArguments)); #endif }