private void DrawPageJoints(Node node, Vector2 mousePosition) { foreach (NodeJoint j in node.joints) { j.ownerID = node.Index; j.ownerNode = node; if (j.IsConnected()) { if (j.IsOutput) { NodeJoint jnt = null; if (j.connectionPoint.ownerNode != null) { jnt = j.connectionPoint.ownerNode.joints[j.connectionPoint.JointIndex]; } else { jnt = VisualNovelEditor.FindJoint(j.connectionPoint.OwnerID, j.connectionPoint.JointIndex); } if (jnt != null) { CalculateAndDrawBezier(j.bounds.center, jnt.bounds.center, j.info, jnt.info); } } GUI.Label(new Rect(new Vector2(j.bounds.position.x + j.bounds.width + 10f, j.bounds.position.y), new Vector2(50, 50)), j.connectionPoint.OwnerID + " " + (j.IsOutput ? "OUT" : "IN"), EditorGUILayoutExtensions.ChangeTextColor(_styles[StyledElement.Label], Color.white)); } } EditorGUI.DrawRect(node.TopJoint.bounds, node.Outputting && !node.TopJoint.IsConnected() ? Color.magenta : node.TopJoint.CheckForHover(mousePosition) ? Color.yellow : Color.red); EditorGUI.DrawRect(node.BottomJoint.bounds, node.Outputting && !node.BottomJoint.IsConnected() ? Color.magenta : node.BottomJoint.CheckForHover(mousePosition) ? Color.yellow : Color.red); EditorGUI.DrawRect(node.LeftJoint.bounds, node.Outputting && !node.LeftJoint.IsConnected() ? Color.magenta : node.LeftJoint.CheckForHover(mousePosition) ? Color.yellow : Color.red); EditorGUI.DrawRect(node.RightJoint.bounds, node.Outputting && !node.RightJoint.IsConnected() ? Color.magenta : node.RightJoint.CheckForHover(mousePosition) ? Color.yellow : Color.red); }
//[MenuItem("Help/Me/I/Love/Hentai/Way/Too/Much/Extremely Experimental/Visual Novel Editor/New Visual Novel")] public static void Start() { //_gridTexture = (Texture2D)EditorGUIUtility.Load("Grid.png"); _editorInstance = GetWindow <VisualNovelEditor>(); _editorInstance.CreateStateNodes(); _editorInstance.titleContent = new GUIContent("Visual Novel Editor"); }
private void OnEnable() { instance = this; _stylesLoaded = false; _gridTexture = AssetDatabase.LoadAssetAtPath <Texture2D>("Assets/Visual Novel Framework/Editor/Textures/Grid.png"); _editorBackground = CreateBackgroundTexture(new Color32(33, 33, 33, 255)); //_gridTexture.Resize((int)_editArea.x, (int)_editArea.y); }
private void DrawStateJoints(Node node, Vector2 mousePosition) { if (node.isStartNode) { node.BottomJoint.ownerID = node.Index; node.BottomJoint.ownerNode = node; EditorGUI.DrawRect(node.BottomJoint.bounds, node.BottomJoint.CheckForHover(mousePosition) ? Color.green : Color.blue); if (node.BottomJoint.IsConnected()) { if (node.BottomJoint.IsOutput) { NodeJoint jnt = null; if (node.BottomJoint.connectionPoint.ownerNode != null) { jnt = node.BottomJoint.connectionPoint.ownerNode.joints[node.BottomJoint.connectionPoint.JointIndex]; } else { jnt = VisualNovelEditor.FindJoint(node.BottomJoint.connectionPoint.OwnerID, node.BottomJoint.connectionPoint.JointIndex); } if (jnt != null) { CalculateAndDrawBezier(node.BottomJoint.bounds.center, jnt.bounds.center, node.BottomJoint.info, jnt.info); } } } } else //End Node { node.TopJoint.ownerID = node.Index; node.TopJoint.ownerNode = node; EditorGUI.DrawRect(node.TopJoint.bounds, node.TopJoint.CheckForHover(mousePosition) ? Color.cyan : Color.grey); if (node.TopJoint.IsConnected()) { if (node.TopJoint.IsOutput) { NodeJoint jnt = null; if (node.TopJoint.connectionPoint.ownerNode != null) { jnt = node.TopJoint.connectionPoint.ownerNode.joints[node.TopJoint.connectionPoint.JointIndex]; } else { jnt = VisualNovelEditor.FindJoint(node.TopJoint.connectionPoint.OwnerID, node.TopJoint.connectionPoint.JointIndex); } if (jnt != null) { CalculateAndDrawBezier(node.TopJoint.bounds.center, jnt.bounds.center, node.TopJoint.info, jnt.info); } } } } }
private void SeparateNovelsAt(int start, int count) { Node[] originalNodes = ((VisualNovel)target).nodes; Node endNode = originalNodes[originalNodes.Length - 1]; foreach (NodeJoint j in endNode.joints) { VisualNovelEditor.ResetNodeJoint(j); endNode.window = new Rect(400, 400, endNode.window.width, endNode.window.height); } Node[] newNodes = Splice(originalNodes, 0, count, endNode); Node[] otherNodes = Splice(originalNodes, start, originalNodes.Length - (start), null); Debug.Log("New: " + newNodes.Length + " Other: " + otherNodes.Length); CreateNovel(0, newNodes); CreateNovel(1, otherNodes); }
private void DrawChoiceNode(Node n) { DrawPageNode(n); GUILayout.BeginVertical(_styles[StyledElement.Box], GUILayout.ExpandHeight(false)); GUIStyle foldoutStyle = new GUIStyle(EditorStyles.foldout); n.choicesShown = EditorGUILayout.Foldout(n.choicesShown, "Choices", EditorGUILayoutExtensions.ChangeTextColor(foldoutStyle, Color.white)); if (n.choices == null) { n.choices = new Choice[n.choiceCount]; } else { if (n.choiceCount != n.oldChoiceCount) { n.oldChoiceCount = n.choiceCount; n.ResetSize(); } } if (n.choicesShown) { c_canResetSize = true; GUILayout.BeginHorizontal(); GUILayout.Space(8f); GUILayout.Label("Choice Count", _styles[StyledElement.Label]); n.choiceCount = EditorGUILayout.IntField(n.choiceCount, _styles[StyledElement.TextField], GUILayout.MaxWidth(30f)); n.choiceCount = Mathf.Clamp(n.choiceCount, 1, Node.ChoiceLimit); if (n.choiceCount != n.oldChoiceCount && n.oldChoiceCount != 0) { //Debug.Log("CHANGE FROM " + n.oldChoiceCount + " TO " + n.choiceCount); n.oldChoiceCount = n.choiceCount; NodeJoint[] lostJoints = n.CalculateLostChoices(); foreach (NodeJoint joint in lostJoints) { VisualNovelEditor.ResetNodeJoint(joint); } } else if (n.oldChoiceCount == 0) { n.oldChoiceCount = n.choiceCount; } GUILayout.EndHorizontal(); for (int i = 0; i < n.choiceCount; i++) { GUILayout.BeginHorizontal(); GUILayout.Space(8f); GUILayout.Label("Choice " + (i + 1), _styles[StyledElement.Label]); n.choices[i].choiceText = GUILayout.TextField(n.choices[i].choiceText ?? "", _styles[StyledElement.TextField], GUILayout.MaxWidth(100f), GUILayout.MaxHeight(_styles[StyledElement.TextField].fixedHeight)); if (n.choices[i].choiceText != n.choices[i].oldChoiceText) { n.choices[i].oldChoiceText = n.choices[i].choiceText; n.ResetSize(); } GUILayout.EndHorizontal(); } } else { if (c_canResetSize) { c_canResetSize = false; n.ResetSize(); } } GUILayout.EndVertical(); }
private void OpenEditor(VisualNovel visualNovel) { _editorWindow = EditorWindow.GetWindow <VisualNovelEditor>(); _editorWindow.LoadVisualNovel(visualNovel); _editorWindow.Show(); }