Exemple #1
0
 public static void IconFoldout(ref bool isOpen, string label, Texture2D icon, Action content, Color background, int padding = 4)
 {
     isOpen = HUMEditor.Foldout(isOpen, new GUIContent(label, icon),
     Styles.backgroundColor.Brighten(0.05f),
     Color.black,
     1,
     () =>
     {
         HUMEditor.Vertical().Box(background, Color.black, new RectOffset(padding, padding, padding, padding), new RectOffset(1, 1, 0, 1), () =>
         {
             content?.Invoke();
         });
     });
 }
Exemple #2
0
        private void OnGUI()
        {
            Images.Cache();

            compilationIsOpen = HUMEditor.Foldout(compilationIsOpen, new GUIContent("Compilation", Images.compilation_16), Styles.backgroundColor, Styles.borderColor, 1, () =>
            {
                HUMEditor.Vertical().Box(Styles.backgroundColor.Brighten(0.06f), Styles.borderColor, new RectOffset(6, 6, 6, 6), new RectOffset(1, 1, 0, 1), () => { LiveStatus(); });
            });

            searchIsOpen = HUMEditor.Foldout(searchIsOpen, new GUIContent("Search", Images.search_16), Styles.backgroundColor, Styles.borderColor, 1, () =>
            {
                EditorGUILayout.HelpBox("The search and replace functionality is not available at this time.", MessageType.Info);
            });

            explorerIsOpen = HUMEditor.Foldout(explorerIsOpen, new GUIContent("Explorer", Images.explorer_16), Styles.backgroundColor, Styles.borderColor, 1, () =>
            {
                EditorGUILayout.HelpBox("The project explorer is not available at this time.", MessageType.Info);
            });
        }
Exemple #3
0
        protected override void OnGUI(Rect position, GUIContent label)
        {
            BeginBlock(metadata, position, GUIContent.none);

            HUMEditor.Vertical().Box(backgroundColor.Brighten(0.05f), Color.black, new RectOffset(4, 4, 4, 4), new RectOffset(1, 1, 1, 1), () =>
            {
                _target.title      = EditorGUILayout.TextField(new GUIContent("Interface Name"), _target.title);
                _target.@namespace = EditorGUILayout.TextField(new GUIContent("Namespace"), _target.@namespace);
            });

            GUILayout.Space(10);

            _target.propertiesOpen = HUMEditor.Foldout(_target.propertiesOpen, new GUIContent("Properties", Images.property_16),
                                                       backgroundColor.Brighten(0.05f),
                                                       Color.black,
                                                       1,
                                                       () =>
            {
                LudiqGUI.InspectorLayout(metadata["properties"], GUIContent.none);
            });

            GUILayout.Space(10);

            _target.methodsOpen = HUMEditor.Foldout(_target.methodsOpen, new GUIContent("Methods", Images.flow_icon_16),
                                                    backgroundColor.Brighten(0.05f),
                                                    Color.black,
                                                    1,
                                                    () =>
            {
                LudiqGUI.InspectorLayout(metadata["methods"], GUIContent.none);
            });

            if (EndBlock(metadata))
            {
                metadata.RecordUndo();
            }
        }
Exemple #4
0
        private void Methods(Rect position)
        {
            UAGUI.IconFoldout(ref _target.editorData.customMethodsOpen, "Methods", Images.flow_icon_16, () =>
            {
                HUMEditor.Vertical().Box(Styles.backgroundColor.Brighten(0.025f), Styles.borderColor, new RectOffset(4, 4, 4, 2), new RectOffset(1, 1, 0, 1), () =>
                {
                    var methods    = metadata["methods"]["custom"];
                    var methodsVal = (List <Method>)metadata["methods"]["custom"].value;

                    for (int i = 0; i < methodsVal.Count; i++)
                    {
                        if (i != 0)
                        {
                            GUILayout.Space(2);
                        }
                        var meth = methodsVal[i];

                        methodsVal[i].isOpen = HUMEditor.Foldout(methodsVal[i].isOpen, Styles.backgroundColor.Brighten(0.05f), Styles.borderColor, 1,
                                                                 () =>
                        {
                            BeginBlock(metadata["name"], position);
                            meth.name = GUILayout.TextField(meth.name);
                            meth.entry.declaration.name = meth.name;
                            if (EndBlock(metadata["name"]))
                            {
                                meth.entry.declaration.Changed();
                            }

                            if (GUILayout.Button("Edit", GUILayout.Width(42)))
                            {
                                GraphWindow.OpenActive(GraphReference.New(methodsVal[i], true));
                            }

                            if (GUILayout.Button("-", GUILayout.Width(16), GUILayout.Height(18)))
                            {
                                methodsVal.Remove(meth);
                                meth.entry.Define();
                                AssetDatabase.RemoveObjectFromAsset(meth);
                                AssetDatabase.SaveAssets();
                                AssetDatabase.Refresh();
                                var definer = _target.Definer() as ClassDefiner;
                                definer.Define();
                            }
                        },
                                                                 () =>
                        {
                            HUMEditor.Vertical(() =>
                            {
                                BeginBlock(methods[i], position, GUIContent.none);
                                HUMEditor.Horizontal(() =>
                                {
                                    HUMEditor.Vertical().Box(HUMEditorColor.DefaultEditorBackground.Darken(0.025f), Styles.borderColor, new RectOffset(8, 8, 8, 8), new RectOffset(1, 1, 0, 1), () =>
                                    {
                                        LudiqGUI.InspectorLayout(methods[i]["entry"]["declaration"]["type"], new GUIContent("Returns"));

                                        if ((Type)methods[i]["entry"]["declaration"]["type"].value == typeof(Lasm.UAlive.Void))
                                        {
                                            GUILayout.Space(6);
                                        }
                                        else
                                        {
                                            LudiqGUI.InspectorLayout(methods[i]["entry"]["declaration"]["pure"], new GUIContent("Pure"));
                                        }

                                        UAGUI.IconFoldout(ref methodsVal[i].entry.declaration.parametersOpen, "Parameters", Images.parameters_16, () =>
                                        {
                                            LudiqGUI.InspectorLayout(methods[i]["entry"]["declaration"]["parameters"], GUIContent.none);
                                        }, Styles.backgroundColor.Brighten(0.05f), 0);
                                    });
                                });
                                if (EndBlock(methods[i]))
                                {
                                    meth.entry.Define();
                                }
                            });
                        });
                    }

                    if (GUILayout.Button("+ New Method"))
                    {
                        var meth = Method.Create(_target);
                        methodsVal.Add(meth);
                        AssetDatabase.SaveAssets();
                        AssetDatabase.Refresh();
                        var definer = _target.Definer() as ClassDefiner;
                        definer.Define();
                    }
                });
            });
        }
Exemple #5
0
        private void Overrides(Rect position)
        {
            _target.overridesOpen = HUMEditor.Foldout(_target.overridesOpen, new GUIContent("Overrides", Images.override_16),
                                                      Styles.backgroundColor.Brighten(0.05f),
                                                      Color.black,
                                                      1,
                                                      () =>
            {
                HUMEditor.Vertical().Box(Styles.backgroundColor, Color.black, new RectOffset(4, 4, 4, 4), new RectOffset(1, 1, 0, 1), () =>
                {
                    _target.methodOverridesOpen = HUMEditor.Foldout(_target.methodOverridesOpen,
                                                                    new GUIContent("Methods", Images.flow_icon_16),
                                                                    Styles.backgroundColor.Brighten(0.05f),
                                                                    Styles.borderColor,
                                                                    1,
                                                                    () =>
                    {
                        HUMEditor.Vertical().Box(Styles.backgroundColor.Brighten(0.025f), Styles.borderColor, new RectOffset(4, 4, 4, 2), new RectOffset(1, 1, 0, 1), () =>
                        {
                            var overrides = metadata["methods"]["overrides"];

                            tempOverrides.Clear();

                            for (int i = 0; i < overrides.Count; i++)
                            {
                                var nest = ((Method)overrides.ValueMetadata(i).value);
                                if (!nest.isSpecial || (nest.isSpecial && nest.isOverridden))
                                {
                                    var _name = nest.name;
                                    if (position.width - 170 < GUI.skin.label.CalcSize(new GUIContent(_name)).x)
                                    {
                                        if (_name.Length > 11)
                                        {
                                            _name = _name.Remove(11, _name.Length - 11) + "..";
                                        }
                                    }

                                    LudiqGUI.InspectorLayout(overrides.ValueMetadata(i), new GUIContent(_name));
                                }
                                else
                                {
                                    var temp = ((KeyValuePair <string, Method>)overrides[i].value);
                                    tempOverrides.Add(temp.Key, temp.Value);
                                }
                            }

                            GUILayout.Space(6);

                            BeginBlock(metadata, position, GUIContent.none);

                            if (GUILayout.Button("+ Message"))
                            {
                                GenericMenu menu   = new GenericMenu();
                                var keys           = tempOverrides.KeysToList();
                                var startSeparator = false;
                                for (int i = 0; i < keys.Count; i++)
                                {
                                    if (startSeparator)
                                    {
                                        menu.AddSeparator("");
                                        startSeparator = false;
                                    }
                                    var key = keys[i];
                                    menu.AddItem(new GUIContent(key), false, (obj) => { tempOverrides[(string)obj].isOverridden = true; }, key);
                                    if (keys[i] == "OnGUI")
                                    {
                                        startSeparator = true;
                                    }
                                }

                                menu.ShowAsContext();
                            }

                            if (EndBlock(metadata))
                            {
                                _target.Define();
                            }
                        });
                    });
                });
            });
        }
Exemple #6
0
        private void Variables(Rect position)
        {
            _target.customVariablesOpen = HUMEditor.Foldout(_target.customVariablesOpen,
                                                            new GUIContent("Variables", Images.variables_16),
                                                            Styles.backgroundColor.Brighten(0.05f),
                                                            Styles.borderColor,
                                                            1,
                                                            () =>
            {
                HUMEditor.Vertical().Box(Styles.backgroundColor.Brighten(0.025f), Styles.borderColor, new RectOffset(4, 4, 4, 2), new RectOffset(1, 1, 0, 1), () =>
                {
                    var variables    = metadata["variables"];
                    var variablesVal = (Variables)metadata["variables"].value;

                    for (int i = 0; i < variablesVal.variables.Count; i++)
                    {
                        if (i != 0)
                        {
                            GUILayout.Space(2);
                        }

                        HUMEditor.Vertical().Box(Styles.backgroundColor.Brighten(0.075f), Styles.borderColor, new RectOffset(4, 4, 4, 2), new RectOffset(1, 1, 1, 1), () =>
                        {
                            var variable    = variables["variables"][i];
                            var variableVal = (Variable)variable.value;
                            HUMEditor.Vertical(() =>
                            {
                                HUMEditor.Horizontal(() =>
                                {
                                    HUMEditor.Vertical(() =>
                                    {
                                        LudiqGUI.InspectorLayout(variable["name"], GUIContent.none);
                                    });

                                    GUILayout.Label(GUIContent.none, new GUIStyle()
                                    {
                                        fixedWidth = 4
                                    });

                                    HUMEditor.Vertical(() =>
                                    {
                                        BeginBlock(variable["type"], position, GUIContent.none);
                                        LudiqGUI.InspectorLayout(variable["type"], GUIContent.none);
                                        if (EndBlock(variable["type"]))
                                        {
                                            variablesVal.variables[i].Changed();
                                            AssetDatabase.SaveAssets();
                                            AssetDatabase.Refresh();
                                        }
                                    });

                                    BeginBlock(metadata, position, GUIContent.none);

                                    if (GUILayout.Button("-", GUILayout.Width(16), GUILayout.Height(14)))
                                    {
                                        variablesVal.variables.Remove(variableVal);
                                        AssetDatabase.RemoveObjectFromAsset(variableVal.getter.macro);
                                        AssetDatabase.RemoveObjectFromAsset(variableVal.setter.macro);
                                        AssetDatabase.SaveAssets();
                                        AssetDatabase.Refresh();
                                    }

                                    if (EndBlock(metadata))
                                    {
                                        _target.Define();
                                    }
                                });

                                GUILayout.Space(2);

                                HUMEditor.Vertical(() =>
                                {
                                    LudiqGUI.InspectorLayout(variable["value"].Cast(variableVal.type), GUIContent.none);
                                });
                            });

                            GUILayout.Space(2);
                        });
                    }

                    BeginBlock(metadata, position, GUIContent.none);
                    if (GUILayout.Button("+ New Variable"))
                    {
                        var variable = new Variable();
                        variable.getter.Initialize();
                        variable.setter.Initialize();
                        variable.getter.showLabel       = false;
                        variable.setter.showLabel       = false;
                        variable.getter.name            = string.Empty;
                        variable.setter.name            = string.Empty;
                        variable.getter.macro.hideFlags = HideFlags.HideInHierarchy;
                        variable.setter.macro.hideFlags = HideFlags.HideInHierarchy;
                        AssetDatabase.AddObjectToAsset(variable.getter.macro, _target);
                        AssetDatabase.AddObjectToAsset(variable.setter.macro, _target);
                        variablesVal.variables.Add(variable);
                        AssetDatabase.SaveAssets();
                        AssetDatabase.Refresh();
                    }
                    if (EndBlock(metadata))
                    {
                        _target.Define();
                    }
                });
            });
        }
Exemple #7
0
        private void Methods(Rect position)
        {
            _target.customMethodsOpen = HUMEditor.Foldout(_target.customMethodsOpen,
                                                          new GUIContent("Methods", Images.flow_icon_16),
                                                          Styles.backgroundColor.Brighten(0.05f),
                                                          Styles.borderColor,
                                                          1,
                                                          () =>
            {
                HUMEditor.Vertical().Box(Styles.backgroundColor.Brighten(0.025f), Styles.borderColor, new RectOffset(4, 4, 4, 2), new RectOffset(1, 1, 0, 1), () =>
                {
                    var methods    = metadata["methods"]["custom"];
                    var methodsVal = (List <Method>)metadata["methods"]["custom"].value;

                    for (int i = 0; i < methodsVal.Count; i++)
                    {
                        if (i != 0)
                        {
                            GUILayout.Space(2);
                        }

                        HUMEditor.Vertical().Box(Styles.backgroundColor.Brighten(0.075f), Styles.borderColor, new RectOffset(4, 4, 4, 2), new RectOffset(1, 1, 1, 1), () =>
                        {
                            var meth        = methodsVal[i];
                            meth.name       = GUILayout.TextField(meth.name);
                            meth.macro.name = meth.name;

                            HUMEditor.Horizontal(() =>
                            {
                                HUMEditor.Vertical(() =>
                                {
                                    LudiqGUI.InspectorLayout(methods[i], GUIContent.none);
                                });

                                BeginBlock(methods, position, GUIContent.none);

                                if (GUILayout.Button("-", GUILayout.Width(16), GUILayout.Height(18)))
                                {
                                    methodsVal.Remove(meth);
                                    AssetDatabase.RemoveObjectFromAsset(meth.macro);
                                    AssetDatabase.SaveAssets();
                                    AssetDatabase.Refresh();
                                }

                                if (EndBlock(methods))
                                {
                                    _target.Define();
                                }
                            });
                        });
                    }

                    BeginBlock(metadata, position, GUIContent.none);

                    if (GUILayout.Button("+ New Method"))
                    {
                        var meth = new Method();
                        meth.Initialize();
                        meth.showLabel       = false;
                        meth.name            = string.Empty;
                        meth.macro.hideFlags = HideFlags.HideInHierarchy;
                        AssetDatabase.AddObjectToAsset(meth.macro, _target);
                        methodsVal.Add(meth);
                        AssetDatabase.SaveAssets();
                        AssetDatabase.Refresh();
                    }

                    if (EndBlock(metadata))
                    {
                        _target.Define();
                    }
                });
            });
        }