Exemple #1
0
        void Parse()
        {
            btnodes.Clear();
            Clear();

            BTLTokenizer.Token[] tokens = null;

            try
            {
                tokens = BTLTokenizer.Tokenize(content);
            }
            catch (PandaScriptException e)
            {
                Debug.LogException(e);
            }

            GUINode node = null;

            if (tokens != null)
            {
                foreach (var t in tokens)
                {
                    if (t.content == null)
                    {
                        continue;
                    }

                    string trimmed = t.content.Trim();
                    if (trimmed == "")
                    {
                        continue;
                    }
                    if (trimmed.StartsWith("//"))
                    {
                        node       = new GUINode(GUINode.NodeType.Comment);
                        node.label = "//";
                        string comment = trimmed.Substring(2, trimmed.Length - 2);
                        node.Parameters_Add(new GUINodeParameter(typeof(string), comment));
                        Nodes_Add(node);
                    }
                    else
                    if (IsLabel(t))
                    {
                        node = new GUINode(trimmed);
                        Nodes_Add(node);
                        node.line = this;
                    }
                    else
                    if (t.valueType != BTLTokenizer.TokenValueType.None)
                    {
                        if (node != null)
                        {
                            node.Parameters_Add(new GUINodeParameter(t));
                        }
                    }
                }
            }
        }
        public GUINode Duplicate()
        {
            GUINode copy = new GUINode();

            copy.label    = this.label;
            copy.nodeType = this.nodeType;

            foreach (var p in this.parameters)
            {
                var pcopy = p.Duplicate();
                copy.Parameters_Add(pcopy);
            }

            return(copy);
        }