Пример #1
0
 void WriteSummary(ExtendedStringBuilder sb)
 {
     sb.SetClassIndent();
     sb.AppendLine("/// <summary>");
     sb.AppendLine($"/// {ClassName}:{SuperClass}");
     sb.AppendLine($"/// Size: 0x{ClassSize:X2}");
     sb.AppendLine($"/// Properties: {Properties.Count}");
     sb.AppendLine("/// </summary>");
 }
Пример #2
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="sb"></param>
 void WritePropertSummary(ExtendedStringBuilder sb)
 {
     sb.AppendLine("/// <summary>");
     sb.AppendLine($"/// Name: {Name}");
     sb.AppendLine(IsTArray ? $"/// Type: TArray<{ArraySubType}>" : $"/// Type: {Type}");
     sb.AppendLine($"/// Offset: 0x{Offset:X2}");
     sb.AppendLine($"/// Size: 0x{ElementSize:X2}");
     if (IsTArray)
     {
         sb.AppendLine($"/// SubElement Size: 0x{SubElementSize:X2}");
     }
     sb.AppendLine("/// </summary>");
 }
Пример #3
0
        void WriteClassFiles()
        {
            string destDir = "C:\\SDK";

            if (MergePackageClasses)
            {
                foreach (var c in Classes)
                {
                    if (c.Value.Count == 0)
                    {
                        continue;
                    }
                    List <string> namespaces = new List <string>();
                    foreach (var obj in c.Value)
                    {
                        foreach (var nss in obj.UsedNamespaces)
                        {
                            if (!namespaces.Contains(nss))
                            {
                                namespaces.Add(nss);
                            }
                        }
                    }
                    string filename          = c.Key + ".cs";
                    var    ns                = c.Key;
                    ExtendedStringBuilder sb = new ExtendedStringBuilder();
                    sb.SetNamespaceIndent();
                    foreach (var s in namespaces)
                    {
                        sb.AppendLine($"using {s};");
                    }
                    sb.AppendLine("");
                    sb.AppendLine("");
                    sb.AppendLine($"namespace {ns}");
                    sb.AppendLine("{");
                    sb.SetNamespaceIndent();
                    foreach (var obj in c.Value)
                    {
                        obj.BuildClass(sb);
                    }
                    sb.SetNamespaceIndent();
                    sb.AppendLine("}");
                    File.WriteAllText(Path.Combine(destDir, filename), sb.ToString());
                }
            }
        }
Пример #4
0
 public void BuildClass(ExtendedStringBuilder sb)
 {
     sb.SetClassIndent();
     WriteSummary(sb);
     if (string.IsNullOrEmpty(SuperClass))
     {
         SuperClass = "MemoryObject";
     }
     sb.AppendLine($"public class {ClassName}:{SuperClass}");
     sb.AppendLine("{");
     sb.SetPropertyIndent();
     sb.AppendLine($"public override int ObjectSize => {ClassSize};");
     foreach (var p in Properties.Values.ToArray())
     {
         p.BuildProperty(sb);
         sb.AppendLine("");
     }
     sb.SetClassIndent();
     sb.AppendLine("}");
     sb.SetNamespaceIndent();
     sb.AppendLine("");
     sb.AppendLine("");
 }
Пример #5
0
        public void BuildProperty(ExtendedStringBuilder sb)
        {
            sb.SetPropertyIndent();
            WritePropertSummary(sb);
            switch (Type)
            {
            case "BoolProperty":
            {
                if (BoolFieldMask == 0xFF)
                {
                    GetSetProperty(sb, (int)(Offset + BoolOffset), "bool", "Bool", Name);
                }
                else
                {
                    sb.AppendLine($"public bool {Name} => (ReadByte(0x{Offset + BoolOffset:X4}) & 0x{BoolByteMask:X2}) == 0x{BoolByteMask:X2};");
                }
                break;
            }

            case "StrProperty":
            {
                sb.AppendLine($"public FString {Name} => new FString(BaseAddress+0x{Offset:X2});");
                break;
            }

            case "StructProperty":
            {
                sb.AppendLine($"public {SubType} {Name} => ReadStruct<{SubType}>(0x{Offset:X2});");
                break;
            }

            case "ObjectProperty":
            {
                sb.AppendLine($"public {SubType} {Name} => ReadUObject<{SubType}>(0x{Offset:X2});");
                break;
            }

            case "ArrayProperty":
            {
                if (!string.IsNullOrEmpty(ArraySubType))
                {
                    sb.AppendLine($"public TArray<{ArraySubType}> {Name} => new TArray<{ArraySubType}>(BaseAddress+0x{Offset:X2});");
                }
                break;
            }

            case "DoubleProperty":
            {
                GetSetProperty(sb, Offset, "double", "Double", Name);
                break;
            }

            case "FloatProperty":
            {
                GetSetProperty(sb, Offset, "float", "Single", Name);
                break;
            }

            case "IntProperty":
            {
                GetSetProperty(sb, Offset, "int", "Int32", Name);
                break;
            }

            case "UIntProperty":
            {
                GetSetProperty(sb, Offset, "uint", "UInt32", Name);
                break;
            }

            case "Int16Property":
            {
                GetSetProperty(sb, Offset, "short", "Int16", Name);
                break;
            }

            case "UInt16Property":
            {
                GetSetProperty(sb, Offset, "ushort", "UInt16", Name);
                break;
            }

            case "UInt64Property":
            {
                GetSetProperty(sb, Offset, "ulong", "UInt64", Name);
                break;
            }

            case "Int64Property":
            {
                GetSetProperty(sb, Offset, "long", "Int64", Name);
                break;
            }

            case "ByteProperty":
            {
                GetSetProperty(sb, Offset, "byte", "Byte", Name);
                break;
            }
            }
        }
Пример #6
0
 void GetSetProperty(ExtendedStringBuilder sb, int offset, string type, string readType, string name)
 {
     sb.SetPropertyIndent();
     sb.AppendLine($"public {type} {Name}");
     sb.AppendLine("{");
     sb.SetGetSetIndet();
     sb.AppendLine("get");
     sb.AppendLine("{");
     sb.SetInsideGetSet();
     sb.AppendLine($"return Read{readType}(0x{offset:X2});");
     sb.SetGetSetIndet();
     sb.AppendLine("}");
     sb.AppendLine("set");
     sb.AppendLine("{");
     sb.SetInsideGetSet();
     sb.AppendLine($"Write{readType}(0x{offset:X2},value);");
     sb.SetGetSetIndet();
     sb.AppendLine("}");
     sb.SetPropertyIndent();
     sb.AppendLine("}");
 }