private void ListBox_SelectionChanged(object sender, SelectionChangedEventArgs e) { if (e.AddedItems.Count == 1 && e.AddedItems[0] is LoggerInfo info) { foreach (var kvp in ME3LoadedFiles.GetFilesLoadedInGame()) { if (Path.GetFileNameWithoutExtension(kvp.Key.ToLower()) == info.packageName) { using (var package = MEPackageHandler.OpenME3Package(kvp.Value)) { foreach (IExportEntry exp in package.Exports) { if (exp.ClassName == info.className && exp.ObjectName == info.objectName && exp.indexValue == info.nameIndex && exp.PackageName == info.sequenceName) { ExportFound(kvp.Value, exp.UIndex); return; } } } } } MessageBox.Show("Could not find matching export!"); } }
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 { using (ME3Package pcc = MEPackageHandler.OpenME3Package(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); } } }
/// <summary> /// Queues a texture for eventual loading. /// </summary> /// <param name="pcc">The full path of the pcc where the texture export is.</param> public PreviewTextureEntry LoadTexture(string pcc, int exportid) { foreach (PreviewTextureEntry e in cache) { if (e.PCCPath == pcc && e.ExportID == exportid) { return(e); } } using (ME3Package texpcc = MEPackageHandler.OpenME3Package(pcc)) { PreviewTextureEntry entry = new PreviewTextureEntry(pcc, exportid); Unreal.Classes.Texture2D metex = new Unreal.Classes.Texture2D(texpcc, exportid); Texture2DDescription desc = new Texture2DDescription(); try { entry.Texture = metex.generatePreviewTexture(Device, out desc); entry.TextureView = new ShaderResourceView(Device, entry.Texture); cache.Add(entry); return(entry); } catch { return(null); } } }
public void OpenAnimSet() { SourceAnimSet = null; SourcePcc?.Dispose(); SourcePcc = null; LiveFile?.Dispose(); LiveFile = null; ActorTag = null; var dlg = new OpenFileDialog { Filter = App.ME3ME2SaveFileFilter, CheckFileExists = true, Multiselect = false, Title = "Select ME3 file containing the FaceFXAnimSet you want to edit" }; if (dlg.ShowDialog() == true) { try { SourcePcc = MEPackageHandler.OpenME3Package(dlg.FileName); } catch (FormatException) { MessageBox.Show("Must be an ME3 file!"); return; } if (EntrySelector.GetEntry <ExportEntry>(null, SourcePcc, "Choose FaceFxAnimSet to edit", exp => exp.ClassName == "FaceFXAnimSet") is ExportEntry animSetEntry) { SourceAnimSet = animSetEntry.GetBinaryData <FaceFXAnimSet>(); } } }
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>(); foreach (string file in files) { try { using (IMEPackage _pcc = MEPackageHandler.OpenME3Package(file)) { bool found = _pcc.Exports.Any(ex => ex.ClassName == "AnimTree" || ex.ClassName == "AnimSet"); if (found) { filenames.Add(file); } } } catch (Exception ex) { MessageBox.Show($"Error: Could not open {Path.GetFileName(file)}\n{ex.Message}"); } } RefreshLists(); }
public static PropertyCollection getDefaultStructValue(string className) { if (Structs.ContainsKey(className)) { bool immutable = isImmutable(className); ClassInfo info = Structs[className]; try { string filepath = (Path.Combine(ME3Directory.gamePath, @"BIOGame\" + info.pccPath)); if (File.Exists(info.pccPath)) { filepath = info.pccPath; //Used for dynamic lookup } using (ME3Package importPCC = MEPackageHandler.OpenME3Package(filepath)) { byte[] buff; //Plane and CoverReference inherit from other structs, meaning they don't have default values (who knows why) //thus, I have hardcoded what those default values should be if (className == "Plane") { buff = PlaneDefault; } else if (className == "CoverReference") { buff = CoverReferenceDefault; } else { buff = importPCC.Exports[info.exportIndex].Data.Skip(0x24).ToArray(); } PropertyCollection props = PropertyCollection.ReadProps(importPCC, new MemoryStream(buff), className); List <UProperty> toRemove = new List <UProperty>(); foreach (var prop in props) { //remove transient props if (!info.properties.ContainsKey(prop.Name) && info.baseClass == "Class") { toRemove.Add(prop); } } foreach (var prop in toRemove) { props.Remove(prop); } return(props); } } catch { return(null); } } return(null); }
//call this method to regenerate ME3ObjectInfo.json //Takes a long time (~5 minutes maybe?). Application will be completely unresponsive during that time. public static void generateInfo() { string path = ME3Directory.gamePath; string[] files = Directory.GetFiles(path, "*.pcc", SearchOption.AllDirectories); string objectName; int length = files.Length; for (int i = 0; i < length; i++) { if (files[i].ToLower().EndsWith(".pcc")) { using (ME3Package pcc = MEPackageHandler.OpenME3Package(files[i])) { IReadOnlyList <IExportEntry> Exports = pcc.Exports; IExportEntry exportEntry; for (int j = 0; j < Exports.Count; j++) { exportEntry = Exports[j]; if (exportEntry.ClassName == "Enum") { generateEnumValues(j, pcc); } else if (exportEntry.ClassName == "Class") { objectName = exportEntry.ObjectName; if (!Classes.ContainsKey(objectName)) { Classes.Add(objectName, generateClassInfo(j, pcc)); } if ((objectName.Contains("SeqAct") || objectName.Contains("SeqCond") || objectName.Contains("SequenceLatentAction") || objectName == "SequenceOp" || objectName == "SequenceAction" || objectName == "SequenceCondition") && !SequenceObjects.ContainsKey(objectName)) { SequenceObjects.Add(objectName, generateSequenceObjectInfo(j, pcc)); } } else if (exportEntry.ClassName == "ScriptStruct") { objectName = exportEntry.ObjectName; if (!Structs.ContainsKey(objectName)) { Structs.Add(objectName, generateClassInfo(j, pcc)); } } } } } System.Diagnostics.Debug.WriteLine($"{i} of {length} processed"); } File.WriteAllText(Application.StartupPath + "//exec//ME3ObjectInfo.json", JsonConvert.SerializeObject(new { SequenceObjects = SequenceObjects, Classes = Classes, Structs = Structs, Enums = Enums })); MessageBox.Show("Done"); }
private void startScanToolStripMenuItem_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(ME3Directory.cookedPath)) { MessageBox.Show("This functionality requires ME3 to be installed. Set its path at:\n Options > Set Custom Path > Mass Effect 3"); return; } string pathcook = ME3Directory.cookedPath; DebugOutput.StartDebugger("ScriptDB"); string[] files = Directory.GetFiles(pathcook, "*.pcc"); int count = 1; database = new List <ScriptEntry>(); foreach (string file in files) { DebugOutput.PrintLn(count + "\\" + files.Length + " : Scanning " + Path.GetFileName(file) + " ..."); try { using (IMEPackage pcc = MEPackageHandler.OpenME3Package(file)) { int count2 = 0; foreach (ExportEntry ent in pcc.Exports) { if (ent.ClassName == "Function") { Function f = new Function(ent.Data, ent); ScriptEntry n = new ScriptEntry(); n.file = Path.GetFileName(file); n.name = ent.InstancedFullPath; f.ParseFunction(); n.script = f.ScriptText; database.Add(n); DebugOutput.PrintLn("\tFound \"" + n.name + "\"", false); } count2++; } } } catch (Exception ex) { MessageBox.Show("Error:\n" + ex.Message); DebugOutput.PrintLn("Could not open file: " + Path.GetFileName(file)); } { pb1.Maximum = files.Length; pb1.Value = count; } count++; } RefreshList(); }
private void ExtractWav(string path, string name = "", bool askSave = true) { if (!File.Exists(path)) { return; } string loc = Path.GetDirectoryName(Application.ExecutablePath) + "\\exec"; Stream fs = new FileStream(path, FileMode.Open, FileAccess.Read); if (path.EndsWith(".pcc")) { using (ME3Package package = MEPackageHandler.OpenME3Package(path)) { if (package.IsCompressed) { Stream result = CompressionHelper.DecompressME3(fs); fs.Dispose(); fs = result; } } } if (DataOffset + DataSize > fs.Length) { return; } ExtractRawFromStream(fs); ConvertRiffToWav(); SaveFileDialog d = new SaveFileDialog(); d.Filter = "Wave Files(*.wav)|*.wav"; d.FileName = name + ".wav"; if (askSave) { if (d.ShowDialog() == DialogResult.OK) { File.Copy(loc + "\\out.wav", d.FileName); } } else { File.Copy(loc + "\\out.wav", name, true); } if (askSave) { MessageBox.Show("Done."); } }
private void buttonCompressPCC_Click(object sender, EventArgs e) { if (openPccDialog.ShowDialog() == DialogResult.OK) { string fileName = openPccDialog.FileName; string backupFile = fileName + ".bak"; if (File.Exists(fileName)) { try { using (ME3Package pccObj = MEPackageHandler.OpenME3Package(fileName)) { if (!pccObj.CanReconstruct) { var res = MessageBox.Show("This file contains a SeekFreeShaderCache. Compressing will cause a crash when ME3 attempts to load this file.\n" + "Do you want to visit a forum thread with more information and a possible solution?", "I'm sorry, Dave. I'm afraid I can't do that.", MessageBoxButtons.YesNo, MessageBoxIcon.Stop); if (res == DialogResult.Yes) { System.Diagnostics.Process.Start("http://me3explorer.freeforums.org/research-how-to-turn-your-dlc-pcc-into-a-vanilla-one-t2264.html"); } return; } DialogResult dialogResult = MessageBox.Show("Do you want to make a backup file?", "Make Backup", MessageBoxButtons.YesNo); if (dialogResult == DialogResult.Yes) { File.Copy(fileName, backupFile); } pccObj.saveByReconstructing(fileName, true); } MessageBox.Show("File " + Path.GetFileName(fileName) + " was successfully compressed.", "Succeed", MessageBoxButtons.OK, MessageBoxIcon.Information); } catch (Exception exc) { MessageBox.Show("An error occurred while compressing " + Path.GetFileName(fileName) + ":\n" + exc.Message, "Exception Error", MessageBoxButtons.OK, MessageBoxIcon.Error); //recovering backup file if (File.Exists(backupFile)) { File.Delete(fileName); File.Move(backupFile, fileName); } } } } }
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) { try { using (ME3Package _pcc = MEPackageHandler.OpenME3Package(file)) { DebugOutput.PrintLn((count++) + "/" + files.Length + " : Scanning file " + Path.GetFileName(file) + " ..."); bool found = false; IReadOnlyList <IExportEntry> Exports = _pcc.Exports; foreach (IExportEntry ex in Exports) { if (ex.ClassName == "AnimTree" || ex.ClassName == "AnimSet") { DebugOutput.PrintLn("Found Animation!"); found = true; break; } } if (found) { filenames.Add(file); } } } catch (Exception ex) { MessageBox.Show("Error:\n" + ex.Message); DebugOutput.PrintLn("Could not open " + Path.GetFileName(file)); } } RefreshLists(); }
public void PlaySound() { if (listView1.SelectedItems.Count != 1 || pcc == null) { return; } ListViewItem item = listView1.SelectedItems[0]; int index = Convert.ToInt32(item.Name); if (pcc.Exports[index].ClassName == "WwiseStream") { using (ME3Package package = MEPackageHandler.OpenME3Package(pcc.pccFileName)) { w = new WwiseStream(package, index); w.Play(pathCooked); } } }
/* * This method is called when using the -compresspcc command line argument */ public static int autoCompressPcc(string sourceFile, string outputFile) { if (!File.Exists(sourceFile)) { MessageBox.Show("PCC to compress does not exist:\n" + sourceFile, "Auto Compression Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return(1); } using (ME3Package pccObj = MEPackageHandler.OpenME3Package(sourceFile)) { if (!pccObj.CanReconstruct) { MessageBox.Show("Cannot compress files with a SeekFreeShaderCache", "Auto Compression Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return(1); } pccObj.saveByReconstructing(outputFile, true); } return(0); }
/* * This method is called when using the -decompresspcc command line argument */ public static int autoDecompressPcc(string sourceFile, string outputFile) { if (!File.Exists(sourceFile)) { MessageBox.Show("PCC to decompress does not exist:\n" + sourceFile, "Auto Decompression Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return(1); } try { using (ME3Package pccObj = MEPackageHandler.OpenME3Package(sourceFile)) { pccObj.saveByReconstructing(outputFile); } } catch (Exception ex) { MessageBox.Show("Error:\n" + ex.Message); return(1); } return(0); }
private void PlayWave(string path) { if (!File.Exists(path)) { return; } string loc = Path.GetDirectoryName(Application.ExecutablePath) + "\\exec"; Stream fs = new FileStream(path, FileMode.Open, FileAccess.Read); if (path.EndsWith(".pcc")) { using (ME3Package package = MEPackageHandler.OpenME3Package(path)) { if (package.IsCompressed) { Stream result = CompressionHelper.DecompressME3(fs); fs.Dispose(); fs = result; } } } if (DataOffset + DataSize > fs.Length) { return; } ExtractRawFromStream(fs); ConvertRiffToWav(); if (File.Exists(loc + "\\out.wav")) { sp = new SoundPlayer(loc + "\\out.wav"); sp.Play(); while (!sp.IsLoadCompleted) { Application.DoEvents(); } } fs.Dispose(); }
public void LetsDump(string path) { using (ME3Package pcc = MEPackageHandler.OpenME3Package(path)) { pb1.Minimum = 0; IReadOnlyList <IExportEntry> Exports = pcc.Exports; pb1.Maximum = Exports.Count; rtb1.Text = ""; int count = 0; string t = ""; for (int i = 0; i < Exports.Count; i++) { IExportEntry e = Exports[i]; string s = "Properties for Object #" + i + " \"" + e.ObjectName + "\" :\n\n"; List <PropertyReader.Property> p = PropertyReader.getPropList(e); foreach (PropertyReader.Property prop in p) { s += PropertyReader.PropertyToText(prop, pcc) + "\n"; } s += "\n"; t += s; if (count++ > 100) { count = 0; pb1.Value = i; Status.Text = "State : " + i + " / " + Exports.Count; Application.DoEvents(); } } Status.Text = "State : Done"; rtb1.Text = t; rtb1.SelectionStart = rtb1.TextLength; rtb1.SelectionLength = 0; rtb1.ScrollToCaret(); pb1.Value = 0; } }
public void LetsDump2(string classname) { if (string.IsNullOrEmpty(ME3Directory.cookedPath)) { MessageBox.Show("This functionality requires ME3 to be installed. Set its path at:\n Options > Set Custom Path > Mass Effect 3"); return; } string path = ME3Directory.cookedPath; string[] files = Directory.GetFiles(path, "*.pcc"); pb1.Minimum = 0; rtb1.Text = ""; pauseToolStripMenuItem.Visible = true; pb2.Value = 0; pb2.Maximum = files.Length; List <string> Names = new List <string>(); List <string> Types = new List <string>(); List <string> First = new List <string>(); DebugOutput.Clear(); for (int i = 0; i < files.Length; i++) { try { while (pause) { Application.DoEvents(); } using (ME3Package pcc = MEPackageHandler.OpenME3Package(files[i])) { DebugOutput.PrintLn(i + "/" + files.Length + " Scanning file : " + Path.GetFileName(files[i])); IReadOnlyList <IExportEntry> Exports = pcc.Exports; pb1.Maximum = Exports.Count; pb2.Value = i; for (int j = 0; j < Exports.Count; j++) { IExportEntry ent = Exports[j]; if (ent.ClassName == classname) { List <PropertyReader.Property> p = PropertyReader.getPropList(ent); for (int k = 0; k < p.Count; k++) { PropertyReader.Property prop = p[k]; int found = -1; for (int l = 0; l < Names.Count(); l++) { if (pcc.getNameEntry(prop.Name) == Names[l]) { found = l; } } if (found == -1) { Names.Add(pcc.getNameEntry(prop.Name)); Types.Add(PropertyReader.TypeToString((int)prop.TypeVal)); First.Add(Path.GetFileName(files[i]) + " #" + j); } } } if (j % 500 == 0) { pb1.Value = j; Status.Text = "State : " + j + " / " + Exports.Count; string s = "Possible properties found so far for class \"" + classname + "\":\n"; for (int k = 0; k < Names.Count(); k++) { s += Types[k] + " : \"" + Names[k] + "\" first found: " + First[k] + "\n"; } Action action = () => rtb1.Text = s; rtb1.Invoke(action); action = () => rtb1.SelectionStart = s.Length; rtb1.Invoke(action); action = () => rtb1.ScrollToCaret(); rtb1.Invoke(action); Application.DoEvents(); } } } } catch (Exception ex) { MessageBox.Show("Error:\n" + ex.Message); DebugOutput.PrintLn("Could not open file : " + Path.GetFileName(files[i])); } } Status.Text = "State : Done"; string t = "Possible properties found for class \"" + classname + "\":\n"; for (int k = 0; k < Names.Count(); k++) { t += Types[k] + " : \"" + Names[k] + "\" first found: " + First[k] + "\n"; } rtb1.Text = t; rtb1.SelectionStart = rtb1.TextLength; rtb1.ScrollToCaret(); pb1.Value = 0; pauseToolStripMenuItem.Visible = false; }
private void treeView1_AfterSelect(object sender, TreeViewEventArgs e) { TreeNode t = treeView1.SelectedNode; if (DisplayStyle == 0) { if (t.Parent == null || t.Name == "") { return; } Renderer.STM?.pcc.Dispose(); Renderer.STM = null; Renderer.SKM?.Owner.Dispose(); Renderer.SKM = null; Renderer.CamDistance = 10; Renderer.CamOffset = new Microsoft.DirectX.Vector3(0, 0, 0); try { int i = 0; if (Int32.TryParse(t.Name, out i)) { EntryStruct en = Entries[i]; if (!en.isDLC) { ME3Package pcc = MEPackageHandler.OpenME3Package(ME3Directory.cookedPath + en.Filename); if (en.isSkeletal) { Renderer.SKM = new SkeletalMesh(pcc, en.Index); Renderer.CamDistance = Renderer.SKM.Bounding.r * 2.0f; Renderer.CamOffset = Renderer.SKM.Bounding.origin; treeView2.Nodes.Clear(); if (previewWithTreeToolStripMenuItem.Checked) { treeView2.Visible = false; Application.DoEvents(); treeView2.Nodes.Add(Renderer.SKM.ToTree()); treeView2.Visible = true; } } else { } } else { string loc = Path.GetDirectoryName(Application.ExecutablePath) + "\\exec\\"; string dirDLC = ME3Directory.DLCPath; dirDLC += en.DLCName; dirDLC += "\\CookedPCConsole\\Default.sfar"; DLCBase dlc = new DLCBase(dirDLC); foreach (sfarFile file in dlc.fileList) { try { string filename = Path.GetFileName(file.fileName); if (Path.GetExtension(filename).ToLower().EndsWith(".pcc") && filename == en.Filename) { using (Stream input = File.OpenRead(dirDLC), output = File.Create(loc + filename)) { AmaroK86.MassEffect3.DLCUnpack.DecompressEntry(file, input, output, dlc.CompressionScheme); } if (File.Exists(loc + filename)) { try { ME3Package pcc = MEPackageHandler.OpenME3Package(loc + filename); if (en.isSkeletal) { Renderer.SKM = new SkeletalMesh(pcc, en.Index); Renderer.CamDistance = Renderer.SKM.Bounding.r * 2.0f; Renderer.CamOffset = Renderer.SKM.Bounding.origin; treeView2.Nodes.Clear(); if (previewWithTreeToolStripMenuItem.Checked) { treeView2.Visible = false; Application.DoEvents(); treeView2.Nodes.Add(Renderer.SKM.ToTree()); treeView2.Visible = true; } } else { } } catch (Exception) { } File.Delete(loc + filename); } } } catch (Exception) { } } } } } catch (Exception ex) { MessageBox.Show(ex.ToString()); } } }
private void treeView1_AfterSelect(object sender, TreeViewEventArgs e) { TreeNode t = treeView1.SelectedNode; if (DisplayStyle == 0) { if (t.Parent == null || t.Name == "") { return; } preview?.Dispose(); preview = null; try { if (int.TryParse(t.Name, out int i)) { EntryStruct en = Entries[i]; if (!en.isDLC) { using (ME3Package pcc = MEPackageHandler.OpenME3Package(ME3Directory.cookedPath + en.Filename)) { if (en.isSkeletal) { SkeletalMesh skmesh = new SkeletalMesh(pcc, en.Index); // TODO: pass device preview = new ModelPreview(view.Device, skmesh, view.TextureCache); CenterView(); treeView2.Nodes.Clear(); if (previewWithTreeToolStripMenuItem.Checked) { treeView2.Visible = false; Application.DoEvents(); treeView2.Nodes.Add(skmesh.ToTree()); treeView2.Visible = true; } } else { } } } else { string loc = Path.GetDirectoryName(Application.ExecutablePath) + "\\exec\\"; string dirDLC = ME3Directory.DLCPath; dirDLC += en.DLCName; dirDLC += "\\CookedPCConsole\\Default.sfar"; DLCUnpack dlc = new DLCUnpack(dirDLC); foreach (DLCUnpack.DLCEntry file in dlc.filesList) { try { string filename = Path.GetFileName(file.filenamePath); if (Path.GetExtension(filename).ToLower().EndsWith(".pcc") && filename == en.Filename) { using (Stream input = File.OpenRead(dirDLC), output = File.Create(loc + filename)) { dlc.ExtractEntry(file, input, output); } if (File.Exists(loc + filename)) { try { if (en.isSkeletal) { using (ME3Package pcc = MEPackageHandler.OpenME3Package(loc + filename)) { SkeletalMesh skmesh = new SkeletalMesh(pcc, en.Index); CenterView(); treeView2.Nodes.Clear(); if (previewWithTreeToolStripMenuItem.Checked) { treeView2.Visible = false; Application.DoEvents(); treeView2.Nodes.Add(skmesh.ToTree()); treeView2.Visible = true; } } } } catch (Exception) { } File.Delete(loc + filename); } } } catch (Exception) { } } } } } catch (Exception ex) { MessageBox.Show(ex.ToString()); } } }
public void LoadME3Package(string s) { Pcc?.Release(winForm: this); Pcc = MEPackageHandler.OpenME3Package(s, winForm: this); }
private void scanToolStripMenuItem_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(ME3Directory.cookedPath)) { MessageBox.Show("This functionality requires ME3 to be installed. Set its path at:\n Options > Set Custom Path > Mass Effect 3"); return; } DebugOutput.StartDebugger("Meshplorer2"); int count = 0; timer1.Enabled = false; Entries = new List <EntryStruct>(); bool ScanDLC = false; if (MessageBox.Show("Scan DLCs too?", "Meshplorer 2", MessageBoxButtons.YesNo) == DialogResult.Yes) { ScanDLC = true; } if (ScanDLC) { #region DLC Stuff string dirDLC = ME3Directory.DLCPath; if (!Directory.Exists(dirDLC)) { DebugOutput.PrintLn("No DLC Folder found!"); } else { string[] subdirs = Directory.GetDirectories(dirDLC); string loc = Path.GetDirectoryName(Application.ExecutablePath) + "\\exec\\"; Directory.CreateDirectory(loc + "temp"); foreach (string DLCpath in subdirs) { if (!DLCpath.StartsWith("__") && !DLCpath.StartsWith("DLC_UPD")) { string path = DLCpath + "\\CookedPCConsole\\Default.sfar"; DLCBase dlcbase; try { dlcbase = new DLCBase(path); count = 0; pbar1.Maximum = dlcbase.fileList.Count; foreach (sfarFile file in dlcbase.fileList) { try { string filename = Path.GetFileName(file.fileName); if (Path.GetExtension(filename).ToLower().EndsWith(".pcc")) { using (Stream input = File.OpenRead(path), output = File.Create(loc + "temp\\" + filename)) { AmaroK86.MassEffect3.DLCUnpack.DecompressEntry(file, input, output, dlcbase.CompressionScheme); } FileInfo f = new FileInfo(loc + "temp\\" + filename); DebugOutput.PrintLn("checking DLC: " + Path.GetFileName(DLCpath) + " File: " + filename + " Size: " + f.Length + " bytes", count % 3 == 0); using (ME3Package pcc = MEPackageHandler.OpenME3Package(loc + "temp\\" + filename)) { IReadOnlyList <IExportEntry> Exports = pcc.Exports; for (int i = 0; i < Exports.Count; i++) { if (Exports[i].ClassName == "SkeletalMesh" || Exports[i].ClassName == "StaticMesh") { EntryStruct ent = new EntryStruct(); ent.DLCName = Path.GetFileName(DLCpath); ent.Filename = filename; ent.Index = i; ent.isDLC = true; ent.ObjectPath = Exports[i].GetFullPath; ent.isSkeletal = Exports[i].ClassName == "SkeletalMesh"; Entries.Add(ent); } } } File.Delete(loc + "temp\\" + filename); } if (count % 3 == 0) { pbar1.Value = count; Application.DoEvents(); } count++; } catch (Exception ex) { DebugOutput.PrintLn("=====ERROR=====\n" + ex.ToString() + "\n=====ERROR====="); } } } catch (Exception ex) { DebugOutput.PrintLn("=====ERROR=====\n" + ex.ToString() + "\n=====ERROR====="); } } } Directory.Delete(loc + "temp", true); } #endregion } #region Basegame Stuff string dir = ME3Directory.cookedPath; string[] files = Directory.GetFiles(dir, "*.pcc"); pbar1.Maximum = files.Length - 1; foreach (string file in files) { DebugOutput.PrintLn("Scan file #" + count + " : " + file, count % 10 == 0); try { using (ME3Package pcc = MEPackageHandler.OpenME3Package(file)) { IReadOnlyList <IExportEntry> Exports = pcc.Exports; for (int i = 0; i < Exports.Count; i++) { if (Exports[i].ClassName == "SkeletalMesh" || Exports[i].ClassName == "StaticMesh") { EntryStruct ent = new EntryStruct(); ent.DLCName = ""; ent.Filename = Path.GetFileName(file); ent.Index = i; ent.isDLC = false; ent.ObjectPath = Exports[i].GetFullPath; ent.isSkeletal = Exports[i].ClassName == "SkeletalMesh"; Entries.Add(ent); } } } if (count % 10 == 0) { Application.DoEvents(); pbar1.Value = count; } count++; } catch (Exception ex) { DebugOutput.PrintLn("=====ERROR=====\n" + ex.ToString() + "\n=====ERROR====="); } } #endregion #region Sorting bool run = true; DebugOutput.PrintLn("=====Info=====\n\nSorting names...\n\n=====Info====="); count = 0; while (run) { run = false; for (int i = 0; i < Entries.Count - 1; i++) { if (Entries[i].Filename.CompareTo(Entries[i + 1].Filename) > 0) { EntryStruct tmp = Entries[i]; Entries[i] = Entries[i + 1]; Entries[i + 1] = tmp; run = true; if (count++ % 100 == 0) { Application.DoEvents(); } } } } #endregion TreeRefresh(); timer1.Enabled = true; }
public static byte[] getDefaultClassValue(ME3Package pcc, string className, bool fullProps = false) { if (Structs.ContainsKey(className)) { bool immutable = UnrealObjectInfo.isImmutable(className, MEGame.ME3); ClassInfo info = Structs[className]; try { string filepath = (Path.Combine(ME3Directory.gamePath, @"BIOGame\" + info.pccPath)); if (File.Exists(info.pccPath)) { filepath = info.pccPath; //Used for dynamic lookup } using (ME3Package importPCC = MEPackageHandler.OpenME3Package(filepath)) { byte[] buff; //Plane and CoverReference inherit from other structs, meaning they don't have default values (who knows why) //thus, I have hardcoded what those default values should be if (className == "Plane") { buff = PlaneDefault; } else if (className == "CoverReference") { buff = CoverReferenceDefault; } else { buff = importPCC.Exports[info.exportIndex].Data.Skip(0x24).ToArray(); } List <PropertyReader.Property> Props = PropertyReader.ReadProp(importPCC, buff, 0); MemoryStream m = new MemoryStream(); foreach (PropertyReader.Property p in Props) { string propName = importPCC.getNameEntry(p.Name); //check if property is transient, if so, skip (neither of the structs that inherit have transient props) if (info.properties.ContainsKey(propName) || propName == "None" || info.baseClass != "Class") { if (immutable && !fullProps) { PropertyReader.ImportImmutableProperty(pcc, importPCC, p, className, m, true); } else { PropertyReader.ImportProperty(pcc, importPCC, p, className, m, true); } } } return(m.ToArray()); } } catch (Exception) { return(null); } } else if (Classes.ContainsKey(className)) { ClassInfo info = Structs[className]; try { string filepath = (Path.Combine(ME3Directory.gamePath, @"BIOGame\" + info.pccPath)); if (File.Exists(info.pccPath)) { filepath = info.pccPath; //Used for dynamic lookup } using (ME3Package importPCC = MEPackageHandler.OpenME3Package(filepath)) { IExportEntry entry = pcc.Exports[info.exportIndex + 1]; List <PropertyReader.Property> Props = PropertyReader.getPropList(entry); MemoryStream m = new MemoryStream(entry.DataSize - 4); foreach (PropertyReader.Property p in Props) { if (!info.properties.ContainsKey(importPCC.getNameEntry(p.Name))) { //property is transient continue; } PropertyReader.ImportProperty(pcc, importPCC, p, className, m); } return(m.ToArray()); } } catch (Exception) { return(null); } } return(null); }
//call this method to regenerate ME3ObjectInfo.json //Takes a long time (~5 minutes maybe?). Application will be completely unresponsive during that time. public static void generateInfo() { Classes = new Dictionary <string, ClassInfo>(); Structs = new Dictionary <string, ClassInfo>(); Enums = new Dictionary <string, List <NameReference> >(); string path = ME3Directory.gamePath; string[] files = Directory.GetFiles(Path.Combine(path, "BIOGame"), "*.pcc", SearchOption.AllDirectories); string objectName; int length = files.Length; for (int i = 0; i < length; i++) { if (files[i].ToLower().EndsWith(".pcc")) { using (ME3Package pcc = MEPackageHandler.OpenME3Package(files[i])) { IReadOnlyList <IExportEntry> Exports = pcc.Exports; for (int j = 0; j < Exports.Count; j++) { IExportEntry exportEntry = Exports[j]; if (exportEntry.ClassName == "Enum") { generateEnumValues(j, pcc); } else if (exportEntry.ClassName == "Class") { objectName = exportEntry.ObjectName; if (!Classes.ContainsKey(objectName)) { Classes.Add(objectName, generateClassInfo(j, pcc)); } if ((objectName.Contains("SeqAct") || objectName.Contains("SeqCond") || objectName.Contains("SequenceLatentAction") || objectName == "SequenceOp" || objectName == "SequenceAction" || objectName == "SequenceCondition") && !SequenceObjects.ContainsKey(objectName)) { SequenceObjects.Add(objectName, generateSequenceObjectInfo(j, pcc)); } } else if (exportEntry.ClassName == "ScriptStruct") { objectName = exportEntry.ObjectName; if (!Structs.ContainsKey(objectName)) { Structs.Add(objectName, generateClassInfo(j, pcc)); } } } } } // System.Diagnostics.Debug.WriteLine($"{i} of {length} processed"); } #region CUSTOM ADDITIONS //Custom additions //Custom additions are tweaks and additional classes either not automatically able to be determined //or by new classes designed in the modding scene that must be present in order for parsing to work properly //Kinkojiro - New Class - SFXSeqAct_AttachToSocket Classes["SFXSeqAct_AttachToSocket"] = new ClassInfo { baseClass = "SequenceAction", pccPath = "ME3Explorer_CustomNativeAdditions", exportIndex = 0, properties = { ["PSC2Component"] = new PropertyInfo { type = PropertyType.ObjectProperty, reference = "ParticleSystemComponent" }, ["PSC1Component"] = new PropertyInfo { type = PropertyType.ObjectProperty, reference = "ParticleSystemComponent" }, ["SkMeshComponent"] = new PropertyInfo { type = PropertyType.ObjectProperty, reference = "SkeletalMeshComponent" }, ["TargetPawn"] = new PropertyInfo { type = PropertyType.ObjectProperty, reference = "Actor" }, ["AttachSocketName"] = new PropertyInfo { type = PropertyType.NameProperty } } }; //Kinkojiro - New Class - BioSeqAct_ShowMedals //Sequence object for showing the medals UI Classes["BioSeqAct_ShowMedals"] = new ClassInfo { baseClass = "SequenceAction", pccPath = "ME3Explorer_CustomNativeAdditions", exportIndex = 0, properties = { ["bFromMainMenu"] = new PropertyInfo { type = PropertyType.BoolProperty, }, ["m_oGuiReferenced"] = new PropertyInfo { type = PropertyType.ObjectProperty, reference = "GFxMovieInfo" } } }; //Kinkojiro - New Class - SFXSeqAct_SetFaceFX Classes["SFXSeqAct_SetFaceFX"] = new ClassInfo { baseClass = "SequenceAction", pccPath = "ME3Explorer_CustomNativeAdditions", exportIndex = 0, properties = { ["m_aoTargets"] = new PropertyInfo { type = PropertyType.ArrayProperty, reference = "Actor" }, ["m_pDefaultFaceFXAsset"] = new PropertyInfo { type = PropertyType.ObjectProperty, reference = "FaceFXAsset" } } }; #endregion File.WriteAllText(jsonPath, JsonConvert.SerializeObject(new { SequenceObjects, Classes, Structs, Enums }, Formatting.Indented)); MessageBox.Show("Done"); }
private void startScanToolStripMenuItem_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(ME3Directory.cookedPath)) { MessageBox.Show("This functionality requires ME3 to be installed. Set its path at:\n Options > Set Custom Path > Mass Effect 3"); return; } string path = ME3Directory.cookedPath; string[] files = Directory.GetFiles(path, "*.pcc"); pb1.Maximum = files.Length; DebugOutput.Clear(); Classes = new List <ClassDef>(); for (int i = 0; i < files.Length; i++) { string file = files[i]; DebugOutput.PrintLn(i.ToString("d4") + "\\" + (files.Length - 1) + " : Loading file \"" + file + "\""); try { using (ME3Package pcc = MEPackageHandler.OpenME3Package(file)) { IReadOnlyList <IExportEntry> Exports = pcc.Exports; pb2.Maximum = Exports.Count(); { pb1.Value = i; RefreshLists(); Application.DoEvents(); } for (int j = 0; j < Exports.Count(); j++) { if (j % 100 == 0)//refresh { pb1.Value = i; pb2.Value = j; Application.DoEvents(); } int f = -1; for (int k = 0; k < Classes.Count(); k++) { if (Classes[k].name == Exports[j].ClassName) { f = k; break; } } if (f == -1)//New Class found, add { ClassDef tmp = new ClassDef(); tmp.name = Exports[j].ClassName; tmp.props = new List <PropDef>(); Classes.Add(tmp); f = Classes.Count() - 1; UpdateStatus(); } List <PropertyReader.Property> props = PropertyReader.getPropList(Exports[j]); ClassDef res = Classes[f]; foreach (PropertyReader.Property p in props) { int f2 = -1; string name = pcc.getNameEntry(p.Name); for (int k = 0; k < res.props.Count(); k++) { if (res.props[k].name == name) { f2 = k; break; } } if (f2 == -1) //found new prop { PropDef ptmp = new PropDef(); ptmp.name = name; ptmp.type = (int)p.TypeVal; ptmp.ffpath = Path.GetFileName(file); ptmp.ffidx = j; res.props.Add(ptmp); //DebugOutput.PrintLn("\tin object #" // + j // + " class \"" // + pcc.Exports[j].ClassName // + "\" found property \"" // + name // + "\" type " // + PropertyTypeToString(ptmp.type)); } } } } } catch (Exception ex) { MessageBox.Show("Error:\n" + ex.Message); DebugOutput.PrintLn("Could not open file: " + file); } } Sort(); RefreshLists(); UpdateStatus(); MessageBox.Show("Done."); }
private void importLODToolStripMenuItem_Click(object sender, EventArgs e) { ME3Package pcc = null; try { int n = listBox1.SelectedIndex; if (n == -1) { return; } int m = listBox2.SelectedIndex; if (m == -1) { return; } TreeNode t1 = treeView1.SelectedNode; if (t1 == null || t1.Parent == null || t1.Name == "") { return; } SkeletalMesh skm = new SkeletalMesh(); EntryStruct en; string loc = Path.GetDirectoryName(Application.ExecutablePath) + "\\exec\\"; if (DisplayStyle == 0) { int o = 0; if (!Int32.TryParse(t1.Name, out o)) { return; } en = Entries[o]; if (!en.isDLC) { if (en.isSkeletal) { pcc = MEPackageHandler.OpenME3Package(ME3Directory.cookedPath + en.Filename); skm = new SkeletalMesh(pcc, en.Index); } else { return; } } else { string dirDLC = ME3Directory.DLCPath; dirDLC += en.DLCName; dirDLC += "\\CookedPCConsole\\Default.sfar"; DLCBase dlc = new DLCBase(dirDLC); foreach (sfarFile file in dlc.fileList) { try { string filename = Path.GetFileName(file.fileName); if (Path.GetExtension(filename).ToLower().EndsWith(".pcc") && filename == en.Filename) { if (File.Exists(loc + "dlc.pcc")) { File.Delete(loc + "dlc.pcc"); } using (Stream input = File.OpenRead(dirDLC), output = File.Create(loc + "dlc.pcc")) { AmaroK86.MassEffect3.DLCUnpack.DecompressEntry(file, input, output, dlc.CompressionScheme); } if (File.Exists(loc + "dlc.pcc")) { try { if (en.isSkeletal) { pcc = MEPackageHandler.OpenME3Package(loc + "dlc.pcc"); skm = new SkeletalMesh(pcc, en.Index); break; } else { return; } } catch (Exception) { return; } } } } catch (Exception) { return; } } } } else { return; } if (!skm.Loaded || pcc == null) { return; } SkeletalMesh.LODModelStruct lodpcc = skm.LODModels[0]; UDKExplorer.UDK.Classes.SkeletalMesh skmudk = new UDKExplorer.UDK.Classes.SkeletalMesh(udk, Objects[n]); UDKExplorer.UDK.Classes.SkeletalMesh.LODModelStruct lodudk = skmudk.LODModels[m]; lodpcc.Sections = new List <SkeletalMesh.SectionStruct>(); foreach (UDKExplorer.UDK.Classes.SkeletalMesh.SectionStruct secudk in lodudk.Sections) { SkeletalMesh.SectionStruct secpcc = new SkeletalMesh.SectionStruct(); secpcc.BaseIndex = secudk.BaseIndex; secpcc.ChunkIndex = secudk.ChunkIndex; secpcc.MaterialIndex = secudk.MaterialIndex; secpcc.NumTriangles = secudk.NumTriangles; lodpcc.Sections.Add(secpcc); } lodpcc.IndexBuffer = new SkeletalMesh.MultiSizeIndexContainerStruct(); lodpcc.IndexBuffer.IndexCount = lodudk.IndexBuffer.IndexCount; lodpcc.IndexBuffer.IndexSize = lodudk.IndexBuffer.IndexSize; lodpcc.IndexBuffer.Indexes = new List <ushort>(); foreach (ushort Idx in lodudk.IndexBuffer.Indexes) { lodpcc.IndexBuffer.Indexes.Add(Idx); } List <int> BoneMap = new List <int>(); for (int i = 0; i < skmudk.Bones.Count; i++) { string udkb = udk.GetName(skmudk.Bones[i].Name); bool found = false; for (int j = 0; j < skm.Bones.Count; j++) { string pccb = pcc.getNameEntry(skm.Bones[j].Name); if (pccb == udkb) { found = true; BoneMap.Add(j); if (importBonesToolStripMenuItem.Checked) { SkeletalMesh.BoneStruct bpcc = skm.Bones[j]; UDKExplorer.UDK.Classes.SkeletalMesh.BoneStruct budk = skmudk.Bones[i]; bpcc.Orientation = budk.Orientation; bpcc.Position = budk.Position; skm.Bones[j] = bpcc; } } } if (!found) { DebugOutput.PrintLn("ERROR: Cant Match Bone \"" + udkb + "\""); BoneMap.Add(0); } } lodpcc.ActiveBones = new List <ushort>(); foreach (ushort Idx in lodudk.ActiveBones) { lodpcc.ActiveBones.Add((ushort)BoneMap[Idx]); } lodpcc.Chunks = new List <SkeletalMesh.SkelMeshChunkStruct>(); foreach (UDKExplorer.UDK.Classes.SkeletalMesh.SkelMeshChunkStruct chunkudk in lodudk.Chunks) { SkeletalMesh.SkelMeshChunkStruct chunkpcc = new SkeletalMesh.SkelMeshChunkStruct(); chunkpcc.BaseVertexIndex = chunkudk.BaseVertexIndex; chunkpcc.MaxBoneInfluences = chunkudk.MaxBoneInfluences; chunkpcc.NumRigidVertices = chunkudk.NumRigidVertices; chunkpcc.NumSoftVertices = chunkudk.NumSoftVertices; chunkpcc.BoneMap = new List <ushort>(); chunkpcc.RiginSkinVertices = new List <SkeletalMesh.RigidSkinVertexStruct>(); chunkpcc.SoftSkinVertices = new List <SkeletalMesh.SoftSkinVertexStruct>(); foreach (ushort Idx in chunkudk.BoneMap) { chunkpcc.BoneMap.Add((ushort)BoneMap[Idx]); } lodpcc.Chunks.Add(chunkpcc); } lodpcc.Size = lodudk.Size; lodpcc.NumVertices = lodudk.NumVertices; lodpcc.RequiredBones = new List <byte>(); foreach (byte b in lodudk.RequiredBones) { lodpcc.RequiredBones.Add(b); } lodpcc.VertexBufferGPUSkin = new SkeletalMesh.VertexBufferGPUSkinStruct(); lodpcc.VertexBufferGPUSkin.NumTexCoords = lodudk.VertexBufferGPUSkin.NumTexCoords; lodpcc.VertexBufferGPUSkin.Extension = lodudk.VertexBufferGPUSkin.Extension; lodpcc.VertexBufferGPUSkin.Origin = lodudk.VertexBufferGPUSkin.Origin; lodpcc.VertexBufferGPUSkin.VertexSize = lodudk.VertexBufferGPUSkin.VertexSize; lodpcc.VertexBufferGPUSkin.Vertices = new List <SkeletalMesh.GPUSkinVertexStruct>(); foreach (UDKExplorer.UDK.Classes.SkeletalMesh.GPUSkinVertexStruct vudk in lodudk.VertexBufferGPUSkin.Vertices) { SkeletalMesh.GPUSkinVertexStruct vpcc = new SkeletalMesh.GPUSkinVertexStruct(); vpcc.TangentX = vudk.TangentX; vpcc.TangentZ = vudk.TangentZ; vpcc.Position = vudk.Position; vpcc.InfluenceBones = vudk.InfluenceBones; vpcc.InfluenceWeights = vudk.InfluenceWeights; vpcc.U = vudk.U; vpcc.V = vudk.V; lodpcc.VertexBufferGPUSkin.Vertices.Add(vpcc); } for (int i = 0; i < skm.LODModels.Count; i++) { skm.LODModels[i] = lodpcc; } SerializingContainer con = new SerializingContainer(); con.Memory = new MemoryStream(); con.isLoading = false; skm.Serialize(con); int end = skm.GetPropertyEnd(); MemoryStream mem = new MemoryStream(); mem.Write(pcc.Exports[en.Index].Data, 0, end); mem.Write(con.Memory.ToArray(), 0, (int)con.Memory.Length); pcc.Exports[en.Index].Data = mem.ToArray(); pcc.save(); if (!en.isDLC) { MessageBox.Show("Done"); } else { MessageBox.Show("Done. The file is now in following folder, please replace it back to DLC :\n" + loc + "dlc.pcc"); } globalTreeToolStripMenuItem.Visible = optionsToolStripMenuItem.Visible = transferToolStripMenuItem.Visible = splitContainer1.Visible = true; fileToolStripMenuItem.Visible = importLODToolStripMenuItem.Visible = splitContainer3.Visible = false; } finally { pcc?.Dispose(); } }
private void startScanToolStripMenuItem_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(ME3Directory.cookedPath)) { MessageBox.Show("This functionality requires ME3 to be installed. Set its path at:\n Options > Set Custom Path > Mass Effect 3"); return; } string path = ME3Directory.cookedPath; string[] files = Directory.GetFiles(path, "*.pcc"); pb1.Maximum = files.Length; DebugOutput.Clear(); database = new List <DBEntry>(); int count = 0; foreach (string file in files) { pb1.Value = count++; DebugOutput.PrintLn("Scanning file : " + Path.GetFileName(file) + " ..."); try { using (ME3Package pcc = MEPackageHandler.OpenME3Package(file)) { DBEntry ent = new DBEntry(); ent.filename = Path.GetFileName(file); ent.Objects = new List <ObjInf>(); IReadOnlyList <IExportEntry> Exports = pcc.Exports; for (int i = 0; i < Exports.Count; i++) { IExportEntry ex = Exports[i]; ObjInf obj; switch (ex.ClassName) { case "StaticMesh": obj = new ObjInf(); obj.Index = i; obj.Type = 0; obj.name = ex.ObjectName; ent.Objects.Add(obj); break; case "SkeletalMesh": obj = new ObjInf(); obj.Index = i; obj.Type = 1; obj.name = ex.ObjectName; ent.Objects.Add(obj); break; } } if (ent.Objects.Count != 0) { DebugOutput.PrintLn("Found " + ent.Objects.Count + " Objects:", false); //foreach (ObjInf o in ent.Objects) // DebugOutput.PrintLn("\t" + o.Index + " : " + o.name + " (" + TypeToString(o.Type) + ")", false); //DebugOutput.Update(); database.Add(ent); } else { DebugOutput.PrintLn("Nothing...", false); } } } catch (Exception ex) { MessageBox.Show("Error:\n" + ex.Message); DebugOutput.PrintLn("Could not open file : " + Path.GetFileName(file)); } } RefreshLists(); pb1.Value = 0; }
public void ScanDLCfolder2() { DebugOutput.PrintLn("\n\nDLC Scan for packed files...\n", true); string dir = ME3Directory.DLCPath; string[] files = Directory.GetFiles(dir, "*.sfar", SearchOption.AllDirectories); if (files.Length == 0) { return; } pbar1.Maximum = files.Length - 1; int count = 0; foreach (string file in files) { if (!file.ToLower().Contains("patch")) { DebugOutput.PrintLn("Scan file #" + count + " : " + file, count % 10 == 0); try { DLCPackage dlc = new DLCPackage(file); DebugOutput.PrintLn("found " + dlc.Files.Length + " files : " + file); for (int j = 0; j < dlc.Files.Length; j++) { if (dlc.Files[j].FileName.ToLower().EndsWith(".pcc")) { string filename = dlc.Files[j].FileName; DebugOutput.PrintLn(" " + j.ToString("d4") + " / " + dlc.Files.Length.ToString("d4") + " : opening " + Path.GetFileName(filename), true); MemoryStream mem = dlc.DecompressEntry(j); File.WriteAllBytes("temp.pcc", mem.ToArray()); using (ME3Package pcc = MEPackageHandler.OpenME3Package("temp.pcc")) { IReadOnlyList <IExportEntry> Exports = pcc.Exports; for (int i = 0; i < Exports.Count; i++) { if (Exports[i].ClassName == "BioConversation") { DebugOutput.PrintLn("Found dialog \"" + Exports[i].ObjectName + "\"", false); ME3BioConversation Dialog = new ME3BioConversation(Exports[i] as ME3ExportEntry); foreach (ME3BioConversation.EntryListStuct e in Dialog.EntryList) { string text = ME3TalkFiles.findDataById(e.refText); if (text.Length != 7 && text != "No Data") { EntryStruct t = new EntryStruct(); t.inDLC = true; t.text = text; t.ID = e.refText; t.indexpcc = i; t.pathafc = "";//Todo t.pathdlc = file; t.pathpcc = filename; t.convname = Exports[i].ObjectName; if (e.SpeakerIndex >= 0 && e.SpeakerIndex < Dialog.SpeakerList.Count) { t.speaker = Dialog.SpeakerList[e.SpeakerIndex].InstancedString; } else { t.speaker = "unknown"; } if (t.speaker == null || t.speaker == "") { t.speaker = "unknown"; } Entries.Add(t); DebugOutput.PrintLn("Requ.: (" + t.speaker + ") " + t.text, false); } } foreach (ME3BioConversation.ReplyListStruct e in Dialog.ReplyList) { string text = ME3TalkFiles.findDataById(e.refText); if (text.Length != 7 && text != "No Data") { EntryStruct t = new EntryStruct(); t.inDLC = true; t.text = text; t.ID = e.refText; t.indexpcc = i; t.pathafc = "";//Todo t.pathdlc = file; t.pathpcc = filename; t.convname = Exports[i].ObjectName; Entries.Add(t); DebugOutput.PrintLn("Reply: " + t.text, false); } } } } } } } if (count % 10 == 0) { Application.DoEvents(); pbar1.Value = count; } count++; } catch (Exception ex) { DebugOutput.PrintLn("=====ERROR=====\n" + ex.ToString() + "\n=====ERROR====="); } } } if (File.Exists("temp.pcc")) { File.Delete("temp.pcc"); } }
public void ScanBasefolder() { string dir = ME3Directory.cookedPath; string[] files = Directory.GetFiles(dir, "*.pcc"); pbar1.Maximum = files.Length - 1; int count = 0; foreach (string file in files) { DebugOutput.PrintLn("Scan file #" + count + " : " + file, count % 10 == 0); try { using (ME3Package pcc = MEPackageHandler.OpenME3Package(file)) { IReadOnlyList <IExportEntry> Exports = pcc.Exports; for (int i = 0; i < Exports.Count; i++) { if (Exports[i].ClassName == "BioConversation") { DebugOutput.PrintLn("Found dialog \"" + Exports[i].ObjectName + "\"", false); ME3BioConversation Dialog = new ME3BioConversation(Exports[i] as ME3ExportEntry); foreach (ME3BioConversation.EntryListStuct e in Dialog.EntryList) { string text = ME3TalkFiles.findDataById(e.refText); if (text.Length != 7 && text != "No Data") { EntryStruct t = new EntryStruct(); t.inDLC = false; t.text = text; t.ID = e.refText; t.indexpcc = i; t.pathafc = "";//Todo t.pathdlc = ""; t.pathpcc = file; t.convname = Exports[i].ObjectName; if (e.SpeakerIndex >= 0 && e.SpeakerIndex < Dialog.SpeakerList.Count) { t.speaker = Dialog.SpeakerList[e.SpeakerIndex].InstancedString; } else { t.speaker = "unknown"; } if (t.speaker == null || t.speaker == "") { t.speaker = "unknown"; } Entries.Add(t); DebugOutput.PrintLn("Requ.: (" + t.speaker + ") " + t.text, false); } } foreach (ME3BioConversation.ReplyListStruct e in Dialog.ReplyList) { string text = ME3TalkFiles.findDataById(e.refText); if (text.Length != 7 && text != "No Data") { EntryStruct t = new EntryStruct(); t.inDLC = false; t.text = text; t.ID = e.refText; t.indexpcc = i; t.pathafc = "";//Todo t.pathdlc = ""; t.pathpcc = file; t.convname = Exports[i].ObjectName; Entries.Add(t); DebugOutput.PrintLn("Reply: " + t.text, false); } } } } if (count % 10 == 0) { Application.DoEvents(); pbar1.Value = count; } count++; } } catch (Exception ex) { DebugOutput.PrintLn("=====ERROR=====\n" + ex.ToString() + "\n=====ERROR====="); } } }
public void LoadME3Package(string s) { pcc?.Release(wpfWindow: this); pcc = MEPackageHandler.OpenME3Package(s, wpfWindow: this); }
private void makeDialogDumpToolStripMenuItem_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(ME3Directory.cookedPath)) { MessageBox.Show("This functionality requires ME3 to be installed. Set its path at:\n Options > Set Custom Path > Mass Effect 3"); return; } string path = ME3Directory.cookedPath; string[] files = Directory.GetFiles(path); pb1.Minimum = 0; rtb1.Text = ""; int count = 0; int count2 = 0; string t = ""; pauseToolStripMenuItem.Visible = true; pb2.Value = 0; pb2.Maximum = files.Length; for (int i = 0; i < files.Length; i++) { try { if (files[i].ToLower().EndsWith(".pcc")) { while (pause) { Application.DoEvents(); } using (ME3Package pcc = MEPackageHandler.OpenME3Package(files[i])) { IReadOnlyList <IExportEntry> Exports = pcc.Exports; pb1.Maximum = Exports.Count; pb2.Value = i; string s = "String references for file " + files[i] + "\n"; for (int j = 0; j < Exports.Count; j++) { IExportEntry ent = Exports[j]; List <PropertyReader.Property> p = PropertyReader.getPropList(ent); for (int k = 0; k < p.Count; k++) { PropertyReader.Property prop = p[k]; if (prop.TypeVal == PropertyType.StringRefProperty) { s += "Object #" + j + " : " + PropertyReader.PropertyToText(prop, pcc) + "\n"; } if (prop.TypeVal == PropertyType.ArrayProperty) { string tt = DumpArray(pcc, ent.Data, prop.offsetval + 4, 1); if (tt.Length != 0) { s += "Object #" + j + " in : " + PropertyReader.PropertyToText(prop, pcc) + "\n"; s += tt; } } if (prop.TypeVal == PropertyType.StructProperty) { string tt = DumpArray(pcc, ent.Data, prop.offsetval + 8, 1); if (tt.Length != 0) { s += "Object #" + j + " in : " + PropertyReader.PropertyToText(prop, pcc) + "\n"; s += tt; } } } if (count++ > 500) { count = 0; pb1.Value = j; Status.Text = "State : " + j + " / " + Exports.Count; if (count2++ > 10) { count2 = 0; rtb1.Text = t; rtb1.SelectionStart = rtb1.TextLength; rtb1.ScrollToCaret(); rtb1.Visible = true; } Application.DoEvents(); } } t += s + "\n"; } } } catch (Exception ex) { MessageBox.Show("Error:\n" + ex.Message); } } Status.Text = "State : Done"; rtb1.Text = t; rtb1.SelectionStart = rtb1.TextLength; rtb1.ScrollToCaret(); pb1.Value = 0; pauseToolStripMenuItem.Visible = false; }