public static ME3LibWV.CustomProperty PropertyToGrid(Property p, UDKFile udk) { string cat = p.TypeVal.ToString(); ME3LibWV.CustomProperty pg; NameProp pp; switch (p.TypeVal) { case Type.BoolProperty: pg = new ME3LibWV.CustomProperty(udk.getName(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 ME3LibWV.CustomProperty(udk.getName(p.Name), cat, f, typeof(float), false, true); break; case Type.ByteProperty: if (p.Size != 8) { pg = new ME3LibWV.CustomProperty(udk.getName(p.Name), cat, (byte)p.Value.IntValue, typeof(byte), false, true); } else { pp = new NameProp(); pp.name = udk.getName(p.Value.IntValue); pp.nameindex = p.Value.IntValue; pg = new ME3LibWV.CustomProperty(udk.getName(p.Name), cat, pp, typeof(NameProp), false, true); } break; case Type.NameProperty: pp = new NameProp(); pp.name = udk.getName(p.Value.IntValue); pp.nameindex = p.Value.IntValue; pg = new ME3LibWV.CustomProperty(udk.getName(p.Name), cat, pp, typeof(NameProp), false, true); break; case Type.ObjectProperty: ObjectProp ppo = new ObjectProp(); ppo.objectName = udk.getObjectName(p.Value.IntValue); ppo.index = p.Value.IntValue; pg = new ME3LibWV.CustomProperty(udk.getName(p.Name), cat, ppo, typeof(ObjectProp), false, true); break; case Type.StrProperty: pg = new ME3LibWV.CustomProperty(udk.getName(p.Name), cat, p.Value.StringValue, typeof(string), false, true); break; case Type.ArrayProperty: pg = new ME3LibWV.CustomProperty(udk.getName(p.Name), cat, BitConverter.ToInt32(p.raw, 24) + " elements", typeof(string), false, true); break; case Type.StructProperty: string structType = udk.getName(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 ME3LibWV.CustomProperty(udk.getName(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 ME3LibWV.CustomProperty(udk.getName(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 = BitConverter.ToInt32(p.raw, 32) * 360f / 65536f; rp.Yaw = BitConverter.ToInt32(p.raw, 36) * 360f / 65536f; rp.Roll = BitConverter.ToInt32(p.raw, 40) * 360f / 65536f; pg = new ME3LibWV.CustomProperty(udk.getName(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 ME3LibWV.CustomProperty(udk.getName(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 ME3LibWV.CustomProperty(udk.getName(p.Name), cat, ppp, typeof(StructProp), false, true); } break; default: pg = new ME3LibWV.CustomProperty(udk.getName(p.Name), cat, p.Value.IntValue, typeof(int), false, true); break; } return(pg); }
private bool importExport(UDKFile importudk, int n, int link) { UDKFile.ExportEntry ex = importudk.Exports[n]; UDKFile.ExportEntry nex = new UDKFile.ExportEntry(); byte[] idata = ex.Data; List<PropertyReader.Property> Props = PropertyReader.getPropList(importudk, ex); int start = PropertyReader.detectStart(importudk, idata, importudk.Exports[n].ObjectFlags); int end = start; if (Props.Count != 0) { end = Props[Props.Count - 1].offend; } MemoryStream res = new MemoryStream(); if ((importudk.Exports[n].ObjectFlags & (ulong)UnrealFlags.EObjectFlags.HasStack) != 0) { byte[] stackdummy = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, //Lets hope for the best :D 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00,}; res.Write(stackdummy, 0, stackdummy.Length); } else { res.Write(new byte[start], 0, start); } //store copy of names list in case something goes wrong List<UDKFile.NameEntry> names = udk.Names.ToList(); try { foreach (PropertyReader.Property p in Props) { PropertyReader.ImportProperty(udk, importudk, p, importudk.getObjectName(ex.idxClass), res); } } catch (Exception exception) { //restore namelist udk.Names = names; MessageBox.Show("Error occured while trying to import " + ex.ObjectName + " : " + exception.Message); return false; } for (int i = end; i < idata.Length; i++) res.WriteByte(idata[i]); nex.header = (byte[])ex.header.Clone(); nex.Data = res.ToArray(); nex.DataSize = nex.Data.Length; nex.idxObjectName = udk.FindNameOrAdd(importudk.getName(ex.idxObjectName)); nex.idxLink = link; nex.idxArchtype = nex.idxClass = nex.idxClassParent = 0; nex.udkRef = udk; udk.addExport(nex); return true; }
public static ME3LibWV.CustomProperty PropertyToGrid(Property p, UDKFile udk) { string cat = p.TypeVal.ToString(); ME3LibWV.CustomProperty pg; NameProp pp; switch (p.TypeVal) { case Type.BoolProperty : pg = new ME3LibWV.CustomProperty(udk.getName(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 ME3LibWV.CustomProperty(udk.getName(p.Name), cat, f, typeof(float), false, true); break; case Type.ByteProperty: if (p.Size != 8) { pg = new ME3LibWV.CustomProperty(udk.getName(p.Name), cat, (byte)p.Value.IntValue, typeof(byte), false, true); } else { pp = new NameProp(); pp.name = udk.getName(p.Value.IntValue); pp.nameindex = p.Value.IntValue; pg = new ME3LibWV.CustomProperty(udk.getName(p.Name), cat, pp, typeof(NameProp), false, true); } break; case Type.NameProperty: pp = new NameProp(); pp.name = udk.getName(p.Value.IntValue); pp.nameindex = p.Value.IntValue; pg = new ME3LibWV.CustomProperty(udk.getName(p.Name), cat, pp, typeof(NameProp), false, true); break; case Type.ObjectProperty: ObjectProp ppo = new ObjectProp(); ppo.objectName = udk.getObjectName(p.Value.IntValue); ppo.index = p.Value.IntValue; pg = new ME3LibWV.CustomProperty(udk.getName(p.Name), cat, ppo, typeof(ObjectProp), false, true); break; case Type.StrProperty: pg = new ME3LibWV.CustomProperty(udk.getName(p.Name), cat, p.Value.StringValue, typeof(string), false, true); break; case Type.ArrayProperty: pg = new ME3LibWV.CustomProperty(udk.getName(p.Name), cat, BitConverter.ToInt32(p.raw,24) + " elements", typeof(string), false, true); break; case Type.StructProperty: string structType = udk.getName(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 ME3LibWV.CustomProperty(udk.getName(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 ME3LibWV.CustomProperty(udk.getName(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 = BitConverter.ToInt32(p.raw, 32) * 360f / 65536f; rp.Yaw = BitConverter.ToInt32(p.raw, 36) * 360f / 65536f; rp.Roll = BitConverter.ToInt32(p.raw, 40) * 360f / 65536f; pg = new ME3LibWV.CustomProperty(udk.getName(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 ME3LibWV.CustomProperty(udk.getName(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 ME3LibWV.CustomProperty(udk.getName(p.Name), cat, ppp, typeof(StructProp), false, true); } break; default: pg = new ME3LibWV.CustomProperty(udk.getName(p.Name),cat,p.Value.IntValue,typeof(int),false,true); break; } return pg; }