Beispiel #1
0
        private static void Generate(string pathToData, bool recompile, System.Func <FlowWindow, bool> predicate)
        {
            var filename  = Path.GetFileName(pathToData);
            var directory = pathToData.Replace(filename, string.Empty);

            FlowCompilerSystem.currentProject          = Path.GetFileNameWithoutExtension(pathToData);
            FlowCompilerSystem.currentProjectDirectory = directory;

            var basePath = directory + FlowCompilerSystem.currentProject;

            IO.CreateDirectory(basePath, string.Empty);
            IO.CreateDirectory(basePath, FlowDatabase.OTHER_NAME);

            predicate = predicate ?? delegate { return(true); };

            AssetDatabase.StartAssetEditing();
            {
                try {
                    var windows = FlowSystem.GetWindows().Where(w => !w.isDefaultLink && predicate(w));

                    foreach (var each in windows)
                    {
                        var relativePath = IO.GetRelativePath(each, "/");
                        FlowCompilerSystem.GenerateWindow(basePath + relativePath + "/", each, recompile);
                    }
                } catch (Exception e) {
                    Debug.LogException(e);
                }
            }
            AssetDatabase.StopAssetEditing();
            AssetDatabase.Refresh(ImportAssetOptions.ForceUpdate);

            FlowSystem.SetDirty();
            FlowSystem.Save();
        }
        public override void OnFlowSettingsGUI()
        {
            GUILayout.Label(FlowAddon.MODULE_INSTALLED, EditorStyles.centeredGreyMiniLabel);

            EditorGUILayout.BeginVertical(EditorStyles.helpBox);
            {
                #region NAMESPACE
                EditorGUIUtility.labelWidth = 70f;

                var namespaceName = EditorGUILayout.TextField("Namespace: ", FlowSystem.GetData().namespaceName);
                if (namespaceName != FlowSystem.GetData().namespaceName)
                {
                    FlowSystem.GetData().namespaceName = namespaceName;
                    FlowSystem.SetDirty();
                }

                EditorGUIUtility.LookLikeControls();

                var forceRecompile = GUILayout.Toggle(FlowSystem.GetData().forceRecompile, "Force Recompile");
                if (forceRecompile != FlowSystem.GetData().forceRecompile)
                {
                    FlowSystem.GetData().forceRecompile = forceRecompile;
                    FlowSystem.SetDirty();
                }

                #endregion
            }
            EditorGUILayout.EndVertical();
        }
Beispiel #3
0
        public void OnFlowSettingsGUI()
        {
            #region NAMESPACE

            GUILayout.Label("Flow Compiler", EditorStyles.boldLabel);

            EditorGUIUtility.labelWidth = 70f;

            var namespaceName = EditorGUILayout.TextField("Namespace: ", FlowSystem.GetData().namespaceName);
            if (namespaceName != FlowSystem.GetData().namespaceName)
            {
                FlowSystem.GetData().namespaceName = namespaceName;
                FlowSystem.SetDirty();
            }

            EditorGUIUtility.LookLikeControls();

            var forceRecompile = GUILayout.Toggle(FlowSystem.GetData().forceRecompile, "Force Recompile");
            if (forceRecompile != FlowSystem.GetData().forceRecompile)
            {
                FlowSystem.GetData().forceRecompile = forceRecompile;
                FlowSystem.SetDirty();
            }

            #endregion
        }
        public void Validate(FD.FlowWindow window)
        {
                        #if UNITY_EDITOR
            if (this.items == null)
            {
                this.items = new List <ABTestingItem>();
                EditorUtility.SetDirty(window);
                FlowSystem.SetDirty();
                FlowSystem.Save();
            }

            if (this.Count() < 2)
            {
                for (int i = this.Count(); i < 2; ++i)
                {
                    this.AddNew();
                }
                EditorUtility.SetDirty(window);
                FlowSystem.SetDirty();
                FlowSystem.Save();
            }

            var data = FlowSystem.GetData();
            if (data != null)
            {
                var attaches = window.attachItems.ToArray();
                for (int i = 0; i < attaches.Count(); ++i)
                {
                    var toId    = attaches[i].targetId;
                    var toIndex = attaches[i].index;

                    if (this.items.FirstOrDefault(x => x.attachItem.targetId == toId && x.attachItem.index == toIndex) == null)
                    {
                        var fromId = window.id;
                        if (FlowSystem.GetWindow(toId).IsContainer() == false)
                        {
                            EditorApplication.delayCall += () => {
                                data.Detach(fromId, toIndex, toId, oneWay: false);
                            };
                        }
                    }
                }

                for (int i = 0; i < this.Count(); ++i)
                {
                    var item = this.items[i];

                    if (data.AlreadyAttached(window.id, item.attachItem.index, item.attachItem.targetId) == false)
                    {
                        // no attachment - remove it
                        item.Detach();
                    }
                }
            }
                        #endif
        }
Beispiel #5
0
        private static void Generate(string pathToData, bool recompile, bool minimalScriptsSize, System.Func <FD.FlowWindow, bool> predicate)
        {
            var filename = Path.GetFileName(pathToData);

            if (string.IsNullOrEmpty(pathToData) == true)
            {
                throw new Exception(string.Format("`pathToData` is wrong: {0}. Filename: {1}", pathToData, filename));
            }

            var directory = pathToData.Replace(filename, string.Empty);

            CompilerSystem.currentProject          = Path.GetFileNameWithoutExtension(pathToData);
            CompilerSystem.currentProjectDirectory = directory;

            var basePath = directory + CompilerSystem.currentProject;

            IO.CreateDirectory(basePath, string.Empty);
            IO.CreateDirectory(basePath, FlowDatabase.OTHER_NAME);

            predicate = predicate ?? delegate { return(true); };

            AssetDatabase.StartAssetEditing();
            {
                try {
                    var windows = FlowSystem.GetContainersAndWindows().Where(w => w.CanCompiled() && predicate(w));
                    //var windows = FlowSystem.GetContainers().Where(w => w.CanCompiled() && predicate(w));
                    foreach (var each in windows)
                    {
                        var relativePath = IO.GetRelativePath(each, "/");
                        CompilerSystem.GenerateWindow(string.Format("{0}{1}/", basePath, relativePath), each, recompile, minimalScriptsSize);
                    }

                    // Generate Base Files
                    var newInfo              = new Tpl.Info(CompilerSystem.currentNamespace, "Container", "ContainerBase", "LayoutWindowType", basePath);
                    var baseClassTemplate    = TemplateGenerator.GenerateWindowLayoutContainerBaseClass(newInfo.baseClassname, newInfo.baseNamespace, newInfo.containerClassName);
                    var derivedClassTemplate = TemplateGenerator.GenerateWindowLayoutDerivedClass(newInfo.classname, newInfo.baseClassname, newInfo.baseNamespace);

                    IO.CreateFile(basePath, newInfo.baseClassnameFile, baseClassTemplate, rewrite: true);
                    IO.CreateFile(basePath, newInfo.classnameFile, derivedClassTemplate, rewrite: false);
                } catch (Exception e) {
                    if (UnityEngine.UI.Windows.Constants.LOGS_ENABLED == true)
                    {
                        UnityEngine.Debug.LogException(e);
                    }
                }
            }
            AssetDatabase.StopAssetEditing();
            AssetDatabase.Refresh(ImportAssetOptions.ForceUpdate);

            FlowSystem.SetDirty();
            FlowSystem.Save();
        }
Beispiel #6
0
        public void SetCompletedState(int index, CompletedState state)
        {
            if (this.states == null || this.states.Length != STATES_COUNT)
            {
                this.states = new CompletedState[STATES_COUNT];
            }

            var oldState = this.states[index];

            if (oldState != state)
            {
                this.states[index] = state;
                FlowSystem.SetDirty();
            }
        }
		public override void OnFlowSettingsGUI() {

			if (this.skin == null) this.skin = FlowSystemEditorWindow.defaultSkin;

			GUILayout.Label(FlowAddon.MODULE_INSTALLED, EditorStyles.centeredGreyMiniLabel);

			EditorGUILayout.BeginVertical(EditorStyles.helpBox);
			{
				
				#region NAMESPACE
				GUILayout.Label("Namespace:");
				GUILayout.BeginVertical(GUILayout.Height(30f));
				{

					var namespaceName = EditorGUILayout.TextField(FlowSystem.GetData().namespaceName, this.skin.textField);
					if (namespaceName != FlowSystem.GetData().namespaceName) {
						
						FlowSystem.GetData().namespaceName = namespaceName;
						FlowSystem.SetDirty();

					}

				}
				GUILayout.EndHorizontal();

				var forceRecompile = EditorGUILayout.ToggleLeft("Force Recompile", FlowSystem.GetData().forceRecompile);
				if (forceRecompile != FlowSystem.GetData().forceRecompile) {
					
					FlowSystem.GetData().forceRecompile = forceRecompile;
					FlowSystem.SetDirty();
					
				}
				
				var minimalScriptsSize = EditorGUILayout.ToggleLeft("Minimal Scripts Size", FlowSystem.GetData().minimalScriptsSize);
				if (minimalScriptsSize != FlowSystem.GetData().minimalScriptsSize) {
					
					FlowSystem.GetData().minimalScriptsSize = minimalScriptsSize;
					FlowSystem.SetDirty();
					
				}
				#endregion

			}
			EditorGUILayout.EndVertical();

		}
        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();
                }
            }
        }
        private void Validate(FD.FlowWindow window)
        {
            if (window.abTests == null)
            {
                window.abTests = new UnityEngine.UI.Windows.Plugins.ABTesting.ABTestingItems();
                EditorUtility.SetDirty(window);
                FlowSystem.SetDirty();
                FlowSystem.Save();
            }

            window.abTests.Validate(window);

            var sourceWin = FlowSystem.GetData().windowAssets.FirstOrDefault(x => x.AlreadyAttached(window.id));

            if (sourceWin != null)
            {
                window.abTests.sourceWindowId = sourceWin.id;
            }
        }
        private static void Generate(string pathToData, bool recompile, bool minimalScriptsSize, System.Func <FD.FlowWindow, bool> predicate)
        {
            var filename = Path.GetFileName(pathToData);

            if (string.IsNullOrEmpty(pathToData) == true)
            {
                throw new Exception("`pathToData` is wrong: " + pathToData + ". Filename: " + filename);
            }

            var directory = pathToData.Replace(filename, string.Empty);

            CompilerSystem.currentProject          = Path.GetFileNameWithoutExtension(pathToData);
            CompilerSystem.currentProjectDirectory = directory;

            var basePath = directory + CompilerSystem.currentProject;

            IO.CreateDirectory(basePath, string.Empty);
            IO.CreateDirectory(basePath, FlowDatabase.OTHER_NAME);

            predicate = predicate ?? delegate { return(true); };

            AssetDatabase.StartAssetEditing();
            {
                try {
                    var windows = FlowSystem.GetWindows().Where(w => w.CanCompiled() && predicate(w));

                    foreach (var each in windows)
                    {
                        var relativePath = IO.GetRelativePath(each, "/");
                        CompilerSystem.GenerateWindow(basePath + relativePath + "/", each, recompile, minimalScriptsSize);
                    }
                } catch (Exception e) {
                    Debug.LogException(e);
                }
            }
            AssetDatabase.StopAssetEditing();
            AssetDatabase.Refresh(ImportAssetOptions.ForceUpdate);

            FlowSystem.SetDirty();
            FlowSystem.Save();
        }
        private void DrawBottom()
        {
            GUILayout.FlexibleSpace();

            CustomGUI.Splitter();

            GUILayout.BeginHorizontal();
            {
                var firstPart = (this.partIndex == 0);
                var lastPart  = (this.partIndex >= this.parts - 2);

                var oldEnabled = GUI.enabled;

                GUI.enabled = !lastPart;
                if (GUILayout.Button("Cancel", this.defaultSkin.button, GUILayout.Width(100f), GUILayout.Height(30f)) == true)
                {
                    this.Close();
                }

                GUILayout.FlexibleSpace();

                GUI.enabled = oldEnabled && !firstPart && !lastPart;
                if (GUILayout.Button("Back", this.defaultSkin.button, GUILayout.Width(100f), GUILayout.Height(30f)) == true)
                {
                    --this.partIndex;
                }
                GUI.enabled = oldEnabled;

                GUI.enabled = GUI.enabled && this.readyToNext;
                if (this.partIndex == this.processPartIndex)
                {
                    if (GUILayout.Button("GO!", this.defaultSkin.button, GUILayout.Width(100f), GUILayout.Height(30f)) == true)
                    {
                        ++this.partIndex;
                        this.Repaint();

                        if (this.saveDefaultSettings == true)
                        {
                            FlowSystem.GetData().namespaceName      = this.compileNamespace;
                            FlowSystem.GetData().forceRecompile     = this.forceRecompile;
                            FlowSystem.GetData().minimalScriptsSize = this.minimalScriptsSize;
                            FlowSystem.SetDirty();
                        }

                        CompilerSystem.currentNamespace = this.compileNamespace;

                        if (this.tagsIgnored.Count == 0)
                        {
                            // Build all

                            CompilerSystem.Generate(AssetDatabase.GetAssetPath(FlowSystem.GetData()), this.forceRecompile, this.minimalScriptsSize);
                        }
                        else
                        {
                            var tags = new List <int>();
                            foreach (var tag in FlowSystem.GetData().tags)
                            {
                                if (this.tagsIgnored.Contains(tag.id) == false)
                                {
                                    tags.Add(tag.id);
                                }
                            }

                            CompilerSystem.GenerateByTags(AssetDatabase.GetAssetPath(FlowSystem.GetData()), tags.ToArray(), this.forceRecompile, this.minimalScriptsSize);
                        }

                        this.Repaint();
                    }
                }
                else
                {
                    if (lastPart == true)
                    {
                        if (this.onComplete != null)
                        {
                            this.onComplete();
                        }
                        this.onComplete = null;

                        if (GUILayout.Button("Finish", this.defaultSkin.button, GUILayout.Width(100f), GUILayout.Height(30f)) == true)
                        {
                            this.Close();
                        }
                    }
                    else
                    {
                        if (GUILayout.Button("Next", this.defaultSkin.button, GUILayout.Width(100f), GUILayout.Height(30f)) == true)
                        {
                            ++this.partIndex;
                        }
                    }
                }
                GUI.enabled = oldEnabled;
            }
            GUILayout.EndHorizontal();
        }
Beispiel #12
0
        public static void DrawList(ref ReorderableList reorderableList, string label, ClipType clipType)
        {
            if (reorderableList == null)
            {
                var objectField = ME.Utilities.CacheStyle("UI.Windows.ObjectFieldSmall", "ObjectFieldSmall", (name) => FlowSystemEditorWindow.defaultSkin.FindStyle(name));
                var textField   = ME.Utilities.CacheStyle("UI.Windows.TextFieldSmall", "TextFieldSmall", (name) => FlowSystemEditorWindow.defaultSkin.FindStyle(name));

                var audioSources = FlowSystem.GetAudioItems(clipType);
                if (audioSources != null)
                {
                    var sources = FlowSystem.GetAudioItems(clipType);

                    reorderableList = new ReorderableList(audioSources, typeof(UnityEngine.UI.Windows.Audio.Data.State), true, true, true, true);

                    reorderableList.onAddCallback += (list) => {
                        FlowSystem.AddAudioItem(clipType, new UnityEngine.UI.Windows.Audio.Data.State());
                        FlowSystem.SetDirty();
                    };
                    reorderableList.onRemoveCallback += (list) => {
                        var index = list.index;
                        if (index < 0 || index >= sources.Count)
                        {
                            return;
                        }

                        FlowSystem.RemoveAudioItem(clipType, (list.list[index] as UnityEngine.UI.Windows.Audio.Data.State).key);
                        FlowSystem.SetDirty();
                    };
                    reorderableList.drawHeaderCallback += (rect) => {
                        const float widthNumber   = 20f;
                        const float widthCategory = 70f;

                        rect.x += 14f;

                        var labelRect = new Rect(rect);
                        labelRect.width = widthNumber;

                        GUI.Label(labelRect, "#");

                        var categoryRect = new Rect(rect);
                        categoryRect.x    += widthNumber;
                        categoryRect.width = widthCategory;

                        GUI.Label(categoryRect, "Category");

                        rect.x     += widthNumber + widthCategory;
                        rect.width -= widthNumber + widthCategory;

                        GUI.Label(rect, label);
                    };
                    reorderableList.drawElementCallback += (rect, index, active, focused) => {
                        const float widthNumber   = 20f;
                        const float widthCategory = 70f;

                        if (index < 0 || index >= sources.Count)
                        {
                            return;
                        }

                        var item = sources[index];

                        var labelRect = new Rect(rect);
                        labelRect.width = widthNumber;

                        GUI.Label(labelRect, item.key.ToString(), EditorStyles.miniLabel);

                        var categoryRect = new Rect(rect);
                        categoryRect.x    += widthNumber;
                        categoryRect.width = widthCategory;

                        item.category = EditorGUI.TextField(categoryRect, item.category, textField);

                        rect.x     += widthNumber + widthCategory;
                        rect.width -= widthNumber + widthCategory;

                        var clip = GUILayoutExt.ObjectField <AudioClip>(rect, item.clip, false, objectField);
                        if (clip != item.clip)
                        {
                            item.clip = clip;
                            FlowSystem.SetDirty();
                        }
                    };
                }
            }

            if (reorderableList != null)
            {
                reorderableList.DoLayoutList();
            }
        }