Exemplo n.º 1
0
        public static void VariantPopup(string desc, SimGameState s, IEnumerable <MechDef> variantsToList, MechBayPanel refresh = null, SimpleMechAssembly_InterruptManager_AssembleMechEntry close = null)
        {
            GenericPopupBuilder pop    = GenericPopupBuilder.Create("Assemble Mech?", desc);
            bool   hasMultipleVariants = variantsToList.Count() > 1;
            string closeButtonText     = hasMultipleVariants ? "-" : "Not now";

            pop.AddButton(closeButtonText, delegate
            {
                if (close != null)
                {
                    close.NewClose();
                }
            }, true, null);


            foreach (MechDef m in variantsToList)
            {
                string buttonText = hasMultipleVariants ? string.Format("{0}", m.Chassis.VariantName) : "Yes";
                pop.AddButton(buttonText, delegate
                {
                    PerformMechAssemblyStorePopup(s, m, refresh, close);
                }, true, null);
            }

            pop.CancelOnEscape();
            pop.AddFader(new UIColorRef?(LazySingletonBehavior <UIManager> .Instance.UILookAndColorConstants.PopupBackfill), 0f, true);
            pop.Render();
        }
            public void RenderSkip(DateTime t)
            {
                GenericPopupBuilder pop = GenericPopupBuilder.Create("Skip Time?", $"Skip to: {t:D}?\nSkipping time can take a moment.");

                pop.AddButton("Cancel", NewClose, true, null);
                pop.AddButton("Skip and collect News", delegate { state.AdvanceTo(t, false); NewClose(); }, true, null);
                pop.AddButton("Skip and block News", delegate { state.AdvanceTo(t, true); NewClose(); }, true, null);
                pop.AddFader(new UIColorRef?(LazySingletonBehavior <UIManager> .Instance.UILookAndColorConstants.PopupBackfill), 0f, true);
                pop.Render();
            }
            public void RenderBy()
            {
                GenericPopupBuilder pop = GenericPopupBuilder.Create("Skip Time?", "Choose how many years to skip.");

                pop.AddButton("0", NewClose, true, null);
                foreach (int t in BTTimeSkip_Main.Settings.SkipBy)
                {
                    DateTime t2 = state.CurrentDate.AddYears(t);
                    pop.AddButton(t.ToString(), delegate { RenderSkip(t2); }, true, null);
                }
                pop.AddFader(new UIColorRef?(LazySingletonBehavior <UIManager> .Instance.UILookAndColorConstants.PopupBackfill), 0f, true);
                pop.Render();
            }
Exemplo n.º 4
0
        public static void UnStorageOmniMechPopup(SimGameState s, MechDef d, MechBayPanel refresh)
        {
            if (Settings.OmniMechTag == null)
            {
                throw new InvalidOperationException("omnimechs disabled");
            }
            int mechbay = s.GetFirstFreeMechBay();

            if (mechbay < 0)
            {
                return;
            }
            List <MechDef> mechs = GetAllOmniVariants(s, d);
            string         desc  = "Yang: We know the following Omni variants. Which should I build?\n\n";

            foreach (MechDef m in mechs)
            {
                if (!CheckOmniKnown(s, d, m))
                {
                    continue;
                }
                int com = GetNumberOfMechsOwnedOfType(s, m);
                desc += string.Format("[[DM.MechDefs[{3}],{0} {1}]] ({2} Complete)\n", m.Chassis.Description.UIName, m.Chassis.VariantName, com, m.Description.Id);
            }
            GenericPopupBuilder pop = GenericPopupBuilder.Create("Ready Mech?", desc);

            pop.AddButton("-", null, true, null);
            foreach (MechDef m in mechs)
            {
                MechDef var = m; // new var to keep it for lambda
                if (!CheckOmniKnown(s, d, m))
                {
                    continue;
                }
                pop.AddButton(string.Format("{0} {1}", var.Chassis.Description.UIName, var.Chassis.VariantName), delegate
                {
                    Log.Log("ready omni as: " + var.Description.Id);
                    s.ScrapInactiveMech(d.Chassis.Description.Id, false);
                    ReadyMech(s, new MechDef(var, s.GenerateSimGameUID(), false), mechbay);
                    if (refresh != null)
                    {
                        refresh.RefreshData(false);
                        refresh.ViewBays();
                    }
                }, true, null);
            }
            pop.AddFader(new UIColorRef?(LazySingletonBehavior <UIManager> .Instance.UILookAndColorConstants.PopupBackfill), 0f, true);
            pop.Render();
        }
Exemplo n.º 5
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);
        }
            public void RenderTo()
            {
                GenericPopupBuilder pop = GenericPopupBuilder.Create("Skip Time?", "Choose when you want to resume playing.");

                pop.AddButton("now", NewClose, true, null);
                foreach (string t in BTTimeSkip_Main.Settings.SkipTo)
                {
                    DateTime t2 = DateTime.Parse(t);
                    if (state.GetDayDiff(t2) > 0)
                    {
                        pop.AddButton(t, delegate { RenderSkip(t2); }, true, null);
                    }
                }
                pop.AddFader(new UIColorRef?(LazySingletonBehavior <UIManager> .Instance.UILookAndColorConstants.PopupBackfill), 0f, true);
                pop.Render();
            }
            public override void Render()
            {
                if (!state.CanAdvance())
                {
                    GenericPopupBuilder.Create("Skip Time?", "Currently impossible!\nYou have to be in a stable orbit and nothing to work on.").AddButton("Cancel", NewClose, true, null)
                    .AddFader(new UIColorRef?(LazySingletonBehavior <UIManager> .Instance.UILookAndColorConstants.PopupBackfill), 0f, true).Render();
                    return;
                }
                GenericPopupBuilder pop = GenericPopupBuilder.Create("Skip Time?", "Skip To a predefined year, skip By an amount of years, or skip to a Custom date?");

                pop.AddButton("Cancel", NewClose, true, null);
                pop.AddButton("Skip To", RenderTo, true, null);
                pop.AddButton("Skip By", RenderBy, true, null);
                pop.AddButton("Skip Custom", RenderCustom, true, null);
                pop.AddFader(new UIColorRef?(LazySingletonBehavior <UIManager> .Instance.UILookAndColorConstants.PopupBackfill), 0f, true);
                pop.Render();
            }
        public static void UnStorageOmniMechPopup(SimGameState s, MechDef d, Action onClose)
        {
            if (Settings.OmniMechTag == null)
            {
                onClose?.Invoke();
                throw new InvalidOperationException("omnimechs disabled");
            }
            int mechbay = s.GetFirstFreeMechBay();

            if (mechbay < 0)
            {
                onClose?.Invoke();
                return;
            }
            IEnumerable <MechDef> mechs = GetAllOmniVariants(s, d);
            string desc             = "Yang: We know the following Omni variants. What should I ready this 'Mech as?\n\n";
            GenericPopupBuilder pop = GenericPopupBuilder.Create("Ready 'Mech?", desc);

            pop.AddButton("nothing", onClose, true, null);
            foreach (MechDef m in mechs)
            {
                MechDef var = m; // new var to keep it for lambda
                if (!CheckOmniKnown(s, d, m))
                {
                    if (Settings.ShowAllVariantsInPopup)
                    {
                        pop.Body += $"unknown: [[DM.MechDefs[{m.Description.Id}],{m.Chassis.Description.UIName} {m.Chassis.VariantName}]]\n";
                    }
                    continue;
                }
                pop.AddButton($"{var.Chassis.VariantName}", delegate
                {
                    Log.Log("ready omni as: " + var.Description.Id);
                    s.ScrapInactiveMech(d.Chassis.Description.Id, false);
                    ReadyMech(s, new MechDef(var, s.GenerateSimGameUID(), false), mechbay);
                    onClose?.Invoke();
                }, true, null);
                int com  = GetNumberOfMechsOwnedOfType(s, m);
                int cost = m.GetMechSellCost(s);
                pop.Body += $"[[DM.MechDefs[{m.Description.Id}],{m.Chassis.Description.UIName} {m.Chassis.VariantName}]] ({com} Complete) ({SimGameState.GetCBillString(cost)})\n";
            }
            pop.AddFader(new UIColorRef?(LazySingletonBehavior <UIManager> .Instance.UILookAndColorConstants.PopupBackfill), 0f, true);
            pop.Render();
        }
        public static void QueryMechAssemblyPopup(SimGameState s, MechDef d, Action onClose = null)
        {
            if (GetNumPartsForAssembly(s, d) < s.Constants.Story.DefaultMechPartMax)
            {
                onClose?.Invoke();
                return;
            }
            IEnumerable <MechDef> mechs = GetAllAssemblyVariants(s, d);
            string desc             = $"Yang: Concerning the [[DM.MechDefs[{d.Description.Id}],{d.Chassis.Description.UIName} {d.Chassis.VariantName}]]: {d.Chassis.YangsThoughts}\n\n We have Parts of the following {d.GetMechOmniVehicle()} variants. What should I build?\n";
            GenericPopupBuilder pop = GenericPopupBuilder.Create($"Assemble {d.GetMechOmniVehicle()}?", desc);

            pop.AddButton("-", delegate
            {
                onClose?.Invoke();
            }, true, null);
            foreach (MechDef m in mechs)
            {
                MechDef var   = m; // new var to keep it for lambda
                int     count = s.GetItemCount(var.Description.Id, "MECHPART", SimGameState.ItemCountType.UNDAMAGED_ONLY);
                int     com   = GetNumberOfMechsOwnedOfType(s, m);
                int     cost  = m.GetMechSellCost(s);
                if (count <= 0 && !CheckOmniKnown(s, d, m))
                {
                    if (Settings.ShowAllVariantsInPopup)
                    {
                        pop.Body += $"no parts: [[DM.MechDefs[{m.Description.Id}],{m.Chassis.Description.UIName} {m.Chassis.VariantName}]] ({com} Complete)\n";
                    }
                    continue;
                }
                if (GetNumPartsForAssembly(s, var) >= s.Constants.Story.DefaultMechPartMax)
                {
                    pop.AddButton(string.Format("{0}", var.Chassis.VariantName), delegate
                    {
                        PerformMechAssemblyStorePopup(s, var, onClose);
                    }, true, null);
                }
                pop.Body += $"[[DM.MechDefs[{m.Description.Id}],{m.Chassis.Description.UIName} {m.Chassis.VariantName}]] ({count} Parts/{com} Complete) ({SimGameState.GetCBillString(cost)})\n";
            }
            pop.AddFader(new UIColorRef?(LazySingletonBehavior <UIManager> .Instance.UILookAndColorConstants.PopupBackfill), 0f, true);
            pop.Render();
        }
Exemplo n.º 10
0
        public void Render()
        {
            GenericPopupBuilder builder = GenericPopupBuilder.Create("__/CAE.Components/__", this.BuildText());

            builder.AddButton("X", null, true);
            builder.AddButton("+", new Action(this.Left), false);
            builder.AddButton("<-", new Action(this.Up), false);
            builder.AddButton("-", new Action(this.Right), false);
            builder.AddButton("->", new Action(this.Down), false);
            builder.AddButton("Ок", null, true);
            popup = builder.CancelOnEscape().Render();
        }
            public void RenderCustom()
            {
                GenericPopupBuilder pop = GenericPopupBuilder.Create("Skip Time?", "Input the date you want to skip to. Format is YYYY-M-D .");

                pop.AddButton("Cancel", NewClose, true, null);
                pop.AddInput("Date", (str) => {
                    if (DateTime.TryParse(str, out DateTime t) && state.GetDayDiff(t) > 0)
                    {
                        RenderSkip(t);
                    }
                    else
                    {
                        GenericPopupBuilder.Create("Skip Time?", "Invalid Date!").AddButton("Cancel", NewClose, true, null)
                        .AddFader(new UIColorRef?(LazySingletonBehavior <UIManager> .Instance.UILookAndColorConstants.PopupBackfill), 0f, true).Render();
                    }
                }, "3030-1-1", false, false);
                pop.AddFader(new UIColorRef?(LazySingletonBehavior <UIManager> .Instance.UILookAndColorConstants.PopupBackfill), 0f, true);
                pop.Render();
            }
        public static void PerformMechAssemblyStorePopup(SimGameState s, MechDef d, Action onClose)
        {
            WwiseManager.PostEvent(AudioEventList_ui.ui_sim_popup_newChassis, WwiseManager.GlobalAudioObject, null, null);
            MechDef toAdd = PerformMechAssembly(s, d);
            int     mechbay;

            if (toAdd.IsVehicle())
            {
                mechbay = CUIntegration.GetFirstFreeMechBay(s, d); // vehicle bay, +100 or something similar
            }
            else
            {
                mechbay = s.GetFirstFreeMechBay();
            }
            GenericPopupBuilder pop = GenericPopupBuilder.Create($"{d.GetMechOmniVehicle()} Assembled", $"Yang: [[DM.MechDefs[{d.Description.Id}],{d.Chassis.Description.UIName} {d.Chassis.VariantName}]] finished!\n{d.Chassis.YangsThoughts}\n\n");

            pop.AddButton("storage", delegate
            {
                StoreMech(s, toAdd);
                CallMessages(s, toAdd);
                Log.Log("direct storage");
                onClose?.Invoke();
            }, true, null);
            if (mechbay < 0) // no space - direct storage
            {
                pop.Body += $"We have no space for a new {d.GetMechOmniVehicle()}, so it goes into storage.";
            }
            else
            {
                pop.Body += "Should I put it into storage or ready it for combat?";
                pop.AddButton("ready it", delegate
                {
                    if (Settings.AssembledMechsNeedReadying)
                    {
                        ReadyMech(s, toAdd, mechbay);
                        CallMessages(s, toAdd);
                    }
                    else
                    {
                        s.AddMech(mechbay, toAdd, true, false, false);
                        CallMessages(s, toAdd);
                    }
                    Log.Log("added to bay " + mechbay);
                    onClose?.Invoke();
                }, true, null);
            }
            if (s.IsSellingAllowed())
            {
                int cost = toAdd.GetMechSellCost(s);
                pop.Body += $"\n\nDarius: We could also sell it for {SimGameState.GetCBillString(cost)}, although Yang would certanly not like it.";
                pop.AddButton("sell it", delegate
                {
                    s.AddFunds(cost, "Store", true, true);
                    Log.Log("sold for " + cost);
                    s.CompanyStats.ModifyStat("Mission", 0, "COMPANY_MechsAdded", StatCollection.StatOperation.Int_Add, 1, -1, true);
                    CallMessages(s, toAdd);
                    onClose?.Invoke();
                }, true, null);
            }
            pop.AddFader(new UIColorRef?(LazySingletonBehavior <UIManager> .Instance.UILookAndColorConstants.PopupBackfill), 0f, true);
            pop.Render();
        }
Exemplo n.º 13
0
        public static void PerformMechAssemblyStorePopup(SimGameState s, MechDef d, MechBayPanel refresh, SimpleMechAssembly_InterruptManager_AssembleMechEntry close)
        {
            MechDef toAdd   = PerformMechAssembly(s, d);
            int     mechbay = s.GetFirstFreeMechBay();

            if (mechbay < 0) // no space - direct storage
            {
                StoreMech(s, toAdd);
                Log.Log("no space, direct storage");
                if (refresh != null)
                {
                    refresh.RefreshData(false);
                }
                GenericPopupBuilder pop = GenericPopupBuilder.Create("Mech Assembled",
                                                                     string.Format("Yang: [[DM.MechDefs[{3}],{1} {2}]] finished!\n{0}\n\nWe have no space for a new mech, so it goes into storage.",
                                                                                   d.Chassis.YangsThoughts, d.Chassis.Description.UIName, d.Chassis.VariantName, d.Description.Id));
                pop.AddButton("ok", delegate
                {
                    if (close != null)
                    {
                        close.NewClose();
                    }
                }, true, null);
                pop.AddFader(new UIColorRef?(LazySingletonBehavior <UIManager> .Instance.UILookAndColorConstants.PopupBackfill), 0f, true);
                pop.Render();
            }
            else
            {
                GenericPopupBuilder pop = GenericPopupBuilder.Create("Mech Assembled",
                                                                     string.Format("Yang: [[DM.MechDefs[{3}],{1} {2}]] finished!\n{0}\n\nShould I put it into storage, or ready it for combat?",
                                                                                   d.Chassis.YangsThoughts, d.Chassis.Description.UIName, d.Chassis.VariantName, d.Description.Id));
                pop.AddButton("storage", delegate
                {
                    StoreMech(s, toAdd);
                    Log.Log("direct storage");
                    if (refresh != null)
                    {
                        refresh.RefreshData(false);
                    }
                    if (close != null)
                    {
                        close.NewClose();
                    }
                }, true, null);
                pop.AddButton("ready it", delegate
                {
                    if (Settings.AssembledMechsNeedReadying)
                    {
                        ReadyMech(s, toAdd, mechbay);
                    }
                    else
                    {
                        s.AddMech(mechbay, toAdd, true, false, false);
                    }
                    Log.Log("added to bay " + mechbay);
                    if (refresh != null)
                    {
                        refresh.RefreshData(false);
                    }
                    if (close != null)
                    {
                        close.NewClose();
                    }
                }, true, null);
                pop.AddFader(new UIColorRef?(LazySingletonBehavior <UIManager> .Instance.UILookAndColorConstants.PopupBackfill), 0f, true);
                pop.Render();
            }
        }