public void SaveData() { Save.ExtractME1Package(0, "temp.upk"); PCCObject pcc = new PCCObject("temp.upk"); File.Delete("temp.upk"); byte[] buff = pcc.Exports[1].Data; List <SaltPropertyReader.Property> props = SaltPropertyReader.getPropList(pcc, buff); int v; float f; foreach (SaltPropertyReader.Property p in props) { string name = p.Name; switch (name) { case "m_nResourceCredits": v = Convert.ToInt32(textBox1.Text); buff = WriteInt(buff, p.offend - 4, v); break; case "m_nResourceGrenades": v = Convert.ToInt32(textBox2.Text); buff = WriteInt(buff, p.offend - 4, v); break; case "m_fResourceMedigel": f = Convert.ToSingle(textBox3.Text); buff = WriteFloat(buff, p.offend - 4, f); break; case "m_fResourceSalvage": f = Convert.ToSingle(textBox4.Text); buff = WriteFloat(buff, p.offend - 4, f); break; } } pcc.Exports[1].Data = buff; pcc.SaveToFile("temp.upk"); Save.ImportME1Package(0, "temp.upk"); File.Delete("temp.upk"); v = Convert.ToInt32(textBox5.Text); buff = Save.Files[1].memory.ToArray(); buff = WriteInt(buff, 0x4A7, v); //Paragon v = Convert.ToInt32(textBox6.Text); buff = WriteInt(buff, 0x4A3, v); //Renegade SaveGame.SaveFileEntry e = Save.Files[1]; e.memory = new MemoryStream(buff); Save.Files[1] = e; }
public void SaveData() { Save.ExtractME1Package(0, "temp.upk"); PCCObject pcc = new PCCObject("temp.upk"); File.Delete("temp.upk"); byte[] buff = pcc.Exports[1].Data; List<SaltPropertyReader.Property> props = SaltPropertyReader.getPropList(pcc, buff); int v; float f; foreach (SaltPropertyReader.Property p in props) { string name = p.Name; switch (name) { case "m_nResourceCredits": v = Convert.ToInt32(textBox1.Text); buff = WriteInt(buff, p.offend - 4, v); break; case "m_nResourceGrenades": v = Convert.ToInt32(textBox2.Text); buff = WriteInt(buff, p.offend - 4, v); break; case "m_fResourceMedigel": f = Convert.ToSingle(textBox3.Text); buff = WriteFloat(buff, p.offend - 4, f); break; case "m_fResourceSalvage": f = Convert.ToSingle(textBox4.Text); buff = WriteFloat(buff, p.offend - 4, f); break; } } pcc.Exports[1].Data = buff; pcc.SaveToFile("temp.upk"); Save.ImportME1Package(0, "temp.upk"); File.Delete("temp.upk"); v = Convert.ToInt32(textBox5.Text); buff = Save.Files[1].memory.ToArray(); buff = WriteInt(buff, 0x4A7, v);//Paragon v = Convert.ToInt32(textBox6.Text); buff = WriteInt(buff, 0x4A3, v);//Renegade SaveGame.SaveFileEntry e = Save.Files[1]; e.memory = new MemoryStream(buff); Save.Files[1] = e; }
public void Save() { int tmp1, tmp2, size; if (pcc == null) { return; } MemoryStream m = new MemoryStream(); m.Write(BitConverter.GetBytes(Unk1), 0, 4); foreach (PropertyReader.Property p in Props) { switch (pcc.getNameEntry(p.Name)) { case "m_StartingList": m.Write(p.raw, 0, 0x10); m.Write(BitConverter.GetBytes(StartingList.Count * 4 + 4), 0, 4); m.Write(BitConverter.GetBytes((int)0), 0, 4); m.Write(BitConverter.GetBytes(StartingList.Count), 0, 4); foreach (int i in StartingList) { m.Write(BitConverter.GetBytes(i), 0, 4); } break; case "m_EntryList": tmp1 = (int)m.Position; m.Write(p.raw, 0, 0x10); m.Write(new byte[8], 0, 8); m.Write(BitConverter.GetBytes(EntryList.Count), 0, 4); size = 4; foreach (EntryListStuct el in EntryList) { size += WriteEntryList(m, el); } tmp2 = (int)m.Position; m.Seek(tmp1 + 0x10, 0); m.Write(BitConverter.GetBytes(size), 0, 4); m.Seek(tmp2, 0); break; case "m_ReplyList": tmp1 = (int)m.Position; m.Write(p.raw, 0, 0x10); m.Write(new byte[8], 0, 8); m.Write(BitConverter.GetBytes(ReplyList.Count), 0, 4); size = 4; foreach (ReplyListStruct rp in ReplyList) { size += WriteReplyList(m, rp); } tmp2 = (int)m.Position; m.Seek(tmp1 + 0x10, 0); m.Write(BitConverter.GetBytes(size), 0, 4); m.Seek(tmp2, 0); break; case "m_aSpeakerList": tmp1 = (int)m.Position; m.Write(p.raw, 0, 0x10); m.Write(new byte[8], 0, 8); //size placeholder m.Write(BitConverter.GetBytes(SpeakerList.Count), 0, 4); size = 4; foreach (SpeakerListStruct sp in SpeakerList) { size += WriteSpeakerList(m, sp); } tmp2 = (int)m.Position; m.Seek(tmp1 + 0x10, 0); m.Write(BitConverter.GetBytes(size), 0, 4); m.Seek(tmp2, 0); break; case "m_aFemaleFaceSets": m.Write(p.raw, 0, 0x10); m.Write(BitConverter.GetBytes(FemaleFaceSets.Count * 4 + 4), 0, 4); m.Write(BitConverter.GetBytes((int)0), 0, 4); m.Write(BitConverter.GetBytes(FemaleFaceSets.Count), 0, 4); foreach (int i in FemaleFaceSets) { m.Write(BitConverter.GetBytes(i), 0, 4); } break; case "m_aMaleFaceSets": m.Write(p.raw, 0, 0x10); m.Write(BitConverter.GetBytes(MaleFaceSets.Count * 4 + 4), 0, 4); m.Write(BitConverter.GetBytes((int)0), 0, 4); m.Write(BitConverter.GetBytes(MaleFaceSets.Count), 0, 4); foreach (int i in MaleFaceSets) { m.Write(BitConverter.GetBytes(i), 0, 4); } break; case "m_ScriptList": tmp1 = (int)m.Position; m.Write(p.raw, 0, 0x10); m.Write(new byte[8], 0, 8); //size placeholder m.Write(BitConverter.GetBytes(ScriptList.Count), 0, 4); size = 4; foreach (ScriptListStruct sd in ScriptList) { size += WriteScriptList(m, sd); } tmp2 = (int)m.Position; m.Seek(tmp1 + 0x10, 0); m.Write(BitConverter.GetBytes(size), 0, 4); m.Seek(tmp2, 0); break; default: m.Write(p.raw, 0, p.raw.Length); break; } } pcc.Exports[MyIndex].Data = m.ToArray(); pcc.SaveToFile(pcc.pccFileName); }