コード例 #1
0
 public override void HandleFunctionNode(TreeWalker walker, FunctionNode function)
 {
     List<Node> arguments = function.GetArguments(2);
     string lvalue = walker.TranslateExpression(arguments[0]);
     string assigned_value = walker.TranslateExpression(arguments[1]);
     walker.scriptBuilder.EmitPython($"{lvalue} {Op()} {assigned_value}");
 }
コード例 #2
0
        public override void HandleFunctionNode(TreeWalker walker, FunctionNode function)
        {
            StringBuilder tempBuilder = new StringBuilder();
            List<Node> arguments = function.GetArguments();
            int argCount = arguments.Count;

            tempBuilder.Append($"call {function.functionName}");

            //add first argument, the 'label' to call ('function' name)
            if(argCount > 0)
            {
                tempBuilder.Append("(");
                tempBuilder.Append(walker.TranslateExpression(arguments[0]));

                //append the function arguments, if any
                for (int i = 1; i < argCount; i++)
                {
                    tempBuilder.Append(", ");
                    tempBuilder.Append(walker.TranslateExpression(arguments[i]));
                }
                tempBuilder.Append(")");
            }

            walker.scriptBuilder.EmitStatement(tempBuilder.ToString());
        }
コード例 #3
0
        public override void HandleFunctionNode(TreeWalker walker, FunctionNode function)
        {
            List<Node> arguments = function.GetArguments(4,5);
            string spriteNumber = walker.TranslateExpression(arguments[0]);
            string filename_or_tag = walker.TranslateExpression(arguments[1]);
            string top_left_x = walker.TranslateExpression(arguments[2]);
            string top_left_y = walker.TranslateExpression(arguments[3]);

            string opacity = "100";
            if(arguments.Count >= 5)
            {
                opacity = walker.TranslateExpression(arguments[4]);
            }

            //ExtractTagsAndFilename(filename_or_tag, out string filename, out string tags);
            //string filename_no_ext = Path.GetFileNameWithoutExtension(filename);

            //save all the sprite information to the sprite number:sprite object hashmap
            //load and display the image
            walker.scriptBuilder.EmitPython($"pons_lsp({spriteNumber}, {filename_or_tag}, {top_left_x}, {top_left_y}, {opacity})");

            /*walker.scriptBuilder.EmitPython($"sprite_number[{}] = {}");

            walker.scriptBuilder.EmitStatement($"show {filename_no_ext}:");

            //TODO: x and y pos need to match the positioning of Ponscripter - currently taken as top left of screen coord.
            walker.scriptBuilder.EmitStatement($"xpos {top_left_x}");
            walker.scriptBuilder.EmitStatement($"ypos {top_left_y}");
            
            if (arguments.Count == 5)
            {
                string opacity = walker.TranslateExpression(arguments[4]);
                walker.scriptBuilder.EmitStatement($"alpha {opacity}");
            }*/


            //TODO: probably better to make a renpy function which handles all of this which mirrors the lsp of ponscripter.


            //Use something like this to implement
            //    $ renpy.show("eileen " + "vhappy", at_list=[makeTransform(200)], tag="tag1")
            /*Where makeTransform is:
             *     def makeTransform(xpos):
                    t = Transform()
                    t.xpos = xpos
                    return t
             * 
             * 
             * */


        }
コード例 #4
0
        public override void HandleFunctionNode(TreeWalker walker, FunctionNode function)
        {
            List<Node> arguments = function.GetArguments(1);
            string btndefFilename = walker.TranslateExpression(arguments[0]);

            walker.scriptBuilder.EmitPython($"pons_btndef({btndefFilename})");
        }
コード例 #5
0
 public override void HandleFunctionNode(TreeWalker walker, FunctionNode function)
 {
     for(int i = 0; i < function.GetArguments().Count; i++)
     {
         string s = walker.TranslateExpression(function.GetArguments()[i]);
         walker.scriptBuilder.EmitPython($"{s} = pons_args[{i}]");
     }           
 }
コード例 #6
0
        public override void HandleFunctionNode(TreeWalker walker, FunctionNode function)
        {
            List<Node> arguments = function.GetArguments(1);
            ArrayReferenceNode arrayReference = VerifyType<ArrayReferenceNode>(arguments[0]);
            //walker.scriptBuilder.EmitPython($"{walker.TranslateArray(arrayReference) }");

            StringBuilder tempBuilder = new StringBuilder();

            tempBuilder.Append($"{TreeWalker.MangleArrayName(arrayReference.arrayName)} = Dim(");

            tempBuilder.Append($"{walker.TranslateExpression(arrayReference.nodes[0])}");
            
            for(int i = 1; i < arrayReference.nodes.Count; i++)
            {
                tempBuilder.Append($", {walker.TranslateExpression(arrayReference.nodes[i])}");
            }

            tempBuilder.Append(")");

            walker.scriptBuilder.EmitPython(tempBuilder.ToString());
        }
コード例 #7
0
        public string TranslateArray(TreeWalker walker, ArrayReferenceNode arrayReference)
        {
            StringBuilder tempBuilder = new StringBuilder();

            tempBuilder.Append($"{MangleArrayName(arrayReference.arrayName)}");
            foreach (Node bracketedExpression in arrayReference.nodes)
            {
                tempBuilder.Append($"[{walker.TranslateExpression(bracketedExpression)}]");
            }

            return tempBuilder.ToString();
        }
コード例 #8
0
        public override void HandleFunctionNode(TreeWalker walker, FunctionNode function)
        {
            List<Node> arguments = function.GetArguments(1);
            string btnWaitResultOutputVariable = walker.TranslateExpression(arguments[0]);

            //use "call" to show the buttons, then clear them after user presses on them
            //TODO: not sure whether to use "call" or "show" here - maybe 'show' because ponscripter won't automatically clear the images off the screen.
            walker.scriptBuilder.EmitStatement($"call screen MultiButton()");

            //Renpy places the result (which button id was pressed) in the `_return` variable. 
            //Copy from the renpy `_return` variable to the user defined output variable
            walker.scriptBuilder.EmitPython($"{btnWaitResultOutputVariable} = _return");
        }
コード例 #9
0
        public override void HandleFunctionNode(TreeWalker walker, FunctionNode function)
        {
            string spriteNumber;
            string buttonNumber;
            string sprite_control;

            if(function.functionName == "spbtn")
            {
                List<Node> arguments = function.GetArguments(2);
                spriteNumber = walker.TranslateExpression(arguments[0]);
                buttonNumber = walker.TranslateExpression(arguments[1]);
            }
            else
            {
                List<Node> arguments = function.GetArguments(3);
                spriteNumber = walker.TranslateExpression(arguments[0]);
                buttonNumber = walker.TranslateExpression(arguments[1]);
                sprite_control = walker.TranslateExpression(arguments[2]);
            }

            walker.scriptBuilder.EmitPython($"pons_spbtn({spriteNumber}, {buttonNumber})");
        }
コード例 #10
0
        public static void HandleAliasNode(TreeWalker walker, FunctionNode function, bool isNumAlias)
        {
            List<Node> arguments = function.GetArguments(2);

            string aliasName = FunctionHandler.VerifyType<AliasNode>(arguments[0]).aliasName;

            string aliasValue = walker.TranslateExpression(arguments[1]);

            Log.Information($"Received numalias {aliasName} = {aliasValue}");

            //string mangledAliasName = isNumAlias ? MangleNumalias(aliasName) : MangleStralias(aliasName);
            string mangledAliasName = MangleAlias(aliasName);
            walker.scriptBuilder.EmitPython($"{mangledAliasName} = {aliasValue}");

            if(isNumAlias)
            {
                walker.numAliasDictionary.Set(aliasName, 0);
            }
            else
            {
                walker.stringAliasDictionary.Set(aliasName, 0);
            }

        }