Example #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);
        }
Example #2
0
        public GUIStyle GetEditorStyle(bool selected)
        {
            if (this.IsSmall() == true)
            {
                // Yellow

                if (string.IsNullOrEmpty(this.smallStyleDefault) == true)
                {
                    this.smallStyleDefault = "flow node 4";
                }
                if (string.IsNullOrEmpty(this.smallStyleSelected) == true)
                {
                    this.smallStyleSelected = "flow node 4 on";
                }

                var style = ME.Utilities.CacheStyle("FlowWindow.GetEditorStyle.SmallStyle.NotSelected", this.smallStyleDefault, (styleName) => {
                    var _style              = WindowLayoutStyles.styles.GetInstanceByName(styleName);
                    _style.padding          = new RectOffset(0, 0, 14, 1);
                    _style.contentOffset    = new Vector2(0f, -15f);
                    _style.fontStyle        = FontStyle.Bold;
                    _style.alignment        = TextAnchor.UpperCenter;
                    _style.normal.textColor = Color.black;
                    //_style.normal.background = this.GetTexture_INTERNAL(styleName, 1f);

                    return(_style);
                });

                var styleSelected = ME.Utilities.CacheStyle("FlowWindow.GetEditorStyle.SmallStyle.Selected", this.smallStyleSelected, (styleName) => {
                    var _style              = WindowLayoutStyles.styles.GetInstanceByName(styleName);
                    _style.padding          = new RectOffset(0, 0, 14, 1);
                    _style.contentOffset    = new Vector2(0f, -15f);
                    _style.fontStyle        = FontStyle.Bold;
                    _style.alignment        = TextAnchor.UpperCenter;
                    _style.normal.textColor = Color.black;
                    //_style.normal.background = this.GetTexture_INTERNAL(styleName, 1f);

                    return(_style);
                });

                return(selected ? styleSelected : style);
            }
            else if (this.IsContainer() == true)
            {
                var styleNormal = string.Empty;
                //var styleSelected = string.Empty;

                // Compiled - Blue
                styleNormal = "flow node 0";
                //styleSelected = "flow node 0 on";

                if (this.IsValidToCompile() == false)
                {
                    // Not Valid
                    styleNormal = "flow node 6";
                    //styleSelected = "flow node 6 on";
                }

                var containerStyle = ME.Utilities.CacheStyle(string.Format("FlowWindow.GetEditorStyle.Container.{0}.{1}", this.randomColor.ToString(), this.randomColor.r + this.randomColor.g + this.randomColor.b), styleNormal, (styleName) => {
                    var _style               = WindowLayoutStyles.styles.GetInstanceByName(styleName);
                    _style.padding           = new RectOffset(0, 0, 16, 1);
                    _style.contentOffset     = new Vector2(0f, -15f);
                    _style.fontStyle         = FontStyle.Bold;
                    _style.alignment         = TextAnchor.UpperCenter;
                    _style.normal.textColor  = Color.white;
                    _style.normal.background = this.GetTexture_INTERNAL(this.randomColor, 0.2f);

                    return(_style);
                });

                return(containerStyle);
            }
            else
            {
                var styleNormal   = string.Empty;
                var styleSelected = string.Empty;

                //if (this.compiled == true) {

                var functionWindow = this.GetFunctionContainer();
                var isFunction     = functionWindow != null;
                var isRoot         = (isFunction == true && functionWindow.functionRootId == this.id);
                var isExit         = (isFunction == true && functionWindow.functionExitId == id);
                if (FlowSystem.GetRootWindow() == this.id || (isFunction == true && (isRoot == true || isExit == true)))
                {
                    if (isFunction == true && isExit == true)
                    {
                        // Function exit point - Green
                        styleNormal   = "flow node 3";
                        styleSelected = "flow node 3 on";
                    }
                    else if (isFunction == true && isRoot == true)
                    {
                        // Function root - Yellow
                        styleNormal   = "flow node 4";
                        styleSelected = "flow node 4 on";
                    }
                    else
                    {
                        // Root - Orange
                        styleNormal   = "flow node 5";
                        styleSelected = "flow node 5 on";
                    }
                }
                else if (FlowSystem.GetDefaultWindows().Contains(this.id) == true)
                {
                    // Default - Cyan
                    styleNormal   = "flow node 2";
                    styleSelected = "flow node 2 on";
                }
                else
                {
                    // Compiled - Blue
                    styleNormal   = "flow node 1";
                    styleSelected = "flow node 1 on";
                }

                /*} else {
                 *
                 *      // Not Compiled - Gray
                 *      styleNormal = "flow node 0";
                 *      styleSelected = "flow node 0 on";
                 *
                 * }*/

                if (this.IsValidToCompile() == false)
                {
                    // Not Valid
                    styleNormal   = "flow node 6";
                    styleSelected = "flow node 6 on";
                }

                var windowStyle = ME.Utilities.CacheStyle("FlowWindow.GetEditorStyle.Window.Selected", styleNormal, (styleName) => {
                    var _style = WindowLayoutStyles.styles.GetInstanceByName(styleName);

                    /*_style.fontStyle = FontStyle.Bold;
                     * _style.margin = new RectOffset(0, 0, 0, 0);
                     * _style.padding = new RectOffset(0, 0, 5, 4);
                     * _style.alignment = TextAnchor.UpperLeft;
                     * _style.contentOffset = new Vector2(5f, 0f);*/

                    _style.padding          = new RectOffset(0, 0, 14, 1);
                    _style.contentOffset    = new Vector2(0f, -15f);
                    _style.fontStyle        = FontStyle.Bold;
                    _style.alignment        = TextAnchor.UpperCenter;
                    _style.normal.textColor = Color.black;
                    //_style.normal.background = this.GetTexture_INTERNAL(styleName, 1f);

                    return(_style);
                });

                var windowStyleSelected = ME.Utilities.CacheStyle("FlowWindow.GetEditorStyle.Window.NotSelected", styleSelected, (styleName) => {
                    var _style = WindowLayoutStyles.styles.GetInstanceByName(styleName);

                    /*_style.fontStyle = FontStyle.Bold;
                     * _style.margin = new RectOffset(0, 0, 0, 0);
                     * _style.padding = new RectOffset(0, -1, 5, 4);
                     * _style.alignment = TextAnchor.UpperLeft;
                     * _style.contentOffset = new Vector2(5f, 0f);*/

                    _style.padding          = new RectOffset(0, 0, 14, 1);
                    _style.contentOffset    = new Vector2(0f, -15f);
                    _style.fontStyle        = FontStyle.Bold;
                    _style.alignment        = TextAnchor.UpperCenter;
                    _style.normal.textColor = Color.black;
                    //_style.normal.background = this.GetTexture_INTERNAL(styleName, 1f);

                    return(_style);
                });

                return(selected ? windowStyleSelected : windowStyle);
            }
        }