コード例 #1
0
ファイル: Compiler.cs プロジェクト: Somnacin7/YarnSpinner
        // an option statement
        // [[ OPTION_TEXT | OPTION_LINK]] or [[OPTION_TEXT]]
        public override int VisitOption_statement(YarnSpinnerParser.Option_statementContext context)
        {
            // if it is a split style option
            if (context.OPTION_LINK() != null)
            {
                string destination = context.OPTION_LINK().GetText();
                string label       = context.OPTION_TEXT().GetText();

                int lineNumber = context.Start.Line;

                // getting the lineID from the hashtags if it has one
                string lineID = compiler.GetLineID(context.hashtag_block());

                string stringID = compiler.RegisterString(label, compiler.currentNode.Name, lineID, lineNumber);
                compiler.Emit(OpCode.AddOption, new Operand(stringID), new Operand(destination));

                // TODO: FIGURE OUT A BETTER WAY TO DECIDE WHEN TO SHOW OPTIONS
                if (compiler.currentNode.Instructions.Where(i => i.Opcode == OpCode.AddOption).Count() >= 4)
                {
                    compiler.Emit(OpCode.ShowOptions);
                }
            }
            else
            {
                string destination = context.OPTION_TEXT().GetText();
                compiler.Emit(OpCode.RunNode, new Operand(destination));
            }
            return(0);
        }
コード例 #2
0
 public override void ExitOption_statement(YarnSpinnerParser.Option_statementContext context)
 {
     var link = context.OPTION_LINK();
     if (link != null)
     {
         graph.edge(currentNode,link.GetText());
     }
     else
     {
         graph.edge(currentNode, context.OPTION_TEXT().GetText());
     }
 }
コード例 #3
0
ファイル: Compiler.cs プロジェクト: wzzwzz687510/YarnSpinner
        // an option statement
        // [[ OPTION_TEXT | OPTION_LINK]] or [[OPTION_TEXT]]
        public override int VisitOption_statement(YarnSpinnerParser.Option_statementContext context)
        {
            // if it is a split style option
            if (context.OPTION_LINK() != null)
            {
                string destination = context.OPTION_LINK().GetText();
                string label       = context.OPTION_TEXT().GetText();

                int lineNumber = context.Start.Line;

                // getting the lineID from the hashtags if it has one
                string lineID = compiler.GetLineID(context.hashtag_block());

                string stringID = compiler.program.RegisterString(label, compiler.currentNode.name, lineID, lineNumber, true);
                compiler.Emit(ByteCode.AddOption, stringID, destination);
            }
            else
            {
                string destination = context.OPTION_TEXT().GetText();
                compiler.Emit(ByteCode.RunNode, destination);
            }
            return(0);
        }
コード例 #4
0
 /// <summary>
 /// Visit a parse tree produced by <see cref="YarnSpinnerParser.option_statement"/>.
 /// <para>
 /// The default implementation returns the result of calling <see cref="AbstractParseTreeVisitor{Result}.VisitChildren(IRuleNode)"/>
 /// on <paramref name="context"/>.
 /// </para>
 /// </summary>
 /// <param name="context">The parse tree.</param>
 /// <return>The visitor result.</return>
 public virtual Result VisitOption_statement([NotNull] YarnSpinnerParser.Option_statementContext context)
 {
     return(VisitChildren(context));
 }
コード例 #5
0
 /// <summary>
 /// Exit a parse tree produced by <see cref="YarnSpinnerParser.option_statement"/>.
 /// <para>The default implementation does nothing.</para>
 /// </summary>
 /// <param name="context">The parse tree.</param>
 public virtual void ExitOption_statement([NotNull] YarnSpinnerParser.Option_statementContext context)
 {
 }