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(); }
static void Postfix(TurnDirector __instance, int round) { Mod.Log.Trace("TD:BNR entered"); Mod.Log.Debug($" OnNewRound -> withdrawStarted:{State.WithdrawStarted} canWithdrawOn:{State.CanWithdrawOnRound}"); if (State.WithdrawStarted) { if (round == State.CanWithdrawOnRound) { int readyIn = State.CanApproachOnRound - round; GenericPopupBuilder genericPopupBuilder = GenericPopupBuilder.Create(GenericPopupType.Info, $"Sumire is overhead. If you don't withdraw on this round, she will retreat. She will be unavailable for another {readyIn} rounds!") .AddButton("Continue", new Action(OnContinue), true, null); genericPopupBuilder.IsNestedPopupWithBuiltInFade = true; State.HUD.SelectionHandler.GenericPopup = genericPopupBuilder.Render(); State.RetreatButton.SetState(ButtonState.Enabled, true); State.RetreatButtonText.SetText($"Withdraw Now", new object[] { }); } else if (round == State.CanApproachOnRound) { State.WithdrawStarted = false; State.CanApproachOnRound = -1; State.CanWithdrawOnRound = -1; State.RetreatButton.SetState(ButtonState.Enabled, false); State.RetreatButtonText.SetText($"Withdraw", new object[] { }); } } }
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(); }
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(); }
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 static bool Prefix(CombatHUDRetreatEscMenu __instance, CombatGameState ___Combat, CombatHUD ___HUD) { Mod.Log.Trace?.Write("CHUDREM:ORC entered"); if (___Combat == null || ___Combat.ActiveContract.ContractTypeValue.IsSkirmish) { return(true); } else { int roundsToWait = Helper.RoundsToWaitByAerospace(); Mod.Log.Info?.Write($"Player must wait:{roundsToWait} rounds for pickup."); if (roundsToWait > 0) { ModState.WithdrawStarted = true; ModState.CanWithdrawOnRound = ___Combat.TurnDirector.CurrentRound + roundsToWait; ModState.CanApproachOnRound = ModState.CanWithdrawOnRound + Helper.RoundsToWaitByAerospace();; Mod.Log.Info?.Write($" Withdraw triggered on round {___Combat.TurnDirector.CurrentRound}. canWithdrawOn:{ModState.CanWithdrawOnRound} canApproachOn: {ModState.CanApproachOnRound}"); ModState.RetreatButton = __instance.RetreatButton; ModState.HUD = ___HUD; Transform textT = __instance.RetreatButton.gameObject.transform.Find("Text"); if (textT != null) { GameObject textGO = textT.gameObject; ModState.RetreatButtonText = textGO.GetComponent <TextMeshProUGUI>(); } ModState.RetreatButtonText.SetText($"In { roundsToWait } Rounds"); GenericPopupBuilder genericPopupBuilder = GenericPopupBuilder.Create(GenericPopupType.Info, $"Sumire is inbound and will be overhead in {roundsToWait} rounds. Survive until then!") .AddButton("Continue", new Action(OnContinue), true, null); genericPopupBuilder.IsNestedPopupWithBuiltInFade = true; ___HUD.SelectionHandler.GenericPopup = genericPopupBuilder.Render(); return(false); } else { return(true); } } }
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 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 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(); }
public static bool Prefix(CombatHUDRetreatEscMenu __instance, HBSDOTweenButton ___RetreatButton, CombatGameState ___Combat, CombatHUD ___HUD) { Mod.Log.Trace?.Write($"CHUDREM:ORBP entered"); Mod.Log.Debug?.Write($" RetreatButton pressed -> withdrawStarted:{ModState.WithdrawStarted} " + $"CurrentRound:{___Combat.TurnDirector.CurrentRound} CanWithdrawOn:{ModState.CanWithdrawOnRound} CanApproachOn:{ModState.CanApproachOnRound}"); if (ModState.WithdrawStarted && ModState.CanWithdrawOnRound == ___Combat.TurnDirector.CurrentRound) { Mod.Log.Debug?.Write($"Checking for combat damage and active enemies"); ModState.CombatDamage = Helper.CalculateCombatDamage(); if (ModState.CombatDamage > 0 && ___Combat.TurnDirector.DoAnyUnitsHaveContactWithEnemy) { int repairCost = (int)Math.Ceiling(ModState.CombatDamage) * Mod.Config.LeopardRepairCostPerDamage; void withdrawAction() { OnImmediateWithdraw(__instance.IsGoodFaithEffort()); } GenericPopupBuilder builder = GenericPopupBuilder.Create(GenericPopupType.Warning, $"Enemies are within weapons range! If you withdraw now the Leopard will take {SimGameState.GetCBillString(repairCost)} worth of damage.") .CancelOnEscape() .AddButton("Cancel") .AddButton("Withdraw", withdrawAction, true, null); builder.IsNestedPopupWithBuiltInFade = true; ___HUD.SelectionHandler.GenericPopup = builder.Render(); return(false); } else { Mod.Log.Info?.Write($" Immediate withdraw due to no enemies"); OnImmediateWithdraw(__instance.IsGoodFaithEffort()); return(false); } } else { return(true); } }
public static void AlertUser(string title, string message) { GenericPopupBuilder genericPopupBuilder = GenericPopupBuilder.Create(title, message); genericPopupBuilder.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(); }
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(); } }