Example #1
0
        private void RenderNode(DialogueEditor editor)
        {
            GUI.SetNextControlName(id.ToString());

            if (node.isLink || ((Node)node).Children.Count == 0)
            {
                EditorGUILayout.SelectableLabel(node.Data.Text, GUILayout.Height(EditorGUIUtility.singleLineHeight));
                //EditorGUILayout.LabelField(node.Data.Text);
                rect = GUILayoutUtility.GetLastRect();
            }
            else
            {
                expanded = EditorGUILayout.Foldout(expanded, node.Data.Text);
                rect     = GUILayoutUtility.GetLastRect();
                if (expanded)
                {
                    EditorGUI.indentLevel++;
                    foreach (BaseNode child in ((Node)node).Children)
                    {
                        RenderNode(editor, child);
                    }
                    EditorGUI.indentLevel--;
                }
            }
        }
Example #2
0
    private static void OPenWindow()
    {
        DialogueEditor window = GetWindow <DialogueEditor>();

        window.titleContent = new GUIContent("Dialogue Editor");
        GUI.FocusControl(null);
    }
Example #3
0
 public static void InitEditorWindow(Object obj)
 {
     currentEditor            = (DialogueEditor)EditorWindow.GetWindow <DialogueEditor>();
     currentEditor.instanceId = obj.GetInstanceID();
     currentEditor.title      = "Node Editor";
     currentEditor.reader     = (DialogueReader)GameObject.FindObjectOfType(typeof(DialogueReader));
 }
    private static void OpenWindow()
    {
        //Generates a 'Custom Dialogue'-Window
        DialogueEditor window = GetWindow <DialogueEditor>();

        window.titleContent = new GUIContent("Custom Dialogue");
    }
Example #5
0
 public override void OnInspectorGUI()
 {
     //DrawDefaultInspector();
     EditorGUILayout.LabelField("Nodes: ", "" + ((Dialogue)target).nodes.Count);
     if (GUILayout.Button("Edit Dialogue"))
     {
         DialogueEditor.InitEditorWindow(target);
     }
 }
Example #6
0
    public DialogueItemWindow(DialogueItem dialogueItem, DialogueEditor parent)
    {
        _dialogue = dialogueItem;
        _parent   = parent;

        //Set default rect if its unitialized
        if (_dialogue.rect == Rect.zero)
        {
            _dialogue.rect = new Rect(10, 10, 200, 150);
        }
    }
Example #7
0
    static void ShowEditor()
    {
        DialogueEditor editor = EditorWindow.GetWindow <DialogueEditor>();

        editor.wantsMouseMove = true;
        //InitStyles();
        Selection.selectionChanged -= editor.OnEditorSelectionChanged;
        Selection.selectionChanged += editor.OnEditorSelectionChanged;

        editor.OnEditorSelectionChanged();
    }
        public static void RenderAllNodes(DialogueEditor editor, BaseNode root)
        {
            List <NodeGUI> removeNodes = new List <NodeGUI>();

            RenderNode(editor, root, removeNodes);

            foreach (NodeGUI gui in removeNodes)
            {
                gui.Remove(editor);
            }
        }
Example #9
0
        public static void RenderNode(DialogueEditor editor, BaseNode node)
        {
            NodeGUI gui = editor.GetNodeGUI(node);

            if (gui == null)
            {
                gui    = new NodeGUI(node);
                gui.id = editor.nextID++;
                editor.nodes.Add(gui.id, gui);
            }
            gui.RenderNode(editor);
        }
 public override void DrawConnection()
 {
     if (parents.Count > 0)
     {
         foreach (var parent in parents)
         {
             if (parent != null)
             {
                 DialogueEditor.DrawNodeConnection(parent.windowRect, windowRect, true, Color.black);
             }
         }
     }
 }
Example #11
0
 public ToolsAreaComponent(
     DialogueEditor editor,
     DialogueEditorFactory guiFactory,
     DialogueCsvHandler csvHandler
     )
 {
     if (background == null)
     {
         background = Resources.Load <Texture2D>("tools_area_background");
     }
     this.editor     = editor;
     this.guiFactory = guiFactory;
     this.csvHandler = csvHandler;
 }
        public void Remove(DialogueEditor editor)
        {
            node.Remove();

            if (!node.isLink)
            {
                foreach (Link link in ((Node)node).Links)
                {
                    editor.GetNodeGUI(link).DestroyGUI(editor);
                }
            }

            DestroyGUI(editor);
        }
 public DialogueNodeComponent(
     DialogueEditor editor,
     DialogueEditorFactory guiFactory,
     DialogueEditorStyles styles,
     DialogueRepository repository,
     DialogueNode node
     )
 {
     this.editor     = editor;
     this.guiFactory = guiFactory;
     this.styles     = styles;
     this.repository = repository;
     this.node       = node;
 }
Example #14
0
 //Draws editable list of keys
 void OnGUI()
 {
     reader = (DialogueReader)EditorUtility.InstanceIDToObject(instanceId);
     if (reader != null)
     {
         int spacer = 10;
         EditorGUIUtility.labelWidth = 80;
         GUILayout.BeginArea(new Rect(spacer, spacer, position.width - spacer * 2, position.height - spacer * 2), GUI.skin.box);
         EditorGUILayout.LabelField("Key List", DialogueEditor.NewStyle("", 15, Color.white, FontStyle.Bold));
         GUILayout.Space(spacer);
         EditorGUILayout.BeginHorizontal();
         if (GUILayout.Button("Name", EditorStyles.label))
         {
             SortKeys("name");
         }
         if (GUILayout.Button("Number", EditorStyles.label, GUILayout.Width(position.width / 5)))
         {
             SortKeys("number");
         }
         EditorGUILayout.EndHorizontal();
         scrollPos = EditorGUILayout.BeginScrollView(scrollPos);
         for (int i = 0; i < reader.Keys.Count; i++)
         {
             Key key = reader.Keys[i];
             EditorGUILayout.BeginHorizontal();
             key.name   = EditorGUILayout.TextField(key.name);
             key.number = EditorGUILayout.IntField(key.number, GUILayout.Width(position.width / 5));
             if (GUILayout.Button("Delete"))
             {
                 reader.Keys.Remove(key);
             }
             EditorGUILayout.EndHorizontal();
         }
         EditorGUILayout.EndScrollView();
         GUILayout.FlexibleSpace();
         EditorGUILayout.BeginHorizontal();
         newName = EditorGUILayout.TextField(newName);
         newNum  = EditorGUILayout.IntField(newNum, GUILayout.Width(position.width / 5));
         if (GUILayout.Button("Create"))
         {
             CreateNewKey(newName, newNum);
         }
         EditorGUILayout.EndHorizontal();
         GUILayout.EndArea();
     }
     if (GUI.changed)
     {
         EditorUtility.SetDirty(reader);
     }
 }
Example #15
0
 public static bool OnOpenAsset(int instanceID, int line)
 {
     if (Selection.activeObject is DialogueAsset)
     {
         DialogueEditor window = CreateWindow <DialogueEditor>();
         DialogueAsset  asset  = Selection.activeObject as DialogueAsset;
         window.titleContent           = new GUIContent("Dialogue Editor");
         window.m_dialogueAssetBuilder = CreateInstance <DialogueAssetBuilder>();
         window.m_dialogueAssetBuilder.m_dialogueAsset = asset;
         window.m_dialogueAssetBuilder.LoadEditorSaveData();
         window.m_dialogueAssetBuilder.m_dialogueAsset = asset;
         return(true);
     }
     return(false);
 }
    public override void OnInspectorGUI()
    {
        //Muestro el botón para abrir la ventana de nodos en el editor del archivo
        if (GUILayout.Button("Abrir Ventana de Nodos"))
        {
            //Abro la ventana de nodos
            window = EditorWindow.GetWindow <DialogueEditor>();

            //Le seteo su tamaño
            window.minSize = new Vector2(800, 600);

            //Le paso la referencia del archivo a la ventana de nodos
            window.LoadAssetFile(_target);
        }
    }
    public GUIDialogueNode(DialogueEditor parentEditor, DialogueNode data)
    {
        this.nodeData   = data;
        this.speakerUID = parentEditor.speakerUID;
        this.editor     = parentEditor;
        this.replies    = new List <GUIDialogueReply>();
        if (nodeData.replies.Count == 0)
        {
            nodeData.replies.Add(new DialogueReply());
        }
        for (int i = 0; i < data.replies.Count; i++)
        {
            DialogueReply replyData = data.replies[i];
            this.replies.Add(new GUIDialogueReply(replyData, this, i, i));
        }
        repliesToRemove = new List <GUIDialogueReply>();

        isInitialLine = (parentEditor.initialLineID == this.lineID);
        nameLabelRect = new Rect(
            data.position.x + padding, data.position.y + padding,
            textWidth, nameHeight
            );
        nameRect = new Rect(
            data.position.x + padding, data.position.y + padding + nameHeight,
            textWidth, nameHeight
            );
        initialLineToggleRect = new Rect(
            data.position.x + padding, data.position.y + padding + nameHeight * 2.0f,
            textWidth, nameHeight
            );
        textLabelRect = new Rect(
            data.position.x + padding, data.position.y + padding + nameHeight * 3.0f,
            textWidth, textHeight
            );
        textRect = new Rect(
            data.position.x + padding, data.position.y + padding * 2.0f + nameHeight * 4.0f,
            textWidth, textHeight
            );
        rect = new Rect(
            data.position.x, data.position.y,
            textWidth + padding * 2.0f, mainBlockHeight + (textHeight + padding) * replies.Count
            );

        style = defaultNodeStyle;

        inPoint = new ConnectionPoint(this, ConnectionPointType.In);
    }
Example #18
0
	public static void InitWindow()
	{
		DialogueEditor editor = GetWindow<DialogueEditor>();
		editor.linetexture = AssetDatabase.LoadAssetAtPath("Assets/Dialogue/Editor/Line.png", typeof(Texture2D)) as Texture2D;
		editor.files.Clear();
        // get dialogue from scene
        //DialogueFile[] files = FindObjectsOfTypeIncludingAssets(typeof(DialogueFile)) as DialogueFile[];
        DialogueFile[] files = Resources.FindObjectsOfTypeAll(typeof(DialogueFile)) as DialogueFile[];
        if (files != null)
		{
			foreach (DialogueFile f in files)
			{
				editor.files.Add(f);
			}
		}

		editor.Init();
	}
        private static void RenderNode(DialogueEditor editor, BaseNode node, List <NodeGUI> removeNodes)
        {
            NodeGUI gui = editor.GetNodeGUI(node);

            if (gui != null && gui.node.Data == null)
            {
                Debug.Log("trying to render a node with null data. destroying...");
                removeNodes.Add(gui);
            }
            else
            {
                if (gui == null)
                {
                    gui    = new NodeGUI(node);
                    gui.id = editor.nextID++;
                    editor.nodes.Add(gui.id, gui);
                }
                gui.RenderNode(editor, removeNodes);
            }
        }
 /// <summary>
 /// Expand or collapse this node and all its children, recursively.
 /// </summary>
 public void ExpandAll(bool expand, DialogueEditor editor)
 {
     if (!node.isLink && ((Node)node).Children.Count > 0)
     {
         if (expand)
         {
             editor.RevealChildren(node);
         }
         else
         {
             expanded = expand;
             foreach (BaseNode child in ((Node)node).Children)
             {
                 NodeGUI gui = editor.GetNodeGUI(child);
                 if (gui != null)
                 {
                     gui.ExpandAll(expand, editor);
                 }
             }
         }
     }
 }
        private void RenderNode(DialogueEditor editor, List <NodeGUI> removeNodes)
        {
            if (node.Data == null)
            {
                Debug.Log("trying to render a node with null data. destroying...");
                removeNodes.Add(this);
                return;
            }

            GUI.SetNextControlName(id.ToString());
            bool   isChoice = (node.Data.Type == NodeType.CHOICE);
            string text     = node.Data.Text;

            if (text == "")
            {
                if (node.Data.Notes == "")
                {
                    text = "<empty>";
                }
                else
                {
                    text = "<<" + node.Data.Notes + ">>";
                }
            }

            if (!node.isBranchComplete())
            {
                text += "*";
            }

            if (editor.forceExpandNodes != null && editor.forceExpandNodes.Contains(node))
            {
                expanded = true;
            }

            bool terminal = (node.isLink || ((Node)node).Children.Count == 0);

            EditorGUILayout.BeginHorizontal();
            GUILayout.Space(editor.indentLevel * INDENT_SIZE);

            GUIContent textContent = new GUIContent(text);
            GUIStyle   style       = terminal ? GetStyle(EditorStyles.label, isChoice, node.isLink) : GetStyle(EditorStyles.foldout, isChoice);

            rect             = GUILayoutUtility.GetRect(textContent, style);
            style.fixedWidth = rect.width;

            if (terminal)
            {
                EditorGUI.SelectableLabel(rect, text, style);
                EditorGUILayout.EndHorizontal();
            }
            else
            {
                expanded = EditorGUI.Foldout(rect, expanded, textContent, style);
                EditorGUILayout.EndHorizontal();
                if (expanded)
                {
                    editor.indentLevel++;
                    foreach (BaseNode child in ((Node)node).Children)
                    {
                        RenderNode(editor, child, removeNodes);
                    }
                    editor.indentLevel--;
                }
            }
        }
Example #22
0
 public PriorityHandleEvent(DialogueEditor editor) : base(editor)
 {
     editorEvents = new List <DialogueEditorEvent>();
 }
    private static void OpenWindow()
    {
        DialogueEditor window = CreateWindow <DialogueEditor>();

        window.titleContent = new GUIContent("Dialogue Editor");
    }
Example #24
0
    static void Init()
    {
        DialogueEditor window = (DialogueEditor)EditorWindow.GetWindow(typeof(DialogueEditor));

        window.Show();
    }
Example #25
0
 //[MenuItem("Window/Dialogue editor")]
 static void ShowEditor()
 {
     DialogueEditor editor = EditorWindow.GetWindow <DialogueEditor>();
 }
Example #26
0
 public virtual BaseNode SetReference(DialogueEditor value)
 {
     reference = value;
     return(this);
 }
Example #27
0
    //Draws actor list, and properties for selected actor
    void DrawActors()
    {
        float spacer = 10;

        GUILayout.BeginArea(new Rect(spacer, spacer, position.width - spacer * 2, position.height - spacer * 2));
        GUILayout.BeginHorizontal();
        GUILayout.BeginVertical(GUI.skin.box, GUILayout.Width(position.width * 0.4f - spacer * 2));
        EditorGUILayout.LabelField("Actor List", DialogueEditor.NewStyle("", 15, Color.white, FontStyle.Bold));
        GUILayout.Space(spacer);
        scrollPos = EditorGUILayout.BeginScrollView(scrollPos);
        for (int i = 0; i < reader.actors.Count; i++)
        {
            Actor    actor = reader.actors[i];
            GUIStyle style = (selectedActor == actor) ? EditorStyles.boldLabel : EditorStyles.label;
            GUILayout.BeginHorizontal();
            if (GUILayout.Button(actor.name, style))
            {
                selectedActor = actor;
                GUI.FocusControl("");
            }
            if (GUILayout.Button("▲", GUILayout.Width(25)))
            {
                MoveActor(actor, "up");
            }
            if (GUILayout.Button("▼", GUILayout.Width(25)))
            {
                MoveActor(actor, "down");
            }
            if (GUILayout.Button("Delete", GUILayout.Width(50)))
            {
                DeleteActor(actor);
            }
            GUILayout.EndHorizontal();
        }
        EditorGUILayout.EndScrollView();
        GUILayout.FlexibleSpace();
        if (GUILayout.Button("Create Actor"))
        {
            CreateActor();
        }
        GUILayout.EndVertical();
        GUILayout.Space(spacer);
        GUILayout.BeginVertical(GUI.skin.box, GUILayout.Width(position.width * 0.6f - spacer));
        EditorGUILayout.LabelField("Actor Properties", DialogueEditor.NewStyle("", 15, Color.white, FontStyle.Bold));
        GUILayout.Space(spacer);
        if (selectedActor != null)
        {
            selectedActor.name         = EditorGUILayout.TextField("Name: ", selectedActor.name);
            selectedActor.positionType = (Actor.PositionType)EditorGUILayout.EnumPopup("Position Type ", selectedActor.positionType);
            if (selectedActor.positionType == Actor.PositionType.Dynamic)
            {
                selectedActor.transform    = (Transform)EditorGUILayout.ObjectField("Transform: ", selectedActor.transform, typeof(Transform), true);
                selectedActor.autoPosition = EditorGUILayout.Toggle("Auto Position: ", selectedActor.autoPosition);
                selectedActor.offset       = EditorGUILayout.Vector3Field("Offset", selectedActor.offset);
            }
            else
            {
                selectedActor.position = (TextAnchor)EditorGUILayout.EnumPopup("Position ", selectedActor.position);
                selectedActor.offset   = EditorGUILayout.Vector2Field("Offset", selectedActor.offset);
            }
            selectedActor.image = (Texture2D)EditorGUILayout.ObjectField("Image: ", selectedActor.image, typeof(Texture2D), true);
            if (selectedActor.image)
            {
                selectedActor.imageRight = EditorGUILayout.Toggle("Switch Side: ", selectedActor.imageRight);
            }

            GUILayout.FlexibleSpace();
        }
        else
        {
            GUILayout.FlexibleSpace();
        }
        GUILayout.EndVertical();
        GUILayout.EndHorizontal();
        GUILayout.EndArea();
    }
Example #28
0
    public static void CreateWindow()
    {
        DialogueEditor window = GetWindowWithRect <DialogueEditor>(new Rect(0, 0, 450, 720), false, "对话管理器");

        window.Show();
    }
 private void DestroyGUI(DialogueEditor editor)
 {
     editor.nodes.Remove(id);
     GUI.FocusControl(DUMMY_CONTROL);
     editor.Repaint();
 }