private bool HandleFunction(FunctionNode function) { if(this.functionLookup.TryGetFunction(function.functionName, out bool _isUserFunction, out FunctionHandler handler)) { handler.HandleFunctionNode(this, function); return true; } return false; }
public override void HandleFunctionNode(TreeWalker walker, FunctionNode function) { if(walker.forNextStatementIncrementString.Count == 0) { walker.scriptBuilder.AppendWarning("'Next' statement without matching 'For' statement"); } walker.scriptBuilder.EmitPython(walker.forNextStatementIncrementString.Pop()); //Reduce indent by 1 as while loop is finished walker.scriptBuilder.ModifyIndentPermanently(-1); }
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 * * * */ }
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"); }
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()); }
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})"); }
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); } }
public override void HandleFunctionNode(TreeWalker walker, FunctionNode function) { walker.sawJumpfCommand = true; walker.scriptBuilder.EmitStatement($"jump {GetJumpfLabelNameFromID(walker.jumpfTargetCount)}"); }
public override void HandleFunctionNode(TreeWalker walker, FunctionNode function) { List<Node> arguments = function.GetArguments(1); LabelNode gosubTargetLabel = VerifyType<LabelNode>(arguments[0]); walker.scriptBuilder.EmitStatement($"call {gosubTargetLabel.labelName}"); }
public override void HandleFunctionNode(TreeWalker walker, FunctionNode function) { List<Node> arguments = function.GetArguments(1); walker.functionLookup.RegisterUserFunction(VerifyType<AliasNode>(arguments[0]).aliasName); }
public override void HandleFunctionNode(TreeWalker walker, FunctionNode function) { TreeWalker.HandleAliasNode(walker, function, isNumAlias:true); }
public abstract void HandleFunctionNode(TreeWalker walker, FunctionNode function);
public override void HandleFunctionNode(TreeWalker walker, FunctionNode function) { List<Node> arguments = function.GetArguments(1); string lvalue = walker.TranslateExpression(arguments[0]); walker.scriptBuilder.EmitPython($"{lvalue} -= 1"); }