public static CustomProperty PropertyToGrid(Property p, PCCObject pcc) { string cat = p.TypeVal.ToString(); CustomProperty pg; switch (p.TypeVal) { case Type.BoolProperty: pg = new CustomProperty(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(p.Name, cat, f, typeof(float), false, true); break; case Type.ByteProperty: case Type.NameProperty: NameProp pp = new NameProp(); pp.name = pcc.getNameEntry(p.Value.IntValue); pp.nameindex = p.Value.IntValue; pg = new CustomProperty(p.Name, cat, pp, typeof(NameProp), false, true); break; case Type.ObjectProperty: ObjectProp ppo = new ObjectProp(); ppo.name = pcc.getObjectName(p.Value.IntValue); //ppo.name = pcc.GetName(pcc.Exports[p.Value.IntValue].name); ppo.nameindex = p.Value.IntValue; pg = new CustomProperty(p.Name, cat, ppo, typeof(ObjectProp), false, true); break; case Type.StructProperty: StructProp ppp = new StructProp(); ppp.name = pcc.getNameEntry(p.Value.IntValue); 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(p.Name, cat, ppp, typeof(StructProp), false, true); break; default: pg = new CustomProperty(p.Name, cat, p.Value.IntValue, typeof(int), false, true); break; } return(pg); }
public TreeNode ToTree() { TreeNode res = new TreeNode(pcc.Exports[index].ObjectName); for (int i = 0; i < Textures.Count(); i++) { string s = Textures[i].Desc + " :# " + (Textures[i].TexIndex - 1).ToString(); s += " " + pcc.getObjectName(Textures[i].TexIndex); res.Nodes.Add(s); } return(res); }
public static CustomProperty PropertyToGrid(Property p, PCCObject pcc) { string cat = p.TypeVal.ToString(); CustomProperty pg; 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: case Type.NameProperty: NameProp pp = new NameProp(); pp.name = pcc.GetName(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.name = pcc.getObjectName(p.Value.IntValue); ppo.nameindex = p.Value.IntValue; pg = new CustomProperty(pcc.Names[p.Name], cat, ppo, typeof(ObjectProp), false, true); break; case Type.StructProperty: StructProp ppp = new StructProp(); ppp.name = pcc.GetName(p.Value.IntValue); 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; }
public TreeNode GenerateNode(PropHeader p) { string s = p.offset.ToString("X4") + " : "; s += "Name: \"" + pcc.getNameEntry(p.name) + "\" "; s += "Type: \"" + pcc.getNameEntry(p.type) + "\" "; s += "Size: " + p.size.ToString() + " Value: "; int propertyType = getType(pcc.getNameEntry(p.type)); int idx; switch (propertyType) { case INT_PROPERTY: idx = BitConverter.ToInt32(memory, p.offset + 24); s += idx.ToString(); break; case OBJECT_PROPERTY: idx = BitConverter.ToInt32(memory, p.offset + 24); s += idx.ToString() + " (" + pcc.getObjectName(idx) + ")"; break; case STRING_PROPERTY: int count = BitConverter.ToInt32(memory, p.offset + 24); s += "\""; for (int i = 0; i < count - 1; i++) { s += (char)memory[p.offset + 28 + i]; } s += "\""; break; case BOOL_PROPERTY: byte val = memory[p.offset + 24]; s += (val == 1).ToString(); break; case FLOAT_PROPERTY: float f = BitConverter.ToSingle(memory, p.offset + 24); s += f.ToString() + "f"; break; case STRUCT_PROPERTY: case NAME_PROPERTY: idx = BitConverter.ToInt32(memory, p.offset + 24); s += "\"" + pcc.getNameEntry(idx) + "\""; break; case BYTE_PROPERTY: idx = BitConverter.ToInt32(memory, p.offset + 24); s += "\"" + pcc.getNameEntry(idx) + "\""; break; case ARRAY_PROPERTY: idx = BitConverter.ToInt32(memory, p.offset + 24); s += idx.ToString() + "(count)"; break; case STRINGREF_PROPERTY: idx = BitConverter.ToInt32(memory, p.offset + 24); s += "#" + idx.ToString() + ": "; s += tlkset == null ? "(.tlk not loaded)" : tlkset.findDataById(idx); break; } TreeNode ret = new TreeNode(s); ret.Tag = propertyType; ret.Name = p.offset.ToString(); return(ret); }