public TriggerSceneEffectEditor() { scenes = Controller.Instance.IdentifierSummary.getIds <IChapterTarget>(); this.effect = new TriggerSceneEffect(scenes[0], 400, 300) { DestinyScale = 1 }; SetDestinyScene(0); localSceneEditor = new SceneEditor(); playerDestination = new Trajectory.Node("", 0, 0, 1f); localSceneEditor.Elements = new List <DataControl>() { new NodeDataControl(null, playerDestination, new Trajectory()) }; transitionTypes = new string[] { TC.get("NextScene.NoTransition"), TC.get("NextScene.TopToBottom"), TC.get("NextScene.BottomToTop"), TC.get("NextScene.LeftToRight"), TC.get("NextScene.RightToLeft"), TC.get("NextScene.FadeIn") }; }
public SceneEditorWindow(Rect rect, GUIContent content, GUIStyle style, SceneEditor sceneEditor, params GUILayoutOption[] options) : base(rect, content, style, options) { this.sceneEditor = sceneEditor; this.sceneEditor.onSelectElement += (s) => { selectedElement = s; }; }
public ExitPlayerPositionComponent(Rect rect, GUIContent content, GUIStyle style, params GUILayoutOption[] options) : base(rect, content, style, options) { localSceneEditor = new SceneEditor(); playerDestination = new Trajectory.Node("", 0, 0, 1f); localSceneEditor.Elements = new List <DataControl>() { new NodeDataControl(null, playerDestination, new Trajectory()) }; }
public override void OnRender() { var side = Target as SideDataControl; var p1 = GetPivot(side.getStart()); var p2 = GetPivot(side.getEnd()); HandleUtil.DrawPolyLine(new Vector2[] { p1, p2 }, false, SceneEditor.GetColor(Color.black), 5f); HandleUtil.DrawPolyLine(new Vector2[] { p1, p2 }, false, SceneEditor.GetColor(Color.white), 3f); var bcColor = GUI.color; if (side.getLength() != side.getRealLength()) { GUI.color = SceneEditor.GetColor(Color.yellow); } EditorGUI.DropShadowLabel(new Rect(((p1 + p2) / 2f) - new Vector2(100f, 25f), new Vector2(200, 30)), new GUIContent(Mathf.RoundToInt(side.getLength()).ToString())); GUI.color = bcColor; }
public ScenesWindowBarriers(Rect aStartPos, GUIContent aContent, GUIStyle aStyle, SceneEditor sceneEditor, params GUILayoutOption[] aOptions) : base(aStartPos, aContent, aStyle, sceneEditor, aOptions) { conditionsTex = Resources.Load <Texture2D>("EAdventureData/img/icons/conditions-24x24"); noConditionsTex = Resources.Load <Texture2D>("EAdventureData/img/icons/no-conditions-24x24"); PreviewTitle = "Scene.Preview".Traslate(); barriersList = new DataControlList() { RequestRepaint = Repaint, elementHeight = 20, Columns = new List <ColumnList.Column>() { new ColumnList.Column() // Layer column { Text = TC.get("Barriers.Name"), SizeOptions = new GUILayoutOption[] { GUILayout.ExpandWidth(true) } }, new ColumnList.Column() // Enabled Column { Text = TC.get("Conditions.Title"), SizeOptions = new GUILayoutOption[] { GUILayout.ExpandWidth(true) } } }, drawCell = (columnRect, row, column, isActive, isFocused) => { var element = barriersList.list[row] as BarrierDataControl; switch (column) { case 0: EditorGUI.LabelField(columnRect, "Barrier: " + (row + 1)); break; case 1: if (GUI.Button(columnRect, element.getConditions().getBlocksCount() > 0 ? conditionsTex : noConditionsTex)) { barriersList.index = row; ConditionEditorWindow window = ScriptableObject.CreateInstance <ConditionEditorWindow>(); window.Init(element.getConditions()); } break; } }, onSelectCallback = (list) => { sceneEditor.SelectedElement = barriersList.list[list.index] as BarrierDataControl; }, onRemoveCallback = (list) => { sceneEditor.SelectedElement = null; } }; sceneEditor.onSelectElement += (element) => { if (element is BarrierDataControl) { barriersList.index = barriersList.list.IndexOf(element as BarrierDataControl); } else { barriersList.index = -1; } }; }
public ScenesWindowAppearance(Rect aStartPos, GUIContent aContent, GUIStyle aStyle, SceneEditor sceneEditor, params GUILayoutOption[] aOptions) : base(aStartPos, aContent, aStyle, sceneEditor, aOptions) { appearanceEditor = ScriptableObject.CreateInstance <AppearanceEditor>(); appearanceEditor.height = 160; appearanceEditor.onAppearanceSelected = sceneEditor.RefreshSceneResources; PreviewTitle = "Scene.Preview".Traslate(); // Fields background = new FileChooser() { Label = TC.get("Resources.DescriptionSceneBackground"), FileType = FileType.SCENE_BACKGROUND, Empty = SpecialAssetPaths.ASSET_EMPTY_BACKGROUND }; foreground = new FileChooser() { Label = TC.get("Resources.DescriptionSceneForeground"), FileType = FileType.SCENE_FOREGROUND }; music = new FileChooser() { Label = TC.get("Resources.DescriptionSceneMusic"), FileType = FileType.SCENE_MUSIC }; }
public ScenesWindowDocumentation(Rect aStartPos, GUIContent aContent, GUIStyle aStyle, SceneEditor sceneEditor, params GUILayoutOption[] aOptions) : base(aStartPos, aContent, aStyle, aOptions) { }
public ScenesWindowElementReference(Rect aStartPos, GUIContent aContent, GUIStyle aStyle, SceneEditor sceneEditor, params GUILayoutOption[] aOptions) : base(aStartPos, aContent, aStyle, sceneEditor, aOptions) { new ReferenceComponent(Rect.zero, new GUIContent(""), aStyle); PreviewTitle = "Scene.Preview".Traslate(); referenceList = new ReferenceList() { onSelectCallback = (list) => { sceneEditor.SelectedElement = (referenceList.list[list.index] as ElementContainer).getErdc(); }, onRemoveCallback = (list) => { sceneEditor.SelectedElement = null; } }; sceneEditor.onSelectElement += (element) => { if (element is ElementReferenceDataControl) { var erdc = element as ElementReferenceDataControl; referenceList.index = referenceList.list.Cast <ElementContainer>().Select(e => e.getErdc()).ToList().IndexOf(erdc); } else { referenceList.index = -1; } }; }
public ScenesWindow(Rect rect, GUIStyle style, params GUILayoutOption[] options) : base(rect, new GUIContent(TC.get("Element.Name1")), style, options) { new RectangleComponentEditor(Rect.zero, new GUIContent(""), style); // Button ButtonContent = new GUIContent() { image = Resources.Load <Texture2D>("EAdventureData/img/icons/scenes"), text = "Element.Name1" }; sceneEditor = new SceneEditor(); sceneEditor.onSelectElement += (element) => { if (sceneEditor.SelectedElement == null) { return; } switch (sceneEditor.SelectedElement.ToString()) { case "uAdventure.Editor.ExitDataControl": this.OpenedWindow = ScenesWindowType.Exits; break; case "uAdventure.Editor.ElementReferenceDataControl": this.OpenedWindow = ScenesWindowType.ElementReference; break; case "uAdventure.Editor.BarrierDataControl": this.OpenedWindow = ScenesWindowType.Barriers; break; case "uAdventure.Editor.ActiveAreaDataControl": this.OpenedWindow = ScenesWindowType.ActiveAreas; break; } }; // Chapter preview subwindow chapterPreview = new ChapterPreview(rect, new GUIContent(""), "Window") { OnRequestRepaint = () => Repaint(), BeginWindows = () => BeginWindows(), EndWindows = () => EndWindows() }; chapterPreview.OnSelectElement += (scene) => { var index = Controller.Instance.SelectedChapterDataControl.getScenesList().getScenes().FindIndex(s => s == scene as SceneDataControl); ShowItemWindowView(index); }; // Windows CreateSceneEditorTab <ScenesWindowAppearance>(rect, new GUIContent(TC.get("Scene.LookPanelTitle")), "Window", ScenesWindowType.Appearance, sceneEditor); CreateSceneEditorTab <ScenesWindowDocumentation>(rect, new GUIContent(TC.get("Scene.DocPanelTitle")), "Window", ScenesWindowType.Documentation, sceneEditor); CreateSceneEditorTab <ScenesWindowElementReference>(rect, new GUIContent(TC.get("ItemReferencesList.Title")), "Window", ScenesWindowType.ElementReference, sceneEditor); CreateSceneEditorTab <ScenesWindowActiveAreas>(rect, new GUIContent(TC.get("ActiveAreasList.Title")), "Window", ScenesWindowType.ActiveAreas, sceneEditor); CreateSceneEditorTab <ScenesWindowExits>(rect, new GUIContent(TC.get("ExitsList.Title")), "Window", ScenesWindowType.Exits, sceneEditor); if (Controller.Instance.PlayerMode == DescriptorData.MODE_PLAYER_3RDPERSON) { CreateSceneEditorTab <ScenesWindowBarriers>(rect, new GUIContent(TC.get("BarriersList.Title")), "Window", ScenesWindowType.Barriers, sceneEditor); CreateSceneEditorTab <ScenesWindowPlayerMovement>(rect, new GUIContent(TC.get("Trajectory.Title")), "Window", ScenesWindowType.PlayerMovement, sceneEditor); } DefaultOpenedWindow = ScenesWindowType.Appearance; OpenedWindow = ScenesWindowType.Appearance; }
private void CreateSceneEditorTab <T>(Rect rect, GUIContent title, GUIStyle style, Enum identifier, SceneEditor sceneEditor) where T : LayoutWindow { var sceneEditorTab = (T)Activator.CreateInstance(typeof(T), rect, title, style, sceneEditor, new GUILayoutOption[0]); sceneEditorTab.OnRequestRepaint = Repaint; AddTab(title.text, identifier, sceneEditorTab); }
public override void OnDrawingGizmos() { var trajectory = Target as TrajectoryDataControl; if (trajectory == null) { return; } if (SceneEditor.Current.Disabled && pairing != null) { pairing = null; } if (previousTrajectoryDataControl != trajectory) { previousTrajectoryDataControl = trajectory; pairing = null; } if (Event.current.type == EventType.MouseDown) { var selected = SceneEditor.Current.SelectedElement; var node = selected as NodeDataControl; var side = selected as SideDataControl; var isNode = node != null && trajectory.getNodes().Contains(node); var isSide = side != null && trajectory.getSides().Contains(side); switch (Action) { // Moving case 1: if (SceneEditor.Current.SelectedElement == null) { var pos = (Event.current.mousePosition - SceneEditor.Current.Viewport.position); pos.x = (pos.x / SceneEditor.Current.Viewport.size.x) * SceneEditor.Current.Size.x; pos.y = (pos.y / SceneEditor.Current.Viewport.size.y) * SceneEditor.Current.Size.y; trajectory.addNode(Mathf.RoundToInt(pos.x), Mathf.RoundToInt(pos.y)); } break; // Pariring case 2: if (isNode) { if (pairing == null) { pairing = node; } else { var duplicated = trajectory.getSides().Find(s => IsPairingStartOrEnd(s, node)) != null; if (!duplicated) { trajectory.addSide(pairing, node); } pairing = null; } } else { pairing = null; } break; // Initial case 3: if (isNode) { trajectory.setInitialNode(node); } break; // Deleting case 4: if ((isNode || isSide) && trajectory.deleteElement(selected, false)) { SceneEditor.Current.SelectedElement = null; } break; } } foreach (var node in trajectory.getNodes()) { HandleUtil.DrawPoint(GetPivot(node), 10f, SceneEditor.GetColor(node.isInitial() ? Color.red : Color.blue), SceneEditor.GetColor(Color.black)); } if (pairing != null) { HandleUtil.DrawPolyLine(new Vector2[] { GetPivot(pairing), Event.current.mousePosition }, false, SceneEditor.GetColor(Color.white), 3f); } }
public override void OnDrawingGizmosSelected() { var rect = ScenesWindowElementReference.ReferenceComponent.GetElementRect(Target); // Rect resizing var id = GUIUtility.GetControlID(GetHashCode(), FocusType.Passive); EditorGUI.BeginChangeCheck(); var newRect = HandleUtil.HandleFixedRatioRect(id, rect, rect.width / rect.height, 10f, (polygon, over, active) => HandleUtil.DrawPolyLine(polygon, true, SceneEditor.GetColor(Color.red)), (point, over, active) => HandleUtil.DrawPoint(point, 4.5f, SceneEditor.GetColor(Color.blue), SceneEditor.GetColor(Color.black))); if (EditorGUI.EndChangeCheck()) { var original = newRect.ViewportToScreen(SceneEditor.Current.Size.x, SceneEditor.Current.Size.y, SceneEditor.Current.Viewport); var unscaled = ScenesWindowElementReference.ReferenceComponent.GetUnscaledRect(Target); // And then we rip the position var position = original.center + new Vector2(0, original.height / 2f); var scale = original.size.magnitude / unscaled.size.magnitude; if (Target is PlayerDataControl) { var workingScene = Controller.Instance.SelectedChapterDataControl.getScenesList().getScenes()[ GameRources.GetInstance().selectedSceneIndex]; // And then we set the values in the reference workingScene.setDefaultInitialPosition(Mathf.RoundToInt(position.x), Mathf.RoundToInt(position.y)); workingScene.setPlayerScale(scale); } else if (Target is NodeDataControl) { var node = Target as NodeDataControl; node.setNode(Mathf.RoundToInt(position.x), Mathf.RoundToInt(position.y), scale); } } // Rect movement var movementId = GUIUtility.GetControlID(GetHashCode() + 1, FocusType.Passive); EditorGUI.BeginChangeCheck(); rect = HandleUtil.HandleRectMovement(movementId, rect); if (EditorGUI.EndChangeCheck()) { var original = rect.ViewportToScreen(SceneEditor.Current.Size.x, SceneEditor.Current.Size.y, SceneEditor.Current.Viewport); var rectBase = original.Base(); if (Target is PlayerDataControl) { var workingScene = Controller.Instance.SelectedChapterDataControl.getScenesList().getScenes()[GameRources.GetInstance().selectedSceneIndex]; workingScene.setDefaultInitialPosition(Mathf.RoundToInt(rectBase.x), Mathf.RoundToInt(rectBase.y)); } else if (Target is NodeDataControl) { var node = Target as NodeDataControl; node.setNode(Mathf.RoundToInt(rectBase.x), Mathf.RoundToInt(rectBase.y), node.getScale()); } } }
public ScenesWindowPlayerMovement(Rect aStartPos, GUIContent aContent, GUIStyle aStyle, SceneEditor sceneEditor, params GUILayoutOption[] aOptions) : base(aStartPos, aContent, aStyle, sceneEditor, aOptions) { new PlayerInitialPositionComponent(Rect.zero, new GUIContent(), null); new SideComponent(Rect.zero, new GUIContent(), null); PreviewTitle = "PlayerMovement.Preview".Traslate(); trajectoryComponent = new TrajectoryComponent(Rect.zero, new GUIContent(), null) { Action = -1 }; if (Controller.Instance.PlayerMode == DescriptorData.MODE_PLAYER_3RDPERSON) { // Creating this component registers it in the scene editor new InfluenceComponent(Rect.zero, new GUIContent(""), aStyle); } sceneEditor.TypeEnabling[typeof(Player)] = false; sceneEditor.TypeEnabling[typeof(TrajectoryDataControl)] = false; sceneEditor.TypeEnabling[typeof(SideDataControl)] = false; sceneEditor.TypeEnabling[typeof(NodeDataControl)] = false; tools = new GUIContent[] { new GUIContent("SceneEditor.PlayerTrajectory.None"), new GUIContent(Resources.Load <Texture2D>("EAdventureData/img/icons/nodeEdit"), "SceneEditor.PlayerTrajectory.Edit"), new GUIContent(Resources.Load <Texture2D>("EAdventureData/img/icons/sideEdit"), "SceneEditor.PlayerTrajectory.AddSide"), new GUIContent(Resources.Load <Texture2D>("EAdventureData/img/icons/selectStartNode"), "SceneEditor.PlayerTrajectory.StartNode"), new GUIContent(Resources.Load <Texture2D>("EAdventureData/img/icons/deleteTool"), "SceneEditor.PlayerTrajectory.Delete") }; }
public ScenesWindowExits(Rect aStartPos, GUIContent aContent, GUIStyle aStyle, SceneEditor sceneEditor, params GUILayoutOption[] aOptions) : base(aStartPos, aContent, aStyle, sceneEditor, aOptions) { new ExitTransitionComponent(Rect.zero, new GUIContent(""), aStyle); new ExitAppearanceComponent(Rect.zero, new GUIContent(""), aStyle); new ExitConditionsAndEffectsComponent(Rect.zero, new GUIContent(""), aStyle); new ExitPlayerPositionComponent(Rect.zero, new GUIContent(""), aStyle); conditionsTex = Resources.Load <Texture2D>("EAdventureData/img/icons/conditions-24x24"); noConditionsTex = Resources.Load <Texture2D>("EAdventureData/img/icons/no-conditions-24x24"); exitsList = new DataControlList() { RequestRepaint = Repaint, elementHeight = 20, Columns = new List <ColumnList.Column>() { new ColumnList.Column() // Layer column { Text = TC.get("ExitsList.NextScene"), SizeOptions = new GUILayoutOption[] { GUILayout.ExpandWidth(true) } }, new ColumnList.Column() // Enabled Column { Text = TC.get("Conditions.Title"), SizeOptions = new GUILayoutOption[] { GUILayout.ExpandWidth(true) } } }, drawCell = (columnRect, row, column, isActive, isFocused) => { var element = exitsList.list[row] as ExitDataControl; switch (column) { case 0: if (isActive) { var selected = sceneNames.ToList().IndexOf(element.getNextSceneId()); EditorGUI.BeginChangeCheck(); var newId = sceneNames[EditorGUI.Popup(columnRect, selected == -1 ? 0 : selected, sceneNames)]; if (EditorGUI.EndChangeCheck()) { element.setNextSceneId(newId == "---" ? "" : newId); } } else { GUI.Label(columnRect, element.getNextSceneId()); } break; case 1: if (GUI.Button(columnRect, element.getConditions().getBlocksCount() > 0 ? conditionsTex : noConditionsTex)) { exitsList.index = row; ConditionEditorWindow window = (ConditionEditorWindow)ScriptableObject.CreateInstance(typeof(ConditionEditorWindow)); window.Init(element.getConditions()); } break; } }, onSelectCallback = (list) => { sceneEditor.SelectedElement = exitsList.list[list.index] as ExitDataControl; }, onRemoveCallback = (list) => { sceneEditor.SelectedElement = null; } }; sceneEditor.onSelectElement += (element) => { if (element is ExitDataControl) { exitsList.index = exitsList.list.IndexOf(element as ExitDataControl); } else { exitsList.index = -1; } }; }
public override void OnDrawingGizmosSelected() { var elemRef = Target as ElementReferenceDataControl; var rect = GetElementRect(elemRef); var id = GUIUtility.GetControlID(GetHashCode(), FocusType.Passive); var newRect = HandleUtil.HandleFixedRatioRect(id, rect, rect.width / rect.height, 10f, (polygon, over, active) => HandleUtil.DrawPolyLine(polygon, true, Color.red, over && MouseOverTexture(elemRef, rect) || active ? 4f : 2f), (point, over, active) => HandleUtil.DrawPoint(point, 4.5f, Color.blue, over || active ? 2f : 1f, SceneEditor.GetColor(over || active ? Color.red : Color.black))); if (newRect != rect) { var original = newRect.ViewportToScreen(SceneEditor.Current.Size.x, SceneEditor.Current.Size.y, SceneEditor.Current.Viewport); var unscaled = ScenesWindowElementReference.ReferenceComponent.GetUnscaledRect(Target); // And then we rip the position var position = original.center + new Vector2(0, original.height / 2f); var scale = original.size.magnitude / unscaled.size.magnitude; // And then we set the values in the reference elemRef.setElementPositionAndScale(Mathf.RoundToInt(position.x), Mathf.RoundToInt(position.y), scale); } var movementId = GUIUtility.GetControlID(GetHashCode() + 1, FocusType.Passive); EditorGUI.BeginChangeCheck(); rect = HandleUtil.HandleRectMovement(movementId, rect); if (EditorGUI.EndChangeCheck()) { var original = rect.ViewportToScreen(SceneEditor.Current.Size.x, SceneEditor.Current.Size.y, SceneEditor.Current.Viewport); elemRef.setElementPosition(Mathf.RoundToInt(original.x + 0.5f * original.width), Mathf.RoundToInt(original.y + original.height)); } }
public ScenesWindowActiveAreas(Rect aStartPos, GUIContent aContent, GUIStyle aStyle, SceneEditor sceneEditor, params GUILayoutOption[] aOptions) : base(aStartPos, aContent, aStyle, sceneEditor, aOptions) { new ActiveAreaActionsComponent(Rect.zero, new GUIContent(""), aStyle); new ActiveAreaDescriptionsComponent(Rect.zero, new GUIContent(""), aStyle); PreviewTitle = "Scene.Preview".Traslate(); conditionsTex = Resources.Load <Texture2D>("EAdventureData/img/icons/conditions-24x24"); noConditionsTex = Resources.Load <Texture2D>("EAdventureData/img/icons/no-conditions-24x24"); activeAreasList = new DataControlList() { RequestRepaint = Repaint, elementHeight = 20, Columns = new List <ColumnList.Column>() { new ColumnList.Column() // Layer column { Text = TC.get("ElementList.Layer"), SizeOptions = new GUILayoutOption[] { GUILayout.Width(50) } }, new ColumnList.Column() // Element name { Text = TC.get("ElementList.Title"), SizeOptions = new GUILayoutOption[] { GUILayout.ExpandWidth(true) } }, new ColumnList.Column() // Enabled Column { Text = TC.get("Conditions.Title"), SizeOptions = new GUILayoutOption[] { GUILayout.ExpandWidth(true) } } }, drawCell = (columnRect, row, column, isActive, isFocused) => { var element = activeAreasList.list[row] as ActiveAreaDataControl; switch (column) { case 0: GUI.Label(columnRect, row.ToString()); break; case 1: if (isActive) { EditorGUI.BeginChangeCheck(); var newId = EditorGUI.DelayedTextField(columnRect, element.getId()); if (EditorGUI.EndChangeCheck()) { element.renameElement(newId); } } else { GUI.Label(columnRect, element.getId()); } break; case 2: if (GUI.Button(columnRect, element.getConditions().getBlocksCount() > 0 ? conditionsTex : noConditionsTex)) { ConditionEditorWindow window = (ConditionEditorWindow)ScriptableObject.CreateInstance(typeof(ConditionEditorWindow)); window.Init(element.getConditions()); } break; } }, onSelectCallback = (list) => { sceneEditor.SelectedElement = activeAreasList.list[list.index] as ExitDataControl; }, onRemoveCallback = (list) => { sceneEditor.SelectedElement = null; } }; sceneEditor.onSelectElement += (element) => { if (element is ActiveAreaDataControl) { activeAreasList.index = activeAreasList.list.IndexOf(element as ActiveAreaDataControl); } else { activeAreasList.index = -1; } }; }