public Connection(ConnectionType type, NodeDataBase data, IConnectionChildCollection childCollection, IDialogueWindow window, bool isFirst) { IsFirst = isFirst; Window = window; Type = type; Data = data; _childCollection = childCollection; Links = new ConnectionLinks(this, childCollection); }
public void CreateData(NodeDataBase data, Vector2 position) { Undo.SetCurrentGroupName("Create node"); Undo.RecordObject(_graph, "New node"); NewNode(data, position); Undo.CollapseUndoOperations(Undo.GetCurrentGroup()); }
public bool IsValid(string data, out IList <INodeData> nodeDatas, int position, out string patched) { nodeDatas = new List <INodeData>(1); NodeDataBase nodeData = new NodeDataBase(NodeType, data, position); nodeDatas.Add(nodeData); patched = string.Empty; return(true); }
public ActionsSortableList(Editor editor, string property, NodeDataBase node, List <ActionDataBase> actions) : base(editor, property) { _soPrinter = new ScriptableObjectListPrinter(_serializedProp); _actionCrud = new NestedDataCrud <ActionDataBase>(node, actions, ActionTypes); _list.drawElementCallback = _soPrinter.DrawScriptableObject; _list.elementHeightCallback = _soPrinter.GetHeight; _list.onAddDropdownCallback = _actionCrud.ShowMenu; _list.onRemoveCallback = _actionCrud.DeleteItem; }
private void NewNode(NodeDataBase data, Vector2 position) { data.ClearConnectionChildren(); data.rect.position = position; _graph.AddNode(data); AssetDatabase.AddObjectToAsset(data, _graph); AssetDatabase.SaveAssets(); var instance = _window.CreateNodeInstance(data); _window.Nodes.Add(instance); Undo.RegisterCreatedObjectUndo(data, "Create node"); }
public NodeEditorBase CreateNodeInstance(NodeDataBase data) { var displayType = NodeAssemblies.DataToDisplay[data.GetType()]; var instance = Activator.CreateInstance(displayType) as NodeEditorBase; if (instance == null) { throw new NullReferenceException($"No type found for ${data}"); } instance.Setup(this, data); DataToNode[data] = instance; return(instance); }
public bool IsValid(string data, out IList <INodeData> nodeDatas, int position, out string patched) { if (string.IsNullOrEmpty(data)) { patched = data; nodeDatas = null; return(false); } if (data.Length < (START_LENGTH + END_LENGTH)) { patched = data; nodeDatas = null; return(false); } if (!data.StartsWith(START_SYMBOL)) { patched = data; nodeDatas = null; return(false); } if (!data.EndsWith(END_SYMBOL)) { patched = data; nodeDatas = null; return(false); } var content = data.Substring(START_LENGTH, data.Length - (START_LENGTH + END_LENGTH)); NodeDataBase obj = new NodeDataBase(NodeType, data, position); nodeDatas = new List <INodeData>(1); INodeData symbolStart = new NodeDataBase(NodeType.SYMBOL, START_SYMBOL, position); INodeData nodeData = new NodeDataBase(NodeType.OBJECT_CONTENT, content, position); INodeData symbolEnd = new NodeDataBase(NodeType.SYMBOL, END_SYMBOL, position); obj.SubNodes.Add(symbolStart); obj.SubNodes.Add(nodeData); obj.SubNodes.Add(symbolEnd); nodeDatas.Add(obj); patched = string.Empty; return(true); }
public void Setup(DialogueWindow window, NodeDataBase data) { Window = window; Data = data; _styles = new NodeStyles(NodeColor); Data.rect.width = NodeWidth; serializedObject = new SerializedObject(data); CreateConnection(ConnectionType.Out, data, true); Out[0].Hide = !HasOutConnection; CreateConnection(ConnectionType.In, data, true); In[0].Hide = !HasInConnection; OnSetup(); }
public static void ShowValidation(NodeDataBase target) { var serializedObject = new SerializedObject(target); var dialogue = serializedObject.FindProperty("dialogue"); var choices = serializedObject.FindProperty("choices"); SpellCheck.Instance.ClearValidation(); if (dialogue != null) { SpellCheck.Instance.AddValidation(dialogue.displayName, dialogue.stringValue); } if (choices != null) { for (var i = 0; i < choices.arraySize; i++) { var choice = choices.GetArrayElementAtIndex(i).objectReferenceValue as ChoiceData; SpellCheck.Instance.AddValidation($"Choice {i}", choice.text); } } }
public bool IsValid(string data, out IList <INodeData> nodeDatas, int position, out string patched) { if (string.IsNullOrEmpty(data)) { nodeDatas = null; patched = data; return(false); } if (data.Length < 2) { nodeDatas = null; patched = data; return(false); } cachedList.Clear(); AllIndexesOf(data, START_SYMBOL, cachedList); if (cachedList.Count() == 0) { nodeDatas = null; patched = data; return(false); } AllIndexesOf(data, END_SYMBOL, cachedList); if (cachedList.Count() == 0) { nodeDatas = null; patched = data; return(false); } var indexes = GetIndexes(data, cachedList); int startIndex = indexes[0] + 1; int endIndex = indexes[1]; var content = data.Substring(startIndex, endIndex - startIndex); var fullText = data.Substring(startIndex - START_LENGTH, content.Length + START_LENGTH + END_LENGTH); NodeDataBase obj = new NodeDataBase(NodeType, fullText, position); nodeDatas = new List <INodeData>(1); INodeData symbolStart = new NodeDataBase(NodeType.COMMENT, START_SYMBOL, position); INodeData nodeData = new NodeDataBase(NodeType, content, position); INodeData symbolEnd = new NodeDataBase(NodeType.COMMENT, END_SYMBOL, position); patched = data.Substring(0, startIndex - 1); patched += data.Substring(endIndex + 1, data.Length - endIndex - 1); obj.SubNodes.Add(symbolStart); obj.SubNodes.Add(nodeData); obj.SubNodes.Add(symbolEnd); nodeDatas.Add(obj); return(true); }
public void RemoveConnectionChild(NodeDataBase child) { children.Remove(child); }
public void AddConnectionChild(NodeDataBase child) { children.Add(child); }
protected override NodeDataBase OnCreateDataCopy(NodeDataBase copy) { return(_choices.GetParentDataCopy(copy as NodeDataChoiceBase)); }
public NestedDataCrud(NodeDataBase node, List <T> list, TypesToMenu <T> menuData) { _menuData = menuData; _node = node; _list = list; }
public bool IsValid(string data, out IList <INodeData> nodeDatas, int position, out string patched) { if (string.IsNullOrEmpty(data)) { nodeDatas = null; patched = data; return(false); } if (data.Length < 2) { nodeDatas = null; patched = data; return(false); } cachedList.Clear(); int startIndex; int endIndex; AllIndexesOf(data, START_SYMBOL, cachedList); if (cachedList.Count == 0) { nodeDatas = null; patched = data; return(false); } startIndex = cachedList[0]; AllIndexesOf(data, END_SYMBOL, cachedList); if (cachedList.Count == 0) { nodeDatas = null; patched = data; return(false); } endIndex = cachedList[0]; if (startIndex != 0) { patched = data; nodeDatas = new List <INodeData>(); return(false); } var content = data.Substring(startIndex + 1, endIndex - startIndex - 1); var fullText = data.Substring(startIndex, endIndex - startIndex + 1); NodeDataBase obj = new NodeDataBase(NodeType, fullText, position); nodeDatas = new List <INodeData>(1); INodeData symbolStart = new NodeDataBase(NodeType.SYMBOL, START_SYMBOL, position); INodeData nodeData = new NodeDataBase(NodeType.METADATA_CONTENT, content, position); INodeData symbolEnd = new NodeDataBase(NodeType.SYMBOL, END_SYMBOL, position); var firstPart = data.Substring(0, startIndex); var secondPart = data.Substring(endIndex + 1, data.Length - 1 - endIndex); patched = firstPart + secondPart; MainParser mainParser = new MainParser(); IList <INodeData> list; mainParser.ExtractNodeData(content, out list); nodeData.SubNodes.AddRange(list); obj.SubNodes.Add(symbolStart); obj.SubNodes.Add(nodeData); obj.SubNodes.Add(symbolEnd); nodeDatas.Add(obj); return(true); }
public void DeleteNode(NodeDataBase node) { _nodes.Remove(node); }
public void AddNode(NodeDataBase node) { node.Setup(); _nodes.Add(node); }
protected virtual NodeDataBase OnCreateDataCopy(NodeDataBase copy) { return(copy); }