コード例 #1
0
        private void openToolStripMenuItem_Click(object sender, EventArgs e)
        {
            OpenFileDialog d = new OpenFileDialog();

            d.Filter = "*.pcc|*.pcc";
            if (d.ShowDialog() == DialogResult.OK)
            {
                try
                {
                    pcc     = MEPackageHandler.OpenME2Package(d.FileName);
                    Objects = new List <int>();
                    IReadOnlyList <IExportEntry> Exports = pcc.Exports;
                    for (int i = 0; i < Exports.Count; i++)
                    {
                        if (Exports[i].ClassName == "FaceFXAnimSet")
                        {
                            Objects.Add(i);
                        }
                    }
                    ListRefresh();
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Error:\n" + ex.Message);
                }
            }
        }
コード例 #2
0
        public static PropertyCollection getDefaultStructValue(string className, bool stripTransients)
        {
            bool isImmutable = UnrealObjectInfo.IsImmutable(className, MEGame.ME2);

            if (Structs.ContainsKey(className))
            {
                ClassInfo info = Structs[className];
                try
                {
                    PropertyCollection structProps = new PropertyCollection();
                    ClassInfo          tempInfo    = info;
                    while (tempInfo != null)
                    {
                        foreach ((string propName, PropertyInfo propInfo) in tempInfo.properties)
                        {
                            if (stripTransients && propInfo.Transient)
                            {
                                continue;
                            }
                            if (getDefaultProperty(propName, propInfo, stripTransients, isImmutable) is UProperty uProp)
                            {
                                structProps.Add(uProp);
                            }
                        }
                        if (!Structs.TryGetValue(tempInfo.baseClass, out tempInfo))
                        {
                            tempInfo = null;
                        }
                    }
                    structProps.Add(new NoneProperty());

                    string filepath = Path.Combine(ME2Directory.gamePath, "BioGame", info.pccPath);
                    if (File.Exists(info.pccPath))
                    {
                        filepath = info.pccPath; //Used for dynamic lookup
                    }
                    if (File.Exists(filepath))
                    {
                        IMEPackage         importPCC    = MEPackageHandler.OpenME2Package(filepath);
                        var                exportToRead = importPCC.getUExport(info.exportIndex);
                        byte[]             buff         = exportToRead.Data.Skip(0x30).ToArray();
                        PropertyCollection defaults     = PropertyCollection.ReadProps(exportToRead, new MemoryStream(buff), className);
                        foreach (var prop in defaults)
                        {
                            structProps.TryReplaceProp(prop);
                        }
                    }
                    return(structProps);
                }
                catch
                {
                    return(null);
                }
            }
            return(null);
        }
コード例 #3
0
        //call this method to regenerate ME2ObjectInfo.json
        //Takes a long time (10 minutes maybe?). Application will be completely unresponsive during that time.
        public static void generateInfo()
        {
            ME2Package pcc;
            string     path = ME2Directory.gamePath;

            string[] files = Directory.GetFiles(path, "*.pcc", SearchOption.AllDirectories);
            string   objectName;

            for (int i = 0; i < files.Length; i++)
            {
                if (files[i].ToLower().EndsWith(".pcc"))
                {
                    pcc = MEPackageHandler.OpenME2Package(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(exportEntry.ObjectName))
                            {
                                Classes.Add(objectName, generateClassInfo(j, pcc));
                            }
                        }
                        else if (exportEntry.ClassName == "ScriptStruct")
                        {
                            objectName = exportEntry.ObjectName;
                            if (!Structs.ContainsKey(exportEntry.ObjectName))
                            {
                                Structs.Add(objectName, generateClassInfo(j, pcc));
                            }
                        }
                    }
                }
            }
            File.WriteAllText(Application.StartupPath + "//exec//ME2ObjectInfo.json", JsonConvert.SerializeObject(new { Classes = Classes, Structs = Structs, Enums = Enums }));
            MessageBox.Show("Done");
        }
コード例 #4
0
 public void LoadME2Package(string s)
 {
     Pcc?.Release(winForm: this);
     Pcc = MEPackageHandler.OpenME2Package(s, winForm: this);
 }
コード例 #5
0
        //call this method to regenerate ME2ObjectInfo.json
        //Takes a long time (10 minutes maybe?). Application will be completely unresponsive during that time.
        public static void generateInfo()
        {
            var NewClasses = new Dictionary <string, ClassInfo>();
            var NewStructs = new Dictionary <string, ClassInfo>();
            var NewEnums   = new Dictionary <string, List <NameReference> >();

            string path = ME2Directory.gamePath;

            string[] files = Directory.GetFiles(path, "*.pcc", SearchOption.AllDirectories);
            foreach (string file in files)
            {
                if (file.ToLower().EndsWith(".pcc") /* && file.Contains("Engine")*/)
                {
                    using (ME2Package pcc = MEPackageHandler.OpenME2Package(file))
                    {
                        IReadOnlyList <IExportEntry> Exports = pcc.Exports;
                        for (int j = 0; j < Exports.Count; j++)
                        {
                            IExportEntry exportEntry = Exports[j];
                            if (exportEntry.ClassName == "Enum")
                            {
                                generateEnumValues(j, pcc, NewEnums);
                            }
                            else if (exportEntry.ClassName == "Class")
                            {
                                string objectName = exportEntry.ObjectName;
                                if (!NewClasses.ContainsKey(objectName))
                                {
                                    NewClasses.Add(objectName, generateClassInfo(j, pcc));
                                }
                            }
                            else if (exportEntry.ClassName == "ScriptStruct")
                            {
                                string objectName = exportEntry.ObjectName;
                                if (!NewStructs.ContainsKey(objectName))
                                {
                                    NewStructs.Add(objectName, generateClassInfo(j, pcc));
                                }
                            }
                        }
                        Debug.WriteLine("Releasing " + pcc.FileName);
                    }
                }
            }

            //CUSTOM ADDITIONS
            ClassInfo info = new ClassInfo
            {
                baseClass   = "Texture2D",
                exportIndex = 0,
                pccPath     = "ME3Explorer_CustomNativeAdditions"
            };

            try
            {
                NewClasses.Add("LightMapTexture2D", info);
            }
            catch (Exception)
            {
            }

            //SFXPhysicalMaterialDecals missing items
            ClassInfo sfxpmd = Classes["SFXPhysicalMaterialDecals"];

            string[] decalComponentArrays = { "HeavyPistol", "AutoPistol", "HandCannon", "SMG", "Shotgun", "HeavyShotgun", "FlakGun", "AssaultRifle", "Needler", "Machinegun", "SniperRifle", "AntiMatRifle", "MassCannon", "ParticleBeam" };
            foreach (string decal in decalComponentArrays)
            {
                sfxpmd.properties[decal] = new PropertyInfo
                {
                    type      = PropertyType.ArrayProperty,
                    reference = "DecalComponent"
                };
            }

            ClassInfo sfxweapon = Classes["SFXWeapon"];

            sfxpmd.properties["InstantHitDamageTypes"] = new PropertyInfo
            {
                type      = PropertyType.ArrayProperty,
                reference = "Class"
            };
            File.WriteAllText(jsonPath, JsonConvert.SerializeObject(new { Classes = NewClasses, Structs = NewStructs, Enums = NewEnums }, Formatting.Indented));
            MessageBox.Show("Done");
        }
コード例 #6
0
 public static PropertyCollection getDefaultStructValue(string className, bool stripTransients = true)
 {
     if (Structs.ContainsKey(className))
     {
         bool      immutable = UnrealObjectInfo.isImmutable(className, MEGame.ME2);
         ClassInfo info      = Structs[className];
         try
         {
             if (info.pccPath != "ME3Explorer_CustomNativeAdditions")
             {
                 string filepath = (Path.Combine(ME2Directory.gamePath, @"BioGame\" + info.pccPath));
                 if (File.Exists(info.pccPath))
                 {
                     filepath = info.pccPath; //Used for dynamic lookup
                 }
                 using (ME2Package importPCC = MEPackageHandler.OpenME2Package(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
                     {
                         var exportToRead = importPCC.Exports[info.exportIndex];
                         buff = exportToRead.Data.Skip(0x30).ToArray();
                     }
                     PropertyCollection props = PropertyCollection.ReadProps(importPCC, new MemoryStream(buff), className);
                     if (stripTransients)
                     {
                         var toRemove = new List <UProperty>();
                         foreach (var prop in props)
                         {
                             //remove transient props
                             if (info.properties.TryGetValue(prop.Name, out PropertyInfo propInfo))
                             {
                                 if (propInfo.transient)
                                 {
                                     toRemove.Add(prop);
                                 }
                             }
                             //if (!info.properties.ContainsKey(prop.Name) && info.baseClass == "Class")
                             //{
                             //    toRemove.Add(prop);
                             //}
                         }
                         foreach (var prop in toRemove)
                         {
                             Debug.WriteLine($"ME2: Get Default Struct value ({className}) - removing transient prop: {prop.Name}");
                             props.Remove(prop);
                         }
                     }
                     return(props);
                 }
             }
         }
         catch
         {
             return(null);
         }
     }
     return(null);
 }
コード例 #7
0
        //call this method to regenerate ME2ObjectInfo.json
        //Takes a long time (10 minutes maybe?). Application will be completely unresponsive during that time.
        public static void generateInfo()
        {
            var NewClasses         = new Dictionary <string, ClassInfo>();
            var NewStructs         = new Dictionary <string, ClassInfo>();
            var NewEnums           = new Dictionary <string, List <NameReference> >();
            var NewSequenceObjects = new Dictionary <string, SequenceObjectInfo>();

            foreach (string filePath in MELoadedFiles.GetOfficialFiles(MEGame.ME2))
            {
                if (Path.GetExtension(filePath) == ".pcc")
                {
                    using IMEPackage pcc = MEPackageHandler.OpenME2Package(filePath);
                    for (int j = 1; j <= pcc.ExportCount; j++)
                    {
                        ExportEntry exportEntry = pcc.GetUExport(j);
                        string      className   = exportEntry.ClassName;
                        if (className == "Enum")
                        {
                            generateEnumValues(exportEntry, NewEnums);
                        }
                        else if (className == "Class")
                        {
                            string objectName = exportEntry.ObjectName;
                            if (!NewClasses.ContainsKey(objectName))
                            {
                                NewClasses.Add(objectName, generateClassInfo(exportEntry));
                            }
                        }
                        else if (className == "ScriptStruct")
                        {
                            string objectName = exportEntry.ObjectName;
                            if (!NewStructs.ContainsKey(objectName))
                            {
                                NewStructs.Add(objectName, generateClassInfo(exportEntry, isStruct: true));
                            }
                        }
                        else if (exportEntry.IsOrInheritsFrom("SequenceObject"))
                        {
                            if (!NewSequenceObjects.TryGetValue(className, out SequenceObjectInfo seqObjInfo))
                            {
                                seqObjInfo = new SequenceObjectInfo();
                                NewSequenceObjects.Add(className, seqObjInfo);
                            }

                            int objInstanceVersion = exportEntry.GetProperty <IntProperty>("ObjInstanceVersion");
                            if (objInstanceVersion > seqObjInfo.ObjInstanceVersion)
                            {
                                seqObjInfo.ObjInstanceVersion = objInstanceVersion;
                            }
                        }
                    }
                    //Debug.WriteLine("Releasing " + pcc.FileName);
                }
            }

            //CUSTOM ADDITIONS
            try
            {
                NewClasses.Add("LightMapTexture2D", new ClassInfo
                {
                    baseClass   = "Texture2D",
                    exportIndex = 0,
                    pccPath     = UnrealObjectInfo.Me3ExplorerCustomNativeAdditionsName
                });

                NewClasses["StaticMesh"] = new ClassInfo
                {
                    baseClass   = "Object",
                    exportIndex = 0,
                    pccPath     = UnrealObjectInfo.Me3ExplorerCustomNativeAdditionsName,
                    properties  =
                    {
                        new KeyValuePair <string, PropertyInfo>("UseSimpleRigidBodyCollision", new PropertyInfo(PropertyType.BoolProperty)),
                        new KeyValuePair <string, PropertyInfo>("UseSimpleLineCollision",      new PropertyInfo(PropertyType.BoolProperty)),
                        new KeyValuePair <string, PropertyInfo>("UseSimpleBoxCollision",       new PropertyInfo(PropertyType.BoolProperty)),
                        new KeyValuePair <string, PropertyInfo>("UseFullPrecisionUVs",         new PropertyInfo(PropertyType.BoolProperty)),
                        new KeyValuePair <string, PropertyInfo>("BodySetup",                   new PropertyInfo(PropertyType.ObjectProperty, "RB_BodySetup")),
                        new KeyValuePair <string, PropertyInfo>("LODDistanceRatio",            new PropertyInfo(PropertyType.FloatProperty)),
                        new KeyValuePair <string, PropertyInfo>("LightMapCoordinateIndex",     new PropertyInfo(PropertyType.IntProperty)),
                        new KeyValuePair <string, PropertyInfo>("LightMapResolution",          new PropertyInfo(PropertyType.IntProperty)),
                    }
                };
            }
            catch (Exception)
            {
            }

            //SFXPhysicalMaterialDecals missing items
            ClassInfo sfxpmd = NewClasses["SFXPhysicalMaterialDecals"];

            string[] decalComponentArrays = { "HeavyPistol", "AutoPistol", "HandCannon", "SMG", "Shotgun", "HeavyShotgun", "FlakGun", "AssaultRifle", "Needler", "Machinegun", "SniperRifle", "AntiMatRifle", "MassCannon", "ParticleBeam" };
            foreach (string decal in decalComponentArrays)
            {
                sfxpmd.properties.Add(decal, new PropertyInfo(PropertyType.ArrayProperty, "DecalComponent"));
            }

            NewClasses["SFXWeapon"].properties.Add("InstantHitDamageTypes", new PropertyInfo(PropertyType.ArrayProperty, "Class"));

            File.WriteAllText(jsonPath, JsonConvert.SerializeObject(new { SequenceObjects = NewSequenceObjects, Classes = NewClasses, Structs = NewStructs, Enums = NewEnums }, Formatting.Indented));
        }