private void InitWindowsRecursive(ConversationNode node) { if (!loopCheck.ContainsKey(node)) { loopCheck.Add(node, true); ConversationNodeEditor editor = ConversationNodeEditorFactory.Intance.createConversationNodeEditorFor(node); editor.setParent(this); editor.Node = node; editor.Collapsed = true; Rect previous = new Rect(0, 25, 0, 100); if (editors.ContainsKey(node)) { previous = editors[node].Window; } //Rect current = new Rect (previous.x + previous.width + 35, previous.y, 150, 0); Rect current; if (node.getEditorX() != -1) { current = new Rect(node.getEditorX(), node.getEditorY(), 100, 0); } else { current = positioner.getRectFor(nodespositioned); } nodespositioned++; if (!tmpRects.ContainsKey(node)) { tmpRects.Add(node, current); } editor.Window = current; editors.Add(node, editor); for (int i = 0; i < node.getChildCount(); i++) { InitWindowsRecursive(node.getChild(i)); } } }
protected override void DrawNodeControls(ConversationDataControl content, ConversationNodeDataControl node) { ConversationNodeEditor editor = null; editors.TryGetValue(node, out editor); string[] editorNames = ConversationNodeEditorFactory.Intance.CurrentConversationNodeEditors; int preEditorSelected = ConversationNodeEditorFactory.Intance.ConversationNodeEditorIndex(node); int editorSelected = EditorGUILayout.Popup(preEditorSelected, editorNames); if (editor == null || preEditorSelected != editorSelected) { bool firstEditor = (editor == null); var intRect = node.getEditorRect(); var prevRect = (editor != null) ? editor.Window : new Rect(intRect.x, intRect.y, intRect.width, intRect.height); editor = ConversationNodeEditorFactory.Intance.createConversationNodeEditorFor(content, editorNames[editorSelected]); editor.setParent(this); editor.Window = prevRect; if (firstEditor) { editor.Node = node; } else { setNode(content, node, editor.Node); } editors.Remove(node); editors[editor.Node] = editor; if (Selection.Contains(node)) { Selection.Remove(node); Selection.Add(editor.Node); } } base.DrawNodeControls(content, node); }
void nodeWindow(int id) { ConversationNode myNode = conversation.getAllNodes()[id]; ConversationNodeEditor editor = null; editors.TryGetValue(myNode, out editor); if (editor != null && editor.Collapsed) { GUIContent bttext = new GUIContent(TC.get("GeneralText.Open")); Rect btrect = GUILayoutUtility.GetRect(bttext, buttonstyle); GUILayout.BeginHorizontal(); if (GUI.Button(btrect, bttext)) { editor.Collapsed = false; } ; GUILayout.EndHorizontal(); } else { string[] editorNames = ConversationNodeEditorFactory.Intance.CurrentConversationNodeEditors; GUILayout.BeginHorizontal(); int preEditorSelected = ConversationNodeEditorFactory.Intance.ConversationNodeEditorIndex(myNode); int editorSelected = EditorGUILayout.Popup(preEditorSelected, editorNames); if (GUILayout.Button("-", collapseStyle, GUILayout.Width(15), GUILayout.Height(15))) { editor.Collapsed = true; GUIContent bttext = new GUIContent(TC.get("GeneralText.Open")); Rect btrect = GUILayoutUtility.GetRect(bttext, buttonstyle); editor.Window = new Rect(editor.Window.x, editor.Window.y, btrect.width, btrect.height); } if (GUILayout.Button("X", closeStyle, GUILayout.Width(15), GUILayout.Height(15))) { } //effects.getEffects().Remove(myEffect); GUILayout.EndHorizontal(); GUILayout.BeginVertical(); if (editor == null || preEditorSelected != editorSelected) { bool firstEditor = (editor == null); editor = ConversationNodeEditorFactory.Intance.createConversationNodeEditorFor(editorNames[editorSelected]); editor.setParent(this); if (firstEditor) { editor.Node = myNode; } else { setNode(myNode, editor.Node); } if (editors.ContainsKey(myNode)) { editor.Window = editors[myNode].Window; } else { editor.Window = tmpRects[myNode]; } editors.Remove(myNode); editors.Add(editor.Node, editor); } editor.draw(); GUILayout.EndVertical(); } if (Event.current.type != EventType.layout) { Rect lastRect = GUILayoutUtility.GetLastRect(); Rect myRect = editors[myNode].Window; myRect.height = lastRect.y + lastRect.height; editors[myNode].Window = myRect; this.Repaint(); } if (Event.current.type == EventType.mouseMove) { if ( new Rect(0, 0, editors[myNode].Window.width, editors[myNode].Window.height).Contains( Event.current.mousePosition)) { hovering = id; } } if (Event.current.type == EventType.mouseDown) { if (hovering == id) { focusing = hovering; } if (lookingChildNode != null) { // link creation between nodes if (lookingChildNode.getChildCount() > 0) { lookingChildNode.removeChild(lookingChildSlot); } lookingChildNode.addChild(lookingChildSlot, myNode); // finishing search lookingChildNode = null; } } GUI.DragWindow(); }