/// <summary>
        ///     Call this in GetPopupText to handle your UI Window
        /// </summary>
        /// <param name="theMachine">Pass the current machine</param>
        /// <param name="theWindow">The mod window inherited from BaseMachineWindow</param>
        /// <returns></returns>
        public static bool HandleThisMachineWindow(SegmentEntity theMachine, BaseMachineWindow theWindow)
        {
            try
            {
                UIUtil.TargetWindow = theWindow;

                bool flag1 = SetupMachineWindow(theMachine);
                if (!flag1)
                {
                    return(false);
                }

                bool flag2 = HandleWindowView(theMachine);
                if (!flag2)
                {
                    return(false);
                }
            }
            catch (Exception ex)
            {
                Debug.LogError("HandleThisMachineWindow: failed : " + ex.Message + " : " + ex.StackTrace);
            }

            return(true);
        }
        /// <summary>
        ///     Closes out and removes references to .Mod UI entiries
        /// </summary>
        /// <param name="name"></param>
        /// <param name="resetWindow"></param>
        public static void CleanupUI(string name, bool resetWindow)
        {
            try
            {
                GenericMachinePanelScript panel = GenericMachinePanelScript.instance;

                UIManager.RemoveUIRules("Machine");

                if (panel == null)
                {
                    Debug.LogError("CleanupUI: panel=null");
                    return;
                }
                else
                {
                    UIUtil.TargetMachine = null;

                    if (resetWindow)
                    {
                        UIUtil.TargetWindow = null;
                    }

                    panel.gameObject.SetActive(false);
                    panel.Background_Panel.SetActive(false);

                    panel.currentWindow = null;
                    panel.targetEntity  = null;

                    DragAndDropManager.instance.CancelDrag();
                    DragAndDropManager.instance.DisableDragBackground();

                    UIUtil.UILock = false;

                    GenericMachineManager manager = typeof(GenericMachinePanelScript).GetField("manager",
                                                                                               BindingFlags.NonPublic | BindingFlags.Instance).GetValue(panel) as GenericMachineManager;

                    manager.windows.Remove(eSegmentEntity.Mod);

                    if (manager.windows.ContainsKey(eSegmentEntity.Mod))
                    {
                        Debug.LogWarning(name + ": was not able to remove the window entry!");
                        return;
                    }
                }
            }
            catch (Exception ex)
            {
                Debug.LogError("CleanupUI: " + ex.Message + " : " + ex.StackTrace);
            }
        }
示例#3
0
        public static void SpawnWindow(BaseMachineWindow sourcewindow)
        {
            UpdateWindowCooldown = 0;
            sourcewindow.manager.AddButton(SearchCancelButton, PersistentSettings.GetString("Cancel"), 100, 0);
            sourcewindow.manager.AddBigLabel(SearchTitleLabel, PersistentSettings.GetString("Enter_Search_Term"), Color.white, 50, 40);
            sourcewindow.manager.AddBigLabel(SearchTextLabel, "_", Color.cyan, 50, 65);
            if (SearchResults == null)
            {
                return;
            }
            int count = SearchResults.Count;

            for (int index = 0; index < count; ++index)
            {
                sourcewindow.manager.AddIcon(ItemIcon + index, "empty", Color.white, 10, 100 + 60 * index);
                sourcewindow.manager.AddBigLabel(ItemInfoLabel + index, PersistentSettings.GetString("Inventory_Item"), Color.white, 60, 90 + 60 * index);
                sourcewindow.manager.AddLabel(GenericMachineManager.LabelType.OneLineFullWidth, ItemCountLabel + index, String.Empty, Color.white, false, 60, 120 + 60 * index);
            }
        }
示例#4
0
        public static bool UpdateMachine(BaseMachineWindow sourcewindow)
        {
            if (SearchResults == null)
            {
                ++Counter;
                foreach (char ch in Input.inputString)
                {
                    if ((int)ch == (int)"\b"[0])
                    {
                        if (EntryString.Length != 0)
                        {
                            EntryString = EntryString.Substring(0, EntryString.Length - 1);
                        }
                    }
                    else
                    {
                        if (ch == "\n"[0] || ch == "\r"[0])
                        {
                            SearchResults = new List <ItemBase>();
                            for (int index = 0; index < ItemEntry.mEntries.Length; ++index)
                            {
                                if (ItemEntry.mEntries[index] != null && PersistentSettings.GetString(ItemEntry.mEntries[index].Name).ToLower().Contains(EntryString.ToLower()))
                                {
                                    SearchResults.Add(ItemManager.SpawnItem(ItemEntry.mEntries[index].ItemID));
                                }
                            }
                            for (int index1 = 0; index1 < TerrainData.mEntries.Length; ++index1)
                            {
                                bool             flag   = false;
                                TerrainDataEntry mEntry = TerrainData.mEntries[index1];
                                if (mEntry != null && !mEntry.Hidden)
                                {
                                    if (PersistentSettings.GetString(mEntry.Name).ToLower().Contains(EntryString.ToLower()))
                                    {
                                        int count = mEntry.Values.Count;
                                        for (int index2 = 0; index2 < count; ++index2)
                                        {
                                            if (PersistentSettings.GetString(mEntry.Values[index2].Name).ToLower().Contains(EntryString.ToLower()))
                                            {
                                                SearchResults.Add(ItemManager.SpawnCubeStack(mEntry.CubeType, mEntry.Values[index2].Value, 1));
                                                flag = true;
                                            }
                                        }
                                        if (!flag && string.IsNullOrEmpty(mEntry.PickReplacement))
                                        {
                                            SearchResults.Add(ItemManager.SpawnCubeStack(mEntry.CubeType, mEntry.DefaultValue, 1));
                                        }
                                    }
                                    if ((EntryString.ToLower().Contains("component") || EntryString.ToLower().Contains("placement") || EntryString.ToLower().Contains("multi")) && mEntry.CubeType == (ushort)600)
                                    {
                                        int count = mEntry.Values.Count;
                                        for (int index2 = 0; index2 < count; ++index2)
                                        {
                                            SearchResults.Add(ItemManager.SpawnCubeStack(600, mEntry.Values[index2].Value, 1));
                                        }
                                    }
                                }
                            }
                            if (SearchResults.Count == 0)
                            {
                                SearchResults = null;
                            }
                            UIManager.mbEditingTextField = false;
                            UIManager.RemoveUIRules("TextEntry");
                            sourcewindow.manager.RedrawWindow();
                            return(true);
                        }
                        EntryString += ch;
                    }
                }
                sourcewindow.manager.UpdateLabel(SearchTextLabel, EntryString + (Counter % 20 <= 10 ? string.Empty : "_"), Color.cyan);
                return(true);
            }

            sourcewindow.manager.UpdateLabel(SearchTitleLabel, PersistentSettings.GetString("Searching_for"), Color.white);
            sourcewindow.manager.UpdateLabel(SearchTextLabel, EntryString, Color.cyan);

            if (!(sourcewindow is QuantumIoPortWindow target))
            {
                return(false);
            }