Esempio n. 1
0
        public static string GenerateTransitionMethods(FD.FlowWindow window)
        {
            var flowData    = FlowSystem.GetData();
            var result      = string.Empty;
            var transitions = new List <FlowWindow>();

            if (window.IsContainer() == true)
            {
                foreach (var attachItem in window.attachItems)
                {
                    var attachWindow = flowData.GetWindow(attachItem.targetId);
                    if (attachWindow.IsContainer() == true)
                    {
                        continue;
                    }

                    var items = attachWindow.attachItems.Where(x => { var w = flowData.GetWindow(x.targetId); return(w.IsContainer() == false); }).Select(x => flowData.GetWindow(x.targetId));
                    foreach (var item in items)
                    {
                        if (transitions.Any(x => x.id == item.id) == false)
                        {
                            transitions.Add(item);
                        }
                    }
                }
            }
            else
            {
                transitions = flowData.windowAssets.Where(w => window.attachItems.Any((item) => item.targetId == w.id) && !w.IsContainer()).ToList();
            }

            if (transitions == null)
            {
                return(result);
            }

            foreach (var each in transitions)
            {
                var className = each.directory;
                var classNameWithNamespace = Tpl.GetNamespace(each) + "." + Tpl.GetDerivedClassName(each);

                if (each.IsShowDefault() == true)
                {
                    // Collect all default windows
                    foreach (var defaultWindowId in FlowSystem.GetDefaultWindows())
                    {
                        var defaultWindow = FlowSystem.GetWindow(defaultWindowId);

                        className = defaultWindow.directory;
                        classNameWithNamespace = Tpl.GetNamespace(defaultWindow) + "." + Tpl.GetDerivedClassName(defaultWindow);

                        result += TemplateGenerator.GenerateWindowLayoutTransitionMethod(window, each, className, classNameWithNamespace);
                        FlowEditorUtilities.CollectCallVariations(each.GetScreen().Load <WindowBase>(), (listTypes, listNames) => {
                            result += TemplateGenerator.GenerateWindowLayoutTransitionTypedMethod(window, each, className, classNameWithNamespace, listTypes, listNames);
                        });
                    }

                    continue;
                }
                else
                {
                    if (each.CanCompiled() == false)
                    {
                        continue;
                    }
                }

                result += TemplateGenerator.GenerateWindowLayoutTransitionMethod(window, each, className, classNameWithNamespace);
                FlowEditorUtilities.CollectCallVariations(each.GetScreen().Load <WindowBase>(), (listTypes, listNames) => {
                    result += TemplateGenerator.GenerateWindowLayoutTransitionTypedMethod(window, each, className, classNameWithNamespace, listTypes, listNames);
                });
            }

            var c = 0;
            var everyPlatformHasUniqueName = false;

            foreach (var attachItem in window.attachItems)
            {
                var attachId = attachItem.targetId;

                var attachedWindow = FlowSystem.GetWindow(attachId);
                var tmp            = UnityEditor.UI.Windows.Plugins.Flow.Flow.IsCompilerTransitionAttachedGeneration(window, attachedWindow);
                if (tmp == true)
                {
                    ++c;
                }
            }

            everyPlatformHasUniqueName = c > 1;

            foreach (var attachItem in window.attachItems)
            {
                var attachId = attachItem.targetId;

                var attachedWindow = FlowSystem.GetWindow(attachId);
                if (attachedWindow.IsShowDefault() == true)
                {
                    // Collect all default windows
                    foreach (var defaultWindowId in FlowSystem.GetDefaultWindows())
                    {
                        var defaultWindow = FlowSystem.GetWindow(defaultWindowId);

                        result += UnityEditor.UI.Windows.Plugins.Flow.Flow.OnCompilerTransitionAttachedGeneration(window, defaultWindow, everyPlatformHasUniqueName);
                        FlowEditorUtilities.CollectCallVariations(attachedWindow.GetScreen().Load <WindowBase>(), (listTypes, listNames) => {
                            result += UnityEditor.UI.Windows.Plugins.Flow.Flow.OnCompilerTransitionTypedAttachedGeneration(window, defaultWindow, everyPlatformHasUniqueName, listTypes, listNames);
                        });
                    }

                    result += TemplateGenerator.GenerateWindowLayoutTransitionMethodDefault();
                }

                /*if (withFunctionRoot == true) {
                 *
                 *      var functionId = attachedWindow.GetFunctionId();
                 *      var functionContainer = flowData.GetWindow(functionId);
                 *      if (functionContainer != null) {
                 *
                 *              var root = flowData.GetWindow(functionContainer.functionRootId);
                 *              if (root != null) {
                 *
                 *                      attachedWindow = root;
                 *
                 *              }
                 *
                 *      }
                 *
                 * }*/

                result += UnityEditor.UI.Windows.Plugins.Flow.Flow.OnCompilerTransitionAttachedGeneration(window, attachedWindow, everyPlatformHasUniqueName);
                FlowEditorUtilities.CollectCallVariations(attachedWindow.GetScreen().Load <WindowBase>(), (listTypes, listNames) => {
                    result += UnityEditor.UI.Windows.Plugins.Flow.Flow.OnCompilerTransitionTypedAttachedGeneration(window, attachedWindow, everyPlatformHasUniqueName, listTypes, listNames);
                });
            }

            // Run addons transition logic
            result += UnityEditor.UI.Windows.Plugins.Flow.Flow.OnCompilerTransitionGeneration(window);

            return(result);
        }