public void PrintClass(string fileName, Package.Class c) { var text = new CorrmStringBuilder($"// {c.FullName}{Utils.NLine}// "); if (c.InheritedSize > 0) { text += $"0x{c.Size - c.InheritedSize:X4} (0x{(long)c.Size:X4} - 0x{(long)c.InheritedSize:X4}){Utils.NLine}"; } else { text += $"0x{(long)c.Size:X4}{Utils.NLine}"; } text += $"{c.NameCppFull}{Utils.NLine}{{{Utils.NLine}public:{Utils.NLine}"; // Member foreach (var m in c.Members) { text += $"\t{(m.IsStatic ? "static " + m.Type : m.Type),-50} {m.Name,-58}; // 0x{(long)m.Offset:X4}(0x{(long)m.Size:X4})" + (!string.IsNullOrEmpty(m.Comment) ? " " + m.Comment : "") + (!string.IsNullOrEmpty(m.FlagsString) ? " (" + m.FlagsString + ")" : "") + $"{Utils.NLine}"; } text += $"{Utils.NLine}"; // Predefined Methods if (c.PredefinedMethods.Count > 0) { text += $"{Utils.NLine}"; foreach (var m in c.PredefinedMethods) { if (m.MethodType == PredefinedMethod.Type.Inline) { text += m.Body; } else { text += $"\t{m.Signature};"; } text += $"{Utils.NLine}{Utils.NLine}"; } } // Methods if (c.PredefinedMethods.Count > 0) { text += $"{Utils.NLine}"; foreach (var m in c.Methods) { text += $"\t{BuildMethodSignature(m, new Package.Class(), true)};{Utils.NLine}"; } } text += $"}};{Utils.NLine}{Utils.NLine}"; IncludeFile <CppLang> .AppendToSdk(Generator.SdkPath, fileName, text); }
public void PrintEnum(string fileName, Package.Enum e) { CorrmStringBuilder text = new CorrmStringBuilder($"// {e.FullName}{Utils.NLine}enum class {e.Name} : uint8_t{Utils.NLine}{{{Utils.NLine}"); for (int i = 0; i < e.Values.Count; i++) { text += $"\t{e.Values[i],-30} = {i},{Utils.NLine}"; } text += $"{Utils.NLine}}};{Utils.NLine}{Utils.NLine}"; IncludeFile <CppLang> .AppendToSdk(Generator.SdkPath, fileName, text); }
public override async Task SaveStructs(Package package) { // Create file string fileName = GenerateFileName(FileContentType.Structs, await package.GetName()); // Init File IncludeFile <CppLang> .CreateFile(Generator.SdkPath, fileName); IncludeFile <CppLang> .AppendToSdk(Generator.SdkPath, fileName, GetFileHeader(true)); if (package.Constants.Count > 0) { IncludeFile <CppLang> .AppendToSdk(Generator.SdkPath, fileName, GetSectionHeader("Constants")); foreach (var c in package.Constants) { PrintConstant(fileName, c); } } if (package.Enums.Count > 0) { IncludeFile <CppLang> .AppendToSdk(Generator.SdkPath, fileName, GetSectionHeader("Enums")); foreach (var e in package.Enums) { PrintEnum(fileName, e); } } if (package.ScriptStructs.Count > 0) { IncludeFile <CppLang> .AppendToSdk(Generator.SdkPath, fileName, GetSectionHeader("Script Structs")); foreach (var ss in package.ScriptStructs) { PrintStruct(fileName, ss); } } IncludeFile <CppLang> .AppendToSdk(Generator.SdkPath, fileName, GetFileFooter()); }
public override async Task SaveFunctionParameters(Package package) { // Create file string fileName = GenerateFileName(FileContentType.FunctionParameters, await package.GetName()); // Init File IncludeFile <CppLang> .CreateFile(Generator.SdkPath, fileName); IncludeFile <CppLang> .AppendToSdk(Generator.SdkPath, fileName, GetFileHeader(new List <string>() { "\"../SDK.h\"" }, true)); // Section var text = new CorrmStringBuilder(GetSectionHeader("Parameters")); // Method Params foreach (var c in package.Classes) { foreach (var m in c.Methods) { text += $"// {m.FullName}{Utils.NLine}" + $"struct {c.NameCpp}_{m.Name}_Params{Utils.NLine}{{{Utils.NLine}"; foreach (var param in m.Parameters) { text += $"\t{param.CppType,-50} {param.Name + ";",-58} // ({param.FlagsString}){Utils.NLine}"; } text += $"}};{Utils.NLine}{Utils.NLine}"; } } text += GetFileFooter(); // Write the file IncludeFile <CppLang> .AppendToSdk(Generator.SdkPath, fileName, text); }
public override async Task SaveClasses(Package package) { // Create file string fileName = GenerateFileName(FileContentType.Classes, await package.GetName()); // Init File IncludeFile <CppLang> .CreateFile(Generator.SdkPath, fileName); IncludeFile <CppLang> .AppendToSdk(Generator.SdkPath, fileName, GetFileHeader(true)); if (package.Classes.Count <= 0) { return; } IncludeFile <CppLang> .AppendToSdk(Generator.SdkPath, fileName, GetSectionHeader("Classes")); foreach (var c in package.Classes) { PrintClass(fileName, c); } IncludeFile <CppLang> .AppendToSdk(Generator.SdkPath, fileName, GetFileFooter()); }
public override async Task SdkAfterFinish(List <Package> packages, List <GenericTypes.UEStruct> missing) { var basicHeader = new BasicHeader(); var basicCpp = new BasicCpp(); // Copy Include File basicHeader.Process(IncludePath); basicCpp.Process(IncludePath); var text = new CorrmStringBuilder(); text += $"#pragma once{Utils.NLine}{Utils.NLine}"; text += $"// ------------------------------------------------ \\\\{Utils.NLine}"; text += $"// Sdk Generated By ( Unreal Finder Tool By CorrM ) \\\\{Utils.NLine}"; text += $"// ------------------------------------------------ \\\\{Utils.NLine}"; text += $"// Name: {Generator.GameName.Trim()}, Version: {Generator.GameVersion}{Utils.NLine}{Utils.NLine}"; text += $"{Utils.NLine}"; text += $"#include <set>{Utils.NLine}"; text += $"#include <string>{Utils.NLine}"; text += $"#include \"SDK/{basicHeader.FileName}\"{Utils.NLine}"; // Check for missing structs if (missing.Count > 0) { string missingText = string.Empty; // Init File IncludeFile <CppLang> .CreateFile(Path.GetDirectoryName(Generator.SdkPath), "MISSING.h"); foreach (var s in missing) { IncludeFile <CppLang> .AppendToSdk(Path.GetDirectoryName(Generator.SdkPath), "MISSING.h", GetFileHeader(true)); missingText += $"// {await s.GetFullName()}{Utils.NLine}// "; missingText += $"0x{await s.GetPropertySize():X4}{Utils.NLine}"; missingText += $"struct {MakeValidName(await s.GetNameCpp())}{Utils.NLine}{{{Utils.NLine}"; missingText += $"\tunsigned char UnknownData[0x{await s.GetPropertySize():X}];{Utils.NLine}}};{Utils.NLine}{Utils.NLine}"; } missingText += GetFileFooter(); IncludeFile <CppLang> .WriteToSdk(Path.GetDirectoryName(Generator.SdkPath), "MISSING.h", missingText); // Append To Sdk Header text += $"{Utils.NLine}#include \"SDK/MISSING.h\"{Utils.NLine}"; } text += $"{Utils.NLine}"; foreach (var package in packages) { text += $"#include \"SDK/{GenerateFileName(FileContentType.Structs, await package.GetName())}\"{Utils.NLine}"; text += $"#include \"SDK/{GenerateFileName(FileContentType.Classes, await package.GetName())}\"{Utils.NLine}"; if (Generator.ShouldGenerateFunctionParametersFile()) { text += $"#include \"SDK/{GenerateFileName(FileContentType.FunctionParameters, await package.GetName())}\"{Utils.NLine}"; } } // Write SDK.h IncludeFile <CppLang> .AppendToSdk(Path.GetDirectoryName(Generator.SdkPath), "SDK.h", text); }
public override async Task SaveFunctions(Package package) { if (Generator.SdkType == SdkType.External) { return; } // Create Function Parameters File if (Generator.ShouldGenerateFunctionParametersFile()) { await SaveFunctionParameters(package); } // //////////////////////// // Create Functions file string fileName = GenerateFileName(FileContentType.Functions, await package.GetName()); // Init Functions File IncludeFile <CppLang> .CreateFile(Generator.SdkPath, fileName); IncludeFile <CppLang> .AppendToSdk(Generator.SdkPath, fileName, GetFileHeader(new List <string>() { "\"../SDK.h\"" }, false)); var text = new CorrmStringBuilder(GetSectionHeader("Functions")); foreach (var s in package.ScriptStructs) { foreach (var m in s.PredefinedMethods) { if (m.MethodType != PredefinedMethod.Type.Inline) { text += $"{m.Body}{Utils.NLine}{Utils.NLine}"; } } } foreach (var c in package.Classes) { foreach (var m in c.PredefinedMethods) { if (m.MethodType != PredefinedMethod.Type.Inline) { text += $"{m.Body}{Utils.NLine}{Utils.NLine}"; } } foreach (var m in c.Methods) { //Method Info text += $"// {m.FullName}{Utils.NLine}" + $"// ({m.FlagsString}){Utils.NLine}"; if (m.Parameters.Count > 0) { text += $"// Parameters:{Utils.NLine}"; foreach (var param in m.Parameters) { text += $"// {param.CppType,-30} {param.Name,-30} ({param.FlagsString}){Utils.NLine}"; } } text += $"{Utils.NLine}"; text += BuildMethodSignature(m, c, false) + $"{Utils.NLine}"; text += BuildMethodBody(c, m) + $"{Utils.NLine}{Utils.NLine}"; } } text += GetFileFooter(); // Write the file IncludeFile <CppLang> .AppendToSdk(Generator.SdkPath, fileName, text); }
public void PrintConstant(string fileName, Package.Constant c) { IncludeFile <CppLang> .AppendToSdk(Generator.SdkPath, fileName, $"#define CONST_{c.Name,-50} {c.Value}{Utils.NLine}"); }