Esempio n. 1
0
        public override void OnInitialState()
        {
            base.OnInitialState();

            if (!SubModule.ConfirmFileExists())
            {
                InformationManager.ShowInquiry(new InquiryData(
                                                   L10N.GetText("ModName"),
                                                   L10N.GetText("ModWarningMessage"),
                                                   true,
                                                   false,
                                                   L10N.GetText("ModWarningMessageConfirm"),
                                                   null,
                                                   SubModule.CreateConfirmFile,
                                                   null));
            }
        }
Esempio n. 2
0
        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
                }
            }
        }
Esempio n. 3
0
        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
                }
            }
        }