public static CustomProperty PropertyToGrid(Property p, PCCObject pcc) { string cat = p.TypeVal.ToString(); CustomProperty pg; NameProp pp; switch (p.TypeVal) { case Type.BoolProperty: pg = new CustomProperty(pcc.Names[p.Name], cat, (p.Value.IntValue == 1), typeof(bool), false, true); break; case Type.FloatProperty: byte[] buff = BitConverter.GetBytes(p.Value.IntValue); float f = BitConverter.ToSingle(buff, 0); pg = new CustomProperty(pcc.Names[p.Name], cat, f, typeof(float), false, true); break; case Type.ByteProperty: if (p.Size != 8) { pg = new CustomProperty(pcc.Names[p.Name], cat, (byte)p.Value.IntValue, typeof(byte), false, true); } else { pp = new NameProp(); pp.name = pcc.getNameEntry(p.Value.IntValue); pp.nameindex = p.Value.IntValue; pg = new CustomProperty(pcc.Names[p.Name], cat, pp, typeof(NameProp), false, true); } break; case Type.NameProperty: pp = new NameProp(); pp.name = pcc.getNameEntry(p.Value.IntValue); pp.nameindex = p.Value.IntValue; pg = new CustomProperty(pcc.Names[p.Name], cat, pp, typeof(NameProp), false, true); break; case Type.ObjectProperty: ObjectProp ppo = new ObjectProp(); ppo.objectName = pcc.getObjectName(p.Value.IntValue); ppo.index = p.Value.IntValue; pg = new CustomProperty(pcc.Names[p.Name], cat, ppo, typeof(ObjectProp), false, true); break; case Type.StrProperty: pg = new CustomProperty(pcc.Names[p.Name], cat, p.Value.StringValue, typeof(string), false, true); break; case Type.ArrayProperty: pg = new CustomProperty(pcc.Names[p.Name], cat, BitConverter.ToInt32(p.raw, 24) + " elements", typeof(string), false, true); break; case Type.StructProperty: string structType = pcc.getNameEntry(p.Value.IntValue); if (structType == "Color") { ColorProp cp = new ColorProp(); cp.name = structType; cp.nameindex = p.Value.IntValue; System.Drawing.Color color = System.Drawing.Color.FromArgb(BitConverter.ToInt32(p.raw, 32)); cp.Alpha = color.A; cp.Red = color.R; cp.Green = color.G; cp.Blue = color.B; pg = new CustomProperty(pcc.Names[p.Name], cat, cp, typeof(ColorProp), false, true); } else if (structType == "Vector") { VectorProp vp = new VectorProp(); vp.name = structType; vp.nameindex = p.Value.IntValue; vp.X = BitConverter.ToSingle(p.raw, 32); vp.Y = BitConverter.ToSingle(p.raw, 36); vp.Z = BitConverter.ToSingle(p.raw, 40); pg = new CustomProperty(pcc.Names[p.Name], cat, vp, typeof(VectorProp), false, true); } else if (structType == "Rotator") { RotatorProp rp = new RotatorProp(); rp.name = structType; rp.nameindex = p.Value.IntValue; rp.Pitch = (float)BitConverter.ToInt32(p.raw, 32) * 360f / 65536f; rp.Yaw = (float)BitConverter.ToInt32(p.raw, 36) * 360f / 65536f; rp.Roll = (float)BitConverter.ToInt32(p.raw, 40) * 360f / 65536f; pg = new CustomProperty(pcc.Names[p.Name], cat, rp, typeof(RotatorProp), false, true); } else if (structType == "LinearColor") { LinearColorProp lcp = new LinearColorProp(); lcp.name = structType; lcp.nameindex = p.Value.IntValue; lcp.Red = BitConverter.ToSingle(p.raw, 32); lcp.Green = BitConverter.ToSingle(p.raw, 36); lcp.Blue = BitConverter.ToSingle(p.raw, 40); lcp.Alpha = BitConverter.ToSingle(p.raw, 44); pg = new CustomProperty(pcc.Names[p.Name], cat, lcp, typeof(VectorProp), false, true); } else { StructProp ppp = new StructProp(); ppp.name = structType; ppp.nameindex = p.Value.IntValue; byte[] buf = new byte[p.Value.Array.Count()]; for (int i = 0; i < p.Value.Array.Count(); i++) { buf[i] = (byte)p.Value.Array[i].IntValue; } List <int> buf2 = new List <int>(); for (int i = 0; i < p.Value.Array.Count() / 4; i++) { buf2.Add(BitConverter.ToInt32(buf, i * 4)); } ppp.data = buf2.ToArray(); pg = new CustomProperty(pcc.Names[p.Name], cat, ppp, typeof(StructProp), false, true); } break; default: pg = new CustomProperty(pcc.Names[p.Name], cat, p.Value.IntValue, typeof(int), false, true); break; } return(pg); }
private static PropertyInfo getProperty(PCCObject pcc, PCCObject.ExportEntry entry) { PropertyInfo p = new PropertyInfo(); switch (entry.ClassName) { case "IntProperty": p.type = PropertyReader.Type.IntProperty; break; case "StringRefProperty": p.type = PropertyReader.Type.StringRefProperty; break; case "FloatProperty": p.type = PropertyReader.Type.FloatProperty; break; case "BoolProperty": p.type = PropertyReader.Type.BoolProperty; break; case "StrProperty": p.type = PropertyReader.Type.StrProperty; break; case "NameProperty": p.type = PropertyReader.Type.NameProperty; break; case "DelegateProperty": p.type = PropertyReader.Type.DelegateProperty; break; case "ObjectProperty": case "ClassProperty": case "ComponentProperty": p.type = PropertyReader.Type.ObjectProperty; p.reference = pcc.getObjectName(BitConverter.ToInt32(entry.Data, entry.Data.Length - 4)); break; case "StructProperty": p.type = PropertyReader.Type.StructProperty; p.reference = pcc.getObjectName(BitConverter.ToInt32(entry.Data, entry.Data.Length - 4)); break; case "BioMask4Property": case "ByteProperty": p.type = PropertyReader.Type.ByteProperty; p.reference = pcc.getObjectName(BitConverter.ToInt32(entry.Data, entry.Data.Length - 4)); break; case "ArrayProperty": p.type = PropertyReader.Type.ArrayProperty; PropertyInfo arrayTypeProp = getProperty(pcc, pcc.Exports[BitConverter.ToInt32(entry.Data, 44) - 1]); if (arrayTypeProp != null) { switch (arrayTypeProp.type) { case PropertyReader.Type.ObjectProperty: case PropertyReader.Type.StructProperty: case PropertyReader.Type.ArrayProperty: p.reference = arrayTypeProp.reference; break; case PropertyReader.Type.ByteProperty: if (arrayTypeProp.reference == "") p.reference = arrayTypeProp.type.ToString(); else p.reference = arrayTypeProp.reference; break; case PropertyReader.Type.IntProperty: case PropertyReader.Type.FloatProperty: case PropertyReader.Type.NameProperty: case PropertyReader.Type.BoolProperty: case PropertyReader.Type.StrProperty: case PropertyReader.Type.StringRefProperty: case PropertyReader.Type.DelegateProperty: p.reference = arrayTypeProp.type.ToString(); break; case PropertyReader.Type.None: case PropertyReader.Type.Unknown: default: System.Diagnostics.Debugger.Break(); p = null; break; } } else { p = null; } break; case "InterfaceProperty": default: p = null; break; } return p; }
private int GenerateSpecialStructProp(TreeNode t, string s, int pos, PropertyReader.Property prop) { if (pos > memory.Length) { throw new Exception(": tried to read past bounds of Export Data"); } int n; TreeNode node; UnrealObjectInfo.PropertyInfo propInfo; switch (prop.TypeVal) { case PropertyReader.Type.FloatProperty: s += BitConverter.ToSingle(memory, pos).ToString("0.0######"); node = new TreeNode(s); node.Name = pos.ToString(); node.Tag = nodeType.StructLeafFloat; t.Nodes.Add(node); pos += 4; break; case PropertyReader.Type.IntProperty: s += BitConverter.ToInt32(memory, pos).ToString(); node = new TreeNode(s); node.Name = pos.ToString(); node.Tag = nodeType.StructLeafInt; t.Nodes.Add(node); pos += 4; break; case PropertyReader.Type.ObjectProperty: n = BitConverter.ToInt32(memory, pos); s += n + " (" + pcc.getObjectName(n) + ")"; node = new TreeNode(s); node.Name = pos.ToString(); node.Tag = nodeType.StructLeafObject; t.Nodes.Add(node); pos += 4; break; case PropertyReader.Type.StringRefProperty: n = BitConverter.ToInt32(memory, pos); s += "#" + n + ": "; s += TalkFiles.tlkList.Count == 0 ? "(.tlk not loaded)" : TalkFiles.findDataById(n); node = new TreeNode(s); node.Name = pos.ToString(); node.Tag = nodeType.StructLeafInt; t.Nodes.Add(node); pos += 4; break; case PropertyReader.Type.NameProperty: n = BitConverter.ToInt32(memory, pos); pos += 4; s += "\"" + pcc.getNameEntry(n) + "\"_" + BitConverter.ToInt32(memory, pos); node = new TreeNode(s); node.Name = pos.ToString(); node.Tag = nodeType.StructLeafName; t.Nodes.Add(node); pos += 4; break; case PropertyReader.Type.BoolProperty: s += (memory[pos] > 0).ToString(); node = new TreeNode(s); node.Name = pos.ToString(); node.Tag = nodeType.StructLeafBool; t.Nodes.Add(node); pos += 1; break; case PropertyReader.Type.ByteProperty: if (prop.Size != 1) { string enumName = UnrealObjectInfo.getPropertyInfo(className, pcc.getNameEntry(prop.Name))?.reference; if (enumName != null) { s += "\"" + enumName + "\", "; } s += "\"" + pcc.getNameEntry(BitConverter.ToInt32(memory, pos)) + "\""; node = new TreeNode(s); node.Name = pos.ToString(); node.Tag = nodeType.StructLeafEnum; t.Nodes.Add(node); pos += 8; } else { s += "(byte)" + memory[pos].ToString(); node = new TreeNode(s); node.Name = pos.ToString(); node.Tag = nodeType.StructLeafByte; t.Nodes.Add(node); pos += 1; } break; case PropertyReader.Type.StrProperty: n = BitConverter.ToInt32(memory, pos); pos += 4; s += "\""; for (int i = 0; i < n - 1; i++) { s += (char)memory[pos + i * 2]; } s += "\""; node = new TreeNode(s); node.Name = pos.ToString(); node.Tag = nodeType.StructLeafStr; t.Nodes.Add(node); pos += n * 2; break; case PropertyReader.Type.ArrayProperty: n = BitConverter.ToInt32(memory, pos); s += n + " elements"; node = new TreeNode(s); node.Name = pos.ToString(); node.Tag = nodeType.StructLeafArray; pos += 4; propInfo = UnrealObjectInfo.getPropertyInfo(className, pcc.getNameEntry(prop.Name)); UnrealObjectInfo.ArrayType arrayType = UnrealObjectInfo.getArrayType(propInfo); TreeNode node2; string s2; for (int i = 0; i < n; i++) { if (arrayType == UnrealObjectInfo.ArrayType.Struct) { readerpos = pos; node2 = new TreeNode(i + ": (" + propInfo.reference + ")"); node2.Name = (-pos).ToString(); node2.Tag = nodeType.StructLeafStruct; GenerateSpecialStruct(node2, propInfo.reference, 0); node.Nodes.Add(node2); pos = readerpos; } else { s2 = ""; PropertyReader.Type type = PropertyReader.Type.None; int size = 0; switch (arrayType) { case UnrealObjectInfo.ArrayType.Object: type = PropertyReader.Type.ObjectProperty; break; case UnrealObjectInfo.ArrayType.Name: type = PropertyReader.Type.NameProperty; break; case UnrealObjectInfo.ArrayType.Byte: type = PropertyReader.Type.ByteProperty; size = 1; break; case UnrealObjectInfo.ArrayType.Enum: type = PropertyReader.Type.ByteProperty; break; case UnrealObjectInfo.ArrayType.Bool: type = PropertyReader.Type.BoolProperty; break; case UnrealObjectInfo.ArrayType.String: type = PropertyReader.Type.StrProperty; break; case UnrealObjectInfo.ArrayType.Float: type = PropertyReader.Type.FloatProperty; break; case UnrealObjectInfo.ArrayType.Int: type = PropertyReader.Type.IntProperty; break; } pos = GenerateSpecialStructProp(node, s2, pos, new PropertyReader.Property { TypeVal = type, Size = size }); } } t.Nodes.Add(node); break; case PropertyReader.Type.StructProperty: propInfo = UnrealObjectInfo.getPropertyInfo(className, pcc.getNameEntry(prop.Name)); s += propInfo.reference; node = new TreeNode(s); node.Name = (-pos).ToString(); node.Tag = nodeType.StructLeafStruct; readerpos = pos; GenerateSpecialStruct(node, propInfo.reference, 0); pos = readerpos; t.Nodes.Add(node); break; case PropertyReader.Type.DelegateProperty: throw new NotImplementedException($"at position {pos.ToString("X4")}: cannot read Delegate property of Immutable struct"); case PropertyReader.Type.Unknown: throw new NotImplementedException($"at position {pos.ToString("X4")}: cannot read Unkown property of Immutable struct"); case PropertyReader.Type.None: default: break; } return(pos); }
private static PropertyInfo getProperty(PCCObject pcc, PCCObject.ExportEntry entry) { PropertyInfo p = new PropertyInfo(); switch (entry.ClassName) { case "IntProperty": p.type = PropertyReader.Type.IntProperty; break; case "StringRefProperty": p.type = PropertyReader.Type.StringRefProperty; break; case "FloatProperty": p.type = PropertyReader.Type.FloatProperty; break; case "BoolProperty": p.type = PropertyReader.Type.BoolProperty; break; case "StrProperty": p.type = PropertyReader.Type.StrProperty; break; case "NameProperty": p.type = PropertyReader.Type.NameProperty; break; case "DelegateProperty": p.type = PropertyReader.Type.DelegateProperty; break; case "ObjectProperty": case "ClassProperty": case "ComponentProperty": p.type = PropertyReader.Type.ObjectProperty; p.reference = pcc.getObjectName(BitConverter.ToInt32(entry.Data, entry.Data.Length - 4)); break; case "StructProperty": p.type = PropertyReader.Type.StructProperty; p.reference = pcc.getObjectName(BitConverter.ToInt32(entry.Data, entry.Data.Length - 4)); break; case "BioMask4Property": case "ByteProperty": p.type = PropertyReader.Type.ByteProperty; p.reference = pcc.getObjectName(BitConverter.ToInt32(entry.Data, entry.Data.Length - 4)); break; case "ArrayProperty": p.type = PropertyReader.Type.ArrayProperty; PropertyInfo arrayTypeProp = getProperty(pcc, pcc.Exports[BitConverter.ToInt32(entry.Data, 44) - 1]); if (arrayTypeProp != null) { switch (arrayTypeProp.type) { case PropertyReader.Type.ObjectProperty: case PropertyReader.Type.StructProperty: case PropertyReader.Type.ArrayProperty: p.reference = arrayTypeProp.reference; break; case PropertyReader.Type.ByteProperty: if (arrayTypeProp.reference == "") { p.reference = arrayTypeProp.type.ToString(); } else { p.reference = arrayTypeProp.reference; } break; case PropertyReader.Type.IntProperty: case PropertyReader.Type.FloatProperty: case PropertyReader.Type.NameProperty: case PropertyReader.Type.BoolProperty: case PropertyReader.Type.StrProperty: case PropertyReader.Type.StringRefProperty: case PropertyReader.Type.DelegateProperty: p.reference = arrayTypeProp.type.ToString(); break; case PropertyReader.Type.None: case PropertyReader.Type.Unknown: default: System.Diagnostics.Debugger.Break(); p = null; break; } } else { p = null; } break; case "InterfaceProperty": default: p = null; break; } return(p); }
public static CustomProperty PropertyToGrid(Property p, PCCObject pcc) { string cat = p.TypeVal.ToString(); CustomProperty pg; NameProp pp; switch (p.TypeVal) { case Type.BoolProperty: pg = new CustomProperty(pcc.Names[p.Name], cat, (p.Value.IntValue == 1), typeof(bool), false, true); break; case Type.FloatProperty: byte[] buff = BitConverter.GetBytes(p.Value.IntValue); float f = BitConverter.ToSingle(buff, 0); pg = new CustomProperty(pcc.Names[p.Name], cat, f, typeof(float), false, true); break; case Type.ByteProperty: if (p.Size != 8) { pg = new CustomProperty(pcc.Names[p.Name], cat, (byte)p.Value.IntValue, typeof(byte), false, true); } else { pp = new NameProp(); pp.name = pcc.getNameEntry(p.Value.IntValue); pp.nameindex = p.Value.IntValue; pg = new CustomProperty(pcc.Names[p.Name], cat, pp, typeof(NameProp), false, true); } break; case Type.NameProperty: pp = new NameProp(); pp.name = pcc.getNameEntry(p.Value.IntValue); pp.nameindex = p.Value.IntValue; pg = new CustomProperty(pcc.Names[p.Name], cat, pp, typeof(NameProp), false, true); break; case Type.ObjectProperty: ObjectProp ppo = new ObjectProp(); ppo.objectName = pcc.getObjectName(p.Value.IntValue); ppo.index = p.Value.IntValue; pg = new CustomProperty(pcc.Names[p.Name], cat, ppo, typeof(ObjectProp), false, true); break; case Type.StrProperty: pg = new CustomProperty(pcc.Names[p.Name], cat, p.Value.StringValue, typeof(string), false, true); break; case Type.ArrayProperty: pg = new CustomProperty(pcc.Names[p.Name], cat, BitConverter.ToInt32(p.raw, 24) + " elements", typeof(string), false, true); break; case Type.StructProperty: string structType = pcc.getNameEntry(p.Value.IntValue); if (structType == "Color") { ColorProp cp = new ColorProp(); cp.name = structType; cp.nameindex = p.Value.IntValue; System.Drawing.Color color = System.Drawing.Color.FromArgb(BitConverter.ToInt32(p.raw, 32)); cp.Alpha = color.A; cp.Red = color.R; cp.Green = color.G; cp.Blue = color.B; pg = new CustomProperty(pcc.Names[p.Name], cat, cp, typeof(ColorProp), false, true); } else if (structType == "Vector") { VectorProp vp = new VectorProp(); vp.name = structType; vp.nameindex = p.Value.IntValue; vp.X = BitConverter.ToSingle(p.raw, 32); vp.Y = BitConverter.ToSingle(p.raw, 36); vp.Z = BitConverter.ToSingle(p.raw, 40); pg = new CustomProperty(pcc.Names[p.Name], cat, vp, typeof(VectorProp), false, true); } else if (structType == "Rotator") { RotatorProp rp = new RotatorProp(); rp.name = structType; rp.nameindex = p.Value.IntValue; rp.Pitch = (float)BitConverter.ToInt32(p.raw, 32) * 360f / 65536f; rp.Yaw = (float)BitConverter.ToInt32(p.raw, 36) * 360f / 65536f; rp.Roll = (float)BitConverter.ToInt32(p.raw, 40) * 360f / 65536f; pg = new CustomProperty(pcc.Names[p.Name], cat, rp, typeof(RotatorProp), false, true); } else if (structType == "LinearColor") { LinearColorProp lcp = new LinearColorProp(); lcp.name = structType; lcp.nameindex = p.Value.IntValue; lcp.Red = BitConverter.ToSingle(p.raw, 32); lcp.Green = BitConverter.ToSingle(p.raw, 36); lcp.Blue = BitConverter.ToSingle(p.raw, 40); lcp.Alpha = BitConverter.ToSingle(p.raw, 44); pg = new CustomProperty(pcc.Names[p.Name], cat, lcp, typeof(VectorProp), false, true); } else { StructProp ppp = new StructProp(); ppp.name = structType; ppp.nameindex = p.Value.IntValue; byte[] buf = new byte[p.Value.Array.Count()]; for (int i = 0; i < p.Value.Array.Count(); i++) buf[i] = (byte)p.Value.Array[i].IntValue; List<int> buf2 = new List<int>(); for (int i = 0; i < p.Value.Array.Count() / 4; i++) buf2.Add(BitConverter.ToInt32(buf, i * 4)); ppp.data = buf2.ToArray(); pg = new CustomProperty(pcc.Names[p.Name], cat, ppp, typeof(StructProp), false, true); } break; default: pg = new CustomProperty(pcc.Names[p.Name], cat, p.Value.IntValue, typeof(int), false, true); break; } return pg; }