private void Declaration(Rect position) { HUMEditor.Vertical().Box(Styles.backgroundColor.Brighten(0.05f), Color.black, new RectOffset(4, 4, 4, 4), new RectOffset(1, 1, 1, 1), () => { HUMEditor.Horizontal().Box(Styles.backgroundColor.Brighten(0.05f), Color.black, new RectOffset(4, 4, 4, 4), new RectOffset(1, 1, 1, 1), () => { HUMEditor.Horizontal(() => { EditorGUI.BeginChangeCheck(); if (_target.editorData.icon == null) { _target.editorData.icon = Images.class_32; } _target.editorData.icon = (Texture2D)EditorGUILayout.ObjectField(GUIContent.none, _target.editorData.icon, typeof(Texture2D), false, GUILayout.Width(40), GUILayout.Height(40)); if (EditorGUI.EndChangeCheck()) { DescribeActiveUnits(); var definer = _target.Definer() as ClassDefiner; definer.Define(); } }); HUMEditor.Horizontal(() => { HUMEditor.Vertical(() => { GUILayout.Label("Name"); GUILayout.Label("Namespace"); }); HUMEditor.Vertical(() => { EditorGUI.BeginChangeCheck(); _target.title = EditorGUILayout.TextField(GUIContent.none, _target.title, GUILayout.MinWidth(100)); if (EditorGUI.EndChangeCheck()) { DescribeActiveUnits(); var definer = _target.Definer() as ClassDefiner; definer.Define(); } _target.@namespace = EditorGUILayout.TextField(GUIContent.none, _target.@namespace, GUILayout.MinWidth(100)); }); }); }); EditorGUILayout.Space(6); BeginBlock(metadata, position, GUIContent.none); LudiqGUI.InspectorLayout(metadata["inheritance"]["type"]); if (EndBlock(metadata)) { var definer = _target.Definer() as ClassDefiner; definer.Define(); } }); }
public static void MethodOverride(Metadata method, GUIContent label) { var _method = ((Method)method.value); HUMEditor.Horizontal(() => { HUMEditor.Horizontal().Box(HUMEditorColor.DefaultEditorBackground.Darken(0.075f), Styles.borderColor, new RectOffset(2, 2, 2, 2), new RectOffset(1, 1, 1, 1), () => { if (_method.entry.declaration.isMagic) { GUILayout.Box(GUIContent.none, new GUIStyle() { normal = new GUIStyleState() { background = Images.special_16 } }, GUILayout.Width(16), GUILayout.Height(16)); } EditorGUILayout.LabelField(GUIContent.none, GUILayout.Width(100)); var lastRect = GUILayoutUtility.GetLastRect(); HUMEditor.Disabled(_method.entry.declaration.isAbstract, () => { HUMEditor.Disabled(_method.entry.declaration.hasOptionalOverride, () => { LudiqGUI.Inspector(method["entry"]["declaration"]["type"], new Rect(lastRect.x, lastRect.y, 80, 20), GUIContent.none); }); LudiqGUI.Inspector(method["entry"]["declaration"]["isOverridden"], new Rect(lastRect.x + lastRect.width - 16, lastRect.y, 20, 20), GUIContent.none); GUILayout.Label(label); }); HUMEditor.Disabled(_method.entry.declaration.hasOptionalOverride && !_method.entry.declaration.isOverridden, () => { if (GUILayout.Button("Edit", GUILayout.Width(42))) { GraphWindow.OpenActive(GraphReference.New(_method, true)); } }); }); }); }
public static void Box(this HUMEditor.Data.Horizontal horizontal, Color backgroundColor, Color borderColor, RectOffset padding, RectOffset border, Action contents = null, params GUILayoutOption[] options) { var style = new GUIStyle(); var borderStyle = new GUIStyle(); style.normal.background = HUMTexture.Create(1, 1).Color(backgroundColor); borderStyle.normal.background = HUMTexture.Create(1, 1).Color(borderColor); borderStyle.padding = border; style.padding = padding; HUMEditor.Horizontal(borderStyle, () => { HUMEditor.Horizontal(style, () => { contents?.Invoke(); }); }, options); }
private void LiveStatus() { var isLive = false; HUMEditor.Horizontal(() => { if (EditorPrefs.HasKey("UAlive_Global_IsLive")) { isLive = EditorPrefs.GetBool("UAlive_Global_IsLive"); } isLive = GUILayout.Toggle(isLive, "Live"); EditorPrefs.SetBool("UAlive_Global_IsLive", isLive); if (GUILayout.Button("Compile")) { } }); }
private void Variables(Rect position) { UAGUI.IconFoldout(ref _target.editorData.customVariablesOpen, "Variables", Images.variables_16, () => { 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(() => { BeginBlock(metadata["name"], position); HUMEditor.Vertical(() => { LudiqGUI.InspectorLayout(variable["name"], GUIContent.none); }); if (EndBlock(metadata["name"])) { variableVal.declaration.Changed(); } GUILayout.Label(GUIContent.none, new GUIStyle() { fixedWidth = 4 }); HUMEditor.Vertical(() => { LudiqGUI.InspectorLayout(variable["declaration"]["type"], GUIContent.none); }); if (GUILayout.Button("-", GUILayout.Width(16), GUILayout.Height(14))) { variablesVal.variables.Remove(variableVal); variableVal.declaration.Changed(); AssetDatabase.RemoveObjectFromAsset(variableVal.getter); AssetDatabase.RemoveObjectFromAsset(variableVal.setter); AssetDatabase.RemoveObjectFromAsset(variableVal); AssetDatabase.SaveAssets(); AssetDatabase.Refresh(); var definer = _target.Definer() as ClassDefiner; definer.Define(); } }); GUILayout.Space(2); HUMEditor.Vertical(() => { LudiqGUI.InspectorLayout(variable["declaration"]["defaultValue"].Cast(variableVal.declaration.type), GUIContent.none); }); }); GUILayout.Space(2); }); } if (GUILayout.Button("+ New Variable")) { var variable = Variable.Create(_target); AssetDatabase.AddObjectToAsset(variable, _target); variablesVal.variables.Add(variable); var definer = _target.Definer() as ClassDefiner; definer.Define(); } }); }); }
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(); } }); }); }
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(); } }); }); }
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(); } }); }); }