Ejemplo n.º 1
0
        public FlowWindow GetFunctionContainer()
        {
            // If current window attached to function
            var attaches = this.attachItems;

            foreach (var attachItem in attaches)
            {
                var win = FlowSystem.GetWindow(attachItem.targetId);
                if (win.IsContainer() == true && win.IsFunction() == true)
                {
                    // We are inside a function
                    return(win);
                }
            }

            return(null);
        }
Ejemplo n.º 2
0
        public static void MoveContainerOrWindow(int id, Vector2 delta)
        {
            var window = FlowSystem.GetWindow(id);

            if (window.IsContainer() == true)
            {
                var childs = window.attachItems;
                foreach (var child in childs)
                {
                    FlowSystem.MoveContainerOrWindow(child.targetId, delta);
                }
            }
            else
            {
                window.Move(delta);
            }
        }
Ejemplo n.º 3
0
        public List <FlowWindow> GetAttachedWindows()
        {
            List <FlowWindow> output = new List <FlowWindow>();

            foreach (var attachId in this.attaches)
            {
                var window = FlowSystem.GetWindow(attachId);
                if (window.isContainer == true)
                {
                    continue;
                }

                output.Add(window);
            }

            return(output);
        }
Ejemplo n.º 4
0
        public bool Attach(int id, bool oneWay = false, WindowLayoutElement component = null)
        {
            if (this.id == id)
            {
                return(false);
            }

            var result = false;

            if (component != null)
            {
                if (this.attachedComponents.Any((c) => c.targetWindowId == id && c.sourceComponentTag == component.tag) == false)
                {
                    this.attachedComponents.Add(new ComponentLink(id, component.tag, component.comment));

                    // If we attaching component - try to attach window if not

                    oneWay = true;
                    result = true;
                }
                else
                {
                    return(false);
                }
            }

            if (this.attaches.Contains(id) == false)
            {
                this.attaches.Add(id);

                if (oneWay == false)
                {
                    var window = FlowSystem.GetWindow(id);
                    window.Attach(this.id, oneWay: true);
                }

                return(true);
            }

            return(result);
        }
Ejemplo n.º 5
0
        public static void SetZoom(float value)
        {
            if (FlowSystem.instance == null ||
                FlowSystem.instance.data == null)
            {
                return;
            }

            var changed = (FlowSystem.instance.data.zoom != value);

            if (value > 0.98f)
            {
                value = 1f;
            }

            FlowSystem.instance.data.zoom = value;
            if (changed == true)
            {
                FlowSystem.SetDirty();
            }
        }
Ejemplo n.º 6
0
        public bool Detach(int id, bool oneWay = false, WindowLayoutElement component = null)
        {
            if (this.id == id)
            {
                return(false);
            }

            var result = false;

            if (component != null)
            {
                if (this.attachedComponents.Any((c) => c.targetWindowId == id && c.sourceComponentTag == component.tag) == true)
                {
                    this.attachedComponents.RemoveAll((c) => c.targetWindowId == id && c.sourceComponentTag == component.tag);

                    result = true;
                }
            }
            else
            {
                if (this.attaches.Contains(id) == true)
                {
                    this.attaches.Remove(id);
                    this.attachedComponents.RemoveAll((c) => c.targetWindowId == id);

                    result = true;
                }

                if (oneWay == false)
                {
                    var window = FlowSystem.GetWindow(id);
                    if (window != null)
                    {
                        result = window.Detach(this.id, oneWay: true);
                    }
                }
            }

            return(result);
        }
Ejemplo n.º 7
0
 public bool IsEnabled()
 {
     return(!FlowSystem.GetTags().Any((t) => this.tags.Contains(t.id) && t.enabled == false));
 }
Ejemplo n.º 8
0
 public bool HasContainer(FlowWindow predicate)
 {
     return(this.attaches.Any((id) => id == predicate.id && FlowSystem.GetWindow(id).isContainer));
 }
Ejemplo n.º 9
0
 public bool HasContainer()
 {
     return(this.attaches.Any((id) => FlowSystem.GetWindow(id).isContainer));
 }
Ejemplo n.º 10
0
 public FlowWindow GetContainer()
 {
     return(ME.Utilities.CacheByFrame("FlowWindow." + this.id.ToString() + ".GetContainer", () => FlowSystem.GetWindow(this.attaches.FirstOrDefault((id) => FlowSystem.GetWindow(id).isContainer))));
 }
Ejemplo n.º 11
0
        public GUIStyle GetEditorStyle(bool selected)
        {
            if (this.isDefaultLink == true)
            {
                // Yellow

                var defaultLinkStyle = ME.Utilities.CacheStyle("FlowWindow.GetEditorStyle.DefaultLinkStyle.NotSelected", "flow node 4", (styleName) => {
                    var _style              = new GUIStyle(styleName);
                    _style.padding          = new RectOffset(0, 0, 14, 1);
                    _style.contentOffset    = new Vector2(0f, -15f);
                    _style.fontStyle        = FontStyle.Bold;
                    _style.alignment        = TextAnchor.MiddleCenter;
                    _style.normal.textColor = Color.white;

                    return(_style);
                });

                var defaultLinkStyleSelected = ME.Utilities.CacheStyle("FlowWindow.GetEditorStyle.DefaultLinkStyle.Selected", "flow node 4 on", (styleName) => {
                    var _style              = new GUIStyle(styleName);
                    _style.padding          = new RectOffset(0, 0, 14, 1);
                    _style.contentOffset    = new Vector2(0f, -15f);
                    _style.fontStyle        = FontStyle.Bold;
                    _style.alignment        = TextAnchor.MiddleCenter;
                    _style.normal.textColor = Color.white;

                    return(_style);
                });

                return(selected ? defaultLinkStyleSelected : defaultLinkStyle);
            }
            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("FlowWindow.GetEditorStyle.Container", styleNormal, (styleName) => {
                    var _style              = new GUIStyle(styleName);
                    _style.padding          = new RectOffset(0, 0, 16, 1);
                    _style.contentOffset    = new Vector2(0f, -15f);
                    _style.fontStyle        = FontStyle.Bold;
                    _style.normal.textColor = Color.white;

                    return(_style);
                });

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

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

                if (FlowSystem.GetRootWindow() == this.id)
                {
                    // 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           = new GUIStyle(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);

                    return(_style);
                });

                var windowStyleSelected = ME.Utilities.CacheStyle("FlowWindow.GetEditorStyle.Window.NotSelected", styleSelected, (styleName) => {
                    var _style           = new GUIStyle(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);

                    return(_style);
                });

                return(selected ? windowStyleSelected : windowStyle);
            }
        }
Ejemplo n.º 12
0
 public bool HasContainer(FlowWindow predicate)
 {
     return(this.attachItems.Any((item) => item.targetId == predicate.id && FlowSystem.GetWindow(item.targetId).IsContainer()));
 }
Ejemplo n.º 13
0
 public bool HasContainer()
 {
     return(this.attachItems.Any((item) => FlowSystem.GetWindow(item.targetId).IsContainer()));
 }
Ejemplo n.º 14
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;

                    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;

                    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("FlowWindow.GetEditorStyle.Container", 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;

                    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);

                    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);

                    return(_style);
                });

                return(selected ? windowStyleSelected : windowStyle);
            }
        }
Ejemplo n.º 15
0
 public static void Detach(int source, int index, int other, bool oneWay, WindowLayoutElement component = null)
 {
     FlowSystem.instance.data.Detach(source, index, other, oneWay, component);
     FlowSystem.SetCompileDirty();
 }
Ejemplo n.º 16
0
 public static void DestroyWindow(int id)
 {
     FlowSystem.instance.data.DestroyWindow(id);
     FlowSystem.SetCompileDirty();
 }