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;
			
		}
Esempio n. 2
0
		public FlowSplash(FlowSystemEditorWindow editor) {

			this.editor = editor;

			if (this.skin == null) this.skin = Resources.Load<GUISkin>("UI.Windows/Flow/Styles/" + (EditorGUIUtility.isProSkin == true ? "SkinDark" : "SkinLight"));
			if (this.splash == null) this.splash = Resources.Load<Texture>("UI.Windows/Flow/Splash");

		}
		public static string GenerateTransitionMethod(FlowSystemEditorWindow flowEditor, FD.FlowWindow windowFrom, FD.FlowWindow windowTo) {
			
			var file = Resources.Load("UI.Windows/ABTesting/Templates/TemplateTransitionMethod") as TextAsset;
			if (file == null) {
				
				Debug.LogError("ABTesting Template Loading Error: Could not load template 'TemplateTransitionMethod'");
				
				return string.Empty;
				
			}
			
			var data = FlowSystem.GetData();
			if (data == null) return string.Empty;
			
			if (windowTo.IsABTest() == false) {
				
				return string.Empty;
				
			}

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

			var methodPattern = "(item, h) => WindowSystemFlow.DoFlow<{0}>(this, item, h, null)";
			var methods = string.Empty;
			var methodList = new List<string>();

			foreach (var item in windowTo.abTests.items) {

				var window = FlowSystem.GetWindow(item.attachItem.targetId);
				if (window == null) {
					
					methodList.Add("null");

				} else {
					
					var classNameWithNamespace = Tpl.GetClassNameWithNamespace(window);
					methodList.Add(string.Format(methodPattern, classNameWithNamespace));

				}

			}

			methods = string.Join(", ", methodList.ToArray());

			result +=
				part.Replace("{METHOD_NAMES}", methods)
					.Replace("{FLOW_FROM_ID}", windowFrom.id.ToString())
					.Replace("{FLOW_TO_ID}", windowTo.id.ToString());
			
			return result;
			
		}
		public static string GenerateTransitionMethod(FlowSystemEditorWindow flowEditor, FlowWindow windowFrom, FlowWindow windowTo) {
			
			var file = Resources.Load("UI.Windows/Functions/Templates/TemplateTransitionMethod") as TextAsset;
			if (file == null) {
				
				Debug.LogError("Functions Template Loading Error: Could not load template 'TemplateTransitionMethod'");
				
				return string.Empty;
				
			}
			
			var data = FlowSystem.GetData();
			if (data == null) return string.Empty;
			
			var result = string.Empty;
			var part = file.text;
			
			// Function link
			var functionId = windowTo.GetFunctionId();
			
			// Find function container
			var functionContainer = data.GetWindow(functionId);
			if (functionContainer == null) {
				
				// Function not found
				return string.Empty;
				
			}
			
			// Get function root window
			var root = data.GetWindow(functionContainer.functionRootId);
			//var exit = data.GetWindow(functionContainer.functionExitId);
			
			var functionName = functionContainer.title;
			var functionCallName = functionContainer.directory;
			var classNameWithNamespace = Tpl.GetNamespace(root) + "." + Tpl.GetDerivedClassName(root);
			var transitionMethods = Tpl.GenerateTransitionMethods(windowTo);
			transitionMethods = transitionMethods.Replace("\r\n", "\r\n\t")
												 .Replace("\n", "\n\t");

			result +=
				part.Replace("{TRANSITION_METHODS}", transitionMethods)
					.Replace("{FUNCTION_NAME}", functionName)
					.Replace("{FUNCTION_CALL_NAME}", functionCallName)
					.Replace("{FLOW_FROM_ID}", windowFrom.id.ToString())
					.Replace("{FLOW_TO_ID}", windowTo.id.ToString())
					.Replace("{CLASS_NAME_WITH_NAMESPACE}", classNameWithNamespace);
			
			return result;
			
		}
Esempio n. 5
0
		public static void OnDrawToolsMenuGUI(FlowSystemEditorWindow flowEditor, string prefix, GenericMenu menu) {
			
			var flowAddons = CoreUtilities.GetAddons<IWindowFlowAddon>();
			foreach (var addon in flowAddons) {
				
				addon.flowEditor = flowEditor;
				addon.OnFlowToolsMenuGUI(prefix, menu);
				
			}
			
		}
Esempio n. 6
0
		public static void OnDrawToolbarGUI(FlowSystemEditorWindow flowEditor, GUIStyle buttonStyle) {
			
			var flowAddons = CoreUtilities.GetAddons<IWindowFlowAddon>();
			foreach (var addon in flowAddons) {
				
				addon.flowEditor = flowEditor;
				addon.OnFlowToolbarGUI(buttonStyle);
				
			}
			
		}
Esempio n. 7
0
		public static void OnDrawSettingsGUI(FlowSystemEditorWindow flowEditor) {
			
			var flowAddons = CoreUtilities.GetAddons<FlowAddon>((name, item) => item.name = name);
			if (flowAddons.Count == 0) {

				GUILayout.Label("No Modules Have Been Installed.");

			} else {

				foreach (var addon in flowAddons) {

					Profiler.BeginSample("[ GUI ] Addon " + addon.name);

					addon.flowEditor = flowEditor;
					Flow.DrawModuleSettingsGUI(addon, addon.GetName(), addon.GetSettingsMenu(null), () => { addon.OnFlowSettingsGUI(); });
					
					Profiler.EndSample();

				}
			
			}

			CustomGUI.Splitter();

			GUILayout.BeginHorizontal();
			{
				
				GUILayout.FlexibleSpace();

				if (GUILayoutExt.LargeButton("Install Modules...", 40f, 200f) == true) {

					Application.OpenURL(VersionInfo.DOWNLOAD_LINK);

				}

				GUILayout.FlexibleSpace();

			}
			GUILayout.EndHorizontal();

		}
Esempio n. 8
0
		public static void OnDrawWindowGUI(FlowSystemEditorWindow flowEditor, FD.FlowWindow window) {
			
			var flowAddons = CoreUtilities.GetAddons<IWindowFlowAddon>();
			foreach (var addon in flowAddons) {
				
				addon.flowEditor = flowEditor;
				addon.OnFlowWindowGUI(window);
				
			}
			
		}
Esempio n. 9
0
		public static Vector2 OnDrawNodeCurveOffset(FlowSystemEditorWindow flowEditor, UnityEngine.UI.Windows.AttachItem attachItem, FD.FlowWindow fromWindow, FD.FlowWindow toWindow, bool doubleSide) {

			var offset = Vector2.zero;

			var flowAddons = CoreUtilities.GetAddons<IWindowFlowAddon>();
			foreach (var addon in flowAddons) {
				
				addon.flowEditor = flowEditor;
				offset += addon.OnFlowDrawNodeCurveOffset(attachItem, fromWindow, toWindow, doubleSide);
				
			}

			return offset;
			
		}
		public static void OnReset(FlowSystemEditorWindow flowEditor) {
			
			var flowAddons = CoreUtilities.GetAddons<IWindowFlowAddon>();
			foreach (var addon in flowAddons) {
				
				addon.flowEditor = flowEditor;
				addon.Reset();
				
			}
			
		}
Esempio n. 11
0
		public static string GenerateTransitionTypedMethod(FlowSystemEditorWindow flowEditor, FD.FlowWindow windowFrom, FD.FlowWindow windowTo, System.Type[] parameters, string[] parameterNames) {
			
			var file = Resources.Load("UI.Windows/Functions/Templates/TemplateTransitionTypedMethod") as TextAsset;
			if (file == null) {
				
				Debug.LogError("Functions Template Loading Error: Could not load template 'TemplateTransitionTypedMethod'");
				
				return string.Empty;
				
			}
			
			var data = FlowSystem.GetData();
			if (data == null) return string.Empty;
			
			var result = string.Empty;
			var part = file.text;
			
			// Function link
			var functionId = windowTo.GetFunctionId();
			
			// Find function container
			var functionContainer = data.GetWindow(functionId);
			if (functionContainer == null) {
				
				// Function not found
				return string.Empty;
				
			}
			
			// Get function root window
			var root = data.GetWindow(functionContainer.functionRootId);
			//var exit = data.GetWindow(functionContainer.functionExitId);
			
			var functionName = functionContainer.title;
			var functionCallName = functionContainer.directory;
			var classNameWithNamespace = Tpl.GetNamespace(root) + "." + Tpl.GetDerivedClassName(root);
			var transitionMethods = Tpl.GenerateTransitionMethods(windowTo);
			transitionMethods = transitionMethods.Replace("\r\n", "\r\n\t")
				.Replace("\n", "\n\t");

			var definition = parameters.Select((x, i) => ME.Utilities.FormatParameter(x) + " " + parameterNames[i]).ToArray();
			var call = parameterNames;
			var description = parameters.Select((x, i) => "/// <param name=\"" + parameterNames[i] + "\">" + parameterNames[i] + " to OnParametersPass</param>").ToArray();

			result +=
				part.Replace("{TRANSITION_METHODS}", transitionMethods)
					.Replace("{FUNCTION_NAME}", functionName)
					.Replace("{FUNCTION_CALL_NAME}", functionCallName)
					.Replace("{FLOW_FROM_ID}", windowFrom.id.ToString())
					.Replace("{FLOW_TO_ID}", windowTo.id.ToString())
					.Replace("{CLASS_NAME_WITH_NAMESPACE}", classNameWithNamespace)
					.Replace("{PARAMETERS_DEFINITION}", string.Join(", ", definition))
					.Replace("{PARAMETERS_CALL}", string.Join(", ", call))
					.Replace("{PARAMETERS_DESCRIPTION}", string.Join(System.Environment.NewLine, description));
			
			return result;
			
		}
		public FlowSceneItem(FlowSystemEditorWindow rootWindow, FlowWindow window, AnimatedValues.AnimFloat progressValue) {

			this.isLocked = false;

			this.rootWindow = rootWindow;
			this.window = window;
			this.currentScene = EditorApplication.currentScene;
			this.layouts = new List<WindowLayout>();
			this.layoutPrefab = null;

			this.screens = new List<WindowBase>();
			this.screenPrefab = null;

			#if UNITY_5_0
			EditorApplication.NewEmptyScene();
			#else
			EditorApplication.NewScene();
			#endif

			var popupOffset = 100f;
			var popupSize = new Vector2(rootWindow.position.width - popupOffset * 2f, rootWindow.position.height - popupOffset * 2f);
			var popupRect = new Rect(rootWindow.position.x + popupOffset, rootWindow.position.y + popupOffset, popupSize.x, popupSize.y);

			this.view = FlowSceneViewWindow.CreateInstance<FlowSceneViewWindow>();
			FlowSceneView.recompileChecker = this.view;

			var title = "UI.Windows Flow Screen Editor ('{0}')";
			title = string.Format(title, this.window.title);
			#if !UNITY_4
			this.view.titleContent = new GUIContent(string.Format(title, this.window.title));
			#else
			this.view.title = string.Format(title, this.window.title);
			#endif
			this.view.position = popupRect;
			this.view.rootWindow = rootWindow;
			
			/*this.inspector = FlowInspectorWindow.CreateInstance<FlowInspectorWindow>();
			this.inspector.position = popupRect;
			this.inspector.rootWindow = rootWindow;
			this.inspector.Repaint();
			this.inspector.Focus();
			
			this.hierarchy = FlowHierarchyWindow.CreateInstance<FlowHierarchyWindow>();
			this.hierarchy.position = popupRect;
			this.hierarchy.rootWindow = rootWindow;
			this.hierarchy.Repaint();
			this.hierarchy.Focus();*/

			this.Show();

			//this.inspector.Repaint();
			//this.inspector.Focus();
			//this.hierarchy.Repaint();
			//this.hierarchy.Focus();
			this.view.Repaint();
			this.view.Focus();

			this.autoloadedScreen = false;
			this.ReloadScreens();
			this.autoloadedLayout = false;
			this.ReloadLayouts();

			this.defaultRects = false;

			progressValue.valueChanged.AddListener(() => {
				
				this.view.DrawProgress(progressValue.value);
				//this.inspector.DrawProgress(progressValue.value);
				//this.hierarchy.DrawProgress(progressValue.value);

				if (progressValue.value == progressValue.target) {
					
					this.view.Repaint();
					this.view.Focus();

				}

			});

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

			}

		}
Esempio n. 14
0
		public static void OnFlowWindowTransition(FlowSystemEditorWindow flowEditor, int index, FD.FlowWindow fromWindow, FD.FlowWindow toWindow, bool doubleSided, Vector2 centerOffset) {
			
			var flowAddons = CoreUtilities.GetAddons<IWindowFlowAddon>();
			foreach (var addon in flowAddons) {
				
				addon.flowEditor = flowEditor;
				addon.OnFlowWindowTransition(index, fromWindow, toWindow, doubleSided, centerOffset);
				
			}
			
		}
		public static void OnFlowWindowScreenMenuGUI(FlowSystemEditorWindow flowEditor, FD.FlowWindow window, GenericMenu menu) {
			
			var flowAddons = CoreUtilities.GetAddons<IWindowFlowAddon>();
			foreach (var addon in flowAddons) {
				
				addon.flowEditor = flowEditor;
				addon.OnFlowWindowScreenMenuGUI(window, menu);
				
			}

		}
Esempio n. 16
0
		public GUIDrawer(FlowSystemEditorWindow editor) {

			this.editor = editor;

		}
		public static void SetControl(FlowSystemEditorWindow rootWindow, FD.FlowWindow window, System.Action<float> onProgress) {

			#if UNITY_5_2
			if (EditorApplication.SaveCurrentSceneIfUserWantsTo() == true) {
			#else
			if (UnityEditor.SceneManagement.EditorSceneManager.SaveCurrentModifiedScenesIfUserWantsTo() == true) {
			#endif

				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;

			}

		}