Ejemplo n.º 1
0
        public bool OnPreferencesWindowGUI(DatabaseInventoryEditor inventoryEditor, int index)
        {
            serializedObject.Update();
            inventoryEditor.searchText = inventoryEditor.searchText.ToLower();
            string spNameString = this.spName.FindPropertyRelative("content").stringValue;
            string spDescString = this.spDescription.FindPropertyRelative("content").stringValue;

            if (!string.IsNullOrEmpty(inventoryEditor.searchText) &&
                !spNameString.ToLower().Contains(inventoryEditor.searchText) &&
                !spDescString.ToLower().Contains(inventoryEditor.searchText))
            {
                return(false);
            }

            bool result = this.PaintHeader(inventoryEditor, index);

            using (var group = new EditorGUILayout.FadeGroupScope(this.animUnfold.faded))
            {
                if (group.visible)
                {
                    EditorGUILayout.BeginVertical(CoreGUIStyles.GetBoxExpanded());
                    this.PaintContent();
                    EditorGUILayout.EndVertical();
                }
            }

            serializedObject.ApplyModifiedProperties();
            return(result);
        }
Ejemplo n.º 2
0
        public bool OnPreferencesWindowGUI(DatabaseInventoryEditor inventoryEditor, int index)
        {
            serializedObject.Update();

            bool result = this.PaintHeader(inventoryEditor, index);

            using (var group = new EditorGUILayout.FadeGroupScope(this.animUnfold.faded))
            {
                if (group.visible)
                {
                    EditorGUILayout.BeginVertical(CoreGUIStyles.GetBoxExpanded());
                    this.PaintContent();
                    EditorGUILayout.EndVertical();
                }
            }

            serializedObject.ApplyModifiedProperties();
            return(result);
        }
Ejemplo n.º 3
0
        private bool PaintHeader(DatabaseInventoryEditor inventoryEditor, int index)
        {
            bool removeItem = false;

            EditorGUILayout.BeginHorizontal();

            bool forceSortRepaint = false;

            if (inventoryEditor.itemsHandleRect.ContainsKey(index))
            {
                EditorGUIUtility.AddCursorRect(inventoryEditor.itemsHandleRect[index], MouseCursor.Pan);
                forceSortRepaint = inventoryEditor.editorSortableListItems.CaptureSortEvents(
                    inventoryEditor.itemsHandleRect[index], index
                    );
            }

            if (forceSortRepaint)
            {
                inventoryEditor.Repaint();
            }

            GUILayout.Label("=", CoreGUIStyles.GetButtonLeft(), GUILayout.Width(25f));
            if (UnityEngine.Event.current.type == EventType.Repaint)
            {
                Rect dragRect = GUILayoutUtility.GetLastRect();
                if (inventoryEditor.itemsHandleRect.ContainsKey(index))
                {
                    inventoryEditor.itemsHandleRect[index] = dragRect;
                }
                else
                {
                    inventoryEditor.itemsHandleRect.Add(index, dragRect);
                }
            }

            if (inventoryEditor.itemsHandleRectRow.ContainsKey(index))
            {
                inventoryEditor.editorSortableListItems.PaintDropPoints(
                    inventoryEditor.itemsHandleRectRow[index],
                    index,
                    inventoryEditor.spItems.arraySize
                    );
            }

            string name         = (this.animUnfold.target ? "▾ " : "▸ ");
            string spNameString = this.spName.FindPropertyRelative("content").stringValue;

            name += (string.IsNullOrEmpty(spNameString) ? "No-name" :  spNameString);

            GUIStyle style = (this.animUnfold.target
                                ? CoreGUIStyles.GetToggleButtonMidOn()
                                : CoreGUIStyles.GetToggleButtonMidOff()
                              );

            if (GUILayout.Button(name, style))
            {
                this.animUnfold.target = !this.animUnfold.value;
            }

            if (GUILayout.Button("×", CoreGUIStyles.GetButtonRight(), GUILayout.Width(25)))
            {
                removeItem = true;
            }

            EditorGUILayout.EndHorizontal();
            if (UnityEngine.Event.current.type == EventType.Repaint)
            {
                Rect rect = GUILayoutUtility.GetLastRect();
                if (inventoryEditor.itemsHandleRectRow.ContainsKey(index))
                {
                    inventoryEditor.itemsHandleRectRow[index] = rect;
                }
                else
                {
                    inventoryEditor.itemsHandleRectRow.Add(index, rect);
                }
            }

            return(removeItem);
        }