예제 #1
0
        /*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));
        }
예제 #2
0
        /*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(windowFrom, linkerWindow, className, classNameWithNamespace);
         *
         *              WindowSystem.CollectCallVariations(linkerWindow.GetScreen(), (listTypes, listNames) => {
         *
         *                      result += TemplateGenerator.GenerateWindowLayoutTransitionTypedMethod(windowFrom, 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);
         *
         *              });
         *
         *              if (UnityEngine.UI.Windows.Constants.LOGS_ENABLED == true) UnityEngine.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 ? string.Format("{0} ({1})", linker.title, linker.directory) : "None", FlowSystemEditorWindow.defaultSkin.button, GUILayout.ExpandHeight(true));
                GUI.color = oldColor;
                var rect = GUILayoutUtility.GetLastRect();
                rect.y += rect.height;

                if (result == true)
                {
                    System.Action <int> onApply = (int id) => {
                        var linkerSources = new List <FD.FlowWindow>();
                        foreach (var w in data.windowAssets)
                        {
                            if (w.AlreadyAttached(window.id) == true)
                            {
                                linkerSources.Add(w);
                            }
                        }

                        if (window.linkerId != 0)
                        {
                            foreach (var w in linkerSources)
                            {
                                data.Detach(w.id, window.linkerId, oneWay: true);
                            }
                        }

                        window.linkerId = id;

                        if (window.linkerId != 0)
                        {
                            foreach (var w in linkerSources)
                            {
                                data.Attach(w.id, window.linkerId, oneWay: true);
                            }
                        }
                    };

                    var menu = new GenericMenu();
                    menu.AddItem(new GUIContent("None"), window.linkerId == 0, () => {
                        onApply(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 caption = new GUIContent(string.Format("{0} ({1})", win.title, win.directory));

                            var count = alreadyConnectedFunctionIds.Count((e) => e == win.id);
                            if (((window.GetLinkerId() == win.id && count == 1) || count == 0) && window.compiled == true)
                            {
                                var id = win.id;
                                menu.AddItem(caption, win.id == window.GetLinkerId(), () => {
                                    onApply(id);
                                });
                            }
                            else
                            {
                                if (window.compiled == false)
                                {
                                    caption = new GUIContent(string.Format("{0} (Compilation needed)", caption.text));
                                }
                                if (win.id == window.GetLinkerId())
                                {
                                    window.linkerId = 0;
                                }

                                alreadyConnectedFunctionIds.Remove(win.id);
                                menu.AddDisabledItem(caption);
                            }
                        }
                    }

                    menu.DropDown(rect);
                }
            }
        }
예제 #3
0
 public override bool IsCompilerTransitionAttachedGeneration(FD.FlowWindow windowFrom, FD.FlowWindow windowTo)
 {
     return
         (windowTo.IsLinker() == true &&
          windowTo.GetLinkerId() > 0);
 }
예제 #4
0
        /*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);
                }
            }
        }