private void AddEntryToSelection(DialogueEntry entry) { newSelectedLink = null; currentEntry = entry; multinodeSelection.nodes.Add(entry); UpdateEntrySelection(); }
private void CheckNewSelectedLink() { if ((newSelectedLink != null) && (newSelectedLink != selectedLink)) { selectedLink = newSelectedLink; inspectorSelection = selectedLink; isLassoing = false; multinodeSelection.nodes.Clear(); Event.current.Use(); } else if (currentEntry != null) { selectedLink = null; } }
private Link NewLink(DialogueEntry origin, DialogueEntry destination, ConditionPriority priority = ConditionPriority.Normal) { Link newLink = new Link(); newLink.originConversationID = origin.conversationID; newLink.originDialogueID = origin.id; newLink.destinationConversationID = destination.conversationID; newLink.destinationDialogueID = destination.id; newLink.isConnector = (origin.conversationID != destination.conversationID); newLink.priority = priority; return newLink; }
private void UpdateEntrySelection() { ResetDialogueTreeCurrentEntryParticipants(); if (multinodeSelection.nodes.Count == 0) { inspectorSelection = currentConversation; selectedLink = null; } else if (multinodeSelection.nodes.Count == 1) { inspectorSelection = currentEntry; } else { inspectorSelection = multinodeSelection; } }
private void SetCurrentEntry(DialogueEntry entry) { newSelectedLink = null; if (entry != currentEntry) ResetLuaWizards(); currentEntry = entry; multinodeSelection.nodes.Clear(); multinodeSelection.nodes.Add(entry); UpdateEntrySelection(); }
private void RemoveEntryFromSelection(DialogueEntry entry) { newSelectedLink = null; multinodeSelection.nodes.Remove(entry); if (multinodeSelection.nodes.Count == 0) { currentEntry = null; } else { currentEntry = multinodeSelection.nodes[multinodeSelection.nodes.Count-1]; } UpdateEntrySelection(); }
private bool IsValidRuntimeResponse(Link link, Response[] responses) { foreach (var response in responses) { if ((link.destinationConversationID == response.destinationEntry.conversationID) && (link.destinationDialogueID == response.destinationEntry.id)) { return true; } } return false; }
private bool IsValidRuntimeLink(Link link) { return IsValidRuntimeResponse(link, currentConversationState.pcResponses) || IsValidRuntimeResponse(link, currentConversationState.npcResponses); }
private void HandleNodeEvents(DialogueEntry entry) { switch (Event.current.type) { case EventType.mouseDown: if (entry.canvasRect.Contains(Event.current.mousePosition)) { if (IsRightMouseButtonEvent()) { currentEntry = entry; ShowNodeContextMenu(entry); Event.current.Use(); } else if (Event.current.button == LeftMouseButton) { newSelectedLink = null; if (isMakingLink) { FinishMakingLink(); } else { nodeToDrag = entry; dragged = false; if (!IsShiftDown() && ((multinodeSelection.nodes.Count <= 1) || !multinodeSelection.nodes.Contains(entry))) { SetCurrentEntry(entry); } } Event.current.Use(); } } break; case EventType.mouseUp: if (Event.current.button == LeftMouseButton) { if (!isMakingLink && entry.canvasRect.Contains(Event.current.mousePosition)) { newSelectedLink = null; if (isLassoing) { FinishLasso(); } else if (IsShiftDown()) { if (multinodeSelection.nodes.Contains(entry)) { RemoveEntryFromSelection(entry); } else { AddEntryToSelection(entry); } } else { if (!(dragged && (multinodeSelection.nodes.Count > 1))) { SetCurrentEntry(entry); } } nodeToDrag = null; dragged = false; Event.current.Use(); } } break; case EventType.mouseDrag: if ((entry == nodeToDrag)) { dragged = true; DragNodes(multinodeSelection.nodes); Event.current.Use(); } break; } if (isMakingLink && Event.current.isMouse) { if (entry.canvasRect.Contains(Event.current.mousePosition)) { linkTargetEntry = entry; } } }
private void HandleEmptyCanvasEvents() { wantsMouseMove = true; Event e = Event.current; switch (Event.current.type) { case EventType.mouseDown: isDraggingCanvas = IsDragCanvasEvent(); if (isMakingLink) { if ((Event.current.button == LeftMouseButton) || (Event.current.button == RightMouseButton)) { FinishMakingLink(); } } else if (IsRightMouseButtonEvent()) { if (selectedLink != null) { ShowLinkContextMenu(); } else { if (currentConversation != null) { ShowEmptyCanvasContextMenu(); } } } else if (Event.current.button == LeftMouseButton) { isLassoing = true; lassoRect = new Rect(Event.current.mousePosition.x + canvasScrollPosition.x, Event.current.mousePosition.y + canvasScrollPosition.y, 1, 1); } break; case EventType.mouseUp: isDraggingCanvas = false; if (isLassoing) { FinishLasso(); newSelectedLink = null; } else if (newSelectedLink == null) { currentEntry = null; selectedLink = null; multinodeSelection.nodes.Clear(); inspectorSelection = currentConversation; } break; case EventType.mouseDrag: if (isDraggingCanvas) { canvasScrollPosition -= Event.current.delta; canvasScrollPosition.x = Mathf.Clamp(canvasScrollPosition.x, 0, Mathf.Infinity); canvasScrollPosition.y = Mathf.Clamp(canvasScrollPosition.y, 0, Mathf.Infinity); } else if (isLassoing) { lassoRect.width += Event.current.delta.x; lassoRect.height += Event.current.delta.y; } break; } if (Event.current.isMouse) e.Use(); }
private void HandleConnectorEvents(Link link, Vector3 start, Vector3 end) { switch (Event.current.type) { case EventType.mouseUp: bool isReallyLassoing = isLassoing && (Mathf.Abs(lassoRect.width) > 10f) && (Mathf.Abs(lassoRect.height) > 10f); if (!isReallyLassoing && (Event.current.button == LeftMouseButton) && IsPointOnLineSegment(Event.current.mousePosition, start, end)) { newSelectedLink = link; currentEntry = null; inspectorSelection = newSelectedLink; } break; } }
private void FinishMakingLink() { if ((linkSourceEntry != null) && (linkTargetEntry != null) && (linkSourceEntry != linkTargetEntry) && !LinkExists(linkSourceEntry, linkTargetEntry)) { Link link = new Link(); link.originConversationID = currentConversation.id; link.originDialogueID = linkSourceEntry.id; link.destinationConversationID = currentConversation.id; link.destinationDialogueID = linkTargetEntry.id; linkSourceEntry.outgoingLinks.Add(link); InitializeDialogueTree(); ResetDialogueEntryText(); Repaint(); } isMakingLink = false; linkSourceEntry = null; linkTargetEntry = null; }
private void DrawCanvasContents() { if (currentConversation == null) return; newSelectedLink = null; DrawAllConnectors(); DrawAllNodes(); DrawLasso(); CheckNewSelectedLink(); newSelectedLink = null; }