void MakeNodeToOptionConnection(int idFrom, int idTo, NodeType targetType) { if (targetType == NodeType.Option) { DialogueNode node = CurrentNodes[idFrom]; List <int> optionsAttachedToNode = new List <int>(node.OptionsAttached); if (!EditorInfo.NodesOptionsFoldouts.ContainsKey(node.NodeID)) { EditorInfo.NodesOptionsFoldouts.Add(node.NodeID, new Dictionary <int, bool>()); } if (!optionsAttachedToNode.Contains(idTo)) { optionsAttachedToNode.Add(idTo); node.OptionsAttached = optionsAttachedToNode.ToArray(); EditorInfo.NodesOptionsFoldouts[node.NodeID].Add(idTo, false); } } else { if (targetType == NodeType.Node) { DialogueOption option = CurrentOptions[idFrom]; if (idTo != Dialogue.ExitDialogue) { option.SetNext(idTo, NodeType.Node); } else { option.SetNextNodeExit(); } } } ClearAllConnectionsPending(); }
void DrawOptionWindow(int id) { int typeid = EditorInfo.NodeTypesIDs[id]; DialogueOption currentOption = CurrentOptions[typeid]; //bool save = false; #region Option's Target Setting if (nodeToOptionToAttach.Count == 1) { DialogueNode nodeAwaiting = CurrentNodes[nodeToOptionToAttach[0]]; List <int> optionsAttached = new List <int>(nodeAwaiting.OptionsAttached); if (!optionsAttached.Contains(typeid) && GUILayout.Button("Connect")) { nodeToOptionToAttach.Add(typeid); if (nodeToNodeToAttach.Count > 0) { nodeAwaiting.RevertToRegularNode(); } } } bool tempCont = currentOption.NextType != NodeType.Exit; GUILayout.BeginHorizontal(); { GUILayout.Label("Next: "); DrawTargetValue(currentOption, currentOption.NextType, currentOption.NextID); if (tempCont) { if (GUILayout.Button("Clear")) { currentOption.SetNextNodeExit(); } } else { if (optionToNodeToAttach.Count == 0 && optionToConditionToAttach.Count == 0) { if (!tempCont) { if (GUILayout.Button("Set")) { RequestOptionConnection(typeid); } } else { if (GUILayout.Button("Clear")) { currentOption.SetNextNodeExit(); } } } else { DrawCancelConnectionButton(); } } } GUILayout.EndHorizontal(); #endregion #region Visit Once currentOption.VisitOnce = EditorGUILayout.Toggle("Visit Once: ", currentOption.VisitOnce); #endregion #region Connect Entry Condition if (!AnyConditionAwaitingConnection()) { GUILayout.BeginHorizontal(); { GUILayout.Label("Entry Condition: "); if (!currentOption.EntryConditionSet) { GUILayout.Label("[none]"); } else { DrawJumpToButton("Go To", EditorInfo.Windows[EditorInfo.ConditionsIndexes[currentOption.EntryCondition.ConditionID]]); if (GUILayout.Button("x")) { currentOption.ClearEntryCondition(); } } } GUILayout.EndHorizontal(); } else { if (!currentOption.EntryConditionSet && GUILayout.Button("Connect As Entry Condition")) { conditionToEntryOption.Add(typeid); } } #endregion #region Option Text string prev = currentOption.OptionText; DrawTextArea(ref currentOption.OptionText, id); //save = save || ( currentOption.OptionText != null && !currentOption.OptionText.Equals(prev)); #endregion GUILayout.BeginHorizontal(); { DrawResizeButtons(id); if (GUILayout.Button("Delete", GUILayout.Width(80))) { DeleteOptionWindow(id, typeid); SaveChanges("Delete dialogue option"); return; } } GUILayout.EndHorizontal(); if (!resizing) { Vector2 margin = new Vector2(DragAreaMargin, DragAreaMargin); GUI.DragWindow(new Rect(Vector2.zero, EditorInfo.Windows[id].size - margin)); } if (/*save*/ GUI.changed) { SaveChanges("Draw Option Window"); } }