/// <inheritdoc /> public void Draw(Rect windowRect) { #if CREATOR_PRO // Do not show when user is not logged in. if (UserAccount.IsAccountLoggedIn() == false) { return; } #endif IChapter chapter = GlobalEditorHandler.GetCurrentChapter(); if (chapter != null && (chapter.Data.FirstStep == null && chapter.Data.Steps.Count == 0)) { GUIStyle style = new GUIStyle(EditorStyles.label); style.normal.textColor = new Color(1, 1, 1, 0.70f); style.alignment = TextAnchor.MiddleCenter; style.fontSize = 20; GUIStyle backgroundStyle = new GUIStyle(GUI.skin.box); backgroundStyle.normal.background = backgroundTexture; Rect positionalRect = new Rect(windowRect.x + (windowRect.width / 2) - (width / 2), windowRect.y + (windowRect.height / 2) - (height / 2), width, height); GUI.Box(positionalRect, "", backgroundStyle); GUI.Label(positionalRect, "Right-click to create new step", style); } }
private void OnFocus() { if (EditorConfigurator.Instance.Validation.IsAllowedToValidate() && activeCourse != null) { EditorConfigurator.Instance.Validation.Validate(activeCourse.Data, GlobalEditorHandler.GetCurrentCourse()); } }
public void SetChapter(IChapter chapter) { if (chapter != GlobalEditorHandler.GetCurrentChapter()) { GlobalEditorHandler.SetCurrentChapter(chapter); } CurrentChapter = chapter; Graphics.Reset(); Grid = new WorkflowEditorGrid(Graphics, gridCellSize); Graphics.Canvas.ContextClick += HandleCanvasContextClick; EntryNode entryNode = CreateEntryNode(chapter); IDictionary <IStep, StepNode> stepNodes = SetupSteps(chapter); SetupTransitions(chapter, entryNode, stepNodes); Graphics.CalculateBoundingBox(); if (EditorConfigurator.Instance.Validation.IsAllowedToValidate()) { EditorConfigurator.Instance.Validation.Validate(CurrentChapter.Data, GlobalEditorHandler.GetCurrentCourse(), null); } }
private void DrawCourseSelectionDropDown() { int index = 0; string courseName = CourseAssetUtils.GetCourseNameFromPath(configurator.GetSelectedCourse()); if (string.IsNullOrEmpty(courseName) == false) { index = trainingCourseDisplayNames.FindIndex(courseName.Equals); } index = EditorGUILayout.Popup("Selected Training Course", index, trainingCourseDisplayNames.ToArray()); if (index < 0) { index = 0; } string newCourseStreamingAssetsPath = CourseAssetUtils.GetCourseStreamingAssetPath(trainingCourseDisplayNames[index]); if (IsCourseListEmpty() == false && configurator.GetSelectedCourse() != newCourseStreamingAssetsPath) { SetConfiguratorSelectedCourse(newCourseStreamingAssetsPath); GlobalEditorHandler.SetCurrentCourse(trainingCourseDisplayNames[index]); } }
private void OnEnable() { wantsMouseMove = true; if (chapterMenu == null) { chapterMenu = CreateInstance <TrainingMenuView>(); } if (chapterRepresentation == null) { #if CREATOR_PRO chapterRepresentation = new ProChapterRepresentation(); #else chapterRepresentation = new ChapterRepresentation(); #endif chapterRepresentation.Graphics.Canvas.PointerDrag += (o, eventArgs) => currentScrollPosition -= eventArgs.PointerDelta; } if (titleIcon == null) { titleIcon = new EditorIcon("icon_training_editor"); } EditorSceneManager.newSceneCreated += OnNewScene; EditorSceneManager.sceneOpened += OnSceneOpened; GlobalEditorHandler.CourseWindowOpened(this); }
private void UpdateAvailableCourses() { if (isDirty == false) { return; } List <string> courses = CourseAssetUtils.GetAllCourses().ToList(); // Create dummy entry if no files are present. if (courses.Any() == false) { trainingCourseDisplayNames.Clear(); trainingCourseDisplayNames.Add("<none>"); return; } trainingCourseDisplayNames = courses; trainingCourseDisplayNames.Sort(); if (string.IsNullOrEmpty(configurator.GetSelectedCourse())) { SetConfiguratorSelectedCourse(CourseAssetUtils.GetCourseStreamingAssetPath(trainingCourseDisplayNames[0])); GlobalEditorHandler.SetCurrentCourse(CourseAssetUtils.GetCourseAssetPath(configurator.GetSelectedCourse())); } }
/// <summary> /// Sets the course with given <paramref name="courseName"/> for the current scene. /// </summary> /// <param name="courseName">Name of the course.</param> public static void SetCourseInCurrentScene(string courseName) { RuntimeConfigurator.Instance.SetSelectedCourse(CourseAssetUtils.GetCourseStreamingAssetPath(courseName)); EditorSceneManager.MarkSceneDirty(SceneManager.GetActiveScene()); GlobalEditorHandler.SetCurrentCourse(courseName); GlobalEditorHandler.StartEditingCourse(); }
public override void OnInspectorGUI() { serializedObject.Update(); // Courses can change without recompile so we have to check for them. UpdateAvailableCourses(); DrawRuntimeConfigurationDropDown(); EditorGUI.BeginDisabledGroup(IsCourseListEmpty()); { DrawCourseSelectionDropDown(); GUILayout.BeginHorizontal(); { if (GUILayout.Button("Open Course in Workflow window")) { GlobalEditorHandler.SetCurrentCourse(CourseAssetUtils.GetCourseNameFromPath(configurator.GetSelectedCourse())); GlobalEditorHandler.StartEditingCourse(); } if (GUILayout.Button(new GUIContent("Show Course in Explorer..."))) { string absolutePath = $"{new FileInfo(CourseAssetUtils.GetCourseAssetPath(CourseAssetUtils.GetCourseNameFromPath(configurator.GetSelectedCourse())))}"; EditorUtility.RevealInFinder(absolutePath); } } GUILayout.EndHorizontal(); } EditorGUI.EndDisabledGroup(); serializedObject.ApplyModifiedProperties(); }
protected override void AdditionalTeardown() { if (EditorUtils.IsWindowOpened <StepWindow>()) { EditorWindow.GetWindow <StepWindow>().Close(); } base.AdditionalTeardown(); GlobalEditorHandler.SetDefaultStrategy(); }
protected override void AdditionalTeardown() { base.AdditionalTeardown(); foreach (CourseCreationWizard window in Resources.FindObjectsOfTypeAll <CourseCreationWizard>()) { window.Close(); } CourseAssetManager.Delete(courseName); GlobalEditorHandler.SetDefaultStrategy(); }
private void DeleteStep(IStep step) { if (CurrentChapter.ChapterMetadata.LastSelectedStep == step) { CurrentChapter.ChapterMetadata.LastSelectedStep = null; GlobalEditorHandler.ChangeCurrentStep(null); } CurrentChapter.Data.Steps.Remove(step); MarkToRefresh(); }
private void OnGUI() { // Magic number. minSize = new Vector2(420f, 320f); titleContent = new GUIContent("Training Course Wizard"); GUIStyle labelStyle = new GUIStyle(EditorStyles.label); labelStyle.richText = true; labelStyle.wordWrap = true; EditorIcon logo = new EditorIcon("logo_creator"); Rect rect = GUILayoutUtility.GetRect(position.width, 150, GUI.skin.box); GUI.DrawTexture(rect, logo.Texture, ScaleMode.ScaleToFit); if (RuntimeConfigurator.Exists == false) { EditorGUILayout.HelpBox("The current scene is not a training scene. No course can be created. To automatically setup the scene, select \"Innoactive > Setup Training Scene\".", MessageType.Error); } EditorGUI.BeginDisabledGroup(RuntimeConfigurator.Exists == false); EditorGUILayout.LabelField("<b>Create a new training course.</b>", labelStyle); courseName = EditorGUILayout.TextField(new GUIContent("Training Course Name", "Set a file name for the new training course."), courseName); EditorGUILayout.LabelField("The new course will be set for the current scene."); GUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); // ReSharper disable once InvertIf if (GUILayout.Button("Create", GUILayout.Width(128), GUILayout.Height(32))) { if (CourseAssetUtils.CanCreate(courseName, out errorMessage)) { CourseAssetManager.Import(EntityFactory.CreateCourse(courseName)); RuntimeConfigurator.Instance.SetSelectedCourse(CourseAssetUtils.GetCourseStreamingAssetPath(courseName)); EditorSceneManager.MarkSceneDirty(EditorSceneManager.GetActiveScene()); GlobalEditorHandler.SetCurrentCourse(courseName); GlobalEditorHandler.StartEditingCourse(); Close(); } } EditorGUI.EndDisabledGroup(); GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); if (string.IsNullOrEmpty(errorMessage) == false) { EditorGUILayout.HelpBox(errorMessage, MessageType.Error); } }
private void OnFocus() { if (step?.Data == null) { return; } if (EditorConfigurator.Instance.Validation.IsAllowedToValidate()) { EditorConfigurator.Instance.Validation.Validate(step.Data, GlobalEditorHandler.GetCurrentCourse()); } }
public override void Draw() { EditorDrawingHelper.DrawRoundedRect(Owner.BoundingBox, CurrentColor, 10f); IValidationHandler validation = EditorConfigurator.Instance.Validation; if (validation.IsAllowedToValidate()) { IContextResolver resolver = validation.ContextResolver; IContext context = resolver.FindContext(Owner.Step.Data, GlobalEditorHandler.GetCurrentCourse()); if (validation.LastReport != null) { List <EditorReportEntry> errors = validation.LastReport.GetEntriesFor(context); if (errors.Count > 0) { string tooltip = ValidationTooltipGenerator.CreateStepTooltip(errors, resolver.FindContext(Owner.ActiveChapter.Data, GlobalEditorHandler.GetCurrentCourse())); GUIContent content = new GUIContent("", null, tooltip); Rect rect = new Rect(Owner.BoundingBox.x + Owner.BoundingBox.width * 0.70f, Owner.BoundingBox.y - 8, 16, 16); // Label icons are too small so we draw a label for the tool tip and icon separated. GUI.Label(rect, content); GUI.DrawTexture(rect, EditorGUIUtility.IconContent("Warning").image); } } } float labelX = Owner.BoundingBox.x + labelBorderOffsetInwards; float labelY = Owner.BoundingBox.y + labelBorderOffsetInwards; float labelWidth = Owner.BoundingBox.width - labelBorderOffsetInwards * 2f; float labelHeight = Owner.BoundingBox.height - labelBorderOffsetInwards * 2f; Rect labelPosition = new Rect(labelX, labelY, labelWidth, labelHeight); GUIStyle labelStyle = new GUIStyle { alignment = TextAnchor.MiddleCenter, normal = { textColor = TextColor }, wordWrap = false, }; string name = EditorDrawingHelper.TruncateText(Owner.Step.Data.Name, labelStyle, labelPosition.width); GUIContent labelContent = new GUIContent(name); GUI.Label(labelPosition, labelContent, labelStyle); }
protected override CourseCreationWizard Given() { GlobalEditorHandler.SetStrategy(new EmptyTestStrategy()); CourseAssetManager.Delete(courseName); foreach (CourseCreationWizard window in Resources.FindObjectsOfTypeAll <CourseCreationWizard>()) { window.Close(); } CourseCreationWizard wizard = ScriptableObject.CreateInstance <CourseCreationWizard>(); wizard.ShowUtility(); wizard.maxSize = wizard.minSize; wizard.position = new Rect(Vector2.zero, wizard.minSize); return(wizard); }
private void SelectStepNode(StepNode stepNode) { IStep step = stepNode == null ? null : stepNode.Step; if (lastSelectedStepNode != null) { lastSelectedStepNode.IsLastSelectedStep = false; } lastSelectedStepNode = stepNode; CurrentChapter.ChapterMetadata.LastSelectedStep = step; if (stepNode != null) { stepNode.IsLastSelectedStep = true; } GlobalEditorHandler.ChangeCurrentStep(step); }
/// <inheritdoc /> protected override CourseWindow Given() { if (EditorUtils.IsWindowOpened <CourseWindow>()) { EditorWindow.GetWindow <CourseWindow>().Close(); } GlobalEditorHandler.SetStrategy(new EmptyTestStrategy()); EditorUtils.ResetKeyboardElementFocus(); CourseWindow window = ScriptableObject.CreateInstance <CourseWindow>(); window.ShowUtility(); window.position = new Rect(Vector2.zero, window.position.size); window.minSize = window.maxSize = new Vector2(1024f, 512f); window.SetCourse(new Course("Test", new Chapter("Test", null))); window.Focus(); return(window); }
/// <inheritdoc /> protected override StepWindow Given() { if (EditorUtils.IsWindowOpened <StepWindow>()) { EditorWindow.GetWindow <StepWindow>().Close(); } GlobalEditorHandler.SetStrategy(new EmptyTestStrategy()); EditorUtils.ResetKeyboardElementFocus(); StepWindow window = ScriptableObject.CreateInstance <StepWindow>(); window.ShowUtility(); window.position = new Rect(Vector2.zero, window.position.size); window.minSize = window.maxSize = new Vector2(512f, 512f); window.SetStep(StepFactory.Instance.Create("Test")); window.Focus(); return(window); }
/// <inheritdoc /> public override void Undo() { base.Undo(); GlobalEditorHandler.CurrentCourseModified(); }
private void OnEnable() { GlobalEditorHandler.StepWindowOpened(this); }
private void OnDestroy() { GlobalEditorHandler.StepWindowClosed(this); }
private void ModifyStep(object newStep) { step = (IStep)newStep; GlobalEditorHandler.CurrentStepModified(step); }
private void OnDestroy() { EditorSceneManager.newSceneCreated -= OnNewScene; EditorSceneManager.sceneOpened -= OnSceneOpened; GlobalEditorHandler.CourseWindowClosed(this); }
private void UserSelectStepNode(StepNode stepNode) { SelectStepNode(stepNode); Graphics.BringToTop(stepNode); GlobalEditorHandler.StartEditingStep(); }
private static string[] OnWillSaveAssets(string[] paths) { GlobalEditorHandler.ProjectIsGoingToSave(); return(paths); }