public static void OnLoad(string path) { var inst = ModDebugRegistry.Instance; RunningPLibAssembly = typeof(PUtil).Assembly; PUtil.InitLibrary(); if (DebugNotIncludedOptions.Instance?.DetailedBacktrace ?? true) { DebugLogger.InstallExceptionLogger(); } POptions.RegisterOptions(typeof(DebugNotIncludedOptions)); if (DebugNotIncludedOptions.Instance?.LogAsserts ?? true) { LogAllFailedAsserts(); } // Patch the exception logger for state machines var logException = typeof(DebugUtil).GetMethodSafe("LogException", true, PPatchTools.AnyArguments); if (logException != null) { inst.DebugInstance.Patch(logException, prefix: new HarmonyMethod(typeof( DebugLogger), nameof(DebugLogger.LogException))); } foreach (var mod in Global.Instance.modManager?.mods) { if (mod.label.install_path == path) { ThisMod = mod; break; } } if (ThisMod == null) { DebugLogger.LogWarning("Unable to determine KMod instance!"); } else { inst.RegisterModAssembly(Assembly.GetExecutingAssembly(), inst.GetDebugInfo( ThisMod)); } // Default UI debug key is ALT+U UIDebugAction = PAction.Register("DebugNotIncluded.UIDebugAction", DebugNotIncludedStrings.KEY_SNAPSHOT, new PKeyBinding(KKeyCode.U, Modifier.Alt)); // Must postload the mods dialog to come out after aki's mods, ony's mods, PLib // options, and so forth PUtil.RegisterPostload(PostloadHandler); }
public override void OnLoad(Harmony harmony) { var inst = ModDebugRegistry.Instance; var method = typeof(Mod).GetMethodSafe("Crash", false); if (method == null) { method = typeof(Mod).GetMethodSafe("SetCrashed", false); } if (method != null) { harmony.Patch(method, prefix: new HarmonyMethod(typeof( DebugNotIncludedPatches), nameof(OnModCrash))); } base.OnLoad(harmony); RunningPLibAssembly = typeof(PUtil).Assembly; PUtil.InitLibrary(); if (DebugNotIncludedOptions.Instance?.DetailedBacktrace ?? true) { DebugLogger.InstallExceptionLogger(); } new POptions().RegisterOptions(this, typeof(DebugNotIncludedOptions)); LocString.CreateLocStringKeys(typeof(DebugNotIncludedStrings.UI)); LocString.CreateLocStringKeys(typeof(DebugNotIncludedStrings.INPUT_BINDINGS)); loc.Register(); if (DebugNotIncludedOptions.Instance?.LogAsserts ?? true) { LogAllFailedAsserts(harmony); } ThisMod = mod; if (ThisMod == null) { DebugLogger.LogWarning("Unable to determine KMod instance!"); } new PPatchManager(harmony).RegisterPatchClass(typeof(DebugNotIncludedPatches)); // Force class initialization to avoid crashes on the background thread if // an Assert fails later DebugUtils.RegisterUIDebug(); new PLib.AVC.PVersionCheck().Register(this, new PLib.AVC.SteamVersionChecker()); }
public static void OnLoad(string path) { var inst = ModDebugRegistry.Instance; RunningPLibAssembly = typeof(PUtil).Assembly; PUtil.InitLibrary(); if (DebugNotIncludedOptions.Instance?.DetailedBacktrace ?? true) { DebugLogger.InstallExceptionLogger(); } POptions.RegisterOptions(typeof(DebugNotIncludedOptions)); // Set up strings LocString.CreateLocStringKeys(typeof(DebugNotIncludedStrings.UI)); LocString.CreateLocStringKeys(typeof(DebugNotIncludedStrings.INPUT_BINDINGS)); PLocalization.Register(); if (DebugNotIncludedOptions.Instance?.LogAsserts ?? true) { LogAllFailedAsserts(); } foreach (var mod in Global.Instance.modManager?.mods) { if (mod.GetModBasePath() == path) { ThisMod = mod; break; } } if (ThisMod == null) { DebugLogger.LogWarning("Unable to determine KMod instance!"); } else { inst.RegisterModAssembly(Assembly.GetExecutingAssembly(), inst.GetDebugInfo( ThisMod)); } // Default UI debug key is ALT+U UIDebugAction = PAction.Register("DebugNotIncluded.UIDebugAction", DebugNotIncludedStrings.INPUT_BINDINGS.DEBUG.SNAPSHOT, new PKeyBinding( KKeyCode.U, Modifier.Alt)); // Must postload the mods dialog to come out after aki's mods, ony's mods, PLib // options, and so forth PUtil.RegisterPatchClass(typeof(DebugNotIncludedPatches)); }