Beispiel #1
0
    private void FilterItems(bool intern, bool truster, bool engine, bool util_top, bool util_side, bool command)
    {
        if (!invetory_panel)
        {
            return;
        }
        FilterInventoryItem invetory_filter = invetory_panel.GetComponent <FilterInventoryItem>();

        if (invetory_filter != null)
        {
            invetory_filter.FilterItems(intern, truster, engine, util_top, util_side, command);
        }
    }
Beispiel #2
0
        private void CreateItemsGUI(string[] binList)
        {
            EditorGUILayout.BeginVertical(CustomStyles.thinBox);
            EditorGUILayout.LabelField("Inventory items", CustomStyles.subHeader);
            EditorGUILayout.Space();

            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.LabelField("Filter by:", GUILayout.Width(100f));
            filterType = (FilterInventoryItem)EditorGUILayout.EnumPopup(filterType, GUILayout.Width(80f));
            if (filterType == FilterInventoryItem.Name)
            {
                nameFilter = EditorGUILayout.TextField(nameFilter);
            }
            else if (filterType == FilterInventoryItem.Category)
            {
                if (bins == null || bins.Count == 0)
                {
                    categoryFilter = -1;
                    EditorGUILayout.HelpBox("No categories defined!", MessageType.Info);
                }
                else
                {
                    categoryFilter = EditorGUILayout.Popup(categoryFilter, binList);
                }
            }
            EditorGUILayout.EndHorizontal();
            filterOnStart = EditorGUILayout.Toggle("Filter by 'Carry on start?'?", filterOnStart);

            EditorGUILayout.Space();

            scrollPos = EditorGUILayout.BeginScrollView(scrollPos, GUILayout.Height(Mathf.Min(items.Count * 21, 235f) + 5));
            foreach (InvItem item in items)
            {
                if ((filterType == FilterInventoryItem.Name && (nameFilter == "" || item.label.ToLower().Contains(nameFilter.ToLower()))) ||
                    (filterType == FilterInventoryItem.Category && (categoryFilter == -1 || GetBinSlot(item.binID) == categoryFilter)))
                {
                    if (!filterOnStart || item.carryOnStart)
                    {
                        EditorGUILayout.BeginHorizontal();

                        string buttonLabel = item.label;
                        if (buttonLabel == "")
                        {
                            buttonLabel = "(Untitled)";
                        }

                        if (GUILayout.Toggle(item.isEditing, item.id + ": " + buttonLabel, "Button"))
                        {
                            if (selectedItem != item)
                            {
                                DeactivateAllItems();
                                ActivateItem(item);
                            }
                        }

                        if (GUILayout.Button(Resource.CogIcon, GUILayout.Width(20f), GUILayout.Height(15f)))
                        {
                            SideMenu(item);
                        }

                        EditorGUILayout.EndHorizontal();
                    }
                }
            }
            EditorGUILayout.EndScrollView();

            if (GUILayout.Button("Create new item"))
            {
                Undo.RecordObject(this, "Create inventory item");

                ResetFilter();
                InvItem newItem = new InvItem(GetIDArray());
                items.Add(newItem);
                DeactivateAllItems();
                ActivateItem(newItem);
            }

            EditorGUILayout.EndVertical();
        }