Ejemplo n.º 1
0
        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());
        }
Ejemplo n.º 2
0
        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);
        }
Ejemplo n.º 3
0
        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());
        }
Ejemplo n.º 4
0
        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);
        }
Ejemplo n.º 5
0
        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);
        }