public string PrintClassInit(string className, string fieldName) { var printer = new LuaPrinterContext(); printer.WriteLine($"{className} = class()"); printer.WriteLine($"function {className}:CreateWidget()"); printer.TabIn(); printer.WriteLine($"self.{fieldName} = {UiComplexProperty.TypeInitExpression(Type)}"); printer.WriteLine("self.Elements = {}"); printer.ElementProperty = "self.Elements"; PrintSetter(printer, $"self.{fieldName}"); printer.ElementProperty = null; printer.TabOut(); printer.WriteLine("end"); printer.WriteLine($"function {className}:init(...)"); printer.TabIn(); printer.WriteLine("self:CreateWidget()"); printer.WriteLine("if self.ctor ~= nil then"); printer.TabIn(); printer.WriteLine("self:ctor(...)"); printer.TabOut(); printer.WriteLine("end"); printer.TabOut(); printer.WriteLine("end"); return(printer.GetString()); }
public string PrintStylesheetInit() { var printer = new LuaPrinterContext(); printer.WriteLine($"function CreateStylesheet()"); printer.TabIn(); printer.WriteLine("local stylesheet = ClrTypes.LibreLancer_Interface_Stylesheet.__new()"); PrintSetter(printer, "stylesheet"); printer.WriteLine("return stylesheet"); printer.TabOut(); printer.WriteLine("end"); return(printer.GetString()); }