/// <summary> /// Continue the dialogue. Only for an extended type of dialogue. /// </summary> /// <returns></returns> public DialogueRuntime Continue() { if (currentDialogue.TextIndexIncrement()) { DialogueReadyListenersCall(currentDialogue.Origin); return(this); } if (currentDialogue.Selections.Count > 0) { throw new InvalidChoiceException(); } listenerRegistry.DialogueGeneralListeners["on_continued"].ForEach(action => { action(this, currentDialogue); }); if (listenerRegistry.DialogueSpecificListeners["on_continued"].ContainsKey(currentDialogue.Id)) { listenerRegistry.DialogueSpecificListeners["on_continued"][currentDialogue.Id].ForEach(action => { action(this, currentDialogue); }); } return(ContinueHandling(() => { if (!dialogueTree.IsExtended(currentDialogue.Origin)) { return End(); } InitializeDialogue(dialogueTree.GetDialogue(dialogueTree.dialogue_relations.data[currentDialogue.Id])); return this; })); }
protected void ContextMenu(Event e) { if (e.type == EventType.ContextClick) { if (IsConnecting()) { BreakConnection(); } else { GenericMenu menu = new GenericMenu(); //menu.AddItem(new GUIContent("Editor/New Tree..."), false, delegate { // int result = EditorUtility.DisplayDialogComplex("", "Save this tree first?", "Ok", "Cancel", "No"); // if (result != 1) { // if (result == 0) // if (!SaveTree()) // return; // string[] segments = CurrentTree.name != null ? CurrentTree.name.Split('/') : new string[0]; // Unitialize(); // string prefix = ""; // if (segments.Length > 1) { // prefix = String.Join("/", segments.Take(segments.Length - 1).ToArray()) + "/"; // } // InitializeTree(prefix); // Repaint(); // } //}); BuildLoadMenu("Editor/", menu, () => { int result = EditorUtility.DisplayDialogComplex("", "Save this tree first?", "Ok", "Cancel", "No"); if (result != 1) { if (result == 0) { if (!SaveTree()) { return(false); } } Uninitialize(); return(true); } return(false); }); menu.AddItem(new GUIContent("Editor/Exit..."), false, delegate { int result = EditorUtility.DisplayDialogComplex("", "Save and Exit?", "Ok", "Cancel", "No"); if (result != 1) { if (result == 0) { if (!SaveTree()) { return; } } } if (result == 1) { return; } Uninitialize(); Repaint(); }); menu.AddSeparator(""); menu.AddItem(new GUIContent("New dialogue"), false, delegate { CreateDialogue(); }); menu.AddItem(new GUIContent("Save"), false, delegate { SaveTree(); }); if (IsScoping) { menu.AddItem(new GUIContent("Exit Scope"), false, delegate { ExitScope(); }); } menu.ShowAsContext(); } } else if (e.type == EventType.MouseDown && e.button == 1 && nodes.Count != 0) { GenericMenu menu = new GenericMenu(); int i = 0; foreach (var node in nodes) { if (!node.Window.Contains(e.mousePosition)) { continue; } Rect startRect = node.startRect; startRect.x += node.Window.x; startRect.y += node.Window.y; if (node.AbsoluteStartRect.Contains(mousePos)) { if (CurrentTree.IsConnected(node.entity)) { menu.AddItem(new GUIContent("Disconnect"), false, delegate { CurrentTree.ClearInboundConnection(node.entity.id); }); } } else if (node.AbsoluteEndRect.Contains(mousePos)) { if (CurrentTree.IsExtended(node.entity)) { menu.AddItem(new GUIContent("Disconnect"), false, delegate { CurrentTree.ClearOutboundConnection(node.entity.id); }); } } else { var option = node.GetNodeOption(e.mousePosition); if (option.Value != null) { if (!CurrentTree.IsOptionExtended(option.Value)) { } else { menu.AddItem(new GUIContent("Disconnect"), false, delegate { ClearOptionConnection(option.Value); }); } } else { menu.AddItem(new GUIContent(node.showId ? "Hide Id" : "Show Id"), false, delegate { node.showId = !node.showId; node.ResetSize(); }); if (!node.actorAvailability) { if (CurrentTree.actors.Count == 0) { menu.AddItem(new GUIContent("Set actor"), false, delegate { node.actorAvailability = true; }); } else { menu.AddItem(new GUIContent("Set actor/New..."), false, delegate { node.actorAvailability = true; }); CurrentTree.actors.ForEach(actor => { menu.AddItem(new GUIContent("Set actor/" + actor), false, delegate { node.actorAvailability = true; node.entity.actor = actor; ActorsUpdate(); }); }); } } if (!CurrentTree.IsExtended(node.entity)) { menu.AddItem(new GUIContent("Add option"), false, delegate { node.entity.options.Add(new OptionEntity() { id = node.entity.id + "." + UnityEngine.Random.Range(1, 100).ToString() }); }); } if (nodes.Count > 1 && nodes.ElementAt(0) != node) { menu.AddItem(new GUIContent("Remove dialogue"), false, delegate { RemoveDialogue(node); }); //menu.AddItem(new GUIContent("Scope To This"), false, delegate { // ScopeDialogue(node); //}); } } } menu.ShowAsContext(); i++; break; } } }