public static string GenerateReturnMethod(FlowSystemEditorWindow flowEditor, FlowWindow exitWindow) { var file = Resources.Load("UI.Windows/Functions/Templates/TemplateReturnMethod") as TextAsset; if (file == null) { Debug.LogError("Functions Template Loading Error: Could not load template 'TemplateReturnMethod'"); return string.Empty; } var data = FlowSystem.GetData(); if (data == null) return string.Empty; var result = string.Empty; var part = file.text; var functionContainer = exitWindow.GetFunctionContainer(); var functionName = functionContainer.title; var functionCallName = functionContainer.directory; var classNameWithNamespace = Tpl.GetNamespace(exitWindow) + "." + Tpl.GetDerivedClassName(exitWindow); result += part.Replace("{FUNCTION_NAME}", functionName) .Replace("{FUNCTION_CALL_NAME}", functionCallName) .Replace("{CLASS_NAME_WITH_NAMESPACE}", classNameWithNamespace); return result; }
private void DrawWindowToolbar(FlowWindow window) { //var edit = false; var id = window.id; var buttonStyle = ME.Utilities.CacheStyle("FlowEditor.DrawWindowToolbar.Styles", "toolbarButton", (name) => { var _buttonStyle = new GUIStyle(EditorStyles.toolbarButton); _buttonStyle.stretchWidth = false; return _buttonStyle; }); GUILayout.BeginHorizontal(EditorStyles.toolbar, GUILayout.ExpandWidth(true)); if (this.waitForAttach == false || this.currentAttachComponent == null) { if (this.waitForAttach == true) { if (id != this.currentAttachId) { var currentAttach = FlowSystem.GetWindow(this.currentAttachId); if (currentAttach != null) { //var attachTo = FlowSystem.GetWindow(id); //var hasContainer = currentAttach.HasContainer(); if (currentAttach.IsContainer() == false) { if (FlowSystem.AlreadyAttached(this.currentAttachId, id) == true) { if (GUILayout.Button(string.Format("Detach Here{0}", (Event.current.alt == true ? " (Double Direction)" : string.Empty)), buttonStyle) == true) { FlowSystem.Detach(this.currentAttachId, id, oneWay: Event.current.alt == false); if (Event.current.shift == false) this.WaitForAttach(-1); } } else { if (GUILayout.Button(string.Format("Attach Here{0}", (Event.current.alt == true ? " (Double Direction)" : string.Empty)), buttonStyle) == true) { FlowSystem.Attach(this.currentAttachId, id, oneWay: Event.current.alt == false); if (Event.current.shift == false) this.WaitForAttach(-1); } } } } } else { if (GUILayout.Button("Cancel", buttonStyle) == true) { this.WaitForAttach(-1); } } } else { if (window.IsSmall() == false || window.IsFunction() == true) { if (GUILayout.Button("Attach/Detach", buttonStyle) == true) { this.ShowNotification(new GUIContent("Use Attach/Detach buttons to Connect/Disconnect a window")); this.WaitForAttach(id); } } if (GUILayout.Button("Destroy", buttonStyle) == true) { if (EditorUtility.DisplayDialog("Are you sure?", "Current window will be destroyed with all links", "Yes, destroy", "No") == true) { this.ShowNotification(new GUIContent(string.Format("The window `{0}` was successfully destroyed", window.title))); FlowSystem.DestroyWindow(id); return; } } } if (window.IsSmall() == false) { //var isExit = false; var functionWindow = window.GetFunctionContainer(); if (functionWindow != null) { if (functionWindow.functionRootId == 0) functionWindow.functionRootId = id; if (functionWindow.functionExitId == 0) functionWindow.functionExitId = id; //isExit = (functionWindow.functionExitId == id); } var isRoot = (FlowSystem.GetRootWindow() == id || (functionWindow != null && functionWindow.functionRootId == id)); if (GUILayout.Toggle(isRoot, new GUIContent("R", "Set as root"), buttonStyle) != isRoot) { if (functionWindow != null) { if (isRoot == true) { // Was root // Setup root for the first window in function functionWindow.functionRootId = window.id; } else { // Was not root // Setup as root but inside this function only functionWindow.functionRootId = window.id; } } else { if (isRoot == true) { // Was root FlowSystem.SetRootWindow(-1); } else { // Was not root FlowSystem.SetRootWindow(id); } } FlowSystem.SetDirty(); } /* if (functionWindow != null) { if (GUILayout.Toggle(isExit, new GUIContent("E", "Set as exit point"), buttonStyle) != isExit) { if (isExit == true) { // Was exit // Setup exit for the first window in function functionWindow.functionExitId = window.id; } else { // Was not exit // Setup as exit but inside this function only functionWindow.functionExitId = window.id; } FlowSystem.SetDirty(); } }*/ var isDefault = FlowSystem.GetDefaultWindows().Contains(id); if (GUILayout.Toggle(isDefault, new GUIContent("D", "Set as default"), buttonStyle) != isDefault) { if (isDefault == true) { // Was as default FlowSystem.GetDefaultWindows().Remove(id); } else { // Was not as default FlowSystem.GetDefaultWindows().Add(id); } FlowSystem.SetDirty(); } } GUILayout.FlexibleSpace(); if (window.IsSmall() == false && FlowSceneView.IsActive() == false && window.storeType == FlowWindow.StoreType.NewScreen) { if (GUILayout.Button("Select", buttonStyle) == true) { this.SelectWindow(window); } /* if (GUILayout.Button("Edit", buttonStyle) == true) { if (window.compiled == false) { this.ShowNotification(new GUIContent("You need to compile this window to use 'Edit' command")); } else { edit = true; } }*/ } } else { // Draw Attach/Detach component link if (this.currentAttachId == id) { // Cancel if (GUILayout.Button("Cancel", buttonStyle) == true) { this.WaitForAttach(-1); } } else { // If it's other window if (window.IsSmall() == false || window.IsFunction() == true) { if (FlowSystem.AlreadyAttached(this.currentAttachId, id, this.currentAttachComponent) == true) { if (GUILayout.Button("Detach Here", buttonStyle) == true) { FlowSystem.Detach(this.currentAttachId, id, oneWay: true, component: this.currentAttachComponent); if (Event.current.shift == false) this.WaitForAttach(-1); } } else { if (GUILayout.Button("Attach Here", buttonStyle) == true) { FlowSystem.Attach(this.currentAttachId, id, oneWay: true, component: this.currentAttachComponent); if (Event.current.shift == false) this.WaitForAttach(-1); } } } } GUILayout.FlexibleSpace(); } GUILayout.EndHorizontal(); /*if (edit == true) { FlowSceneView.SetControl(this, window, this.OnItemProgress); }*/ }
public override string OnCompilerTransitionGeneration(FlowWindow window) { var functionContainer = window.GetFunctionContainer(); if (functionContainer != null) { var exit = FlowSystem.GetWindow(functionContainer.functionExitId); if (exit != null && exit.id == window.id) { return FlowFunctionsTemplateGenerator.GenerateReturnMethod(this.flowEditor, exit); } } return base.OnCompilerTransitionGeneration(window); }