コード例 #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);
        }