public static string GenerateReturnMethod(FlowSystemEditorWindow flowEditor, FlowWindow exitWindow)
        {
            var file = Resources.Load("UI.Windows/Functions/Templates/TemplateReturnMethod") as TextAsset;

            if (file == null)
            {
                Debug.LogError("Functions Template Loading Error: Could not load template 'TemplateReturnMethod'");

                return(string.Empty);
            }

            var data = FlowSystem.GetData();

            if (data == null)
            {
                return(string.Empty);
            }

            var result = string.Empty;
            var part   = file.text;

            var functionContainer = exitWindow.GetFunctionContainer();

            var functionName           = functionContainer.title;
            var functionCallName       = functionContainer.directory;
            var classNameWithNamespace = Tpl.GetNamespace(exitWindow) + "." + Tpl.GetDerivedClassName(exitWindow);

            result +=
                part.Replace("{FUNCTION_NAME}", functionName)
                .Replace("{FUNCTION_CALL_NAME}", functionCallName)
                .Replace("{CLASS_NAME_WITH_NAMESPACE}", classNameWithNamespace);

            return(result);
        }
예제 #2
0
            public Window Get(FlowWindow window)
            {
                Window result = null;

                this.list.RemoveAll((info) => {
                    var w = Flow.FlowSystem.GetWindow(info.id);
                    return(w == null);
                });

                foreach (var item in this.list)
                {
                    if (item.id == window.id)
                    {
                        result = item;
                        break;
                    }
                }

                if (result == null)
                {
                    result = new Window(window);
                    this.list.Add(result);
                }

                return(result);
            }
        public override void OnFlowWindowGUI(FlowWindow window)
        {
            if (window.CanCompiled() == false)
            {
                return;
            }

            if (string.IsNullOrEmpty(window.compiledDirectory) == false)
            {
                window.compiled = System.IO.File.Exists(window.compiledDirectory + "/" + window.compiledBaseClassName + ".cs");
            }

            var oldColor      = GUI.color;
            var style         = new GUIStyle("U2D.dragDotDimmed");
            var styleCompiled = new GUIStyle("U2D.dragDot");

            var elemWidth = style.fixedWidth - 3f;

            var posY = -1f;
            var posX = -1f;

            GUI.color = window.compiled ? Color.white : Color.red;
            GUI.Label(new Rect(posX, posY, elemWidth, style.fixedHeight), new GUIContent(string.Empty, window.compiled ? "Compiled" : "Not compiled"), window.compiled ? styleCompiled : style);

            GUI.color = oldColor;
        }
예제 #4
0
 public Info(FlowWindow window)
 {
     this.baseNamespace = window.compiledNamespace;
     this.classname     = window.compiledDerivedClassName;
     this.baseClassname = window.compiledBaseClassName;
     this.screenName    = window.directory;
 }
예제 #5
0
        public static void OnDrawWindowGUI(FlowWindow window)
        {
            var flowAddons = WindowUtilities.GetAddons <IWindowFlowAddon>();

            foreach (var addon in flowAddons)
            {
                addon.OnFlowWindowGUI(window);
            }
        }
예제 #6
0
        public static void OnDrawWindowLayoutGUI(Rect rect, FlowWindow window)
        {
            var flowAddons = CoreUtilities.GetAddons <IWindowFlowAddon>();

            foreach (var addon in flowAddons)
            {
                addon.OnFlowWindowLayoutGUI(rect, window);
            }
        }
예제 #7
0
        public static void OnDrawWindowGUI(FlowSystemEditorWindow flowEditor, FlowWindow window)
        {
            var flowAddons = CoreUtilities.GetAddons <IWindowFlowAddon>();

            foreach (var addon in flowAddons)
            {
                addon.flowEditor = flowEditor;
                addon.OnFlowWindowGUI(window);
            }
        }
예제 #8
0
        private static IEnumerable <FlowWindow> GetParentContainers(FlowWindow window, IEnumerable <FlowWindow> containers)
        {
            var parent = containers.FirstOrDefault(where => where.attaches.Contains(window.id));

            while (parent != null)
            {
                yield return(parent);

                parent = containers.FirstOrDefault(where => where.attaches.Contains(parent.id));
            }
        }
예제 #9
0
        private static IEnumerable <FlowWindow> GetParentContainers(FlowWindow window, IEnumerable <FlowWindow> containers)
        {
            var parent = containers.FirstOrDefault(where => where.attachItems.Any((item) => item.targetId == window.id));

            while (parent != null)
            {
                yield return(parent);

                parent = containers.FirstOrDefault(where => where.attachItems.Any((item) => item.targetId == parent.id));
            }
        }
예제 #10
0
        public override void OnFlowWindowGUI(FlowWindow window)
        {
            if (Social.settings == null)
            {
                return;
            }

            var socialFlag = (window.flags & Social.settings.uniqueTag) == Social.settings.uniqueTag;

            if (socialFlag == true)
            {
                var settings = Social.settings;
                if (settings == null)
                {
                    return;
                }

                var data             = settings.data.Get(window);
                var isActiveSelected = settings.IsPlatformActive(data.settings);

                var oldColor = GUI.color;
                GUI.color = isActiveSelected ? Color.white : Color.grey;
                var result = GUILayoutExt.LargeButton(data.settings ? data.settings.GetPlatformName() : "None", 60f, 150f);
                GUI.color = oldColor;
                var rect = GUILayoutUtility.GetLastRect();
                rect.y += rect.height;

                if (result == true)
                {
                    var menu = new GenericMenu();
                    menu.AddItem(new GUIContent("None"), data.settings == null, () => {
                        data.settings = null;
                    });

                    foreach (var platform in settings.activePlatforms)
                    {
                        if (platform.active == true)
                        {
                            var item = platform.settings;
                            menu.AddItem(new GUIContent(platform.GetPlatformName()), data.settings == platform.settings, () => {
                                data.settings = item;
                            });
                        }
                        else
                        {
                            menu.AddDisabledItem(new GUIContent(platform.GetPlatformName()));
                        }
                    }

                    menu.DropDown(rect);
                }
            }
        }
예제 #11
0
        public override string OnCompilerTransitionAttachedGeneration(FlowWindow windowFrom, 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));
        }
예제 #12
0
        public static string OnCompilerTransitionGeneration(FlowWindow window)
        {
            var result     = string.Empty;
            var flowAddons = CoreUtilities.GetAddons <IWindowFlowAddon>();

            foreach (var addon in flowAddons)
            {
                result += addon.OnCompilerTransitionGeneration(window);
            }

            return(result);
        }
예제 #13
0
        public static string OnCompilerTransitionAttachedGeneration(FlowWindow windowFrom, FlowWindow windowTo, bool everyPlatformHasUniqueName)
        {
            var result     = string.Empty;
            var flowAddons = CoreUtilities.GetAddons <IWindowFlowAddon>();

            foreach (var addon in flowAddons)
            {
                result += addon.OnCompilerTransitionAttachedGeneration(windowFrom, windowTo, everyPlatformHasUniqueName);
            }

            return(result);
        }
예제 #14
0
        public static string GenerateTransitionMethods(FlowWindow window)
        {
            var flowData = FlowSystem.GetData();

            var transitions = flowData.windows.Where(w => window.attachItems.Any((item) => item.targetId == w.id) && w.CanCompiled() && !w.IsContainer());

            var result = string.Empty;

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

                result += FlowTemplateGenerator.GenerateWindowLayoutTransitionMethod(window, each, className, classNameWithNamespace);
            }

            // Make FlowDefault() method if exists
            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)
                {
                    result += FlowTemplateGenerator.GenerateWindowLayoutTransitionMethodDefault();
                }

                result += UnityEditor.UI.Windows.Plugins.Flow.Flow.OnCompilerTransitionAttachedGeneration(window, attachedWindow, everyPlatformHasUniqueName);
            }

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

            return(result);
        }
예제 #15
0
        public void DrawNodeCurve(FlowWindow fromContainer, FlowWindow toContainer, Rect centerStart, Rect centerEnd, Rect fromRect, Rect toRect, bool doubleSide, float size = 6f)
        {
            Rect start = fromRect;
            Rect end   = toRect;

            var color1 = Color.white;
            var color2 = Color.white;

            if (fromContainer != toContainer)
            {
                color1 = Color.gray;
                color2 = Color.gray;

                if (toContainer != null)
                {
                    color1 = toContainer.randomColor;
                }
                if (fromContainer != null)
                {
                    color2 = fromContainer.randomColor;
                }
            }

            var zOffset = -4f;

            if (doubleSide == true)
            {
                var rot = Quaternion.AngleAxis(90f, Vector3.back);
                var ray = new Ray(Vector3.zero, (rot * (end.center - start.center)).normalized);

                var offset   = ray.GetPoint(size);
                var startPos = new Vector3(start.center.x + offset.x, start.center.y + offset.y, zOffset);
                var endPos   = new Vector3(centerEnd.center.x + offset.x, centerEnd.center.y + offset.y, zOffset);

                this.DrawNodeCurve(startPos, endPos, color1);

                offset   = ray.GetPoint(-size);
                startPos = new Vector3(centerStart.center.x + offset.x, centerStart.center.y + offset.y, zOffset);
                endPos   = new Vector3(end.center.x + offset.x, end.center.y + offset.y, zOffset);

                this.DrawNodeCurve(endPos, startPos, color2);
            }
            else
            {
                var offset   = Vector2.zero;
                var startPos = new Vector3(start.center.x + offset.x, start.center.y + offset.y, zOffset);
                var endPos   = new Vector3(centerEnd.center.x + offset.x, centerEnd.center.y + offset.y, zOffset);

                this.DrawNodeCurve(startPos, endPos, color1);
            }
        }
예제 #16
0
        public static bool IsCompilerTransitionAttachedGeneration(FlowWindow windowFrom, FlowWindow windowTo)
        {
            var flowAddons = CoreUtilities.GetAddons <IWindowFlowAddon>();

            foreach (var addon in flowAddons)
            {
                if (addon.IsCompilerTransitionAttachedGeneration(windowFrom, windowTo) == true)
                {
                    return(true);
                }
            }

            return(false);
        }
예제 #17
0
        public override string OnCompilerTransitionGeneration(FlowWindow window)
        {
            var functionContainer = window.GetFunctionContainer();

            if (functionContainer != null)
            {
                var exit = FlowSystem.GetWindow(functionContainer.functionExitId);
                if (exit != null && exit.id == window.id)
                {
                    return(FlowFunctionsTemplateGenerator.GenerateReturnMethod(this.flowEditor, exit));
                }
            }

            return(base.OnCompilerTransitionGeneration(window));
        }
예제 #18
0
        public override bool IsCompilerTransitionAttachedGeneration(FlowWindow windowFrom, FlowWindow windowTo)
        {
            var settings = Social.settings;

            if (settings != null)
            {
                var data = settings.data.Get(windowTo);
                if (data != null && data.settings != null && settings.IsPlatformActive(data.settings) == true)
                {
                    return(true);
                }
            }

            return(false);
        }
예제 #19
0
        public override string OnCompilerTransitionAttachedGeneration(FlowWindow windowFrom, FlowWindow windowTo, bool everyPlatformHasUniqueName)
        {
            var settings = Social.settings;

            if (settings != null)
            {
                var data = settings.data.Get(windowTo);
                if (data != null && data.settings != null && settings.IsPlatformActive(data.settings) == true)
                {
                    return(FlowSocialTemplateGenerator.GenerateTransitionMethod(data.settings, everyPlatformHasUniqueName));
                }
            }

            return(base.OnCompilerTransitionAttachedGeneration(windowFrom, windowTo, everyPlatformHasUniqueName));
        }
예제 #20
0
        public static void SetControl(FlowSystemEditorWindow rootWindow, FlowWindow window, System.Action <float> onProgress)
        {
            if (EditorApplication.SaveCurrentSceneIfUserWantsTo() == true)
            {
                FlowSceneView.editAnimation = new UnityEditor.AnimatedValues.AnimFloat(0f, () => {
                    onProgress(FlowSceneView.editAnimation.value);
                });
                FlowSceneView.editAnimation.value  = 0f;
                FlowSceneView.editAnimation.speed  = 2f;
                FlowSceneView.editAnimation.target = 1f;

                FlowSceneView.currentItem = new FlowSceneItem(rootWindow, window, FlowSceneView.editAnimation);
                FlowSceneView.isActive    = true;
            }
        }
예제 #21
0
        public static string GetRelativePath(FlowWindow window, string token)
        {
            var result = GetParentContainers(window, FlowSystem.GetContainers())
                         .Reverse()
                         .Select(w => w.directory)
                         .Aggregate(string.Empty, (total, path) => total + token + path);

            if (string.IsNullOrEmpty(result) == true)
            {
                result = token + FlowDatabase.OTHER_NAME;
            }

            result += token + window.directory;

            return(result);
        }
        public static string GenerateWindowLayoutTransitionMethod(FlowWindow from, FlowWindow to, string targetClassName, string targetClassNameWithNamespace)
        {
            var file = Resources.Load("UI.Windows/Templates/TemplateTransitionMethod") as TextAsset;

            if (file == null)
            {
                Debug.LogError("Template Loading Error: Could not load template 'TemplateTransitionMethod'");

                return(null);
            }

            return(file.text.Replace("{CLASS_NAME}", targetClassName)
                   .Replace("{FLOW_FROM_ID}", from.id.ToString())
                   .Replace("{FLOW_TO_ID}", to.id.ToString())
                   .Replace("{CLASS_NAME_WITH_NAMESPACE}", targetClassNameWithNamespace));
        }
예제 #23
0
        public void DrawComponentCurve(FlowWindow from, ref UnityEngine.UI.Windows.Plugins.Flow.FlowWindow.ComponentLink link, FlowWindow to)
        {
            if (from.IsEnabled() == false || to.IsEnabled() == false)
            {
                return;
            }

            var component = from.GetLayoutComponent(link.sourceComponentTag);

            if (component != null)
            {
                var rect = component.tempEditorRect;

                var start = new Rect(from.rect.x + rect.x, from.rect.y + rect.y, rect.width, rect.height);
                var end   = to.rect;

                var zOffset = -4f;

                var offset   = Vector2.zero;
                var startPos = new Vector3(start.center.x + offset.x, start.center.y + offset.y, zOffset);
                var endPos   = new Vector3(end.center.x + offset.x, end.center.y + offset.y, zOffset);

                var scale = FlowSystem.GetData().flowWindowWithLayoutScaleFactor;

                var side1        = from.rect.size.x * 0.5f;
                var side2        = from.rect.size.y * 0.5f;
                var stopDistance = Mathf.Sqrt(side1 * side1 + side2 * side2);

                var color = Color.white;
                if (from.GetContainer() != to.GetContainer())
                {
                    color = Color.gray;
                    if (to.GetContainer() != null)
                    {
                        color = to.GetContainer().randomColor;
                    }
                }
                var comment = this.DrawComponentCurve(startPos, endPos, color, stopDistance + 50f * scale, link.comment);
                if (link.comment != comment)
                {
                    link.comment = comment;
                    FlowSystem.SetDirty();
                }
            }
        }
예제 #24
0
        public static string GenerateTransitionMethods(FlowWindow window)
        {
            var flowData = FlowSystem.GetData();

            var transitions = flowData.windows.Where(w => window.attaches.Contains(w.id) && !w.isDefaultLink && !w.isContainer);

            var result = string.Empty;

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

                result = result + FlowTemplateGenerator.GenerateWindowLayoutTransitionMethod(className, classNameWithNamespace);
            }

            return(result);
        }
예제 #25
0
 public static string GetNamespace(FlowWindow window)
 {
     return(Tpl.GetNamespace() + IO.GetRelativePath(window, "."));
 }
예제 #26
0
 public static string GetDerivedClassName(FlowWindow flowWindow)
 {
     return(flowWindow.directory.UppercaseFirst() + "Screen");
 }
예제 #27
0
 public static void GenerateByWindow(string pathToData, bool recompile = false, FlowWindow window = null)
 {
     FlowCompilerSystem.Generate(pathToData, recompile, flowWindow => flowWindow == window);
 }
예제 #28
0
        /*
         * private static bool CompiledInfoIsInvalid( FlowWindow flowWindow ) {
         *
         *      return GetBaseClassName( flowWindow ) != flowWindow.compiledBaseClassName
         || GetNamespace( flowWindow ) != flowWindow.compiledNamespace;
         ||}
         ||
         ||private static void UpdateInheritedClasses( string oldBaseClassName, string newBaseClassName, string oldDerivedClassName, string newDerivedClassName, string oldNamespace, string newNamespace ) {
         ||
         ||     if ( string.IsNullOrEmpty( oldBaseClassName ) || string.IsNullOrEmpty( newBaseClassName ) ) {
         ||
         ||             return;
         ||     }
         ||
         ||     var oldFullClassPath = oldNamespace + oldBaseClassName;
         ||     var newFullClassPath = newNamespace + newBaseClassName;
         ||
         ||     AssetDatabase.StartAssetEditing();
         ||
         ||     try {
         ||
         ||             var scripts =
         ||                     AssetDatabase.FindAssets( "t:MonoScript" )
         ||                             .Select( _ => AssetDatabase.GUIDToAssetPath( _ ) )
         ||                             .Select( _ => AssetDatabase.LoadAssetAtPath( _, typeof( MonoScript ) ) )
         ||                             .OfType<MonoScript>()
         ||                             .Where( _ => _.text.Contains( oldBaseClassName ) || _.text.Contains( oldDerivedClassName ) || _.text.Contains( oldNamespace ) )
         ||                             .Where( _ => _.name != newBaseClassName );
         ||
         ||             foreach ( var each in scripts ) {
         ||
         ||                     var path = AssetDatabase.GetAssetPath( each );
         ||
         ||                     var lines = File.ReadAllLines( path );
         ||
         ||                     var writer = new StreamWriter( path );
         ||
         ||                     foreach ( var line in lines ) {
         ||
         ||                             writer.WriteLine( line.Replace( oldFullClassPath, newFullClassPath )
         ||                                                                       .Replace( oldNamespace, newNamespace )
         ||                                                                       .Replace( oldBaseClassName, newBaseClassName )
         ||                                                                       .Replace( oldDerivedClassName, newDerivedClassName ) );
         ||                     }
         ||
         ||                     writer.Dispose();
         ||             }
         ||     } catch ( Exception e ) { Debug.LogException( e ); }
         ||
         ||     AssetDatabase.StopAssetEditing();
         ||     AssetDatabase.Refresh( ImportAssetOptions.ForceUpdate );
         ||
         ||}
         ||
         ||private static void GenerateUIWindow( string fullpath, FlowWindow window, bool recompile = false ) {
         ||
         ||     var isCompiledInfoInvalid = window.compiled && CompiledInfoIsInvalid( window );
         ||
         ||     if ( window.compiled == false || recompile == true || isCompiledInfoInvalid ) {
         ||
         ||             var baseClassName = GetBaseClassName( window );
         ||             var derivedClassName = GetDerivedClassName( window );
         ||             var classNamespace = GetNamespace( window );
         ||
         ||             var baseClassTemplate = FlowTemplateGenerator.GenerateWindowLayoutBaseClass( baseClassName, classNamespace, GenerateTransitionMethods( window ) );
         ||             var derivedClassTemplate = FlowTemplateGenerator.GenerateWindowLayoutDerivedClass( derivedClassName, baseClassName, classNamespace );
         ||
         #if !UNITY_WEBPLAYER
         ||             var baseClassPath = ( fullpath + "/" + baseClassName + ".cs" ).Replace( "//", "/" );
         ||             var derivedClassPath = ( fullpath + "/" + derivedClassName + ".cs" ).Replace( "//", "/" );
         #endif
         ||
         ||             if ( baseClassTemplate != null && derivedClassTemplate != null ) {
         ||
         ||                     IO.CreateDirectory( fullpath, string.Empty );
         ||                     IO.CreateDirectory( fullpath, FlowDatabase.COMPONENTS_FOLDER );
         ||                     IO.CreateDirectory( fullpath, FlowDatabase.LAYOUT_FOLDER );
         ||                     IO.CreateDirectory( fullpath, FlowDatabase.SCREENS_FOLDER );
         ||
         #if !UNITY_WEBPLAYER
         ||
         ||                     Directory.CreateDirectory( fullpath );
         ||
         ||                     File.WriteAllText( baseClassPath, baseClassTemplate );
         ||
         ||                     if ( !File.Exists( derivedClassPath ) ) {
         ||
         ||                             File.WriteAllText( derivedClassPath, derivedClassTemplate );
         ||
         ||                             AssetDatabase.ImportAsset( derivedClassName );
         ||                     }
         ||
         ||                     AssetDatabase.ImportAsset( baseClassPath );
         ||
         #endif
         ||
         ||             } else {
         ||
         ||                     return;
         ||             }
         ||
         ||             var oldBaseClassName = window.compiledBaseClassName;
         ||             var newBaseClassName = baseClassName;
         ||             var oldDerivedClassName = window.compiledDerivedClassName;
         ||             var newDerivedClassName = derivedClassName;
         ||
         ||             var oldNamespace = window.compiledNamespace;
         ||
         ||             window.compiledBaseClassName = baseClassName;
         ||             window.compiledDerivedClassName = derivedClassName;
         ||             window.compiledNamespace = classNamespace;
         ||
         ||             var newNamespace = window.compiledNamespace;
         ||
         ||             window.compiledDirectory = fullpath;
         ||
         ||             window.compiled = true;
         ||
         ||             AssetDatabase.Refresh( ImportAssetOptions.ForceUpdate );
         ||
         ||             if ( isCompiledInfoInvalid ) {
         ||
         ||                     EditorApplication.delayCall += () => UpdateInheritedClasses( oldBaseClassName, newBaseClassName, oldDerivedClassName, newDerivedClassName, oldNamespace, newNamespace );
         ||             }
         ||     }
         ||
         ||}
         ||
         ||public static void GenerateUI( string pathToData, bool recompile = false, Func<FlowWindow, bool> predicate = null ) {
         ||
         ||     var filename = Path.GetFileName( pathToData );
         ||     var directory = pathToData.Replace( filename, "" );
         ||
         ||     currentProject = Path.GetFileNameWithoutExtension( pathToData );
         ||     var basePath = directory + currentProject;
         ||
         ||     CreateDirectory( basePath, string.Empty );
         ||     CreateDirectory( basePath, FlowDatabase.OTHER_NAME );
         ||
         ||     AssetDatabase.StartAssetEditing();
         ||
         ||     predicate = predicate ?? delegate { return true; };
         ||
         ||     try {
         ||
         ||             foreach ( var each in FlowSystem.GetWindows().Where( _ => !_.isDefaultLink && predicate( _ ) ) ) {
         ||
         ||                     var relativePath = GetRelativePath( each, "/" );
         ||
         ||                     if ( !string.IsNullOrEmpty( each.directory ) ) {
         ||
         ||                             CreateDirectory( basePath, relativePath );
         ||                     }
         ||
         ||                     GenerateUIWindow( basePath + relativePath + "/", each, recompile );
         ||             }
         ||     } catch ( Exception e ) {
         ||
         ||             Debug.LogException( e );
         ||     }
         ||
         ||     AssetDatabase.StopAssetEditing();
         ||     AssetDatabase.Refresh( ImportAssetOptions.ForceUpdate );
         ||
         ||}*/
        #endregion

        private static void GenerateWindow(string newPath, FlowWindow window, bool recompile)
        {
            if (window.compiled == true && recompile == false)
            {
                return;
            }

            var oldPath = window.compiledDirectory;

            var newInfo = new Tpl.Info(Tpl.GetNamespace(window), Tpl.GetDerivedClassName(window), Tpl.GetBaseClassName(window), window.directory);
            var oldInfo = new Tpl.Info(window);

            if (string.IsNullOrEmpty(oldPath) == true)
            {
                oldPath = newPath;
            }

            var path = oldPath;

            if (window.compiled == true && (oldPath != newPath))
            {
                // If window is moving and compiled - just rename

                // Replace in files
                IO.ReplaceInFiles(FlowCompilerSystem.currentProjectDirectory, (file) => {
                    var text = file.text;
                    return(text.Contains(oldInfo.baseNamespace));
                }, (text) => {
                    return(Tpl.ReplaceText(text, oldInfo, newInfo));
                });

                // Rename base class name
                IO.RenameFile(oldPath + oldInfo.baseClassnameFile, oldPath + newInfo.baseClassnameFile);

                // Rename derived class name
                IO.RenameFile(oldPath + oldInfo.classnameFile, oldPath + newInfo.classnameFile);

                // Rename main folder
                IO.RenameDirectory(oldPath, newPath);

                path = newPath;
            }

            // Rebuild without rename
            //Debug.Log(window.title + " :: REBUILD BASE :: " + path);

            IO.CreateDirectory(path, string.Empty);
            IO.CreateDirectory(path, FlowDatabase.COMPONENTS_FOLDER);
            IO.CreateDirectory(path, FlowDatabase.LAYOUT_FOLDER);
            IO.CreateDirectory(path, FlowDatabase.SCREENS_FOLDER);

            var baseClassTemplate    = FlowTemplateGenerator.GenerateWindowLayoutBaseClass(newInfo.baseClassname, newInfo.baseNamespace, Tpl.GenerateTransitionMethods(window));
            var derivedClassTemplate = FlowTemplateGenerator.GenerateWindowLayoutDerivedClass(newInfo.classname, newInfo.baseClassname, newInfo.baseNamespace);

            if (baseClassTemplate != null && derivedClassTemplate != null)
            {
                IO.CreateFile(path, newInfo.baseClassnameFile, baseClassTemplate, rewrite: true);
                IO.CreateFile(path, newInfo.classnameFile, derivedClassTemplate, rewrite: false);
            }

            window.compiledNamespace        = newInfo.baseNamespace;
            window.compiledScreenName       = newInfo.screenName;
            window.compiledBaseClassName    = newInfo.baseClassname;
            window.compiledDerivedClassName = newInfo.classname;

            window.compiledDirectory = path;
            window.compiled          = true;
        }
예제 #29
0
 public virtual bool IsCompilerTransitionAttachedGeneration(FlowWindow windowFrom, FlowWindow windowTo)
 {
     return(false);
 }
예제 #30
0
 public virtual string OnCompilerTransitionAttachedGeneration(FlowWindow windowFrom, FlowWindow windowTo, bool everyPlatformHasUniqueName)
 {
     return(string.Empty);
 }