Exemplo n.º 1
0
 public static void Postfix(MechDef mechDef, MechLabPanel ___mechLab, HBS_InputField ___mechNickname)
 {
     if (MechNamesHelper.HasUiName(___mechLab.activeMechDef))
     {
         ___mechNickname.SetText(___mechLab.activeMechDef.Description.UIName);
     }
 }
Exemplo n.º 2
0
        public static void Prefix(HeraldryNameWidget __instance)
        {
            try
            {
                Logger.Debug("[HeraldryNameWidget_SetData_PREFIX] Disable text validation, expand character limit");

                HBS_InputField nameInput = (HBS_InputField)AccessTools.Field(typeof(HeraldryNameWidget), "nameInput").GetValue(__instance);
                nameInput.characterLimit      = 80;
                nameInput.contentType         = HBS_InputField.ContentType.Standard;
                nameInput.characterValidation = HBS_InputField.CharacterValidation.None;
            }
            catch (Exception e)
            {
                Logger.Error(e);
            }
        }
Exemplo n.º 3
0
        public static void Prefix(MechLabMechInfoWidget __instance)
        {
            try
            {
                MechLabPanel mechLabPanel = (MechLabPanel)AccessTools.Field(typeof(MechLabMechInfoWidget), "mechLab").GetValue(__instance);

                if (!mechLabPanel.IsSimGame)
                {
                    Logger.Debug("[MechLabMechInfoWidget_SetData_PREFIX] This is NOT SimGame. Aborting.");
                    return;
                }

                Logger.Debug("[MechLabMechInfoWidget_SetData_PREFIX] Disable text validation, expand character limit");

                HBS_InputField mechNickname = (HBS_InputField)AccessTools.Field(typeof(MechLabMechInfoWidget), "mechNickname").GetValue(__instance);
                mechNickname.characterLimit      = 20;
                mechNickname.contentType         = HBS_InputField.ContentType.Standard;
                mechNickname.characterValidation = HBS_InputField.CharacterValidation.None;
            }
            catch (Exception e)
            {
                Logger.Error(e);
            }
        }
Exemplo n.º 4
0
        public static void ApplyLoadout(this MechLabPanel mechLabPanel, string mechDefId)
        {
            try
            {
                // Check first
                if (!mechLabPanel.Sim.DataManager.Exists(BattleTechResourceType.MechDef, mechDefId))
                {
                    GenericPopupBuilder
                    .Create("Apply Loadout failed", "The requested MechDef " + mechDefId + " was not found")
                    .AddButton("Confirm", null, true, null)
                    .AddFader(new UIColorRef?(LazySingletonBehavior <UIManager> .Instance.UILookAndColorConstants.PopupBackfill), 0f, true)
                    .SetAlwaysOnTop()
                    .SetOnClose(delegate
                    {
                        // Nothing
                    })
                    .Render();

                    // Abort!
                    return;
                }
                MechDef activeMechDef    = mechLabPanel.activeMechDef;
                MechDef requestedMechDef = new MechDef(mechLabPanel.Sim.DataManager.MechDefs.Get(mechDefId), null, true);

                // Check second
                List <string> errorDescriptions = new List <string>();
                if (!mechLabPanel.CanApplyLoadout(requestedMechDef, out errorDescriptions))
                {
                    string popupTitle = "Apply Loadout failed";
                    //string popupBody = "The following problems were encountered:" + Environment.NewLine;
                    string popupBody = "";

                    foreach (string errorDescription in errorDescriptions)
                    {
                        popupBody += errorDescription + Environment.NewLine;
                    }

                    GenericPopupBuilder
                    .Create(popupTitle, popupBody)
                    .AddButton("Confirm", null, true, null)
                    .AddFader(new UIColorRef?(LazySingletonBehavior <UIManager> .Instance.UILookAndColorConstants.PopupBackfill), 0f, true)
                    .SetAlwaysOnTop()
                    .SetOnClose(delegate
                    {
                        // Nothing
                    })
                    .Render();

                    // Abort!
                    return;
                }
                // Checks done



                // Hard cleanup upfront
                mechLabPanel.OnRevertMech();

                // Get data
                MechLabInventoryWidget inventoryWidget = (MechLabInventoryWidget)AccessTools.Field(typeof(MechLabPanel), "inventoryWidget").GetValue(mechLabPanel);
                MechLabDismountWidget  dismountWidget  = (MechLabDismountWidget)AccessTools.Field(typeof(MechLabPanel), "dismountWidget").GetValue(mechLabPanel);
                MechLabMechInfoWidget  mechInfoWidget  = (MechLabMechInfoWidget)AccessTools.Field(typeof(MechLabPanel), "mechInfoWidget").GetValue(mechLabPanel);
                HBS_InputField         mechNickname    = (HBS_InputField)AccessTools.Field(typeof(MechLabMechInfoWidget), "mechNickname").GetValue(mechInfoWidget);

                List <MechComponentRef> dropshipInventory            = mechLabPanel.Sim.GetAllInventoryItemDefs();
                List <MechComponentRef> storageInventory             = mechLabPanel.storageInventory;
                List <MechComponentRef> activeMechInventory          = mechLabPanel.activeMechInventory;
                MechComponentRef[]      requestedMechComponentsArray = (MechComponentRef[])AccessTools.Field(typeof(MechDef), "inventory").GetValue(requestedMechDef);
                List <MechComponentRef> requestedMechComponents      = requestedMechComponentsArray.ToList();

                // Remove fixed equipment as it will be ignored from dismounting et all
                for (int i = requestedMechComponents.Count - 1; i >= 0; i--)
                {
                    if (requestedMechComponents[i].IsFixed)
                    {
                        Logger.Debug("[Extensions.ResetToStock] FOUND AND WILL REMOVE FIXED EQUIPMENT: " + requestedMechComponents[i].ComponentDefID);
                        requestedMechComponents.RemoveAt(i);
                    }
                }

                // This puts the current equipment into dismountWidget and also clears the Mechs inventory
                // NOTE that fixed equipment will stay where it is -> must be removed from requestedComponents manually!
                mechLabPanel.OnStripEquipment();

                // Collect items from dismountWidget and/or inventoryWidget
                List <MechComponentRef> requestedMechComponentsRequired = requestedMechComponents.ToList();

                //List<MechLabItemSlotElement> activeMechDismountedItems = new List<MechLabItemSlotElement>(dismountWidget.localInventory);
                List <MechLabItemSlotElement> activeMechDismountedItems = dismountWidget.localInventory;

                //List<InventoryItemElement_NotListView> localInventoryItems = new List<InventoryItemElement_NotListView>(inventoryWidget.localInventory);
                List <InventoryItemElement_NotListView> localInventoryItems = inventoryWidget.localInventory;

                List <MechLabItemSlotElement>           itemsCollectedFromDismount  = new List <MechLabItemSlotElement>();
                List <InventoryItemElement_NotListView> itemsCollectedFromInventory = new List <InventoryItemElement_NotListView>();

                // CHECK
                foreach (MechComponentRef comp in requestedMechComponentsRequired)
                {
                    Logger.Debug("[Extensions.ResetToStock] INIT requestedMechComponentsRequired: " + comp.ComponentDefID);
                }



                // Check for required items in dismountWidget first, remove/add from/to applicable Lists
                // @ToDo: Put in method
                for (int i = requestedMechComponentsRequired.Count - 1; i >= 0; i--)
                {
                    bool found = false;
                    for (int j = activeMechDismountedItems.Count - 1; j >= 0; j--)
                    {
                        if (requestedMechComponentsRequired[i].ComponentDefID == activeMechDismountedItems[j].ComponentRef.ComponentDefID)
                        {
                            Logger.Debug("[Extensions.ResetToStock] FOUND in activeMechDismountedItems: " + requestedMechComponentsRequired[i].ComponentDefID);
                            found = true;
                            requestedMechComponentsRequired.RemoveAt(i);
                            itemsCollectedFromDismount.Add(activeMechDismountedItems[j]);

                            // Remove visually
                            // Do not forget to refresh the widget
                            MechLabItemSlotElement mechLabItemSlotElement = activeMechDismountedItems[j];
                            mechLabItemSlotElement.gameObject.transform.SetParent(null, false);
                            mechLabPanel.dataManager.PoolGameObject(MechLabPanel.MECHCOMPONENT_ITEM_PREFAB, mechLabItemSlotElement.gameObject);

                            // Remove data AFTERWARDS too
                            activeMechDismountedItems.RemoveAt(j);

                            break;
                        }
                    }
                    if (!found)
                    {
                        Logger.Debug("[Extensions.ResetToStock] NOT FOUND in activeMechDismountedItems: " + requestedMechComponentsRequired[i].ComponentDefID);
                    }
                }
                // Refresh UI
                ReflectionHelper.InvokePrivateMethode(dismountWidget, "RefreshComponentCountText", null);



                // CHECK
                foreach (MechLabItemSlotElement item in itemsCollectedFromDismount)
                {
                    Logger.Debug("[Extensions.ResetToStock] itemsCollectedFromDismount: " + item.ComponentRef.ComponentDefID + ", MountedLocation: " + item.MountedLocation + ", DropParent: " + item.DropParent);
                }



                // Check for REMAINING required items in inventoryWidget, remove/add from/to applicable Lists
                // NEEDS conversion of remaining components to inventory items via custom type
                List <InventoryItemElement_Simple> requestedMechItemsRequired = Utilities.ComponentsToInventoryItems(requestedMechComponentsRequired, true);
                List <InventoryItemElement_Simple> missingItems = new List <InventoryItemElement_Simple>();
                bool itemsAvailableInInventory = mechLabPanel.ItemsAvailableInInventory(requestedMechItemsRequired, localInventoryItems, out missingItems);
                Logger.Debug("[Extensions.ResetToStock] itemsAvailableInInventory: " + itemsAvailableInInventory);

                if (itemsAvailableInInventory)
                {
                    itemsCollectedFromInventory = mechLabPanel.PullItemsFromInventory(requestedMechItemsRequired, localInventoryItems);
                    // Clear required components list
                    requestedMechComponentsRequired.Clear();
                }
                else
                {
                    // Hard exit, SHOULD NEVER END UP HERE!
                    Logger.Debug("[Extensions.ResetToStock] MISSING ITEMS. ABORTING. YOU SHOULD NEVER SEE THIS!");
                    mechLabPanel.OnRevertMech();
                    return;
                }

                // CHECK
                foreach (InventoryItemElement_NotListView item in itemsCollectedFromInventory)
                {
                    Logger.Debug("[Extensions.ResetToStock] itemsCollectedFromInventory: " + item.ComponentRef.ComponentDefID + ", MountedLocation: " + item.MountedLocation + ", DropParent: " + item.DropParent);
                }



                // At this point inventoryWidget.localInventory AND dismountWidget.localInventory already have the potentially reusable components REMOVED
                // So, in "SetEquipment" they must be SPAWNED otherwise they are lost forever



                // Helper Dictionary
                Dictionary <ChassisLocations, MechLabLocationWidget> LocationHandler = new Dictionary <ChassisLocations, MechLabLocationWidget>();
                LocationHandler.Add(ChassisLocations.Head, mechLabPanel.headWidget);
                LocationHandler.Add(ChassisLocations.CenterTorso, mechLabPanel.centerTorsoWidget);
                LocationHandler.Add(ChassisLocations.LeftTorso, mechLabPanel.leftTorsoWidget);
                LocationHandler.Add(ChassisLocations.RightTorso, mechLabPanel.rightTorsoWidget);
                LocationHandler.Add(ChassisLocations.LeftArm, mechLabPanel.leftArmWidget);
                LocationHandler.Add(ChassisLocations.RightArm, mechLabPanel.rightArmWidget);
                LocationHandler.Add(ChassisLocations.LeftLeg, mechLabPanel.leftLegWidget);
                LocationHandler.Add(ChassisLocations.RightLeg, mechLabPanel.rightLegWidget);

                // Prepare custom equipment with info about desired origin beforehand
                List <InventoryItemElement_Simple> requestedEquipment = new List <InventoryItemElement_Simple>();
                List <MechLabItemSlotElement>      dismountedItems    = itemsCollectedFromDismount.ToList();
                foreach (MechComponentRef requestedItem in requestedMechComponents)
                {
                    InventoryItemElement_Simple requestedInventoryItem = new InventoryItemElement_Simple();
                    requestedInventoryItem.ComponentRef = requestedItem;
                    requestedInventoryItem.Origin       = MechLabDropTargetType.InventoryList;

                    for (int i = dismountedItems.Count - 1; i >= 0; i--)
                    {
                        if (requestedItem.ComponentDefID == dismountedItems[i].ComponentRef.ComponentDefID)
                        {
                            requestedInventoryItem.Origin = MechLabDropTargetType.Dismount;
                            dismountedItems.RemoveAt(i);
                            break;
                        }
                    }
                    requestedEquipment.Add(requestedInventoryItem);
                }
                // CHECK
                foreach (MechComponentRef item in requestedMechComponents)
                {
                    Logger.Debug("[Extensions.ResetToStock] baseMechComponents: " + item.ComponentDefID);
                }
                foreach (InventoryItemElement_Simple item in requestedEquipment)
                {
                    Logger.Debug("[Extensions.ResetToStock] requestedEquipment: " + item.ComponentRef.ComponentDefID + ", Origin: " + item.Origin);
                }

                // Set inventory including a hint to where the components were taken from
                // Example manual call: mechLabPanel.SetEquipment(requestedEquipment, mechLabPanel.centerTorsoWidget, requestedMechDef.GetLocationLoadoutDef(ChassisLocations.CenterTorso));
                foreach (KeyValuePair <ChassisLocations, MechLabLocationWidget> LocationPair in LocationHandler)
                {
                    mechLabPanel.SetEquipment(requestedEquipment, LocationPair.Value, requestedMechDef.GetLocationLoadoutDef(LocationPair.Key));
                    mechLabPanel.SetArmor(LocationPair.Value, requestedMechDef.GetLocationLoadoutDef(LocationPair.Key));
                }

                // Refresh main inventory
                mechLabPanel.activeMechInventory = new List <MechComponentRef>(requestedMechDef.Inventory);
                //ReflectionHelper.InvokePrivateMethode(mechLabPanel.activeMechDef, "InsertFixedEquipmentIntoInventory", null);

                // Better as it calls RefreshInventory()? -> No, Tonnage is not adjusted... need to look into it somewhen
                //mechLabPanel.activeMechDef.SetInventory(requestedMechDef.Inventory);



                // Update dependent widgets (also calls CalculateCBillValue() -> CalculateSimGameWorkOrderCost() -> PruneWorkOrder())
                mechInfoWidget.RefreshInfo();

                // Mark as modified
                Traverse.Create(mechLabPanel).Field("Modified").SetValue(true);
                GameObject modifiedIcon = (GameObject)AccessTools.Field(typeof(MechLabPanel), "modifiedIcon").GetValue(mechLabPanel);
                modifiedIcon.SetActive(mechLabPanel.Modified);

                // Validate
                mechLabPanel.ValidateLoadout(true);
                ReflectionHelper.InvokePrivateMethode(mechLabPanel, "RefreshInventorySelectability", null);

                // Set Nickname
                mechNickname.SetText(requestedMechDef.Description.Name);

                // @ToDo: Inform user about what components were installed from where
            }
            catch (Exception e)
            {
                Logger.Error(e);
            }
        }
Exemplo n.º 5
0
        public static void Postfix(HeraldryNameWidget __instance)
        {
            try
            {
                HBS_InputField nameInput           = (HBS_InputField)AccessTools.Field(typeof(HeraldryNameWidget), "nameInput").GetValue(__instance);
                string         currentHeraldryName = nameInput.text;

                if (string.IsNullOrEmpty(currentHeraldryName))
                {
                    Logger.Debug("[HeraldryNameWidget_OnNameInputEndEdit_POSTFIX] No input");
                    return;
                }
                if (currentHeraldryName.Length > 0 && currentHeraldryName.Substring(0, 1) != "/")
                {
                    Logger.Debug("[HeraldryNameWidget_OnNameInputEndEdit_POSTFIX] No command");
                    return;
                }

                List <string> validCommands = new List <string>()
                {
                    "/help", "/list", "/mech", "/comp", "/funds", "/xp", "/upgr", "/ronin", "/rep", "/travel", "/event"
                };
                string command = validCommands.FirstOrDefault(c => currentHeraldryName.Contains(c));

                if (command != null)
                {
                    Logger.Debug("[HeraldryNameWidget_OnNameInputEndEdit_POSTFIX] Command: " + command);

                    string param = currentHeraldryName.Replace(command, "").Trim();

                    if (command != "/help" && String.IsNullOrEmpty(param))
                    {
                        Logger.Debug("[HeraldryNameWidget_OnNameInputEndEdit_POSTFIX] Recognized a command but no param was given");
                        PopupHelper.Info("Recognized a command but no param was given");
                        return;
                    }

                    switch (command)
                    {
                    case "/help":

                        Info.Help.Show();

                        return;

                    case "/list":

                        Info.Data.List(param);

                        return;

                    case "/mech":

                        Cheater.Mech.Add(param);

                        return;

                    case "/comp":

                        Cheater.Component.Add(param);

                        return;

                    case "/rep":

                        Cheater.Reputation.Add(param);

                        return;

                    case "/funds":

                        Cheater.Funds.Add(param);

                        return;

                    case "/xp":

                        Cheater.Experience.Add(param);

                        return;

                    case "/upgr":

                        Cheater.Upgrade.Add(param);

                        return;

                    case "/ronin":

                        Cheater.Ronin.Add(param);

                        return;

                    case "/travel":

                        Cheater.Travel.To(param);

                        return;

                    case "/event":

                        Cheater.Event.Force(param);

                        return;

                    default:
                        return;
                    }
                }
                else
                {
                    Logger.Debug("[HeraldryNameWidget_OnNameInputEndEdit_POSTFIX] Unknown command");
                    PopupHelper.Info("Unknown command");
                }
            }
            catch (Exception e)
            {
                Logger.Error(e);
            }
        }
Exemplo n.º 6
0
        public static void Postfix(MechLabMechInfoWidget __instance)
        {
            try
            {
                MechLabPanel mechLabPanel = (MechLabPanel)AccessTools.Field(typeof(MechLabMechInfoWidget), "mechLab").GetValue(__instance);

                if (!mechLabPanel.IsSimGame)
                {
                    Logger.Debug("[MechLabMechInfoWidget_OnNameInputEndEdit_POSTFIX] This is NOT SimGame. Aborting.");
                    return;
                }

                HBS_InputField mechNickname       = (HBS_InputField)AccessTools.Field(typeof(MechLabMechInfoWidget), "mechNickname").GetValue(__instance);
                string         mechDefaultVariant = mechLabPanel.activeMechDef.Chassis.VariantName;
                Logger.Debug("[MechLabMechInfoWidget_OnNameInputEndEdit_POSTFIX] mechDefaultVariant: " + mechDefaultVariant);
                string currentNickname = mechNickname.text;

                if (string.IsNullOrEmpty(currentNickname) || (currentNickname.Length > 0 && currentNickname.Substring(0, 1) != "/"))
                {
                    Logger.Debug("[MechLabMechInfoWidget_OnNameInputEndEdit_POSTFIX] no command");
                    return;
                }

                bool triggerLoad  = false;
                bool triggerStock = false;
                bool triggerSave  = false;

                List <string> loadCommands = new List <string>()
                {
                    "/load ", "/l ", "/apply "
                };
                List <string> stockCommands = new List <string>()
                {
                    "/stock"
                };
                stockCommands.Add("/" + mechDefaultVariant);
                stockCommands.Add("/" + mechDefaultVariant.ToLower());
                List <string> saveCommands = new List <string>()
                {
                    "/save ", "/s ", "/export "
                };
                List <string> validateCommands = new List <string>()
                {
                    "/validate", "/v"
                };
                List <string> chassisCommands = new List <string>()
                {
                    "/chassis ", "/c "
                };
                List <string> allCommands = loadCommands.Concat(stockCommands).Concat(saveCommands).Concat(validateCommands).Concat(chassisCommands).ToList();

                string mechDefIdSuffix = "";
                string mechDefId       = "";
                string mechDefName     = mechLabPanel.activeMechDef.Chassis.Description.Name;

                foreach (string command in allCommands)
                {
                    if (currentNickname.Contains(command))
                    {
                        mechDefIdSuffix = currentNickname.Replace(command, "");
                        mechDefIdSuffix = mechDefIdSuffix.Replace(" ", "-");
                        mechDefIdSuffix = mechDefIdSuffix.ToUpper();

                        if (loadCommands.Contains(command))
                        {
                            triggerLoad = true;

                            mechDefId = $"{mechLabPanel.activeMechDef.Description.Id}_{mechDefIdSuffix}";
                            Logger.Debug("[MechLabMechInfoWidget_OnNameInputEndEdit_POSTFIX] triggerLoad: " + mechDefId);
                        }
                        else if (stockCommands.Contains(command))
                        {
                            triggerStock = true;

                            Logger.Debug("[MechLabMechInfoWidget_OnNameInputEndEdit_POSTFIX] triggerStock");
                        }
                        else if (saveCommands.Contains(command))
                        {
                            triggerSave = true;

                            mechDefName = mechDefName + " " + mechDefIdSuffix;
                            mechDefId   = $"{mechLabPanel.activeMechDef.Description.Id}_{mechDefIdSuffix}";
                            Logger.Debug("[MechLabMechInfoWidget_OnNameInputEndEdit_POSTFIX] triggerSave: " + mechDefId);
                        }
                        else if (validateCommands.Contains(command))
                        {
                            Logger.Debug("[MechLabMechInfoWidget_OnNameInputEndEdit_POSTFIX] validating...");
                            mechLabPanel.ValidateAllMechDefTonnages();
                        }
                        else if (chassisCommands.Contains(command))
                        {
                            string variant = currentNickname.Replace(command, "").ToUpper();

                            Logger.Debug("[MechLabMechInfoWidget_OnNameInputEndEdit_POSTFIX] forcing new chassis in stock loadout...");
                            Logger.Debug("[MechLabMechInfoWidget_OnNameInputEndEdit_POSTFIX] variant: " + variant);

                            MechDef newMechDef = mechLabPanel.GetMechDefFromVariantName(variant);
                            if (newMechDef != null)
                            {
                                Logger.Debug("[MechLabMechInfoWidget_OnNameInputEndEdit_POSTFIX] loading: " + newMechDef.Description.Id);
                                mechLabPanel.LoadMech(newMechDef);
                                return;
                            }
                        }
                        else
                        {
                            Logger.Debug("[MechLabMechInfoWidget_OnNameInputEndEdit_POSTFIX] no action defined for command: " + command);
                        }
                    }
                }

                // @ToDo: Try to use LoadingCurtain

                if (triggerLoad)
                {
                    GenericPopupBuilder
                    .Create("Apply Loadout", "If you have all necessary components available this will apply saved loadout: " + mechDefId)
                    .AddButton("Cancel", null, true, null)
                    .AddButton("Apply", new Action(() => mechLabPanel.ApplyLoadout(mechDefId)), true, null)
                    .CancelOnEscape()
                    .AddFader(new UIColorRef?(LazySingletonBehavior <UIManager> .Instance.UILookAndColorConstants.PopupBackfill), 0.5f, true)
                    .SetAlwaysOnTop()
                    .SetOnClose(delegate
                    {
                        // Nothing yet
                    })
                    .Render();
                }
                else if (triggerStock)
                {
                    GenericPopupBuilder
                    .Create("Set To Stock", "If you have all necessary components available this will set the current loadout to stock")
                    .AddButton("Cancel", null, true, null)
                    .AddButton("Apply", new Action(() => mechLabPanel.SetToStock()), true, null)
                    .CancelOnEscape()
                    .AddFader(new UIColorRef?(LazySingletonBehavior <UIManager> .Instance.UILookAndColorConstants.PopupBackfill), 0.5f, true)
                    .SetAlwaysOnTop()
                    .SetOnClose(delegate
                    {
                        // Nothing yet
                    })
                    .Render();
                }
                else if (triggerSave)
                {
                    GenericPopupBuilder
                    .Create("Export MechDef", "This will export current MechDef to /Mods/MadLabs/MechDefs/" + mechDefId + ".json")
                    .AddButton("Cancel", null, true, null)
                    .AddButton("Export", new Action(() => mechLabPanel.ExportCurrentMechDefToJson(mechDefId, mechDefName)), true, null)
                    .CancelOnEscape()
                    .AddFader(new UIColorRef?(LazySingletonBehavior <UIManager> .Instance.UILookAndColorConstants.PopupBackfill), 0.5f, true)
                    .SetAlwaysOnTop()
                    .SetOnClose(delegate
                    {
                        // Nothing yet
                    })
                    .Render();
                }
            }
            catch (Exception e)
            {
                Logger.Error(e);
            }
        }
Exemplo n.º 7
0
 // Re-enable keyboard input (don't block out wasd)
 public static void CombatChatModule_Active_OnEnter_Postfix(CombatChatModule __instance, HBS_InputField ____inputField)
 {
     ____inputField.DeactivateInputField();
     BTInput.Instance.DynamicActions.Enabled = true;
 }
Exemplo n.º 8
0
        public static void CombatChatModule_CombatInit_Postfix(CombatChatModule __instance, MessageCenter ____messageCenter,
                                                               HBSDOTweenButton ____chatBtn, HBSDOTweenButton ____muteBtn, HBS_InputField ____inputField,
                                                               GameObject ____activeChatWindow, ActiveChatListView ____activeChatList, PassiveChatListView ____passiveChatList)
        {
            ____chatBtn.enabled = true;
            ____chatBtn.gameObject.SetActive(true);
            ____muteBtn.enabled = false;
            ____muteBtn.gameObject.SetActive(false);
            ____inputField.enabled = false;
            ____inputField.gameObject.SetActive(false);
            ____inputField.readOnly = true;

            // Hide the send button
            Transform sendButtonT = ____activeChatWindow.gameObject.transform.Find("uixPrf_genericButton");

            if (sendButtonT != null)
            {
                sendButtonT.gameObject.SetActive(false);
            }
            else
            {
                Mod.Log.Info("Could not find send button to disable!");
            }

            // Set the scroll spacing to 0
            Transform scrollListT = ____activeChatWindow.gameObject.transform.Find("panel_history/uixPrfPanl_listView/ScrollRect/Viewport/List");

            if (scrollListT != null)
            {
                VerticalLayoutGroup scrollListVLG = scrollListT.gameObject.GetComponent <VerticalLayoutGroup>();
                scrollListVLG.spacing = 0;
            }
            else
            {
                Mod.Log.Info("Could not find scrollList to change spacing!");
            }

            // Resize the image background
            Transform imageBackgroundT = ____activeChatWindow.gameObject.transform.Find("image_background");

            if (imageBackgroundT != null)
            {
                RectTransform imageBackgroundRT = imageBackgroundT.gameObject.GetComponent <RectTransform>();
                Rect          ibRect            = imageBackgroundRT.rect;
                Mod.Log.Info($"Background image size: {ibRect.height}h x {ibRect.width}");
                Vector3 newPos = imageBackgroundRT.position;
                newPos.y += 20f;
                imageBackgroundRT.position = newPos;
                imageBackgroundRT.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, ibRect.height - 20);
                imageBackgroundRT.ForceUpdateRectTransforms();
            }
            else
            {
                Mod.Log.Info("Could not find imageBackground to change size!");
            }
        }
Exemplo n.º 9
0
 public static void Postfix(MechBayMechInfoWidget __instance, MechDef ___selectedMech, HBS_InputField ___mechNameInput)
 {
     if (__instance != null && MechNamesHelper.HasUiName(___selectedMech))
     {
         ___mechNameInput.SetText(___selectedMech.Description.UIName);
     }
 }