public override void OnGameInitializationFinished(Game game) { base.OnGameInitializationFinished(game); if (!(game.GameType is Campaign) || SubModule.PatchesApplied) { return; } try { var harmony = new Harmony("BannerlordCheats"); harmony.PatchAll(); SubModule.PatchesApplied = true; } catch (Exception e) { Debugger.Break(); try { var errorFilePath = SubModule.CreateErrorFile(e); InformationManager.ShowInquiry(new InquiryData( L10N.GetText("ModFailedLoadWarningTitle"), L10N.GetTextFormat("ModFailedLoadWarningMessage", errorFilePath), true, false, L10N.GetText("ModWarningMessageConfirm"), null, null, null)); } catch { // Not worth crashing for } } }
internal static void LogError(Exception e, Type type) { string errorFilePath; try { errorFilePath = SubModule.CreateErrorFile(e, type); } catch { return; } try { InformationManager.ShowInquiry(new InquiryData( L10N.GetText("ModExceptionTitle"), L10N.GetTextFormat("ModExceptionMessage", errorFilePath), true, false, L10N.GetText("ModWarningMessageConfirm"), null, null, null)); } catch { try { Message.Show(L10N.GetTextFormat("ModExceptionMessage", errorFilePath), Colors.Red); } catch { // If this fails everything is lost anyways } } }