private void DrawNode(DialogueNode node) { GUIStyle style, wrapStyle; SetNodeStyleAndSize(node, out style, out wrapStyle); GUILayout.BeginArea(node.GetRect(), style); // Create, Link, Destroy buttons GUILayout.BeginHorizontal(); if (GUILayout.Button("+")) { creatingNode = node; } DrawLinkButtons(node); if (GUILayout.Button("x")) { nodeToDelete = node; } GUILayout.EndHorizontal(); // Toggle Is Player Speaking GUILayout.BeginHorizontal(); node.SetPlayerSpeaking(EditorGUILayout.Toggle(node.IsPlayerSpeaking())); EditorGUILayout.LabelField("Is Player speaking?"); GUILayout.EndHorizontal(); if (!node.IsPlayerSpeaking()) { GUILayout.BeginHorizontal(); EditorGUILayout.LabelField("Speaker:", GUILayout.Width(51)); node.SetSpeaker(EditorGUILayout.TextField(node.GetSpeaker())); GUILayout.EndHorizontal(); } // Dialogue Text node.SetText(EditorGUILayout.TextArea(node.GetText(), wrapStyle)); // Toggles For Actions and Conditions GUILayout.BeginHorizontal(); node.SetHasOnEnterAction(EditorGUILayout.Toggle(node.GetHasOnEnterAction())); EditorGUILayout.LabelField("Enter", GUILayout.Width(34)); node.SetHasOnExitAction(EditorGUILayout.Toggle(node.GetHasOnExitAction())); EditorGUILayout.LabelField("Exit", GUILayout.Width(30)); node.SetHasConditionSelect(EditorGUILayout.Toggle(node.GetHasConditionSelect())); if (node.GetHasConditionSelect()) { EditorGUILayout.LabelField("Condition", GUILayout.Width(68)); if (GUILayout.Button("New")) { node.AddNewRootCondition(); } } else { EditorGUILayout.LabelField("Condition"); } GUILayout.EndHorizontal(); if (node.GetHasOnEnterAction()) { OnDialogueAction enterAction; GUILayout.BeginHorizontal(); EditorGUILayout.LabelField("OnEnter:", GUILayout.Width(49)); enterAction = (OnDialogueAction)EditorGUILayout.EnumPopup(node.GetOnEnterAction()); GUILayout.EndHorizontal(); node.SetOnEnterAction(enterAction); string[] actionParams = node.GetOnEnterActionParameters().ToArray(); List <string> onEnterActions = new List <string>(); BuildDialogueActionsSelect(node, enterAction, actionParams, onEnterActions); node.SetOnEnterActionParameters(onEnterActions); } if (node.GetHasOnExitAction()) { OnDialogueAction exitAction; GUILayout.BeginHorizontal(); EditorGUILayout.LabelField("OnExit:", GUILayout.Width(49)); exitAction = (OnDialogueAction)EditorGUILayout.EnumPopup(node.GetOnExitAction()); GUILayout.EndHorizontal(); node.SetOnExitAction(exitAction); string[] actionParams = node.GetOnExitActionParameters().ToArray(); List <string> onExitActions = new List <string>(); BuildDialogueActionsSelect(node, exitAction, actionParams, onExitActions); node.SetOnExitActionParameters(onExitActions); } if (node.GetHasConditionSelect()) { LayoutConditionSelectionUI(node); } GUILayout.EndArea(); }
private void DrawNode(DialogueNode node) { GUIStyle style, wrapStyle; SetNodeStyleAndSize(node, out style, out wrapStyle); GUILayout.BeginArea(node.GetRect(), style); // Create, Link, Destroy buttons GUILayout.BeginHorizontal(); if (GUILayout.Button("+")) { creatingNode = node; } DrawLinkButtons(node); if (GUILayout.Button("x")) { nodeToDelete = node; } GUILayout.EndHorizontal(); // If root node, extra option to assign conversation start if (node.IsRootNode()) { GUILayout.BeginHorizontal(); EditorGUILayout.LabelField("Convo Name:", GUILayout.Width(79)); GUI.SetNextControlName("RootNameField" + node.name); node.SetRootName(EditorGUILayout.TextField(node.GetConversationChainName())); GUILayout.EndHorizontal(); } // Option for character sprite GUILayout.BeginHorizontal(); GirlSpriteDB girlSpriteDB = (GirlSpriteDB)Resources.Load("Game/GirlDialogueSpriteDB"); string[] girlOptions = girlSpriteDB.GetGirlNames().ToArray(); string currentGirl = node.GetGirlToDisplay(); int selected = GetIndexInArray(girlOptions, currentGirl); EditorGUILayout.LabelField("Girl Sprite:", GUILayout.Width(61)); selected = EditorGUILayout.Popup(selected, girlOptions); node.SetGirlToDisplay(girlOptions[selected]); GUILayout.EndHorizontal(); if (selected > 0) { GUILayout.BeginHorizontal(); string[] spriteOptions; if (girlSpriteDB.GetAllSpriteNames(girlOptions[selected], out spriteOptions)) { int selectedSprite = GetIndexInArray(spriteOptions, node.GetSpriteToDisplayName()); selectedSprite = EditorGUILayout.Popup(selectedSprite, spriteOptions); Sprite newSprite; if (girlSpriteDB.GetSprite(currentGirl, selectedSprite, out newSprite)) { node.SetSpriteToDisplay(newSprite); } } GUILayout.EndHorizontal(); } girlSpriteDB = null; // Toggle Is Player Speaking GUILayout.BeginHorizontal(); node.SetPlayerSpeaking(EditorGUILayout.Toggle(node.IsPlayerSpeaking())); EditorGUILayout.LabelField("Is Player speaking?"); GUILayout.EndHorizontal(); if (!node.IsPlayerSpeaking()) { GUILayout.BeginHorizontal(); EditorGUILayout.LabelField("Speaker:", GUILayout.Width(51)); GUI.SetNextControlName("SpeakerNameField" + node.name); node.SetSpeaker(EditorGUILayout.TextField(node.GetSpeaker())); GUILayout.EndHorizontal(); } // Dialogue Text GUI.SetNextControlName("MainTextField" + node.name); node.SetText(EditorGUILayout.TextArea(node.GetText(), wrapStyle)); // Toggles For Actions and Conditions GUILayout.BeginHorizontal(); node.SetHasOnEnterAction(EditorGUILayout.Toggle(node.GetHasOnEnterAction())); EditorGUILayout.LabelField("Enter", GUILayout.Width(34)); node.SetHasOnExitAction(EditorGUILayout.Toggle(node.GetHasOnExitAction())); EditorGUILayout.LabelField("Exit", GUILayout.Width(30)); node.SetHasConditionSelect(EditorGUILayout.Toggle(node.GetHasConditionSelect())); if (node.GetHasConditionSelect()) { EditorGUILayout.LabelField("Condition", GUILayout.Width(68)); if (GUILayout.Button("New")) { node.AddNewRootCondition(); } } else { EditorGUILayout.LabelField("Condition"); } GUILayout.EndHorizontal(); if (node.GetHasOnEnterAction()) { OnDialogueAction enterAction; GUILayout.BeginHorizontal(); EditorGUILayout.LabelField("OnEnter:", GUILayout.Width(49)); enterAction = (OnDialogueAction)EditorGUILayout.EnumPopup(node.GetOnEnterAction()); GUILayout.EndHorizontal(); node.SetOnEnterAction(enterAction); string[] actionParams = node.GetOnEnterActionParameters().ToArray(); List <string> onEnterActions = new List <string>(); BuildDialogueActionsSelect(node, enterAction, actionParams, onEnterActions); node.SetOnEnterActionParameters(onEnterActions); } if (node.GetHasOnExitAction()) { OnDialogueAction exitAction; GUILayout.BeginHorizontal(); EditorGUILayout.LabelField("OnExit:", GUILayout.Width(49)); exitAction = (OnDialogueAction)EditorGUILayout.EnumPopup(node.GetOnExitAction()); GUILayout.EndHorizontal(); node.SetOnExitAction(exitAction); string[] actionParams = node.GetOnExitActionParameters().ToArray(); List <string> onExitActions = new List <string>(); BuildDialogueActionsSelect(node, exitAction, actionParams, onExitActions); node.SetOnExitActionParameters(onExitActions); } if (node.GetHasConditionSelect()) { LayoutConditionSelectionUI(node); } GUILayout.EndArea(); }