public void AddChoicePort(DialogueNode nodeCache, string overriddenPortName = "") { var generatedPort = GetPortInstance(nodeCache, Direction.Output); var portLabel = generatedPort.contentContainer.Q <Label>("type"); generatedPort.contentContainer.Remove(portLabel); var outputPortCount = nodeCache.outputContainer.Query("connector").ToList().Count(); var outputPortName = string.IsNullOrEmpty(overriddenPortName) ? $"Option {outputPortCount + 1}" : overriddenPortName; var textField = new TextField() { name = string.Empty, value = outputPortName }; textField.RegisterValueChangedCallback(evt => generatedPort.portName = evt.newValue); generatedPort.contentContainer.Add(new Label(" ")); generatedPort.contentContainer.Add(textField); var deleteButton = new Button(() => RemovePort(nodeCache, generatedPort)) { text = "X" }; generatedPort.contentContainer.Add(deleteButton); generatedPort.portName = outputPortName; nodeCache.outputContainer.Add(generatedPort); nodeCache.RefreshPorts(); nodeCache.RefreshExpandedState(); }
public DialogueNode CreateNode(string nodeName, string nodeText, Vector2 position) { var tempDialogueNode = new DialogueNode() { title = nodeName, DialogueId = nodeName, DialogueText = nodeText, GUID = Guid.NewGuid().ToString() }; tempDialogueNode.styleSheets.Add(Resources.Load <StyleSheet>("Node")); var inputPort = GetPortInstance(tempDialogueNode, Direction.Input, Port.Capacity.Multi); inputPort.portName = "Input"; tempDialogueNode.inputContainer.Add(inputPort); tempDialogueNode.RefreshExpandedState(); tempDialogueNode.RefreshPorts(); tempDialogueNode.SetPosition(new Rect(position, DefaultNodeSize)); //To-Do: implement screen center instantiation positioning var idLabel = new Label("Node Id:"); tempDialogueNode.mainContainer.Add(idLabel); var idField = new TextField(int.MaxValue, false, false, '*'); idField.RegisterValueChangedCallback(evt => { tempDialogueNode.DialogueId = evt.newValue; tempDialogueNode.title = evt.newValue; }); idField.SetValueWithoutNotify(tempDialogueNode.DialogueId); tempDialogueNode.mainContainer.Add(idField); var textLabel = new Label("Dialogue (multi-line):"); tempDialogueNode.mainContainer.Add(textLabel); var textField = new TextField(int.MaxValue, true, false, '*'); textField.RegisterValueChangedCallback(evt => { tempDialogueNode.DialogueText = evt.newValue; }); textField.SetValueWithoutNotify(tempDialogueNode.DialogueText); tempDialogueNode.mainContainer.Add(textField); var button = new Button(() => { AddChoicePort(tempDialogueNode); }) { text = "Add Choice" }; tempDialogueNode.titleButtonContainer.Add(button); return(tempDialogueNode); }
private DialogueNode GetEntryPointNodeInstance() { var nodeCache = new DialogueNode() { title = "START", GUID = Guid.NewGuid().ToString(), DialogueText = "ENTRYPOINT", EntyPoint = true }; var generatedPort = GetPortInstance(nodeCache, Direction.Output); generatedPort.portName = "Next"; nodeCache.outputContainer.Add(generatedPort); nodeCache.capabilities &= ~Capabilities.Movable; nodeCache.capabilities &= ~Capabilities.Deletable; nodeCache.RefreshExpandedState(); nodeCache.RefreshPorts(); nodeCache.SetPosition(new Rect(100, 200, 100, 150)); return(nodeCache); }
public DialogueNode CreateNode(string nodeName, Vector2 position, Texture2D Sprite, string nameCharacter) { var tempDialogueNode = new DialogueNode() { title = nodeName, DialogueText = nodeName, // SpriteCharacter = Sprite, NameCharacter = nameCharacter, SpriteCharacter = Sprite, GUID = Guid.NewGuid().ToString() }; tempDialogueNode.styleSheets.Add(Resources.Load <StyleSheet>("Node")); var inputPort = GetPortInstance(tempDialogueNode, Direction.Input, Port.Capacity.Multi); inputPort.portName = "Input"; tempDialogueNode.inputContainer.Add(inputPort); tempDialogueNode.RefreshExpandedState(); tempDialogueNode.RefreshPorts(); tempDialogueNode.SetPosition(new Rect(position, DefaultNodeSize)); //To-Do: implement screen center instantiation positioning var textField = new TextField(""); var textFieldCharacter = new TextField(""); var SpriteCharacter = DefaultSprite; // var SpriteCharacterDefault = DefaultSprite; textField.RegisterValueChangedCallback(evt => { tempDialogueNode.title = evt.newValue; // tempDialogueNode.NameCharacter = evt.newValue; //tempDialogueNode.NameCharacter = evt.newValue; tempDialogueNode.DialogueText = evt.newValue; }); textFieldCharacter.RegisterValueChangedCallback(evt => { tempDialogueNode.NameCharacter = evt.newValue; }); /* * textFieldCharacter.RegisterValueChangedCallback(evt => * { * * }); */ textFieldCharacter.SetValueWithoutNotify(tempDialogueNode.NameCharacter); textField.SetValueWithoutNotify(tempDialogueNode.title); // SpriteCharacterDefault = tempDialogueNode.SpriteCharacter; tempDialogueNode.mainContainer.Add(textField); tempDialogueNode.mainContainer.Add(textFieldCharacter); var button = new Button(() => { AddChoicePort(tempDialogueNode); }) { text = "Add Choice" }; //TODO: load sprinte in editor //OR //Load image using Events //var Sprite = new Image(() = >{ Addimage(Image) ;) tempDialogueNode.titleButtonContainer.Add(button); return(tempDialogueNode); }