Esempio n. 1
0
        public static void Postfix(AAR_ObjectiveListItem __instance, MissionObjectiveResult missionObjectiveResult, Contract contract, LocalizableText ___GainsText)
        {
            try
            {
                // Only for successful opportunity missions
                if (contract.IsOpportunityMission() && contract.State == Contract.ContractState.Complete)
                {
                    Logger.Debug($"[AAR_ObjectiveListItem_Init_POSTFIX] Append text for {contract.Override.ID} if special tags are present.");

                    // Successful secondary objective
                    if (!missionObjectiveResult.isPrimary && missionObjectiveResult.status == ObjectiveStatus.Succeeded)
                    {
                        foreach (SimGameEventResult simGameEventResult in missionObjectiveResult.simGameEventResultList)
                        {
                            // If any result of the objective contains a special tag, which will trigger a reward popup, set the info text and leave the loop
                            if (simGameEventResult.AddedTags.ToArray().Any(tag => tag.Contains("triggerReward-")))
                            {
                                // NOTE: If any other result did already set some text it will get overwritten
                                ___GainsText.gameObject.SetActive(true);
                                ___GainsText.SetText("• Acquired Mission Bonus Reward", new object[] { });
                                break;
                            }
                        }
                    }
                }
            }
            catch (Exception e)
            {
                Logger.Error(e);
            }
        }
        static void Postfix(LanceHeaderWidget __instance, List <MechDef> mechs, LocalizableText ___simLanceTonnageText, LanceConfiguratorPanel ___LC)
        {
            try {
                if (___LC.IsSimGame)
                {
                    DropCostManager.Instance.CalculateLanceCost(mechs);

                    // longer strings interfere with messages about incorrect lance configurations
                    ___simLanceTonnageText.SetText($"DROP COST: ¢{DropCostManager.Instance.FormattedCosts}   LANCE WEIGHT: {DropCostManager.Instance.LanceTonnage} TONS");
                    if (DCECore.settings.diffMode != EDifficultyType.NotActive)
                    {
                        SGDifficultyIndicatorWidget lanceRatingWidget = (SGDifficultyIndicatorWidget)AccessTools
                                                                        .Field(typeof(LanceHeaderWidget), "lanceRatingWidget").GetValue(__instance);
                        TextMeshProUGUI label = lanceRatingWidget.transform.parent
                                                .GetComponentsInChildren <TextMeshProUGUI>()
                                                .FirstOrDefault(t => t.transform.name == "label-lanceRating");
                        label.text = "Lance Rating";
                        int difficulty = DropCostManager.Instance.RawCost / DCECore.settings.valuePerHalfSkull;
                        DCECore.modLog.Debug?.Write($"Calculated Drop Rating: {difficulty}, total value: {DropCostManager.Instance.RawCost}");
                        lanceRatingWidget.SetDifficulty(difficulty);
                    }
                }
            }
            catch (Exception e) {
                DCECore.modLog.Error?.Write(e);
            }
        }
        static void Postfix(SimGameDifficultySettingsModule __instance, PreGameCareerModeSettingsTotalScoreDescAndBar ___difficultyBarAndMod)
        {
            if (__instance != null && ___difficultyBarAndMod != null)
            {
                ___difficultyBarAndMod.TotalScoreModifierLabel.SetText(
                    new Text(Mod.LocalizedText.SimGameDifficultyStrings[ModText.SGDS_Desc], new object[] { })
                    );

                GameObject difficultyTotalGO = __instance.gameObject.FindFirstChildNamed("OBJ_difficultyTotal");
                if (difficultyTotalGO != null)
                {
                    // Find difTotal-text
                    GameObject diffTotalGO = difficultyTotalGO.FindFirstChildNamed("difTotal-text");
                    if (diffTotalGO != null)
                    {
                        // Use the label here
                        LocalizableText localText = diffTotalGO.GetComponent <LocalizableText>();
                        if (localText != null)
                        {
                            Mod.Log.Info?.Write("UPDATED LABEL");
                            localText.SetText(Mod.LocalizedText.SimGameDifficultyStrings[ModText.SGDS_Label]);
                        }
                        else
                        {
                            Mod.Log.Warn?.Write("FAILED TO FIND LocalizableText COMP FOR `diffTotal-text`");
                        }
                    }
                    else
                    {
                        Mod.Log.Warn?.Write("FAILED TO FIND `diffTotal-text` CHILD OF `OBJ_difficultyTotal`!");
                    }
                }
            }
        }
Esempio n. 4
0
        public static void MultiPurchasePopup_Refresh_Postfix(SG_Stores_MultiPurchasePopup __instance, int ___costPerUnit, int ___quantityBeingSold,
                                                              LocalizableText ___TitleText, LocalizableText ___DescriptionText, string ___itemName, HBSDOTweenButton ___ConfirmButton)
        {
            Mod.Log.Debug("SG_S_MPP:R entered.");
            int value = ___costPerUnit * ___quantityBeingSold;

            Mod.Log.Debug($"SG_S_MPP:R   value:{value} = costPerUnit:{___costPerUnit} x quantityBeingSold:{___quantityBeingSold}.");

            string actionS = "??";

            if (State.StoreIsBuying)
            {
                actionS = "BUY";
            }
            else if (State.StoreIsSelling)
            {
                actionS = "SELL";
            }

            Text titleT = new Text($"{actionS}: {___itemName}");

            ___TitleText.SetText(titleT.ToString(), new object[] { });

            Text descT = new Text($"{actionS} FOR <color=#F79B26>{SimGameState.GetCBillString(value)}</color>");

            ___DescriptionText.SetText(descT.ToString(), new object[] { });

            ___ConfirmButton.SetText(actionS);
        }
Esempio n. 5
0
        static void Postfix(SG_HiringHall_Screen __instance,
                            Pilot ___selectedPilot, LocalizableText ___MWInitialCostText, UIColorRefTracker ___MWCostColor,
                            HBSDOTweenButton ___HireButton)
        {
            Mod.Log.Debug?.Write("Updating UpdateMoneySpot");

            if (___selectedPilot != null)
            {
                Mod.Log.Debug?.Write(" -- pilot is selected");

                // Account for the salary
                CrewDetails details       = ModState.GetCrewDetails(___selectedPilot.pilotDef);
                int         modifiedBonus = (int)Mathf.RoundToInt(details.AdjustedBonus);
                string      bonus         = new Text(Mod.LocalizedText.Labels[ModText.LT_Crew_Bonus_Label],
                                                     new string[] { SimGameState.GetCBillString(Mathf.RoundToInt(modifiedBonus)) })
                                            .ToString();
                Mod.Log.Debug?.Write($"  -- bonus will be: {bonus}");

                ___MWInitialCostText.SetText(bonus);

                if (modifiedBonus > ModState.SimGameState.Funds)
                {
                    Mod.Log.Debug?.Write(" -- Disabling hire.");
                    ___MWCostColor.SetUIColor(UIColor.Red);
                    ___HireButton.SetState(ButtonState.Disabled);
                }
                else
                {
                    Mod.Log.Debug?.Write(" -- Enabling hire.");
                    ___MWCostColor.SetUIColor(UIColor.White);
                    ___HireButton.SetState(ButtonState.Enabled);
                }
            }
        }
Esempio n. 6
0
 public static void Postfix(LanceLoadoutMechItem __instance, MechDef mechDef, LocalizableText ___MechNameText)
 {
     if (__instance != null && MechNamesHelper.HasUiName(mechDef))
     {
         ___MechNameText.SetText(mechDef.Description.UIName);
     }
 }
        private void Play()
        {
            this.sideStack.PanelFrame.gameObject.SetActive(true);
            if (this.currentMessage.DialogueSource.team.IsLocalPlayer)
            {
                //LogDebug($"  Displaying pilot portrait");
                this.sideStack.ShowPortrait(this.currentMessage.DialogueSource.GetPilot().GetPortraitSpriteThumb());
            }
            else
            {
                //LogDebug($"  Displaying castDef portrait");
                this.sideStack.ShowPortrait(this.currentMessage.DialogueContent.CastDef.defaultEmotePortrait.LoadPortrait(false));
            }

            try {
                Transform speakerNameFieldT = this.sideStack.gameObject.transform.Find("Representation/dialog-layout/Portrait/speakerNameField");
                speakerNameFieldT.gameObject.SetActive(true);

                //LogDebug($" Setting SpeakerName to: '{this.currentMessage.DialogueContent.SpeakerName}' with callsign: '{this.currentMessage.DialogueContent.CastDef.callsign}'");
                LocalizableText speakerNameLT = speakerNameFieldT.GetComponentInChildren <LocalizableText>();
                speakerNameLT.SetText(this.currentMessage.DialogueContent.SpeakerName);
                speakerNameLT.gameObject.SetActive(true);
                speakerNameLT.alignment = TMPro.TextAlignmentOptions.Bottom;
            } catch (Exception e)
            {
                LogDebug(e);
            }

            this.activeDialog = this.sideStack.GetNextItem();
            this.activeDialog.Init(this.currentMessage.ShowDuration, true, new Action(this.AfterDialogShow), new Action(this.AfterDialogHide));

            //LogDebug($"CDS - Showing dialog: words: '{this.currentMessage.DialogueContent.words}' color: '{this.currentMessage.DialogueContent.wordsColor}' speakerName: '{this.currentMessage.DialogueContent.SpeakerName}' timeout: {this.currentMessage.ShowDuration}");
            this.activeDialog.Show(this.currentMessage.DialogueContent.words, this.currentMessage.DialogueContent.wordsColor, this.currentMessage.DialogueContent.SpeakerName);
        }
 public static void Postfix(SG_Shop_ItemSelectedPanel __instance, InventoryDataObject_BASE theController, SimGameState ___simState, LocalizableText ___MechPartCountText)
 {
     if (theController.mechDef == null)
     {
         return;
     }
     ___MechPartCountText.SetText(SimpleMechAssembly_Main.GetMechCountDescrString(___simState, theController.mechDef));
 }
Esempio n. 9
0
        public static void Postfix(object data, LocalizableText ___NameField, LocalizableText ___VariantField)
        {
            MechDef mechDef = data as MechDef;

            if (MechNamesHelper.HasUiName(mechDef))
            {
                ___NameField.SetText(mechDef.Description.UIName, Array.Empty <object>());
            }
            else
            {
                ___NameField.SetText(mechDef.Description.Name, Array.Empty <object>());
                ___VariantField.SetText("( {0} {1} )", new object[]
                {
                    mechDef.Chassis.Description.Name,
                    mechDef.Chassis.VariantName
                });
            }
        }
Esempio n. 10
0
 public static void Postfix(BattleTech.UI.ModManagerListViewItem __instance, ModStatusItem modStatusItem, LocalizableText ___modNameText, BattleTech.UI.HBSDOTweenToggle ___toggleBox)
 {
     if (ModTek.allModDefs.ContainsKey(modStatusItem.name))
     {
         ModDefEx mod = ModTek.allModDefs[modStatusItem.name];
         ___toggleBox.SetToggled(mod.PendingEnable);
         if (mod.LoadFail)
         {
             ___modNameText.color = Color.red;
             ___modNameText.SetText("!" + mod.Name);
         }
         else
         {
             ___modNameText.color = Color.white;
             ___modNameText.SetText(mod.Name);
         }
     }
 }
        static void Postfix(CombatHUDActorNameDisplay __instance, LocalizableText ___MechNameText)
        {
            if (__instance.DisplayedCombatant != null &&
                __instance.DisplayedCombatant is BattleTech.Building building &&
                ModState.AmbushBuildingGUIDToTurrets.ContainsKey(building.GUID))
            {
                Turret turret = ModState.AmbushBuildingGUIDToTurrets[building.GUID];

                Text localText = new Text(turret.DisplayName);
                ___MechNameText.SetText(localText.ToString());
            }
        }
Esempio n. 12
0
        public static void Postfix(SG_Shop_ItemSelectedPanel __instance, InventoryDataObject_BASE theController, SimGameState ___simState, LocalizableText ___MechPartCountText)
        {
            if (theController.mechDef == null)
            {
                return;
            }
            int pieces    = ___simState.GetItemCount(theController.mechDef.Description.Id, "MECHPART", SimGameState.ItemCountType.UNDAMAGED_ONLY);
            int needed    = ___simState.Constants.Story.DefaultMechPartMax;
            int varpieces = SimpleMechAssembly_Main.GetNumPartsForAssembly(___simState, theController.mechDef);
            int owned     = SimpleMechAssembly_Main.GetNumberOfMechsOwnedOfType(___simState, theController.mechDef);

            ___MechPartCountText.SetText(string.Format("{0}({1})/{3}({2})", pieces, varpieces, owned, needed));
        }
Esempio n. 13
0
        // This method duplicates functionality of MechLabStockInfoPopup.StockMechDefLoaded
        static void OverrideStockMechDefLoaded(this MechLabStockInfoPopup __instance, string id, MechDef def)
        {
            Logger.Debug("[MechLabStockInfoPopup.OverrideStockMechDefLoaded] called.");

            MechDef ___stockMechDef = Traverse.Create(__instance).Field("stockMechDef").GetValue <MechDef>();
            MechBayMechInfoWidget ___mechInfoWidget  = Traverse.Create(__instance).Field("mechInfoWidget").GetValue <MechBayMechInfoWidget>();
            DataManager           ___dataManager     = Traverse.Create(__instance).Field("dataManager").GetValue <DataManager>();
            LocalizableText       ___descriptionText = Traverse.Create(__instance).Field("descriptionText").GetValue <LocalizableText>();

            ___stockMechDef = def;
            ___mechInfoWidget.SetData(___stockMechDef, ___dataManager);
            ___descriptionText.SetText(___stockMechDef.Description.Details, Array.Empty <object>());
        }
Esempio n. 14
0
        public static LocalizableText AddLine(VerticalLayoutGroup layout, LocalizableText src, string text, TMPro.TextAlignmentOptions aligin)
        {
            GameObject      aline     = new GameObject();
            LocalizableText atextline = aline.AddComponent <LocalizableText>();

            atextline.fontSizeMax = src.fontSizeMax;
            atextline.fontSizeMin = src.fontSizeMin;
            atextline.fontSize    = src.fontSize;
            atextline.SetText(text);
            atextline.alignment          = aligin;
            atextline.enableWordWrapping = false;
            aline.transform.SetParent(layout.transform);
            return(atextline);
        }
Esempio n. 15
0
        public static void ReplaceTitle(LocalizableText ___TitleText, LocalizableText ___DescriptionText,
                                        string ___itemName, int ___costPerUnit, int ___quantityBeingSold, HBSDOTweenButton ___ConfirmButton)
        {
            if (!SG_Stores_MultiPurchasePopup_Handler.Replace)
            {
                return;
            }

            ___TitleText.SetText($"{SG_Stores_MultiPurchasePopup_Handler.Text} {___itemName}");
            var value = SimGameState.GetCBillString(___costPerUnit * ___quantityBeingSold);

            ___DescriptionText.SetText($"{SG_Stores_MultiPurchasePopup_Handler.Text} FOR <color=#F79B26>{value}</color>");
            ___ConfirmButton.SetText(SG_Stores_MultiPurchasePopup_Handler.Text);
        }
Esempio n. 16
0
 public static void Postfix(SGEventPanel __instance)
 {
     try
     {
         int             daysPassed = UnityGameInstance.BattleTechGame.Simulation.DaysPassed;
         string          message    = GetTimelineDate(daysPassed);
         LocalizableText eventTime  = (LocalizableText)ReflectionHelper.GetPrivateField(__instance, "eventTime");
         eventTime.SetText(message);
     }
     catch (Exception e)
     {
         Logger.LogError(e);
     }
 }
Esempio n. 17
0
            public static void Postfix(TooltipPrefab_Equipment __instance, object data, LocalizableText ___bonusesText)
            {
                try
                {
                    Logger.Debug("[TooltipPrefab_Equipment_SetData_POSTFIX] Comma-separating bonusesText");

                    MechComponentDef mechComponentDef = (MechComponentDef)data;
                    if (string.IsNullOrEmpty(mechComponentDef.BonusValueA) && string.IsNullOrEmpty(mechComponentDef.BonusValueB))
                    {
                        ___bonusesText.SetText("-", Array.Empty <object>());
                    }
                    // BEN: Added these
                    else if (!string.IsNullOrEmpty(mechComponentDef.BonusValueA) && string.IsNullOrEmpty(mechComponentDef.BonusValueB))
                    {
                        ___bonusesText.SetText(mechComponentDef.BonusValueA, Array.Empty <object>());
                    }
                    else if (string.IsNullOrEmpty(mechComponentDef.BonusValueA) && !string.IsNullOrEmpty(mechComponentDef.BonusValueB))
                    {
                        ___bonusesText.SetText(mechComponentDef.BonusValueB, Array.Empty <object>());
                    }
                    // :NEB
                    else
                    {
                        // BEN: Added missing comma
                        ___bonusesText.SetText("{0}, {1}", new object[]
                        {
                            mechComponentDef.BonusValueA,
                            mechComponentDef.BonusValueB
                        });
                    }
                }
                catch (Exception e)
                {
                    Logger.Error(e);
                }
            }
Esempio n. 18
0
        internal void RefreshIndicator()
        {
            try
            {
                if (playPauseButton is null)
                {
                    InitGameObject();
                }

                if (Globals.Sim.CurRoomState != DropshipLocation.SHIP ||
                    UIManager.Instance.PopupRoot.gameObject.FindFirstChildNamed("uixPrfScrn_quarterlyReport-screenV2(Clone)").GetComponent <SGCaptainsQuartersStatusScreen>().Visible)
                {
                    return;
                }


                //LogDebug(Globals.Sim.TravelState);
                //LogDebug("HotBox.IsHot " + Globals.WarStatusTracker.HotBox.IsHot(Globals.Sim.CurSystem.Name));
                //LogDebug(1);
                //LogDebug("Globals.Sim.SelectedContract is not null " + (Globals.Sim.SelectedContract is not null));
                //LogDebug(2);
                //LogDebug("SelectedContract.TargetSystemID " + (Globals.Sim.starDict[Globals.Sim.CurSystem.Contract] == Globals.Sim.CurSystem));
                //LogDebug(3);
                //LogDebug("Globals.Sim.starDict[Globals.Sim.SelectedContract.TargetSystemID] == Globals.Sim.CurSystem " + (Globals.Sim.starDict[Globals.Sim.SelectedContract?.TargetSystemID] == Globals.Sim.CurSystem));
                //LogDebug(4);
                //LogDebug("EscalationDays " + Globals.WarStatusTracker.EscalationDays);

                if (Globals.Sim.TravelState is SimGameTravelStatus.IN_SYSTEM &&
                    Globals.WarStatusTracker.HotBox.IsHot(Globals.Sim.CurSystem.Name) &&
                    Globals.WarStatusTracker.EscalationDays == 0)
                {
                    text.SetText("Deployment Required");
                    image.color = new Color(0.5f, 0, 0, 0.863f);
                    playPauseButton.SetActive(false);
                    hitBox.SetActive(false);
                }
                else
                {
                    image.color = new Color(0, 0, 0, 0.863f);
                    playPauseButton.SetActive(true);
                    hitBox.SetActive(true);
                }
            }
            catch (Exception ex)
            {
                Error(ex);
            }
        }
Esempio n. 19
0
        static void Postfix(LanceHeaderWidget __instance, List <MechDef> mechs, LocalizableText ___simLanceTonnageText, LanceConfiguratorPanel ___LC)
        {
            try {
                Settings settings        = Helper.LoadSettings();
                string   freeTonnageText = "";


                if (___LC.IsSimGame)
                {
                    int   lanceTonnage = 0;
                    float dropCost     = 0f;
                    if (settings.CostByTons)
                    {
                        foreach (MechDef def in mechs)
                        {
                            dropCost     += (def.Chassis.Tonnage * settings.cbillsPerTon);
                            lanceTonnage += (int)def.Chassis.Tonnage;
                        }
                    }
                    else
                    {
                        foreach (MechDef def in mechs)
                        {
                            dropCost     += (Helper.CalculateCBillValue(def) * settings.percentageOfMechCost);
                            lanceTonnage += (int)def.Chassis.Tonnage;
                        }
                    }
                    if (settings.CostByTons && settings.someFreeTonnage)
                    {
                        freeTonnageText = $"({settings.freeTonnageAmount} TONS FREE)";
                        dropCost        = Math.Max(0f, (lanceTonnage - settings.freeTonnageAmount) * settings.cbillsPerTon);
                    }

                    string formattedDropCost = string.Format("{0:n0}", dropCost);
                    Fields.DropCost          = dropCost;
                    Fields.LanceTonnage      = lanceTonnage;
                    Fields.FormattedDropCost = formattedDropCost;
                    Fields.FreeTonnageText   = freeTonnageText;

                    // longer strings interfere with messages about incorrect lance configurations
                    ___simLanceTonnageText.SetText($"DROP COST: ¢{Fields.FormattedDropCost}   LANCE WEIGHT: {Fields.LanceTonnage} TONS {Fields.FreeTonnageText}");
                }
            }
            catch (Exception e) {
                Logger.LogError(e);
            }
        }
Esempio n. 20
0
        static void Postfix(SG_HiringHall_MWSelectedPanel __instance, Pilot p, LocalizableText ___BaseSalaryText)
        {
            if (p != null && ___BaseSalaryText != null)
            {
                Mod.Log.Debug?.Write($"Updating MWSelectedPanel for pilot: {p.Name}");

                // Account for the salary
                CrewDetails details         = ModState.GetCrewDetails(p.pilotDef);
                int         modifiedSalary  = (int)Mathf.RoundToInt(details.AdjustedSalary);
                string      modifiedSalaryS = SimGameState.GetCBillString(modifiedSalary);
                Mod.Log.Debug?.Write($"  -- salary will be: {modifiedSalaryS}");

                string salaryS = new Text(Mod.LocalizedText.Labels[ModText.LT_Crew_Salary_Label], new string[] { modifiedSalaryS })
                                 .ToString();
                ___BaseSalaryText.SetText(salaryS);
            }
        }
        static bool Prefix(SGBarracksRosterList __instance, LocalizableText ___mechWarriorCount)
        {
            if (ModState.SimGameState == null)
            {
                return(true);                               // Only patch if we're in SimGame
            }
            int usedBerths = CrewHelper.UsedBerths(ModState.SimGameState.PilotRoster);

            Mod.Log.Debug?.Write($"Berths => used: {usedBerths}  available: {ModState.SimGameState.GetMaxMechWarriors()}");

            string text = new Localize.Text(Mod.LocalizedText.Labels[ModText.LT_Crew_Berths_Used],
                                            new object[] { usedBerths, ModState.SimGameState.GetMaxMechWarriors() }).ToString();

            ___mechWarriorCount.SetText(text);

            return(false);
        }
Esempio n. 22
0
        static void Postfix(SG_HiringHall_DetailPanel __instance, Pilot p, LocalizableText ___DescriptionText)
        {
            CrewDetails details = ModState.GetCrewDetails(p.pilotDef);

            StringBuilder sb = new StringBuilder();

            // Check hazard pay
            if (details.HazardPay > 0)
            {
                string hazardPayS = new Text(Mod.LocalizedText.Labels[ModText.LT_Crew_Hazard_Pay],
                                             new object[] { SimGameState.GetCBillString(details.HazardPay) }).ToString();
                Mod.Log.Debug?.Write($"Hazard pay is: {hazardPayS}");
                sb.Append(hazardPayS);
                sb.Append("\n\n");
            }

            // Convert favored and hated faction
            if (details.FavoredFactionId > 0)
            {
                FactionValue faction         = FactionEnumeration.GetFactionByID(details.FavoredFactionId);
                string       favoredFactionS = new Text(Mod.LocalizedText.Labels[ModText.LT_Crew_Dossier_Biography_Faction_Favored],
                                                        new object[] { faction.FactionDef.CapitalizedName }).ToString();
                sb.Append(favoredFactionS);
                sb.Append("\n\n");
                Mod.Log.Debug?.Write($"  Favored Faction is: {favoredFactionS}");
                //Mod.Log.Debug?.Write($"  Favored Faction => name: '{faction.Name}'  friendlyName: '{faction.FriendlyName}'  " +
                //    $"factionDef.Name: {faction.FactionDef?.Name}  factionDef.CapitalizedName: {faction.FactionDef.CapitalizedName}  " +
                //    $"factionDef.ShortName: {faction.FactionDef?.ShortName}  factionDef.CapitalizedShortName: {faction.FactionDef.CapitalizedShortName}  " +
                //    $"");
            }

            if (details.HatedFactionId > 0)
            {
                FactionValue faction       = FactionEnumeration.GetFactionByID(details.HatedFactionId);
                string       hatedFactionS = new Text(Mod.LocalizedText.Labels[ModText.LT_Crew_Dossier_Biography_Faction_Hated],
                                                      new object[] { faction.FactionDef.CapitalizedName }).ToString();
                sb.Append(hatedFactionS);
                sb.Append("\n\n");
                Mod.Log.Debug?.Write($"  Hated Faction is: {hatedFactionS}");
            }

            sb.Append(Interpolator.Interpolate(p.pilotDef.Description.GetLocalizedDetails().ToString(true), ModState.SimGameState.Context, true));

            ___DescriptionText.SetText(sb.ToString());
        }
Esempio n. 23
0
        static void Postfix(SG_HiringHall_Screen __instance, GameObject ___WarningAreaObject,
                            HBSDOTweenButton ___HireButton, LocalizableText ___WarningText,
                            HBSTooltip ___NoHireTooltip, Pilot ___selectedPilot)
        {
            Mod.Log.Debug?.Write("Updating MWSelectedPanel:WarningsCheck");

            // Use the warnings area to display the contract length terms
            if (___selectedPilot != null && ___HireButton.State == ButtonState.Enabled)
            {
                ___WarningAreaObject.SetActive(true);

                CrewDetails details = ModState.GetCrewDetails(___selectedPilot.pilotDef);

                string contractTermS = new Text(Mod.LocalizedText.Labels[ModText.LT_Crew_Contract_Term],
                                                new object[] { details.ContractTerm }
                                                ).ToString();
                ___WarningText.SetText(contractTermS);
            }
        }
Esempio n. 24
0
        static void Postfix(MechLabPanel __instance)
        {
            try
            {
                // Change the label on the confirm button
                Mod.Log.Info?.Write($"MLP:SD - walking transforms of GO: {__instance.gameObject.name}");

                Transform cancelConfirmT = __instance.gameObject.transform.Find("Representation/OBJ_cancelconfirm");
                if (cancelConfirmT == null)
                {
                    Mod.Log.Error?.Write("Failed to find OBJ_cancelconfirm!");
                }

                Transform readyTextT = cancelConfirmT.Find("uixPrfBttn_BASE_button2-MANAGED-confirm/bttn2_contentLayout/ready_Text-optional");
                if (readyTextT == null)
                {
                    Mod.Log.Error?.Write("Failed to find ready_Text-optional!");
                }

                LocalizableText buttonText = readyTextT.gameObject.GetComponent <LocalizableText>();
                if (buttonText == null)
                {
                    Mod.Log.Error?.Write("Failed to find LocalizableText!");
                }
                buttonText.SetText("VALIDATE");

                // Disable the store button
                if (Mod.Config.Fixes.MechbayLayoutDisableStore)
                {
                    Transform storeButtonT = __instance.gameObject.transform.Find("Representation/OBJGROUP_LEFT/OBJ_inventoryLong/OBJ_storeButton");
                    if (storeButtonT == null)
                    {
                        Mod.Log.Error?.Write("Failed to find OBJ_storeButton!");
                    }
                    storeButtonT.gameObject.SetActive(false);
                }
            }
            catch (Exception e)
            {
                Mod.Log.Warn?.Write(e, $"Failed to set MechLab confirm button to new text");
            }
        }
Esempio n. 25
0
            static bool Prefix(CombatChatModule __instance, ActiveChatListView ____activeChatList)
            {
                //Mod.Log.Info(" -- CCM:Update:pre invoked");
                // Invoke base.Update()
                CombatChatModule_UIModule_Update.Invoke(__instance);

                // Remove the [T] from the chat button
                Transform chatBtnT = __instance.gameObject.transform.Find("Representation/chat_panel/uixPrf_chatButton");

                if (chatBtnT != null)
                {
                    LocalizableText chatBtnLT = chatBtnT.GetComponentInChildren <LocalizableText>();
                    chatBtnLT.SetText(" ");
                }
                else
                {
                    Mod.Log.Info("Could not find chat button");
                }

                return(false);
            }
        private void Play()
        {
            Mod.Log.Debug?.Write($"CDS::Play - invoked");

            this.sideStack.PanelFrame.gameObject.SetActive(true);
            if (this.currentMessage.DialogueSource != null && this.currentMessage.DialogueSource.team.IsLocalPlayer)
            {
                Mod.Log.Debug?.Write($"  Displaying pilot portrait");
                this.sideStack.ShowPortrait(this.currentMessage.DialogueSource.GetPilot().GetPortraitSpriteThumb());
            }
            else
            {
                Mod.Log.Debug?.Write($"  Displaying castDef portrait");
                this.sideStack.ShowPortrait(this.currentMessage.DialogueContent.CastDef.defaultEmotePortrait.LoadPortrait(false));
            }

            try {
                Transform speakerNameFieldT = this.sideStack.gameObject.transform.Find("Representation/dialog-layout/Portrait/speakerNameField");
                if (speakerNameFieldT == null)
                {
                    Mod.Log.Warn?.Write("COULD NOT FIND speakerNameFieldT!");
                }
                speakerNameFieldT.gameObject.SetActive(true);

                Mod.Log.Debug?.Write($" Setting SpeakerName to: '{this.currentMessage.DialogueContent?.SpeakerName}' with callsign: '{this.currentMessage.DialogueContent?.CastDef?.callsign}'");
                LocalizableText speakerNameLT = speakerNameFieldT.GetComponentInChildren <LocalizableText>();
                speakerNameLT.SetText(this.currentMessage.DialogueContent?.SpeakerName);
                speakerNameLT.gameObject.SetActive(true);
                speakerNameLT.alignment = TMPro.TextAlignmentOptions.Bottom;
            } catch (Exception e) {
                Mod.Log.Error?.Write(e, "Failed to set display name due to error!");
            }

            this.activeDialog = this.sideStack.GetNextItem();
            this.activeDialog.Init(this.currentMessage.ShowDuration, true, new Action(this.AfterDialogShow), new Action(this.AfterDialogHide));

            Mod.Log.Debug?.Write($"CDS - Showing dialog: words: '{this.currentMessage.DialogueContent.words}' color: '{this.currentMessage.DialogueContent.wordsColor}' speakerName: '{this.currentMessage.DialogueContent.SpeakerName}' timeout: {this.currentMessage.ShowDuration}");
            this.activeDialog.Show(this.currentMessage.DialogueContent.words, this.currentMessage.DialogueContent.wordsColor, this.currentMessage.DialogueContent.SpeakerName);
            Mod.Log.Trace?.Write("CDS::Play - DONE");
        }
Esempio n. 27
0
        public static void Postfix(AAR_SalvageChosen __instance, LocalizableText ___howManyReceivedText, AAR_SalvageScreen ___parent, SimGameState ___simState, Contract ___contract)
        {
            // Skip if the UI element isn't visible
            if (!__instance.Visible)
            {
                Mod.Log.Info?.Write("SalvageChosen not visible, but ConvertToFinalState called - this should not happen, skipping.");
                return;
            }

            // Set each of the items clickable
            foreach (InventoryItemElement_NotListView iie in __instance.LeftoverInventory)
            {
                if (iie.controller != null && iie.controller.salvageDef != null && iie.controller.salvageDef.Type != SalvageDef.SalvageType.MECH_PART)
                {
                    Mod.Log.Debug?.Write($"Enabling non-mechpart for clicking: {iie.controller.salvageDef.Description.Id}");
                    iie.SetClickable(true);
                }
            }

            // Update text with Quick Sell instructions
            string localText = new Text(Mod.Config.LocalizedText[ModConfig.LT_QUICK_SELL], new object[] { }).ToString();

            ___howManyReceivedText.SetText(string.Concat(___howManyReceivedText.text, localText));

            // Set the Mod state we'll rely upon
            ModState.AAR_SalvageScreen = ___parent;
            ModState.Contract          = ___contract;
            ModState.SimGameState      = ___simState;

            // Painful, full-context searches here
            ModState.HBSPopupRoot =
                GameObject.Find(ModConsts.HBSPopupRootGOName);
            ModState.FloatieFont =
                Resources.FindObjectsOfTypeAll <TMP_FontAsset>().First(x => x.name == "UnitedSansReg-Black SDF");
            ModState.SGCurrencyDisplay = (SGCurrencyDisplay)Object.FindObjectOfType(typeof(SGCurrencyDisplay));
        }
Esempio n. 28
0
        public static void Postfix(SGContractsWidget __instance, Contract contract, LocalizableText ___ContractLocationField, GameObject ___ContractLocation, GameObject ___ContractLocationArrow, GameObject ___TravelContractBGFill, GameObject ___TravelIcon, GameObject ___PriorityMissionStoryObject)
        {
            try
            {
                // Only for "normal" contracts with no negotiations
                if (contract.IsOpportunityMission())
                {
                    Logger.Debug($"[SGContractsWidget_PopulateContract_POSTFIX] {contract.Override.ID} is an opportunity mission");

                    StarSystem targetSystem = contract.GameContext.GetObject(GameContextObjectTagEnum.TargetStarSystem) as StarSystem;
                    ___ContractLocationField.SetText("Opportunity Mission at {0}", new object[] { targetSystem.Name });
                    ___ContractLocation.SetActive(true);
                    ___ContractLocationArrow.SetActive(false);
                    //___TravelContractBGFill.SetActive(false);
                    ___TravelIcon.SetActive(false);

                    __instance.ForceRefreshImmediate();
                }
            }
            catch (Exception e)
            {
                Logger.Error(e);
            }
        }
Esempio n. 29
0
        public static void Postfix(object data, LocalizableText ___Title)
        {
            try
            {
                var settings    = OverrideStatTooltipsFeature.Shared.Settings;
                var tooltipData = (StatTooltipData)data;
                switch (tooltipData.dataType)
                {
                case StatType.Movement:
                    ___Title.SetText(settings.MovementTitleText);
                    break;

                case StatType.HeatEffeciency:
                    ___Title.SetText(settings.HeatEfficiencyTitleText);
                    break;

                case StatType.Durability:
                    ___Title.SetText(settings.DurabilityTitleText);
                    break;

                case StatType.AvgRange:
                    ___Title.SetText(settings.AvgRangeTitleText);
                    break;

                case StatType.Melee:
                    ___Title.SetText(settings.MeleeTitleText);
                    break;

                case StatType.Firepower:
                    ___Title.SetText(settings.FirepowerTitleText);
                    break;
                }
            }
            catch (Exception e)
            {
                Control.mod.Logger.LogError(e);
            }
        }
        static void Postfix(SGBarracksDossierPanel __instance, Pilot p,
                            LocalizableText ___healthText, List <GameObject> ___healthList, LocalizableText ___salary,
                            LocalizableText ___firstName, LocalizableText ___lastName)
        {
            if (p == null)
            {
                return;
            }

            Mod.DossierLog.Debug?.Write($"Updating Dossier for pilot: {p.Name}");
            CrewDetails details = ModState.GetCrewDetails(p.pilotDef);

            if (details.IsMechTechCrew || details.IsMedTechCrew || details.IsAerospaceCrew)
            {
                ___healthText.SetText("N/A");
                for (int i = 0; i < ___healthList.Count; i++)
                {
                    ___healthList[i].SetActive(false);
                }
            }

            string nameS = new Text(Mod.LocalizedText.Labels[ModText.LT_Crew_Name_Format],
                                    new object[] { p.FirstName, p.LastName }).ToString();

            ___firstName.SetText(nameS);

            // Set the firstname label to 'Name' instead of 'First Name'
            Mod.DossierLog.Debug?.Write("Updating firstName to Name");
            GameObject      firstNameGO      = __instance.gameObject.FindFirstChildNamed(ModConsts.GO_HBS_Barracks_Dossier_LastName);
            GameObject      firstNameLabelGO = firstNameGO.transform.parent.GetChild(0).GetChild(0).gameObject;
            LocalizableText firstNameLabel   = firstNameLabelGO.GetComponentInChildren <LocalizableText>();
            string          firstNameS       = new Text(Mod.LocalizedText.Labels[ModText.LT_Crew_Dossier_Contract_Term]).ToString();

            firstNameLabel.SetText(firstNameS);

            // Set the lastname label to 'Contract End' and the name value to the remaining days
            Mod.DossierLog.Debug?.Write("Updating lastName to ContractTerm");
            GameObject      lastNameGO      = __instance.gameObject.FindFirstChildNamed(ModConsts.GO_HBS_Barracks_Dossier_LastName);
            GameObject      lastNameLabelGO = lastNameGO.transform.parent.GetChild(0).GetChild(0).gameObject; // should be text_lastName -> parent -> layout-label -> label
            LocalizableText lastNameLabel   = lastNameLabelGO.GetComponentInChildren <LocalizableText>();
            string          contractTermS   = new Text(Mod.LocalizedText.Labels[ModText.LT_Crew_Dossier_Contract_Term]).ToString();

            lastNameLabel.SetText(contractTermS);

            string contractTermRemaining = "------";

            if (!details.IsPlayer && details.ContractTerm != 0)
            {
                int daysRemaining = details.ExpirationDay - ModState.SimGameState.DaysPassed;
                if (daysRemaining < 0)
                {
                    daysRemaining = 0;
                }
                contractTermRemaining = new Text(Mod.LocalizedText.Labels[ModText.LT_Crew_Dossier_Days_Remaining],
                                                 new object[] { daysRemaining }).ToString();
                Mod.DossierLog.Debug?.Write($" {daysRemaining} daysRemaining = {ModState.SimGameState.DaysPassed} daysPassed - {details.ExpirationDay} endDay");
            }

            ___lastName.SetText(contractTermRemaining);
            Mod.DossierLog.Debug?.Write($"  -- done updating dossier for pilot: {p.Name}");
        }