public BioConversation(PCCObject Pcc, int Index) { pcc = Pcc; MyIndex = Index; Memory = pcc.Exports[Index].Data; ReadData(); }
public AnimSet(PCCObject Pcc, int Index) { pcc = Pcc; MyIndex = Index; if (pcc.isExport(Index)) { data = pcc.Exports[Index].Data; } Props = PropertyReader.getPropList(pcc, pcc.Exports[Index]); BitConverter.IsLittleEndian = true; Sequences = new List <int>(); foreach (PropertyReader.Property p in Props) { switch (pcc.getNameEntry(p.Name)) { case "PreviewSkelMeshName": PreviewSkelMeshName = p.Value.IntValue; break; case "m_pBioAnimSetData": m_pBioAnimSetData = p.Value.IntValue; if (pcc.isExport(m_pBioAnimSetData - 1) && pcc.Exports[m_pBioAnimSetData - 1].ClassName == "BioAnimSetData") { SetData = new BioAnimSetData(pcc, m_pBioAnimSetData - 1); } break; case "Sequences": ReadSequences(p.raw); break; } } }
public TalkFile(PCCObject _pcc, int _index) { pcc = _pcc; index = _index; tlkSetIndex = -1; LoadTlkData(); }
public void LoadPcc(string s) { AT = new List <AnimTree>(); AS = new List <AnimSet>(); pcc = new PCCObject(s); for (int i = 0; i < pcc.Exports.Count; i++) { switch (pcc.Exports[i].ClassName) { case "AnimTree": AT.Add(new AnimTree(pcc, i)); break; case "AnimSet": AS.Add(new AnimSet(pcc, i)); break; } } treeView1.Nodes.Clear(); foreach (AnimTree at in AT) { treeView1.Nodes.Add(at.ToTree()); } foreach (AnimSet ans in AS) { treeView1.Nodes.Add(ans.ToTree()); } }
private void listBox1_SelectedIndexChanged(object sender, EventArgs e) { int n = listBox1.SelectedIndex; if (n == -1) { return; } DBEntry l = database[n]; if (File.Exists(l.filepath)) { try { PCCObject pcc = new PCCObject(l.filepath); Level lev = new Level(pcc, l.index, true); string s = ""; s += "Loading Level from : " + Path.GetFileName(l.filepath) + "\n"; s += "Object count : " + lev.Objects.Count + "\n==============\n\n"; for (int i = 0; i < lev.Objects.Count(); i++) { int index = lev.Objects[i]; s += "(" + i + "/" + (lev.Objects.Count() - 1) + ") "; s += "#" + index + " : \"" + pcc.Exports[index].ObjectName + "\" Class : \"" + pcc.Exports[index].ClassName + "\"\n"; } rtb1.Text = s; } catch (Exception ex) { MessageBox.Show("Error:\n" + ex.Message); } } }
private static Type getType(PCCObject pcc, int type) { switch (pcc.getNameEntry(type)) { case "None": return(Type.None); case "StructProperty": return(Type.StructProperty); case "IntProperty": return(Type.IntProperty); case "FloatProperty": return(Type.FloatProperty); case "ObjectProperty": return(Type.ObjectProperty); case "NameProperty": return(Type.NameProperty); case "BoolProperty": return(Type.BoolProperty); case "ByteProperty": return(Type.ByteProperty); case "ArrayProperty": return(Type.ArrayProperty); case "DelegateProperty": return(Type.DelegateProperty); case "StrProperty": return(Type.StrProperty); case "StringRefProperty": return(Type.StringRefProperty); default: return(Type.Unknown); } }
private void saveCloneToolStripMenuItem_Click(object sender, EventArgs e) { if (pcc == null || Index == -1) { return; } if (pcc.pccFileName != null) { string path = pcc.pccFileName; savePccFile(path); // Reload File Print("Reloading File..."); pcc = new PCCObject(path); Print("Checking for texture..."); if (path.StartsWith(Path.Combine(Properties.Settings.Default.TexplorerME3Path, "CookedPCConsole")) && pcc.Exports[pcc.Exports.Count - 1].ClassName == "Texture2D" || pcc.Exports[pcc.Exports.Count - 1].ClassName == "LightMapTexture2D" || pcc.Exports[pcc.Exports.Count - 1].ClassName == "TextureFlipBook") { Print("PCC in Game Directory. Texture Found. Adding to DB..."); int exportID = (pcc.Exports.Count - 1); Texplorer2 tp = new Texplorer2(true); tp.AddToTree(path, exportID); MessageBox.Show("Texture added to DB."); } else { Print("No Texture Found or File not in Game Directory."); } Print("Refreshing Screen..."); ListRefresh(); MessageBox.Show("Done."); } }
private void openPccToolStripMenuItem_Click(object sender, EventArgs e) { OpenFileDialog d = new OpenFileDialog(); d.Filter = "*.pcc|*.pcc"; if (d.ShowDialog() == System.Windows.Forms.DialogResult.OK) { try { pcc = new PCCObject(d.FileName); objects = new List <int>(); for (int i = 0; i < pcc.Exports.Count; i++) { if (pcc.Exports[i].ClassName == "WwiseBank") { objects.Add(i); } } ListRefresh(); } catch (Exception ex) { MessageBox.Show("Error:\n" + ex.Message); } } }
public string DumpArray(PCCObject pcc, byte [] raw, int pos, string s, int depth) { string res = ""; List <PropertyReader.Property> p = PropertyReader.ReadProp(pcc, raw, pos); for (int i = 0; i < p.Count; i++) { if (p[i].TypeVal == PropertyReader.Type.StringRefProperty) { for (int j = 0; j < depth; j++) { res += "\t"; } res += i + " : " + PropertyReader.PropertyToText(p[i], pcc) + "\n"; } if (p[i].TypeVal == PropertyReader.Type.ArrayProperty) { //for (int j = 0; j < depth; j++) // res += "\t"; //res += "in Property #" + i + " : " + PropertyReader.PropertyToText(p[i], pcc) + "\n"; res += DumpArray(pcc, raw, p[i].offsetval + 4, res, depth + 1); } if (p[i].TypeVal == PropertyReader.Type.StructProperty) { //for (int j = 0; j < depth; j++) // res += "\t"; //res += "in Property #" + i + " : " + PropertyReader.PropertyToText(p[i], pcc) + "\n"; res += DumpArray(pcc, raw, p[i].offsetval + 8, res, depth + 1); } } return(res); }
public InterpGroup(int idx, PCCObject pccobj) : base() { index = idx; pcc = pccobj; title = new SText(""); if (pcc.Exports[index].ClassName == "InterpGroupDirector") { GroupName = "DirGroup"; } listEntry = PPath.CreateRectangle(0, 0, Timeline.ListWidth, Timeline.TrackHeight); listEntry.Brush = GroupBrush; listEntry.Pen = null; PPath p = PPath.CreatePolygon(7, 5, 12, 10, 7, 15); p.Brush = Brushes.Black; listEntry.AddChild(p); listEntry.AddChild(PPath.CreateLine(0, listEntry.Bounds.Bottom, Timeline.ListWidth, listEntry.Bounds.Bottom)); colorAccent = new PNode(); colorAccent.Brush = null; colorAccent.Bounds = new RectangleF(Timeline.ListWidth - 10, 0, 10, listEntry.Bounds.Bottom); listEntry.AddChild(colorAccent); title.TranslateBy(20, 3); listEntry.AddChild(title); listEntry.MouseDown += listEntry_MouseDown; collapsed = true; InterpTracks = new List <InterpTrack>(); LoadData(); }
public TreeNode FindSequences(PCCObject pcc, int index, bool wantFullName = false) { TreeNode ret = new TreeNode("#" + index.ToString() + ": " + (wantFullName ? pcc.Exports[index].GetFullPath : pcc.Exports[index].ObjectName)); ret.Name = index.ToString(); Sequence seq = new Sequence(pcc, index); if (seq.SequenceObjects != null) { for (int i = 0; i < seq.SequenceObjects.Count(); i++) { if (pcc.Exports[seq.SequenceObjects[i] - 1].ClassName == "Sequence" || pcc.Exports[seq.SequenceObjects[i] - 1].ClassName.StartsWith("PrefabSequence")) { TreeNode t = FindSequences(pcc, seq.SequenceObjects[i] - 1, wantFullName); ret.Nodes.Add(t); } else if (pcc.Exports[seq.SequenceObjects[i] - 1].ClassName == "SequenceReference") { var props = PropertyReader.getPropList(pcc, pcc.Exports[seq.SequenceObjects[i] - 1]); var propSequenceReference = props.FirstOrDefault(p => pcc.getNameEntry(p.Name).Equals("oSequenceReference")); if (propSequenceReference != null) { TreeNode t = FindSequences(pcc, propSequenceReference.Value.IntValue - 1, wantFullName); ret.Nodes.Add(t); } } } } return(ret); }
private void loadToolStripMenuItem_Click(object sender, EventArgs e) { if (autoSaveViewToolStripMenuItem.Checked) { saveView(); } OpenFileDialog d = new OpenFileDialog(); d.Filter = "PCC Files(*.pcc)|*.pcc"; if (d.ShowDialog() == DialogResult.OK) { try { pcc = new PCCObject(d.FileName); CurrentFile = d.FileName; toolStripStatusLabel1.Text = CurrentFile.Substring(CurrentFile.LastIndexOf(@"\") + 1); LoadSequences(); graphEditor.nodeLayer.RemoveAllChildren(); graphEditor.edgeLayer.RemoveAllChildren(); if (CurrentObjects != null) { CurrentObjects.Clear(); } } catch (Exception ex) { MessageBox.Show("Error:\n" + ex.Message); } } }
public void LoadPcc(string s) { try { pcc = new PCCObject(s); AT = new List <AnimTree>(); AS = new List <AnimSet>(); for (int i = 0; i < pcc.Exports.Count; i++) { switch (pcc.Exports[i].ClassName) { case "AnimTree": AT.Add(new AnimTree(pcc, i)); break; case "AnimSet": AS.Add(new AnimSet(pcc, i)); break; } } treeView1.Nodes.Clear(); foreach (AnimTree at in AT) { treeView1.Nodes.Add(at.ToTree()); } foreach (AnimSet ans in AS) { treeView1.Nodes.Add(ans.ToTree()); } } catch (Exception ex) { MessageBox.Show("Error:\n" + ex.Message); } }
public WwiseStream(PCCObject Pcc, byte[] Raw) { pcc = Pcc; memory = Raw; memsize = memory.Length; Deserialize(); }
public Level(PCCObject Pcc, int index, bool SimpleRead = false) { memory = Pcc.Exports[index].Data; memlength = memory.Length; pcc = Pcc; Deserialize(SimpleRead); }
public StaticMeshCollectionActor(PCCObject Pcc, int Index) { pcc = Pcc; MyIndex = Index; if (pcc.isExport(Index)) { data = pcc.Exports[Index].Data; } Props = PropertyReader.getPropList(pcc, pcc.Exports[Index]); BitConverter.IsLittleEndian = true; foreach (PropertyReader.Property p in Props) { switch (pcc.getNameEntry(p.Name)) { case "bCanStepUpOn": if (p.raw[p.raw.Length - 1] == 1) { bCanStepUpOn = true; } break; case "Tag": Tag = p.Value.IntValue; break; case "CreationTime": CreationTime = BitConverter.ToSingle(p.raw, p.raw.Length - 4); break; } } ReadObjects(); ReadMatrices(); }
public TreeNode ToTree(int MyIndex, ITalkFile talk, PCCObject pcc) { string s = ""; if (Text.Length != 0) { s = Text.Substring(0, Text.Length - 1); } TreeNode res = new TreeNode(MyIndex + " : " + s + " " + talk.findDataById(refText)); TreeNode t = new TreeNode("Entry List"); for (int i = 0; i < EntryList.Count; i++) { t.Nodes.Add(i + " : " + EntryList[i]); } res.Nodes.Add(t); res.Nodes.Add("Listener Index : " + ListenerIndex); res.Nodes.Add("Unskippable : " + Unskippable); res.Nodes.Add("ReplyType : " + pcc.getNameEntry(ReplyTypeValue)); res.Nodes.Add("Text : " + Text); res.Nodes.Add("refText : " + refText + " " + talk.findDataById(refText, true)); res.Nodes.Add("ConditionalFunc : " + ConditionalFunc); res.Nodes.Add("ConditionalParam : " + ConditionalParam); res.Nodes.Add("StateTransition : " + StateTransition); res.Nodes.Add("StateTransitionParam : " + StateTransitionParam); res.Nodes.Add("ExportID : " + ExportID); res.Nodes.Add("ScriptIndex : " + ScriptIndex); res.Nodes.Add("CameraIntimacy : " + CameraIntimacy); res.Nodes.Add("FireConditional : " + FireConditional); res.Nodes.Add("Ambient : " + Ambient); res.Nodes.Add("NonTextline : " + NonTextLine); res.Nodes.Add("IgnoreBodyGestures : " + IgnoreBodyGestures); res.Nodes.Add("GUIStyle : " + pcc.getNameEntry(GUIStyleValue)); return(res); }
public static string PropertyToText(Property p, PCCObject pcc) { string s = ""; s = "Name: " + pcc.Names[p.Name]; s += " Type: " + TypeToString((int)p.TypeVal); s += " Size: " + p.Value.len.ToString(); switch (p.TypeVal) { case Type.StructProperty: s += " \"" + pcc.getNameEntry(p.Value.IntValue) + "\" with " + p.Value.Array.Count.ToString() + " bytes"; break; case Type.IntProperty: case Type.BoolProperty: case Type.StringRefProperty: s += " Value: " + p.Value.IntValue.ToString(); break; case Type.ObjectProperty: s += " Value: " + p.Value.IntValue.ToString() + " "; int v = p.Value.IntValue; if (v == 0) { s += "None"; } else { s += pcc.GetClass(v); } break; case Type.FloatProperty: byte[] buff = BitConverter.GetBytes(p.Value.IntValue); float f = BitConverter.ToSingle(buff, 0); s += " Value: " + f.ToString(); break; case Type.NameProperty: s += " " + pcc.Names[p.Value.IntValue]; break; case Type.ByteProperty: s += " Value: \"" + p.Value.StringValue + "\""; break; case Type.ArrayProperty: s += " bytes"; //Value: " + p.Value.Array.Count.ToString() + " Elements"; break; case Type.StrProperty: if (p.Value.StringValue.Length == 0) { break; } s += " Value: " + p.Value.StringValue.Substring(0, p.Value.StringValue.Length - 1); break; } return(s); }
private void startScanToolStripMenuItem_Click(object sender, EventArgs e) { string path = ME3Directory.cookedPath; if (String.IsNullOrEmpty(path)) { MessageBox.Show("This functionality requires ME3 to be installed. Set its path at:\n Options > Set Custom Path > Mass Effect 3"); return; } string[] files = Directory.GetFiles(path, "*.pcc"); filenames = new List <string>(); int count = 1; foreach (string file in files) { PCCObject _pcc = new PCCObject(file); DebugOutput.PrintLn((count++) + "/" + files.Length + " : Scanning file " + Path.GetFileName(file) + " ..."); bool found = false; foreach (PCCObject.ExportEntry ex in _pcc.Exports) { if (ex.ClassName == "AnimTree" || ex.ClassName == "AnimSet") { DebugOutput.PrintLn("Found Animation!"); found = true; break; } } if (found) { filenames.Add(file); } } RefreshLists(); }
public void LoadData() { 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); foreach (SaltPropertyReader.Property p in props) { string name = p.Name; switch (name) { case "m_nResourceCredits": textBox1.Text = BitConverter.ToInt32(buff, p.offend - 4).ToString(); break; case "m_nResourceGrenades": textBox2.Text = BitConverter.ToInt32(buff, p.offend - 4).ToString(); break; case "m_fResourceMedigel": textBox3.Text = BitConverter.ToSingle(buff, p.offend - 4).ToString(); break; case "m_fResourceSalvage": textBox4.Text = BitConverter.ToSingle(buff, p.offend - 4).ToString(); break; } } textBox5.Text = BitConverter.ToInt32(Save.Files[1].memory.ToArray(), 0x4A7).ToString();//Paragon textBox6.Text = BitConverter.ToInt32(Save.Files[1].memory.ToArray(), 0x4A3).ToString();//Renegade }
private static PropertyValue ReadValue(PCCObject pcc, byte[] raw, int start, int type) { PropertyValue v = new PropertyValue(); switch (pcc.getNameEntry(type)) { case "IntProperty": case "FloatProperty": case "ObjectProperty": case "StringRefProperty": v.IntValue = BitConverter.ToInt32(raw, start); v.len = 4; break; case "NameProperty": v.IntValue = BitConverter.ToInt32(raw, start); v.len = 8; break; case "BoolProperty": if (start < raw.Length) { v.IntValue = raw[start]; } v.len = 1; break; } return(v); }
public TreeNode ToTree(int MyIndex, PCCObject pcc) { string s = ""; if (Text.Length != 0) { s = Text.Substring(0, Text.Length - 1); } TreeNode res = new TreeNode(MyIndex + " : " + s + " " + TalkFiles.findDataById(refText)); TreeNode t = new TreeNode("Reply List"); for (int i = 0; i < ReplyList.Count; i++) { EntryListReplyListStruct e = ReplyList[i]; string par = e.Paraphrase; if (par.Length != 0 && par[par.Length - 1] == '\0') { par = par.Substring(0, par.Length - 1); } t.Nodes.Add(i + " : " + par + " " + e.refParaphrase + " " + TalkFiles.findDataById(e.refParaphrase) + " " + e.Index + " " + pcc.getNameEntry(e.CategoryType) + " " + pcc.getNameEntry(e.CategoryValue)); } res.Nodes.Add(t); TreeNode t2 = new TreeNode("Speaker List"); for (int i = 0; i < SpeakerList.Count; i++) { t2.Nodes.Add(i + " : " + SpeakerList[i]); } res.Nodes.Add(t2); res.Nodes.Add("SpeakerIndex : " + SpeakerIndex); res.Nodes.Add("ListenerIndex : " + ListenerIndex); res.Nodes.Add("ConditionalFunc : " + ConditionalFunc); res.Nodes.Add("ConditionalParam : " + ConditionalParam); res.Nodes.Add("StateTransition : " + StateTransition); res.Nodes.Add("StateTransitionParam : " + StateTransitionParam); res.Nodes.Add("ExportID : " + ExportID); res.Nodes.Add("ScriptIndex : " + ScriptIndex); res.Nodes.Add("CameraIntimacy : " + CameraIntimacy); res.Nodes.Add("Skippable : " + Skippable); res.Nodes.Add("FireConditional : " + FireConditional); res.Nodes.Add("Ambient : " + Ambient); res.Nodes.Add("NonTextline : " + NonTextline); res.Nodes.Add("IgnoreBodyGestures : " + IgnoreBodyGestures); res.Nodes.Add("AlwaysHideSubtitle : " + AlwaysHideSubtitle); res.Nodes.Add("Text : " + Text); res.Nodes.Add("refText : " + refText + " " + TalkFiles.findDataById(refText, true)); res.Nodes.Add("GUIStyle : (" + pcc.getNameEntry(GUIStyleType) + ") " + pcc.getNameEntry(GUIStyleValue)); return(res); }
public void LoadData() { 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); foreach (SaltPropertyReader.Property p in props) { string name = p.Name; switch (name) { case "m_nResourceCredits": textBox1.Text = BitConverter.ToInt32(buff, p.offend - 4).ToString(); break; case "m_nResourceGrenades": textBox2.Text = BitConverter.ToInt32(buff, p.offend - 4).ToString(); break; case "m_fResourceMedigel": textBox3.Text = BitConverter.ToSingle(buff, p.offend - 4).ToString(); break; case "m_fResourceSalvage": textBox4.Text = BitConverter.ToSingle(buff, p.offend - 4).ToString(); break; } } textBox5.Text = BitConverter.ToInt32(Save.Files[1].memory.ToArray(), 0x4A7).ToString(); //Paragon textBox6.Text = BitConverter.ToInt32(Save.Files[1].memory.ToArray(), 0x4A3).ToString(); //Renegade }
public BioAnimSetData(PCCObject Pcc, int Index) { pcc = Pcc; MyIndex = Index; if (pcc.isExport(Index)) { data = pcc.Exports[Index].Data; } Props = PropertyReader.getPropList(pcc, pcc.Exports[Index]); BitConverter.IsLittleEndian = true; TrackBoneNames = new List <string>(); UseTranslationBoneNames = new List <string>(); foreach (PropertyReader.Property p in Props) { switch (pcc.getNameEntry(p.Name)) { case "bAnimRotationOnly": if (p.raw[p.raw.Length - 1] == 1) { bAnimRotationOnly = true; } break; case "TrackBoneNames": ReadTBN(p.raw); break; case "UseTranslationBoneNames": ReadUTBN(p.raw); break; } } }
private void QMapEditor_Activated(object sender, EventArgs e) { if (String.IsNullOrEmpty(ME3Directory.cookedPath)) { MessageBox.Show("This tool requires ME3 to be installed. Set its path at:\n Options > Set Custom Path > Mass Effect 3"); this.Close(); return; } string pathcook = ME3Directory.cookedPath; if (!File.Exists(pathcook + "SFXGameInfoSP_SF.pcc")) { MessageBox.Show("File SFXGameInfoSP_SF.pcc not found!"); this.Close(); return; } try { pcc = new PCCObject(pathcook + "SFXGameInfoSP_SF.pcc"); GetEntries(); RefreshTree(); } catch (Exception ex) { MessageBox.Show("Error:\n" + ex.Message); this.Close(); return; } }
public static List <Property> getPropList(PCCObject pcc, byte[] raw) { Application.DoEvents(); int start = detectStart(pcc, raw); return(ReadProp(pcc, raw, start)); }
public Sequence(PCCObject Pcc, int export) { pcc = Pcc; memory = pcc.Exports[export].Data; memsize = pcc.Exports[export].Data.Length; index = export; Deserialize(); }
public WwiseStream(PCCObject Pcc, int index) { pcc = Pcc; Index = index; memory = pcc.Exports[Index].Data; memsize = memory.Length; Deserialize(); }
public TalkFile(PCCObject _pcc, int _index, bool _male, int _langRef, int _tlkSetIndex) { pcc = _pcc; index = _index; LangRef = _langRef; male = _male; tlkSetIndex = _tlkSetIndex; LoadTlkData(); }
public MaterialInstanceConstant(PCCObject Pcc, int Idx) { BitConverter.IsLittleEndian = true; pcc = Pcc; index = Idx; memory = pcc.Exports[index].Data; memsize = memory.Length; ReadProperties(); }
public WwiseBank(PCCObject Pcc, int Index) { BitConverter.IsLittleEndian = true; MyIndex = Index; pcc = Pcc; memory = pcc.Exports[Index].Data; memsize = memory.Length; Deserialize(); }
public MaterialInstanceConstant(PCCObject Pcc,int Idx) { BitConverter.IsLittleEndian = true; pcc = Pcc; index = Idx; memory = pcc.Exports[index].Data; memsize = memory.Length; ReadProperties(); }
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 FaceFXAnimSet(PCCObject Pcc, int Index) { BitConverter.IsLittleEndian = true; pcc = Pcc; MyIndex = Index; byte[] buff = pcc.Exports[Index].Data; List<PropertyReader.Property> props = PropertyReader.getPropList(pcc, buff); int start = props[props.Count - 1].offend + 4; Memory = new byte[buff.Length - start]; for (int i = 0; i < buff.Length - start; i++) Memory[i] = buff[i + start];//Skip Props and size int MemoryStream m = new MemoryStream(Memory); SerializingContainer Container = new SerializingContainer(m); Container.isLoading = true; Serialize(Container); }
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 TextureGroup(PCCObject pccObj, byte[] data) { enumTextureGroups = new List<ByteProp>(); pccRef = pccObj; MemoryStream buffer = new MemoryStream(data); firstVal = buffer.ReadValueU32(); buffer.Seek(16, SeekOrigin.Begin); otherVal = buffer.ReadValueU32(); int numEnums = buffer.ReadValueS32(); for (int i = 0; i < numEnums; i++) { ByteProp aux = new ByteProp(pccRef.Names[buffer.ReadValueS32()], buffer.ReadValueS32()); enumTextureGroups.Add(aux); } }
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 SkeletalMeshOld(PCCObject Pcc, byte[] Raw) { pcc = Pcc; memory = Raw; memsize = memory.Length; props = PropertyReader.getPropList(pcc, memory); Deserialize(); }
public MemoryTributary DecompressPCC(Stream raw, PCCObject pcc) { raw.Seek(pcc.header.Length, SeekOrigin.Begin); int pos = 4; pcc.NumChunks = raw.ReadValueS32(); List<Chunk> Chunks = new List<Chunk>(); //DebugOutput.PrintLn("Reading chunk headers..."); for (int i = 0; i < pcc.NumChunks; i++) { Chunk c = new Chunk(); c.uncompressedOffset = raw.ReadValueS32(); c.uncompressedSize = raw.ReadValueS32(); c.compressedOffset = raw.ReadValueS32(); c.compressedSize = raw.ReadValueS32(); c.Compressed = new byte[c.compressedSize]; c.Uncompressed = new byte[c.uncompressedSize]; //DebugOutput.PrintLn("Chunk " + i + ", compressed size = " + c.compressedSize + ", uncompressed size = " + c.uncompressedSize); //DebugOutput.PrintLn("Compressed offset = " + c.compressedOffset + ", uncompressed offset = " + c.uncompressedOffset); Chunks.Add(c); } //DebugOutput.PrintLn("\tRead Chunks..."); int count = 0; for (int i = 0; i < Chunks.Count; i++) { Chunk c = Chunks[i]; raw.Seek(c.compressedOffset, SeekOrigin.Begin); c.Compressed = raw.ReadBytes(c.compressedSize); ChunkHeader h = new ChunkHeader(); h.magic = BitConverter.ToInt32(c.Compressed, 0); if (h.magic != -1641380927) throw new FormatException("Chunk magic number incorrect"); h.blocksize = BitConverter.ToInt32(c.Compressed, 4); h.compressedsize = BitConverter.ToInt32(c.Compressed, 8); h.uncompressedsize = BitConverter.ToInt32(c.Compressed, 12); //DebugOutput.PrintLn("Chunkheader read: Magic = " + h.magic + ", Blocksize = " + h.blocksize + ", Compressed Size = " + h.compressedsize + ", Uncompressed size = " + h.uncompressedsize); pos = 16; int blockCount = (h.uncompressedsize % h.blocksize == 0) ? h.uncompressedsize / h.blocksize : h.uncompressedsize / h.blocksize + 1; List<Block> BlockList = new List<Block>(); //DebugOutput.PrintLn("\t\t" + count + " Read Blockheaders..."); for (int j = 0; j < blockCount; j++) { Block b = new Block(); b.compressedsize = BitConverter.ToInt32(c.Compressed, pos); b.uncompressedsize = BitConverter.ToInt32(c.Compressed, pos + 4); //DebugOutput.PrintLn("Block " + j + ", compressed size = " + b.compressedsize + ", uncompressed size = " + b.uncompressedsize); pos += 8; BlockList.Add(b); } int outpos = 0; //DebugOutput.PrintLn("\t\t" + count + " Read and decompress Blocks..."); foreach (Block b in BlockList) { byte[] datain = new byte[b.compressedsize]; byte[] dataout = new byte[b.uncompressedsize]; for (int j = 0; j < b.compressedsize; j++) datain[j] = c.Compressed[pos + j]; pos += b.compressedsize; LZO1X.Decompress(datain, dataout); for (int j = 0; j < b.uncompressedsize; j++) c.Uncompressed[outpos + j] = dataout[j]; outpos += b.uncompressedsize; } c.header = h; c.blocks = BlockList; count++; Chunks[i] = c; } MemoryTributary result = new MemoryTributary(); foreach (Chunk c in Chunks) { result.Seek(c.uncompressedOffset, SeekOrigin.Begin); result.WriteBytes(c.Uncompressed); } return result; }
public static int detectStart(PCCObject pcc, byte[] raw, long flags) { if ((flags & (long)UnrealFlags.EObjectFlags.HasStack) != 0) { return 30; } int result = 8; int test1 = BitConverter.ToInt32(raw, 4); int test2 = BitConverter.ToInt32(raw, 8); if (pcc.isName(test1) && test2 == 0) result = 4; if (pcc.isName(test1) && pcc.isName(test2) && test2 != 0) result = 8; return result; }
public static int detectStart(PCCObject pcc, byte[] raw) { int result = 8; int test1 = BitConverter.ToInt32(raw, 4); if (test1 < 0) result = 30; else { int test2 = BitConverter.ToInt32(raw, 8); if (pcc.isName(test1) && test2 == 0) result = 4; if (pcc.isName(test1) && pcc.isName(test2) && test2 != 0) result = 8; } return result; }
private static PropertyValue ReadValue(PCCObject pcc, byte[] raw, int start, int type) { PropertyValue v = new PropertyValue(); switch (pcc.Names[type]) { case "IntProperty": case "FloatProperty": case "ObjectProperty": case "StringRefProperty": v.IntValue = BitConverter.ToInt32(raw, start); v.len = 4; break; case "NameProperty": v.IntValue = BitConverter.ToInt32(raw, start); v.len = 8; break; case "BoolProperty": if(start < raw.Length) v.IntValue = raw[start]; v.len = 1; break; } return v; }
private static Type getType(PCCObject pcc, int type) { switch (pcc.GetName(type)) { case "None": return Type.None; case "StructProperty": return Type.StructProperty; case "IntProperty": return Type.IntProperty; case "FloatProperty": return Type.FloatProperty; case "ObjectProperty": return Type.ObjectProperty; case "NameProperty": return Type.NameProperty; case "BoolProperty": return Type.BoolProperty; case "ByteProperty": return Type.ByteProperty; case "ArrayProperty": return Type.ArrayProperty; case "DelegateProperty": return Type.DelegateProperty; case "StrProperty": return Type.StrProperty; case "StringRefProperty": return Type.StringRefProperty; default: return Type.Unknown; } }
public static List<Property> ReadProp(PCCObject pcc, byte[] raw, int start) { Property p; PropertyValue v; int sname; List<Property> result = new List<Property>(); int pos = start; if(raw.Length - pos < 8) return result; int name = (int)BitConverter.ToInt64(raw, pos); if (!pcc.isName(name)) return result; string t = pcc.Names[name]; if (pcc.Names[name] == "None") { p = new Property(); p.Name = name; p.TypeVal = Type.None; p.i = 0; p.offsetval = pos; p.Size = 8; p.Value = new PropertyValue(); p.raw = BitConverter.GetBytes((Int64)name); p.offend = pos + 8; result.Add(p); return result; } int type = (int)BitConverter.ToInt64(raw, pos + 8); int size = BitConverter.ToInt32(raw, pos + 16); int idx = BitConverter.ToInt32(raw, pos + 20); if (!pcc.isName(type) || size < 0 || size >= raw.Length) return result; string tp = pcc.Names[type]; switch (tp) { case "DelegateProperty": p = new Property(); p.Name = name; p.TypeVal = Type.DelegateProperty; p.i = 0; p.offsetval = pos + 24; v = new PropertyValue(); v.IntValue = BitConverter.ToInt32(raw, pos + 28); v.len = size; v.Array = new List<PropertyValue>(); pos += 24; for (int i = 0; i < size; i++) { PropertyValue v2 = new PropertyValue(); if(pos < raw.Length) v2.IntValue = raw[pos]; v.Array.Add(v2); pos ++; } p.Value = v; break; case "ArrayProperty": int count = (int)BitConverter.ToInt64(raw, pos + 24); p = new Property(); p.Name = name; p.TypeVal = Type.ArrayProperty; p.i = 0; p.offsetval = pos + 24; v = new PropertyValue(); v.IntValue = type; v.len = size - 4; count = v.len;//TODO can be other objects too v.Array = new List<PropertyValue>(); pos += 28; for (int i = 0; i < count; i++) { PropertyValue v2 = new PropertyValue(); if(pos < raw.Length) v2.IntValue = raw[pos]; v.Array.Add(v2); pos ++; } p.Value = v; break; case "StrProperty": count = (int)BitConverter.ToInt64(raw, pos + 24); p = new Property(); p.Name = name; p.TypeVal = Type.StrProperty; p.i = 0; p.offsetval = pos + 24; v = new PropertyValue(); v.IntValue = type; v.len = count; pos += 28; string s = ""; for (int i = 0; i < count; i++) s += (char)raw[pos++]; v.StringValue = s; p.Value = v; break; case "StructProperty": sname = (int)BitConverter.ToInt64(raw, pos + 24); p = new Property(); p.Name = name; p.TypeVal = Type.StructProperty; p.i = 0; p.offsetval = pos + 24; v = new PropertyValue(); v.IntValue = sname; v.len = size; v.Array = new List<PropertyValue>(); pos += 32; for (int i = 0; i < size; i++) { PropertyValue v2 = new PropertyValue(); if (pos < raw.Length) v2.IntValue = raw[pos]; v.Array.Add(v2); pos++; } p.Value = v; break; case "ByteProperty": p = new Property(); p.Name = name; p.TypeVal = Type.ByteProperty; p.i = idx; p.offsetval = pos + 24; v = new PropertyValue(); v.IntValue = raw[pos + 24]; v.len = size; pos += 24 + size; p.Value = v; break; case "BoolProperty": p = new Property(); p.Name = name; p.TypeVal = Type.BoolProperty; p.i = idx; p.offsetval = pos + 24; v = new PropertyValue(); v.IntValue = raw[pos + 24]; v.len = 4; pos += 28; p.Value = v; break; default: p = new Property(); p.Name = name; p.TypeVal = getType(pcc,type); p.i = 0; p.offsetval = pos + 24; p.Value = ReadValue(pcc, raw, pos + 24, type); pos += p.Value.len + 24; break; } p.raw = new byte[pos - start]; p.offend = pos; if(pos < raw.Length) for (int i = 0; i < pos - start; i++) p.raw[i] = raw[start + i]; result.Add(p); if(pos!=start) result.AddRange(ReadProp(pcc, raw, pos)); return result; }
public static string PropertyToText(Property p,PCCObject pcc) { string s = ""; s = "Name: " + pcc.Names[p.Name]; s += " Type: " + TypeToString((int)p.TypeVal); s += " Size: " + p.Value.len.ToString(); switch (p.TypeVal) { case Type.StructProperty: s += " \"" + pcc.GetName (p.Value.IntValue) + "\" with " + p.Value.Array.Count.ToString() + " bytes"; break; case Type.IntProperty: case Type.BoolProperty: case Type.StringRefProperty : s += " Value: " + p.Value.IntValue.ToString(); break; case Type.ObjectProperty: s += " Value: " + p.Value.IntValue.ToString() + " "; int v = p.Value.IntValue; if (v == 0) s += "None"; else s += pcc.GetClass(v); break; case Type.FloatProperty: byte[] buff = BitConverter.GetBytes(p.Value.IntValue); float f = BitConverter.ToSingle(buff,0); s += " Value: " + f.ToString(); break; case Type.NameProperty: s += " " + pcc.Names[p.Value.IntValue]; break; case Type.ByteProperty: s += " Value: \"" + p.Value.StringValue + "\" with \"" + pcc.GetName(p.Value.IntValue) + "\""; break; case Type.ArrayProperty: s += " bytes"; //Value: " + p.Value.Array.Count.ToString() + " Elements"; break; case Type.StrProperty: if (p.Value.StringValue.Length == 0) break; s += " Value: " + p.Value.StringValue.Substring(0,p.Value.StringValue.Length - 1); break; } return s; }
public static List<Property> getPropList(PCCObject pcc, byte[] raw) { Application.DoEvents(); int start = detectStart(pcc, raw); return ReadProp(pcc,raw,start); }
public SkeletalMesh(PCCObject pcc, int Index) { Loaded = true; MyIndex = Index; Owner = pcc; Flags = (int)(pcc.Exports[Index].ObjectFlags >> 32); int start = GetPropertyEnd(); byte[] buff = new byte[pcc.Exports[Index].Data.Length - start]; for (int i = 0; i < pcc.Exports[Index].Data.Length - start; i++) buff[i] = pcc.Exports[Index].Data[i + start]; MemoryStream m = new MemoryStream(buff); SerializingContainer Container = new SerializingContainer(m); Container.isLoading = true; Serialize(Container); GenerateDXMeshes(); }