/*public override string OnCompilerTransitionGeneration(FD.FlowWindow window) { return Tpl.GenerateTransitionMethods(window); } public override string OnCompilerTransitionAttachedGeneration(FD.FlowWindow windowFrom, FD.FlowWindow windowTo, bool everyPlatformHasUniqueName) { if (windowTo.IsFunction() == true && windowTo.IsSmall() == true && windowTo.IsContainer() == false && windowTo.GetFunctionId() > 0) { return FlowFunctionsTemplateGenerator.GenerateTransitionMethod(this.flowEditor, windowFrom, windowTo); } return base.OnCompilerTransitionAttachedGeneration(windowFrom, windowTo, everyPlatformHasUniqueName); }*/ public override string OnCompilerTransitionAttachedGeneration(FD.FlowWindow windowFrom, FD.FlowWindow windowTo, bool everyPlatformHasUniqueName) { if (windowTo.IsLinker() == true && windowTo.GetLinkerId() > 0) { var result = string.Empty; var linkerWindow = FlowSystem.GetWindow(windowTo.GetLinkerId()); var className = linkerWindow.directory; var classNameWithNamespace = Tpl.GetNamespace(linkerWindow) + "." + Tpl.GetDerivedClassName(linkerWindow); result += TemplateGenerator.GenerateWindowLayoutTransitionMethod(windowTo, linkerWindow, className, classNameWithNamespace); WindowSystem.CollectCallVariations(linkerWindow.GetScreen(), (listTypes, listNames) => { result += TemplateGenerator.GenerateWindowLayoutTransitionTypedMethod(windowTo, linkerWindow, className, classNameWithNamespace, listTypes, listNames); }); return result; } return base.OnCompilerTransitionAttachedGeneration(windowFrom, windowTo, everyPlatformHasUniqueName); }
/*public override string OnCompilerTransitionTypedAttachedGeneration(FD.FlowWindow windowFrom, FD.FlowWindow windowTo, bool everyPlatformHasUniqueName, System.Type[] types, string[] names) { if (windowTo.IsLinker() == true && windowTo.GetLinkerId() > 0) { var result = string.Empty; var window = FlowSystem.GetWindow(windowTo.GetLinkerId()); var className = window.directory; var classNameWithNamespace = Tpl.GetNamespace(window) + "." + Tpl.GetDerivedClassName(window); result += TemplateGenerator.GenerateWindowLayoutTransitionMethod(windowFrom, window, className, classNameWithNamespace); WindowSystem.CollectCallVariations(windowTo.GetScreen(), (listTypes, listNames) => { result += TemplateGenerator.GenerateWindowLayoutTransitionTypedMethod(windowFrom, window, className, classNameWithNamespace, listTypes, listNames); }); Debug.Log(className + " :: " + classNameWithNamespace + " == " + result); return result; } return base.OnCompilerTransitionTypedAttachedGeneration(windowFrom, windowTo, everyPlatformHasUniqueName, types, names); }*/ public override void OnFlowWindowGUI(FD.FlowWindow window) { var data = FlowSystem.GetData(); if (data == null) return; var flag = (window.IsLinker() == true && window.IsSmall() == true && window.IsContainer() == false); if (flag == true) { var alreadyConnectedFunctionIds = new List<int>(); // Find caller window var windowFrom = data.windowAssets.FirstOrDefault((item) => item.HasAttach(window.id)); if (windowFrom != null) { var attaches = windowFrom.GetAttachedWindows(); foreach (var attachWindow in attaches) { if (attachWindow.IsLinker() == true) { alreadyConnectedFunctionIds.Add(attachWindow.GetLinkerId()); } } } foreach (var win in data.windowAssets) { if (win.CanDirectCall() == true) { var count = alreadyConnectedFunctionIds.Count((e) => e == win.id); if ((window.GetLinkerId() == win.id && count == 1) || count == 0) { } else { if (win.id == window.GetLinkerId()) window.linkerId = 0; alreadyConnectedFunctionIds.Remove(win.id); } } } var linkerId = window.GetLinkerId(); var linker = linkerId == 0 ? null : data.GetWindow(linkerId); var isActiveSelected = true; var oldColor = GUI.color; GUI.color = isActiveSelected ? Color.white : Color.grey; var result = GUILayout.Button(linker != null ? linker.title : "None", FlowSystemEditorWindow.defaultSkin.button, GUILayout.ExpandHeight(true)); GUI.color = oldColor; var rect = GUILayoutUtility.GetLastRect(); rect.y += rect.height; if (result == true) { var menu = new GenericMenu(); menu.AddItem(new GUIContent("None"), window.linkerId == 0, () => { window.linkerId = 0; }); if (windowFrom != null) { alreadyConnectedFunctionIds.Clear(); var attaches = windowFrom.GetAttachedWindows(); foreach (var attachWindow in attaches) { if (attachWindow.IsLinker() == true) { alreadyConnectedFunctionIds.Add(attachWindow.GetLinkerId()); } } } foreach (var win in data.windowAssets) { if (win.CanDirectCall() == true) { var count = alreadyConnectedFunctionIds.Count((e) => e == win.id); if ((window.GetLinkerId() == win.id && count == 1) || count == 0) { var id = win.id; menu.AddItem(new GUIContent(win.title), win.id == window.GetLinkerId(), () => { window.linkerId = id; }); } else { if (win.id == window.GetLinkerId()) window.linkerId = 0; alreadyConnectedFunctionIds.Remove(win.id); menu.AddDisabledItem(new GUIContent(win.title)); } } } menu.DropDown(rect); } } }
public override bool IsCompilerTransitionAttachedGeneration(FD.FlowWindow windowFrom, FD.FlowWindow windowTo) { return windowTo.IsLinker() == true && windowTo.GetLinkerId() > 0; }