public void addBoolValue(string name, bool value) { TexPropertyEntry texProperty = new TexPropertyEntry(); if (GameData.gameType == MeType.ME3_TYPE) { texProperty.valueRaw = new byte[1]; } else { texProperty.valueRaw = new byte[4]; } if (!package.existsNameId(name)) { throw new Exception("Not able to add property: " + name); } texProperty.type = "BoolProperty"; texProperty.name = name; texProperty.fetched = true; if (value) { texProperty.valueRaw[0] = 1; } else { texProperty.valueRaw[0] = 0; } texProperty.valueBool = value; texPropertyList.Insert(0, texProperty); }
public void addByteValue(string name, string valueName, int valueInt = 0) { TexPropertyEntry texProperty = new TexPropertyEntry(); if (GameData.gameType == MeType.ME3_TYPE) { texProperty.valueRaw = new byte[16]; } else { texProperty.valueRaw = new byte[8]; } texProperty.type = "ByteProperty"; texProperty.name = name; texProperty.fetched = true; if (!package.existsNameId(name)) { throw new Exception("Not able to add property: " + name); } if (GameData.gameType == MeType.ME3_TYPE) { Buffer.BlockCopy(BitConverter.GetBytes(package.getNameId(valueName)), 8, texProperty.valueRaw, 8, sizeof(int)); Buffer.BlockCopy(BitConverter.GetBytes(valueInt), 0, texProperty.valueRaw, 12, sizeof(int)); } else { Buffer.BlockCopy(BitConverter.GetBytes(package.getNameId(valueName)), 0, texProperty.valueRaw, 0, sizeof(int)); Buffer.BlockCopy(BitConverter.GetBytes(valueInt), 0, texProperty.valueRaw, 4, sizeof(int)); } texProperty.valueName = valueName; texProperty.valueInt = valueInt; texPropertyList.Insert(0, texProperty); }
public void fetchValue(int index) { if (index < 0 || index >= texPropertyList.Count) { new Exception(""); } TexPropertyEntry texProperty = texPropertyList[index]; if (texProperty.fetched || texProperty.type == null) { return; } switch (texProperty.type) { case "IntProperty": texProperty.valueInt = BitConverter.ToInt32(texProperty.valueRaw, 0); break; case "ByteProperty": texProperty.valueName = package.getName(BitConverter.ToInt32(texProperty.valueRaw, 0)); if (GameData.gameType == MeType.ME3_TYPE) { texProperty.valueName = package.getName(BitConverter.ToInt32(texProperty.valueRaw, 8)); texProperty.valueInt = BitConverter.ToInt32(texProperty.valueRaw, 12); } else { texProperty.valueInt = BitConverter.ToInt32(texProperty.valueRaw, 4); } break; case "BoolProperty": texProperty.valueBool = texProperty.valueRaw[0] != 0; break; case "StrProperty": break; case "FloatProperty": texProperty.valueFloat = BitConverter.ToSingle(texProperty.valueRaw, 0); break; case "NameProperty": texProperty.valueName = package.getName(BitConverter.ToInt32(texProperty.valueRaw, 0)); texProperty.valueInt = BitConverter.ToInt32(texProperty.valueRaw, 4); break; case "StructProperty": texProperty.valueName = package.getName(BitConverter.ToInt32(texProperty.valueRaw, 0)); texProperty.valueInt = BitConverter.ToInt32(texProperty.valueRaw, 4); texProperty.valueStruct = new byte[texProperty.valueRaw.Length - 8]; Array.Copy(texProperty.valueRaw, 8, texProperty.valueStruct, 0, texProperty.valueStruct.Length); break; default: throw new Exception(); } texProperty.fetched = true; texPropertyList[index] = texProperty; }
public string getDisplayString(int index) { string result = ""; if (index < 0 || index >= texPropertyList.Count) { new Exception(""); } fetchValue(index); TexPropertyEntry texProperty = texPropertyList[index]; if (texProperty.type == null) { return(result); } result = " " + texProperty.name + ": "; switch (texProperty.type) { case "IntProperty": result += texProperty.valueInt + "\n"; break; case "ByteProperty": result += texProperty.valueName + ": "; result += texProperty.valueInt + "\n"; break; case "BoolProperty": result += texProperty.valueBool + "\n"; break; case "StrProperty": result += "\n"; break; case "FloatProperty": result += texProperty.valueFloat + "\n"; break; case "NameProperty": result += texProperty.valueName + ": "; result += texProperty.valueInt + "\n"; break; case "StructProperty": result += texProperty.valueName + ": "; result += texProperty.valueInt + "\n"; break; default: throw new Exception(); } return(result); }
public void setBoolValue(string name, bool value) { TexPropertyEntry texProperty; if (exists(name)) { texProperty = texPropertyList.Find(s => s.name == name); if (texProperty.type != "BoolProperty") { throw new Exception(); } } else { texProperty = new TexPropertyEntry(); if (GameData.gameType == MeType.ME3_TYPE) { texProperty.valueRaw = new byte[1]; } else { texProperty.valueRaw = new byte[4]; } texProperty.type = "BoolProperty"; if (!package.existsNameId(texProperty.type)) { package.addName(texProperty.type); } } if (!package.existsNameId(name)) { package.addName(name); } texProperty.name = name; texProperty.fetched = true; if (value) { texProperty.valueRaw[0] = 1; } else { texProperty.valueRaw[0] = 0; } texProperty.valueBool = value; if (texPropertyList.Exists(s => s.name == name)) { texPropertyList[texPropertyList.FindIndex(s => s.name == name)] = texProperty; } else { texPropertyList.Insert(0, texProperty); } }
public void setFloatValue(string name, float value) { TexPropertyEntry texProperty = texPropertyList.Find(s => s.name == name); if (texProperty.type != "FloatProperty") { throw new Exception(); } Buffer.BlockCopy(BitConverter.GetBytes(value), 0, texProperty.valueRaw, 0, sizeof(float)); texProperty.valueFloat = value; texPropertyList[texPropertyList.FindIndex(s => s.name == name)] = texProperty; }
public void setNameValue(string name, string valueName, int valueInt = 0) { TexPropertyEntry texProperty = texPropertyList.Find(s => s.name == name); if (texProperty.type != "NameProperty") { throw new Exception(); } Buffer.BlockCopy(BitConverter.GetBytes(package.getNameId(valueName)), 0, texProperty.valueRaw, 0, sizeof(int)); Buffer.BlockCopy(BitConverter.GetBytes(valueInt), 0, texProperty.valueRaw, 4, sizeof(int)); texProperty.valueName = valueName; texProperty.valueInt = valueInt; texPropertyList[texPropertyList.FindIndex(s => s.name == name)] = texProperty; }
public void setStructValue(string name, string valueName, byte[] valueStruct) { fetchValue(name); TexPropertyEntry texProperty = texPropertyList.Find(s => s.name == name); if (texProperty.type != "StructProperty" || texProperty.valueStruct.Length != valueStruct.Length) { throw new Exception(); } Buffer.BlockCopy(BitConverter.GetBytes(package.getNameId(valueName)), 0, texProperty.valueRaw, 0, sizeof(int)); Buffer.BlockCopy(valueStruct, 0, texProperty.valueRaw, 8, valueStruct.Length); texProperty.valueName = valueName; Buffer.BlockCopy(valueStruct, 0, texProperty.valueStruct, 0, valueStruct.Length); texPropertyList[texPropertyList.FindIndex(s => s.name == name)] = texProperty; }
public void setNameValue(string name, string valueName, int valueInt = 0) { TexPropertyEntry texProperty; if (exists(name)) { texProperty = texPropertyList.Find(s => s.name == name); if (texProperty.type != "NameProperty") { throw new Exception(); } } else { texProperty = new TexPropertyEntry(); texProperty.valueRaw = new byte[8]; texProperty.type = "NameProperty"; if (!package.existsNameId(texProperty.type)) { package.addName(texProperty.type); } } if (!package.existsNameId(name)) { package.addName(name); } texProperty.name = name; texProperty.fetched = true; if (!package.existsNameId(valueName)) { package.addName(valueName); } Buffer.BlockCopy(BitConverter.GetBytes(package.getNameId(valueName)), 0, texProperty.valueRaw, 0, sizeof(int)); Buffer.BlockCopy(BitConverter.GetBytes(valueInt), 0, texProperty.valueRaw, 4, sizeof(int)); texProperty.valueName = valueName; texProperty.valueInt = valueInt; if (exists(name)) { texPropertyList[texPropertyList.FindIndex(s => s.name == name)] = texProperty; } else { texPropertyList.Insert(0, texProperty); } }
public void addNameValue(string name, string valueName, int valueInt = 0) { TexPropertyEntry texProperty = new TexPropertyEntry(); texProperty.type = "NameProperty"; if (!package.existsNameId(name)) { throw new Exception("Not able to add property: " + name); } texProperty.name = name; texProperty.fetched = true; texProperty.valueRaw = new byte[8]; Buffer.BlockCopy(BitConverter.GetBytes(package.getNameId(valueName)), 0, texProperty.valueRaw, 0, sizeof(int)); Buffer.BlockCopy(BitConverter.GetBytes(valueInt), 0, texProperty.valueRaw, 4, sizeof(int)); texProperty.valueName = valueName; texProperty.valueInt = valueInt; texPropertyList.Insert(0, texProperty); }
public void setBoolValue(string name, bool value) { TexPropertyEntry texProperty = texPropertyList.Find(s => s.name == name); if (texProperty.type != "BoolProperty") { throw new Exception(); } if (value) { texProperty.valueRaw[0] = 1; } else { texProperty.valueRaw[0] = 0; } texProperty.valueBool = value; texPropertyList[texPropertyList.FindIndex(s => s.name == name)] = texProperty; }
public void setFloatValue(string name, float value) { TexPropertyEntry texProperty; if (exists(name)) { texProperty = texPropertyList.Find(s => s.name == name); if (texProperty.type != "FloatProperty") { throw new Exception(); } } else { texProperty = new TexPropertyEntry(); texProperty.valueRaw = new byte[4]; texProperty.type = "FloatProperty"; if (!package.existsNameId(texProperty.type)) { package.addName(texProperty.type); } } if (!package.existsNameId(name)) { package.addName(name); } texProperty.name = name; texProperty.fetched = true; Buffer.BlockCopy(BitConverter.GetBytes(value), 0, texProperty.valueRaw, 0, sizeof(float)); texProperty.valueFloat = value; if (exists(name)) { texPropertyList[texPropertyList.FindIndex(s => s.name == name)] = texProperty; } else { texPropertyList.Insert(0, texProperty); } }
public void setByteValue(string name, string valueName, int valueInt = 0) { TexPropertyEntry texProperty = texPropertyList.Find(s => s.name == name); if (texProperty.type != "ByteProperty") { throw new Exception(); } if (GameData.gameType == MeType.ME3_TYPE) { Buffer.BlockCopy(BitConverter.GetBytes(package.getNameId(valueName)), 8, texProperty.valueRaw, 8, sizeof(int)); Buffer.BlockCopy(BitConverter.GetBytes(valueInt), 0, texProperty.valueRaw, 12, sizeof(int)); } else { Buffer.BlockCopy(BitConverter.GetBytes(package.getNameId(valueName)), 0, texProperty.valueRaw, 0, sizeof(int)); Buffer.BlockCopy(BitConverter.GetBytes(valueInt), 0, texProperty.valueRaw, 4, sizeof(int)); } texProperty.valueName = valueName; texProperty.valueInt = valueInt; texPropertyList[texPropertyList.FindIndex(s => s.name == name)] = texProperty; }
private void getProperty(byte[] data, int offset) { TexPropertyEntry texProperty = new TexPropertyEntry(); int size, valueRawPos, nextOffset; texProperty.name = package.getName(BitConverter.ToInt32(data, offset)); if (texProperty.name == "None") { nextOffset = offset; propertyEndOffset = valueRawPos = offset + 8; size = 0; } else { texProperty.type = package.getName(BitConverter.ToInt32(data, offset + 8)); size = BitConverter.ToInt32(data, offset + 16); texProperty.index = BitConverter.ToInt32(data, offset + 20); valueRawPos = offset + 24; switch (texProperty.type) { case "IntProperty": case "StrProperty": case "FloatProperty": case "NameProperty": break; case "StructProperty": size += 8; break; case "ByteProperty": if (GameData.gameType == MeType.ME3_TYPE) { size += 8; } break; case "BoolProperty": if (GameData.gameType == MeType.ME3_TYPE) { size = 1; } else { size = 4; } break; default: throw new Exception(); } nextOffset = valueRawPos + size; } texProperty.valueRaw = new byte[size]; Array.Copy(data, valueRawPos, texProperty.valueRaw, 0, size); texPropertyList.Add(texProperty); if (nextOffset != offset) { getProperty(data, nextOffset); } }