Esempio n. 1
0
        static bool Prefix(SimGameOptionsMenu __instance, Action quitAction)
        {
            CombatGameState combatGameState = SharedState.Combat;

            if (combatGameState != null && !combatGameState.TurnDirector.IsMissionOver && combatGameState.TurnDirector.GameHasBegun)
            {
                Mod.Log.Trace?.Write("SGOM:CS - in combat.");

                string text   = Strings.T("Are you sure you want to quit?");
                string body   = Strings.T("You will lose all unsaved progress since your last manual save or autosave");
                string title  = Strings.T("Are you sure you want to quit?");
                string title2 = text;
                string body2  = Strings.T("You will forfeit the match if you quit");

                GameInstance        battleTechGame      = UnityGameInstance.BattleTechGame;
                GenericPopupBuilder genericPopupBuilder = GenericPopupBuilder.Create(text, body);
                genericPopupBuilder.AddButton("Cancel", null, true, null)
                .AddButton("Quit", quitAction, true, null)
                .CancelOnEscape();
                genericPopupBuilder.IsNestedPopupWithBuiltInFader().Render();

                return(false);
            }

            return(true);
        }
Esempio n. 2
0
        static void Postfix(SimGameOptionsMenu __instance,
                            HBSDOTweenButton ___saveGame, HBSTooltipHBSButton ___saveTooltip,
                            HBSDOTweenButton ___restartMission, HBSTooltipHBSButton ___restartTooltip)
        {
            CombatGameState combatGameState = SharedState.Combat;

            if (combatGameState != null && !combatGameState.TurnDirector.IsMissionOver && combatGameState.TurnDirector.GameHasBegun)
            {
                Mod.Log.Trace?.Write("SGOM:CS - in combat.");

                if (Mod.Config.Fixes.DisableCombatRestarts)
                {
                    Mod.Log.Debug?.Write("Disabling combat restarts.");
                    ___restartMission.SetState(ButtonState.Disabled);

                    string             title   = new Text(Mod.LocalizedText.Tooltips[ModText.TT_CombatRestartMission_Title]).ToString();
                    string             details = new Text(Mod.LocalizedText.Tooltips[ModText.TT_CombatRestartMission_Details]).ToString();
                    BaseDescriptionDef def     = new BaseDescriptionDef("SGMTipData", title, details, null);
                    ___restartTooltip.SetStateDataForButtonState(ButtonState.Disabled, TooltipUtilities.GetStateDataFromObject(def));
                }

                if (Mod.Config.Fixes.DisableCombatSaves && ___saveGame.State != ButtonState.Disabled)
                {
                    Mod.Log.Debug?.Write("Disabling combat saves.");
                    ___saveGame.SetState(ButtonState.Disabled);

                    string             title   = new Text(Mod.LocalizedText.Tooltips[ModText.TT_CombatSave_Title]).ToString();
                    string             details = new Text(Mod.LocalizedText.Tooltips[ModText.TT_CombatSave_Details]).ToString();
                    BaseDescriptionDef def     = new BaseDescriptionDef("SGMTipData", title, details, null);
                    ___saveTooltip.SetStateDataForButtonState(ButtonState.Disabled, TooltipUtilities.GetStateDataFromObject(def));
                }
            }
        }
Esempio n. 3
0
        public static void SimGameOptionsMenu_SetSaveTooltip_Postfix(SimGameOptionsMenu __instance, HBSTooltipHBSButton ___saveTooltip, SaveReason ___reason, HBSDOTweenButton ___saveGame)
        {
            if (___saveTooltip == null)
            {
                return;
            }

            GameInstance    battleTechGame = UnityGameInstance.BattleTechGame;
            CombatGameState combat         = battleTechGame.Combat;

            if (combat != null && !combat.TurnDirector.IsMissionOver && combat.TurnDirector.GameHasBegun)
            {
                string             details = "Saving during combat missions disabled to prevent errors and bugs.";
                BaseDescriptionDef def     = new BaseDescriptionDef("SGMTipData", "Unable to Save", details, null);
                ___saveTooltip.SetStateDataForButtonState(ButtonState.Disabled, TooltipUtilities.GetStateDataFromObject(def));
            }
        }
Esempio n. 4
0
        private static bool Prefix(SimGameOptionsMenu __instance, Action quitAction)
        {
            if (UnityGameInstance.BattleTechGame.IsMultiplayer)
            {
                return(true);
            }

            MessageCenter messageCenter = Traverse.Create(__instance).Field("messageCenter").GetValue <MessageCenter>();

            GenericPopupBuilder.
            Create("Are you sure you want to quit?", String.Empty).
            AddButton("Cancel", null, true, null).
            AddButton("Save & Quit", delegate
            {
                messageCenter.AddFiniteSubscriber(MessageCenterMessageType.BlockSaved, delegate(MessageCenterMessage message)
                {
                    quitAction();
                    return(true);
                });
                UnityGameInstance.BattleTechGame.Save(ModSettings.SIMGAME_AUTOSAVE_REASON, false);
            }, true, null).
            CancelOnEscape().IsNestedPopupWithBuiltInFader().Render();
            return(false);
        }