public static DialogBeginningNodeDisplayer CreateDisplayerFor(DialogBeginningWireNode node) { DialogBeginningNodeDisplayer nodeRenderer = new DialogBeginningNodeDisplayer(node) { WindowRect = new Rect(node.DisplayerPosition.x, node.DisplayerPosition.y, 270, 100) }; return(nodeRenderer); }
public bool HasCorrectBeginning() { if (NodesDictionary.Values.OfType <DialogBeginningWireNode>().Any()) { DialogBeginningWireNode beginning = NodesDictionary.Values.OfType <DialogBeginningWireNode>().ElementAt(0); if (beginning == null || beginning.Outputs == null || beginning.Outputs.Any(output => output.PinName == "Outgoing activity" && output.DataType == WDEngine.ActivityStream)) { return(true); } } return(false); }
public static DialogBeginningNodeDisplayer CreateDialogBeginningDisplayer(Vector2 position) { DialogBeginningWireNode node = new DialogBeginningWireNode(DialogEditor.Instance.EditingDialog) { NodeName = "Dialog beginning" }; DialogEditor.InitializeNode(ref node); DialogBeginningNodeDisplayer nodeRenderer = new DialogBeginningNodeDisplayer(node) { WindowRect = new Rect(position.x, position.y, 270, 100) }; return(nodeRenderer); }
/// <summary> /// <para> /// Call this to CREATE the dialog, the first time you want to use it. This is automatically managed by the /// dialog editor, so use this method only if you are sure of what you are doing. It will erase any content /// that could have been set in the dialog, and the add the specified beginning. The boolean /// <see cref="Initialized"/> will be set to "true" so that it will be considered as initialized (which is /// the case!) After that, it will save the dialog so that it will be loadable using the <see cref="Load"/> /// function. /// </para> /// <para> /// The beginning node will take an ID of 1 after being passed to this function. This is because as it will /// become the new first node of the dialog, it must take an ID of one. The <see cref="WireNode.WireNodeId"/> /// field will then be equal to one. Moreover, the output pin of the beginning node also takes an ID of one /// as it is the first pin created in this dialog. /// </para> /// <para> /// It is recommended to call the <see cref="UnityEditor.EditorApplication.SaveAssets"/> function in order /// to ensure that the dialog asset will be saved after the initialization of the dialog. /// </para> /// </summary> /// <param name="beginning">The node that will be the beginning of all the Wired Logic of the dialog.</param> public void Initialize(ref DialogBeginningWireNode beginning) { currWirePinId = 1; currWireNodeId = 1; dialogName = string.Empty; NodesDictionary = new Dictionary <uint, WireNode>(); Pins = new Dictionary <uint, WirePin>(); beginning.WireNodeId = GetNextWireNodeId(); NodesDictionary.Add(beginning.WireNodeId, beginning); beginning.Outputs[0].WirePinId = GetNextWirePinId(); Pins.Add(beginning.Outputs[0].WirePinId, beginning.Outputs[0]); // Do not do anything with the nodesList field, as it will be managed via the Save() function // Same thing with the serializedNodes field initialized = true; // Then save the dialog Save(null); }
public void LoadDialog(WireDialog dialog) { Debug.Log("Loading a new dialog..."); try { GraphEditor.NodeDisplayers.Clear(); // Clear the displayer UI } catch (Exception) { Debug.Log("An error occurred. Please reload the Dialog Editor. If this bug always happens, please contact me."); Close(); } if (!dialog.Initialized) { EditingDialog = dialog; // Needed to create the displayer DialogBeginningNodeDisplayer beginningDisplayer = DialogBeginningNodeDisplayer.CreateDialogBeginningDisplayer(new Vector2(100, 150)); DialogBeginningWireNode beginningNode = beginningDisplayer.GetRenderedNodeAs <DialogBeginningWireNode>(); dialog.Initialize(ref beginningNode); } dialog.Load(); EditingDialog = dialog; // Set the new dialog to edit foreach (WireNode node in dialog.NodesDictionary.Values) { if (node is EqualityWireNode) { GraphEditor.NodeDisplayers.Add((node as EqualityWireNode).CreateDisplayer()); } else if (node is GreaterWireNode) { GraphEditor.NodeDisplayers.Add((node as GreaterWireNode).CreateDisplayer()); } else if (node is InequalityWireNode) { GraphEditor.NodeDisplayers.Add((node as InequalityWireNode).CreateDisplayer()); } else if (node is LesserWireNode) { GraphEditor.NodeDisplayers.Add((node as LesserWireNode).CreateDisplayer()); } else if (node is ConstantWireNode) { GraphEditor.NodeDisplayers.Add((node as ConstantWireNode).CreateDisplayer()); } else if (node is SayReplyWireNode) { GraphEditor.NodeDisplayers.Add((node as SayReplyWireNode).CreateDisplayer()); } else if (node is BranchWireNode) { GraphEditor.NodeDisplayers.Add((node as BranchWireNode).CreateDisplayer()); } else if (node is SetAnimatorVariableWireNode) { GraphEditor.NodeDisplayers.Add((node as SetAnimatorVariableWireNode).CreateDisplayer()); } else if (node is GetAnimatorVariableWireNode) { GraphEditor.NodeDisplayers.Add((node as GetAnimatorVariableWireNode).CreateDisplayer()); } else if (node is ChooseReplyWireNode) { GraphEditor.NodeDisplayers.Add((node as ChooseReplyWireNode).CreateDisplayer()); } else if (node is ReunionWireNode) { GraphEditor.NodeDisplayers.Add((node as ReunionWireNode).CreateDisplayer()); } else if (node is GetVariableWireNode) { GraphEditor.NodeDisplayers.Add((node as GetVariableWireNode).CreateDisplayer()); } else if (node is SetVariableValWireNode) { GraphEditor.NodeDisplayers.Add((node as SetVariableValWireNode).CreateDisplayer()); } else if (node is DialogBeginningWireNode) { GraphEditor.NodeDisplayers.Add((node as DialogBeginningWireNode).CreateDisplayer()); } else if (node is TriggerScriptWireNode) { GraphEditor.NodeDisplayers.Add((node as TriggerScriptWireNode).CreateDisplayer()); } else if (node is SetTriggerParamValueWireNode) { GraphEditor.NodeDisplayers.Add((node as SetTriggerParamValueWireNode).CreateDisplayer()); } } Debug.Log("Loaded"); }
private DialogBeginningNodeDisplayer(DialogBeginningWireNode node) : base(node) { }
public static DialogBeginningNodeDisplayer CreateDisplayer(this DialogBeginningWireNode node) { return(DialogBeginningNodeDisplayer.CreateDisplayerFor(node)); }