public static void Postfix(SimGameState __instance, int val) { if (!ModState.SimGameFunds.ContainsKey(__instance.InstanceGUID)) { ModState.SimGameFunds.Add(__instance.InstanceGUID, __instance.Funds); Mod.Log.Info?.Write( $"CHEATDETECTION: Added key to SimGameFunds with Funds {__instance.Funds}; this should have been done already...WTF. At Addfunds, Post"); } ModState.SimGameFunds[__instance.InstanceGUID] += val; if (__instance.Funds != ModState.SimGameFunds[__instance.InstanceGUID]) { __instance.CompanyStats.AddStatistic(Mod.Config.CheatDetection.CheatDetectionStat, "FUNDS: SGS.AddFunds - Post"); Mod.Log.Info?.Write( $"CHEATDETECTION: Caught you, you little shit. Cheated money. SGS Funds: {__instance.Funds} while tracker funds {ModState.SimGameFunds[__instance.InstanceGUID]} after adding {val} at AddFunds, Post"); if (Mod.Config.CheatDetection.CheatDetectionNotify) { GenericPopupBuilder .Create("CHEAT DETECTED!", "t-bone thinks you're cheating. if you aren't, you should let the RT crew know on Discord.") .AddButton("Okay", null, true, null).CancelOnEscape() .AddFader( new UIColorRef?(LazySingletonBehavior <UIManager> .Instance.UILookAndColorConstants .PopupBackfill), 0f, true).Render(); } } }
Prefix(SGBarracksMWDetailPanel __instance, Pilot ___curPilot) { if ( Local.state.getItem("cheat_pilotskill_reset") == "" || !( Input.GetKey(KeyCode.LeftShift) || Input.GetKey(KeyCode.RightShift) ) ) { return(true); } GenericPopupBuilder .Create( "Pilot Reskill", "This will set skills to 1 and refund all XP." ) .AddButton("Cancel") .AddButton("Pilot Reskill", () => { PilotReskill(__instance, ___curPilot); }) .CancelOnEscape() .AddFader( HBS.LazySingletonBehavior <UIManager> .Instance .UILookAndColorConstants .PopupBackfill ) .Render(); return(false); }
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); }
private static void ProcessSell(InventoryDataObject_SHOP selected) { if (selected == null) { Control.LogDebug(DInfo.ShopActions, "-- nothing to sell, return"); return; } var price = selected.GetCBillValue(); if (selected.quantity == 1 || !Control.Settings.AllowMultiSell) { Control.LogDebug(DInfo.ShopActions, $"-- selling 1x{selected.GetName()}"); if (Control.Settings.ShowConfirm && price > Control.Settings.ConfirmLowLimit) { GenericPopupBuilder.Create("Confirm?", $"Sell {selected.GetName()} for {price}?") .AddButton("Cancel", null, true, null) .AddButton("Accept", () => OnSellItems(1), true, null) .CancelOnEscape() .AddFader(new UIColorRef?(LazySingletonBehavior <UIManager> .Instance.UILookAndColorConstants.PopupBackfill), 0f, true) .Render(); } else { OnSellItems(1); } } else { Control.LogDebug(DInfo.ShopActions, $"-- show multisell dialog"); SG_Stores_MultiPurchasePopup_Handler.StartDialog("Sell", selected.shopDefItem, selected.GetName(), selected.quantity, price, OnSellItems, null); } }
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(); }
void SomeMethod() { GenericPopupBuilder.Create(GenericPopupType.Info, "No saved games found").AddButton("Ok", delegate { this.ReceiveButtonPress("cancel"); }, true, null).IsNestedPopupWithBuiltInFader().Render(); }
static bool Prefix(SG_HiringHall_Screen __instance, Pilot ___selectedPilot, string button) { Mod.Log.Debug?.Write("Updating Dialog"); if (___selectedPilot != null && "Hire".Equals(button, StringComparison.InvariantCultureIgnoreCase) && __instance.HireButtonValid()) { Mod.Log.Debug?.Write(" -- pilot is selected"); CrewDetails details = ModState.GetCrewDetails(___selectedPilot.pilotDef); int modifiedBonus = (int)Mathf.RoundToInt(details.AdjustedBonus); string salaryS = new Text(Mod.LocalizedText.Labels[ModText.LT_Crew_Hire_Button], new string[] { SimGameState.GetCBillString(Mathf.RoundToInt(modifiedBonus)) }) .ToString(); Mod.Log.Debug?.Write($" -- bonus will be: {salaryS}"); GenericPopupBuilder.Create("Confirm?", salaryS) .AddButton("Cancel") .AddButton("Accept", __instance.HireCurrentPilot) .CancelOnEscape() .AddFader(LazySingletonBehavior <UIManager> .Instance.UILookAndColorConstants.PopupBackfill) .Render(); return(false); } return(true); }
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[] { }); } } }
private static void AddUpgradeToSalvage(Contract __instance, MechComponentDef d, SimGameState s, List <SalvageDef> sal) { string lootable = d.GetCCLootableItem(); if (lootable != null) { MechComponentDef l = s.DataManager.GetComponentDefFromID(lootable); if (l != null) { d = l; } } if (IsBlacklisted(d)) { SimpleMechAssembly_Main.Log.LogError("skipping, cause its blacklisted"); return; } try { __instance.AddMechComponentToSalvage(sal, d, ComponentDamageLevel.Functional, false, s.Constants, s.NetworkRandom, true); } catch (Exception e) { SimpleMechAssembly_Main.Log.LogError("failed to add mech component"); SimpleMechAssembly_Main.Log.LogException(e); GenericPopupBuilder.Create("SMA add component error", "Please delete your .modtek folder (so everything gets regenerated next start).\nIf it still happens afterwards, please report.").AddButton("ok", null, true, null).Render(); } }
public static bool Prefix(SGBarracksMWDetailPanel __instance, Pilot ___curPilot) { var hotkeyPerformed = Input.GetKey(KeyCode.LeftShift) || Input.GetKey(KeyCode.RightShift); if (!hotkeyPerformed) { return(true); } var simState = UnityGameInstance.BattleTechGame.Simulation; if (modSettings.onceOnly && ___curPilot.pilotDef.PilotTags.Contains("HasRetrained")) { GenericPopupBuilder .Create("Unable To Retrain", "Each pilot can only retrain once.") .AddButton("Acknowledged") .CancelOnEscape() .AddFader(LazySingletonBehavior <UIManager> .Instance.UILookAndColorConstants.PopupBackfill) .Render(); return(true); } if (modSettings.trainingModuleRequired && !simState.ShipUpgrades.Any(u => u.Tags.Any(t => t.Contains("argo_trainingModule2")))) { GenericPopupBuilder .Create("Unable To Retrain", "You must have built the Training Module 2 upgrade aboard the Argo.") .AddButton("Acknowledged") .CancelOnEscape() .AddFader(LazySingletonBehavior <UIManager> .Instance.UILookAndColorConstants.PopupBackfill) .Render(); return(true); } if (simState.Funds < modSettings.cost) { GenericPopupBuilder .Create("Unable To Retrain", $"You need ¢{modSettings.cost:N0}.") .AddButton("Acknowledged") .CancelOnEscape() .AddFader(LazySingletonBehavior <UIManager> .Instance.UILookAndColorConstants.PopupBackfill) .Render(); return(true); } var message = modSettings.onceOnly ? $"This will set skills to 1 and refund all XP.\nIt will cost ¢{modSettings.cost:N0} and each pilot can only retrain once." : $"This will set skills to 1 and refund all XP.\nIt will cost ¢{modSettings.cost:N0}"; GenericPopupBuilder .Create("Retrain", message) .AddButton("Cancel") .AddButton("Retrain Pilot", () => RespecAndRefresh(__instance, ___curPilot)) .CancelOnEscape() .AddFader(LazySingletonBehavior <UIManager> .Instance.UILookAndColorConstants.PopupBackfill) .Render(); return(false); }
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 static void Postfix() { if (Played) { return; } GenericPopupBuilder.Create("ModTek need to be reinjected", "ModTek have to be reinjected. Please restart application") .AddButton("Exit", (Action)(() => { Application.Quit(); })) .Render(); Played = true; }
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 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 Postfix() { if (ModTek.FailedToLoadMods.Count <= 0) { return; } GenericPopupBuilder.Create("Some Mods Didn't Load", $"Check \"{ModTek.GetRelativePath(Logger.LogPath, ModTek.GameDirectory)}\" for more info\n\n" + string.Join(", ", ModTek.FailedToLoadMods.ToArray())) .AddButton("Continue") .Render(); ModTek.FailedToLoadMods.Clear(); }
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 BuildScrapAllDialog(List <ChassisCount> filteredChassis, float scrapPartModifier, string title, Action confirmAction) { int cbills = ScrapHelper.CalculateTotalScrap(filteredChassis, scrapPartModifier); string cbillStr = SimGameState.GetCBillString(cbills); string descLT = new Text(Mod.LocalizedText.Dialog[ModText.DT_Desc_ScrapAll], new object[] { cbillStr }).ToString(); string cancelLT = new Text(Mod.LocalizedText.Dialog[ModText.DT_Button_Cancel]).ToString(); string scrapLT = new Text(Mod.LocalizedText.Dialog[ModText.DT_Button_Scrap]).ToString(); GenericPopupBuilder.Create(title, descLT) .AddButton(cancelLT) .AddButton(scrapLT, confirmAction) .CancelOnEscape() .AddFader(LazySingletonBehavior <UIManager> .Instance.UILookAndColorConstants.PopupBackfill) .Render(); }
static bool Prefix(MechLabPanel __instance, MechLabMechInfoWidget ___mechInfoWidget, MechLabItemSlotElement ___dragItem) { var hk = Input.GetKey(KeyCode.LeftControl) || Input.GetKey(KeyCode.RightControl); if (hk) { return(true); } if (!__instance.Initialized) { return(false); } if (___dragItem != null) { return(false); } if (__instance.headWidget.IsDestroyed || __instance.centerTorsoWidget.IsDestroyed || __instance.leftTorsoWidget.IsDestroyed || __instance.rightTorsoWidget.IsDestroyed || __instance.leftArmWidget.IsDestroyed || __instance.rightArmWidget.IsDestroyed || __instance.leftLegWidget.IsDestroyed || __instance.rightLegWidget.IsDestroyed) { __instance.modifiedDialogShowing = true; GenericPopupBuilder.Create("'Mech Location Destroyed", "You cannot auto-assign armor while a 'Mech location is Destroyed.").AddButton("Okay", null, true, null).CancelOnEscape().AddFader(new UIColorRef?(LazySingletonBehavior <UIManager> .Instance.UILookAndColorConstants.PopupBackfill), 0f, true).SetAlwaysOnTop().SetOnClose(delegate { __instance.modifiedDialogShowing = false; }).Render(); return(false); } __instance.headWidget.ModifyArmor(false, __instance.headWidget.maxArmor, true); __instance.centerTorsoWidget.ModifyArmor(false, __instance.centerTorsoWidget.maxArmor, true); __instance.centerTorsoWidget.ModifyArmor(true, __instance.centerTorsoWidget.maxRearArmor, true); __instance.leftTorsoWidget.ModifyArmor(false, __instance.leftTorsoWidget.maxArmor, true); __instance.leftTorsoWidget.ModifyArmor(true, __instance.leftTorsoWidget.maxRearArmor, true); __instance.rightTorsoWidget.ModifyArmor(false, __instance.rightTorsoWidget.maxArmor, true); __instance.rightTorsoWidget.ModifyArmor(true, __instance.rightTorsoWidget.maxRearArmor, true); __instance.leftArmWidget.ModifyArmor(false, __instance.leftArmWidget.maxArmor, true); __instance.rightArmWidget.ModifyArmor(false, __instance.rightArmWidget.maxArmor, true); __instance.leftLegWidget.ModifyArmor(false, __instance.leftLegWidget.maxArmor, true); __instance.rightLegWidget.ModifyArmor(false, __instance.rightLegWidget.maxArmor, true); ___mechInfoWidget.RefreshInfo(false); __instance.FlagAsModified(); __instance.ValidateLoadout(false); return(false); }
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(); }
private static void SplitToParts(ChassisDef chassisDef, int min, int max, MechBayPanel mechBay) { int k = mechBay.Sim.NetworkRandom.Int(min, max + 1); UnityGameInstance.BattleTechGame.Simulation.ScrapInactiveMech(chassisDef.Description.Id, false); var mech = ChassisHandler.GetMech(chassisDef.Description.Id); for (int i = 0; i < k; i++) { mechBay.Sim.AddMechPart(mech.Description.Id); } mechBay.RefreshData(false); mechBay.SelectChassis(null); GenericPopupBuilder.Create($"Scraped {mech.Description.UIName}.", $"We manage to get <color=#20ff20>{k}</color> parts from {mech.Description.UIName} chassis") .AddButton("Ok", null, true, null) .CancelOnEscape().AddFader(new UIColorRef?(LazySingletonBehavior <UIManager> .Instance.UILookAndColorConstants.PopupBackfill), 0f, true).Render(); }
public static void Postfix(string logString, string stackTrace, LogType type) { if (!ModTek.HasLoaded || type != LogType.Error && type != LogType.Exception || ModTek.Config.UseErrorWhiteList && !ModTek.Config.ErrorWhitelist.Exists(logString.StartsWith)) { return; } if (LoadingCurtain.IsVisible && ModTek.Config.ShowLoadingScreenErrors) { LoadingCurtainErrorText.AddMessage(logString); } else if (!LoadingCurtain.IsVisible && ModTek.Config.ShowErrorPopup) { GenericPopupBuilder.Create("ModTek Detected Error", logString) .AddButton("Continue") .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 Info(string message) { Fields.IsCustomPopup = true; GenericPopup popup = GenericPopupBuilder .Create(title, message) .AddButton("Ok", null, true, null) .CancelOnEscape() .AddFader(new UIColorRef?(LazySingletonBehavior <UIManager> .Instance.UILookAndColorConstants.PopupBackfill), 0.5f, true) .SetAlwaysOnTop() .SetOnClose(delegate { Fields.IsCustomPopup = false; }) .Render(); LocalizableText ___contentText = (LocalizableText)AccessTools.Field(typeof(GenericPopup), "_contentText").GetValue(popup); ___contentText.alignment = TMPro.TextAlignmentOptions.TopLeft; }
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 bool Prefix(MechBayChassisInfoWidget __instance, ChassisDef ___selectedChassis, MechBayPanel ___mechBay) { if (___selectedChassis == null) { return(true); } int bay = ___mechBay.Sim.GetFirstFreeMechBay(); string id = ___selectedChassis.Description.Id.Replace("chassisdef", "mechdef"); MechDef d = ___mechBay.Sim.DataManager.MechDefs.Get(id); if (___selectedChassis.MechPartCount > 0) // this is actually a part that gets assembled { int p = SimpleMechAssembly_Main.GetNumPartsForAssembly(___mechBay.Sim, d); if (p < ___mechBay.Sim.Constants.Story.DefaultMechPartMax) { GenericPopupBuilder.Create("Mech Assembly", "Yang: I do not have enough parts to assemble a mech out of it.").AddButton("Cancel", null, true, null) .AddFader(new UIColorRef?(LazySingletonBehavior <UIManager> .Instance.UILookAndColorConstants.PopupBackfill), 0f, true).Render(); return(false); } //SimpleMechAssembly_Main.QueryMechAssemblyPopup(___mechBay.Sim, d, ___mechBay); ___mechBay.Sim.InterruptQueue.AddInterrupt(new SimpleMechAssembly_Main.SimpleMechAssembly_InterruptManager_AssembleMechEntry(___mechBay.Sim, d, ___mechBay), true); return(false); } if (___selectedChassis.MechPartCount < ___selectedChassis.MechPartMax) { return(true); } if (SimpleMechAssembly_Main.Settings.OmniMechTag == null || !___selectedChassis.ChassisTags.Contains(SimpleMechAssembly_Main.Settings.OmniMechTag)) { return(true); } if (bay < 0) { return(true); } SimpleMechAssembly_Main.UnStorageOmniMechPopup(___mechBay.Sim, d, ___mechBay); return(false); }
public static void Postfix(Pilot __instance, int stackID, string sourceID, uint value) { var sim = UnityGameInstance.BattleTechGame.Simulation; if (sim == null) { return; } if (String.IsNullOrEmpty(__instance.GUID)) { return; } ModState.PilotCurrentFreeXP[__instance.GUID] -= (int)value; Mod.Log.Info?.Write( $"CHEATDETECTION: {__instance.Description.Id}: {__instance.GUID} pilot UnspentXP was {__instance.UnspentXP} after subtracting {value} at SpendExperience, Post."); if (__instance.UnspentXP != ModState.PilotCurrentFreeXP[__instance.GUID]) { Mod.Log.Info?.Write( $"CHEATDETECTION: {__instance.Description.Id}: {__instance.GUID} pilot UnspentXP was {__instance.UnspentXP} but state variable was {ModState.PilotCurrentFreeXP[__instance.GUID]}."); sim.CompanyStats.AddStatistic(Mod.Config.CheatDetection.CheatDetectionStat, "XP: at Pilot.SpendExperience"); Mod.Log.Info?.Write($"CHEATDETECTION: Caught you, you little shit. Cheated experience."); if (Mod.Config.CheatDetection.CheatDetectionNotify) { GenericPopupBuilder .Create("CHEAT DETECTED!", "t-bone thinks you're cheating. if you aren't, you should let the RT crew know on Discord.") .AddButton("Okay", null, true, null).CancelOnEscape() .AddFader( new UIColorRef?(LazySingletonBehavior <UIManager> .Instance.UILookAndColorConstants .PopupBackfill), 0f, true).Render(); } } }