예제 #1
0
 // we have found a new node
 // set up the currentNode var ready to hold it and otherwise continue
 public override void EnterNode(YarnSpinnerParser.NodeContext context)
 {
     if (currentNode != null)
     {
         string newNode = context.header().header_title().TITLE_TEXT().GetText().Trim();
         string message = string.Format(CultureInfo.CurrentCulture, "Discovered a new node {0} while {1} is still being parsed", newNode, currentNode.name);
         throw new Yarn.ParseException(message);
     }
     currentNode = new Node();
     rawTextNode = false;
 }
예제 #2
0
        public override Yarn.Type VisitNode(YarnSpinnerParser.NodeContext context)
        {
            currentNodeContext = context;
            foreach (var header in context.header())
            {
                if (header.header_key.Text == "title")
                {
                    currentNodeName = header.header_value.Text;
                }
            }
            Visit(context.body());

            return(Yarn.Type.Undefined);
        }
        public override int VisitNode(YarnSpinnerParser.NodeContext context)
        {
            currentNodeContext = context;

            List <string> tags = new List <string>();

            foreach (var header in context.header())
            {
                string headerKey   = header.header_key.Text;
                string headerValue = header.header_value?.Text ?? string.Empty;

                if (headerKey.Equals("title", StringComparison.InvariantCulture))
                {
                    currentNodeName = header.header_value.Text;
                }

                if (headerKey.Equals("tags", StringComparison.InvariantCulture))
                {
                    // Split the list of tags by spaces, and use that
                    tags = new List <string>(headerValue.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries));
                }
            }

            if (string.IsNullOrEmpty(currentNodeName) == false && tags.Contains("rawText"))
            {
                // This is a raw text node. Use its entire contents as a
                // string and don't use its contents.
                var lineID = Compiler.GetLineIDForNodeName(currentNodeName);
                stringTableManager.RegisterString(context.body().GetText(), fileName, currentNodeName, lineID, context.body().Start.Line, null);
            }
            else
            {
                // This is a regular node
                // this.Visit(context.body());

                var body = context.body();
                if (body != null)
                {
                    this.Visit(body);
                }
                // String table generator: don't crash if a node has no body
            }

            return(0);
        }
예제 #4
0
        public override Yarn.IType VisitNode(YarnSpinnerParser.NodeContext context)
        {
            currentNodeContext = context;
            foreach (var header in context.header())
            {
                if (header.header_key.Text == "title")
                {
                    currentNodeName = header.header_value.Text;
                }
            }

            var body = context.body();

            if (body != null)
            {
                base.Visit(body);
            }

            return(null);
        }
예제 #5
0
        public override string VisitNode([NotNull] YarnSpinnerParser.NodeContext context)
        {
            string title    = null;
            string tracking = null;

            foreach (var header in context.header())
            {
                var headerKey = header.header_key.Text;
                if (headerKey.Equals("title"))
                {
                    title = header.header_value?.Text;
                }
                else if (headerKey.Equals("tracking"))
                {
                    tracking = header.header_value?.Text;
                }
            }

            if (title != null && tracking != null)
            {
                if (tracking.Equals("always"))
                {
                    TrackingNode.Add(title);
                }
                else if (tracking.Equals("never"))
                {
                    NeverVisitNodes.Add(title);
                }
            }

            if (context.body() != null)
            {
                return(Visit(context.body()));
            }
            return(null);
        }