public void LoadData()
        {
            Save.ExtractME1Package(0, "load.upk");
            ME1Package pcc = MEPackageHandler.OpenME1Package("load.upk");

            File.Delete("load.upk");
            byte[] buff = pcc.Exports[1].Data;
            List <PropertyReader.Property> props = PropertyReader.getPropList(pcc.Exports[1]);

            foreach (PropertyReader.Property p in props)
            {
                string name = pcc.getNameEntry(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
        }
예제 #2
0
        private void replaceWithFileButton_Click(object sender, EventArgs e)
        {
            int n = tlkFileBox.SelectedIndex;

            if (n == -1)
            {
                return;
            }
            TalkFile           tlk        = tlkFileSets[bioTlkSetBox.SelectedIndex].talkFiles[n];
            HuffmanCompression compressor = new HuffmanCompression();

            OpenFileDialog d = new OpenFileDialog();

            d.Filter = "*.xml|*.xml";
            if (d.ShowDialog() == DialogResult.OK)
            {
                compressor.LoadInputData(d.FileName);
                compressor.replaceTlkwithFile(tlk.pcc, tlk.index);
                MessageBox.Show("Done");
            }
            n = packages.FindIndex(x => tlk.pcc.FileName == x.FileName);
            packages.RemoveAt(n);
            packages.Insert(n, MEPackageHandler.OpenME1Package(tlk.pcc.FileName));
            refreshFileBox();
        }
예제 #3
0
 private static void loadME1Tlk()
 {
     if (File.Exists(LoadedTLKsPathME1))
     {
         List <(int, string)> files = JsonConvert.DeserializeObject <List <(int, string)> >(File.ReadAllText(LoadedTLKsPathME1));
         foreach ((int exportnum, string filename) in files)
         {
             ME1TalkFiles.LoadTlkData(filename, exportnum);
         }
     }
     else
     {
         string path = ME1Directory.CookedPCPath + @"Packages\Dialog\GlobalTlk.upk";
         if (File.Exists(path))
         {
             try
             {
                 IMEPackage pcc = MEPackageHandler.OpenME1Package(path);
                 ME1TalkFiles.tlkList.Add(new ME1TalkFile(pcc, 1));
             }
             catch (Exception)
             {
             }
         }
     }
 }
예제 #4
0
        public static PropertyCollection getDefaultStructValue(string className, bool stripTransients)
        {
            bool isImmutable = UnrealObjectInfo.IsImmutable(className, MEGame.ME1);

            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(ME1Directory.gamePath, "BioGame", info.pccPath);
                    if (File.Exists(info.pccPath))
                    {
                        filepath = info.pccPath; //Used for dynamic lookup
                    }
                    if (File.Exists(filepath))
                    {
                        IMEPackage         importPCC    = MEPackageHandler.OpenME1Package(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);
        }
예제 #5
0
 public static void LoadTlkData(string fileName, int index)
 {
     if (File.Exists(fileName))
     {
         ME1Package pcc = MEPackageHandler.OpenME1Package(fileName);
         TalkFile   tlk = new TalkFile(pcc, index);
         tlk.LoadTlkData();
         tlkList.Add(tlk);
     }
 }
예제 #6
0
 public static void LoadTlkData(string fileName, int index)
 {
     if (File.Exists(fileName))
     {
         IMEPackage  pcc = MEPackageHandler.OpenME1Package(fileName, forceLoadFromDisk: true); //do not cache this in the packages list.
         ME1TalkFile tlk = new ME1TalkFile(pcc, index);
         tlk.LoadTlkData();
         tlkList.Add(tlk);
     }
 }
예제 #7
0
        private void addFileButton_Click(object sender, EventArgs e)
        {
            OpenFileDialog d = new OpenFileDialog();

            d.Filter = "*.u;*.upk;*sfm|*.u;*.upk;*sfm";
            if (d.ShowDialog() == DialogResult.OK)
            {
                packages.Add(MEPackageHandler.OpenME1Package(d.FileName));
                refreshFileBox();
            }
        }
        public void SaveData()
        {
            Save.ExtractME1Package(0, "save.upk");
            ME1Package pcc = MEPackageHandler.OpenME1Package("save.upk");

            File.Delete("save.upk");
            byte[] buff = pcc.Exports[1].Data;
            List <PropertyReader.Property> props = PropertyReader.getPropList(pcc.Exports[1]);
            int   v;
            float f;

            foreach (PropertyReader.Property p in props)
            {
                string name = pcc.getNameEntry(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.save();
            Save.ImportME1Package(0, "save.upk");
            File.Delete("save.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;
        }
예제 #9
0
        public void LoadGlobalTlk()
        {
            string path = ME1Directory.cookedPath + @"Packages\Dialog\GlobalTlk.upk";

            try
            {
                ME1Package pcc = MEPackageHandler.OpenME1Package(path);
                tlkList.Add(new TalkFile(pcc, 0));
            }
            catch (Exception)
            {
                return;
            }
        }
예제 #10
0
        //call this method to regenerate ME1ObjectInfo.json
        //Takes a long time (10 to 20 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 <string> >();
            ME1Package pcc;
            string     path = ME1Directory.gamePath;

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

            for (int i = 0; i < files.Length; i++)
            {
                if (Path.GetExtension(files[i]) == ".upk" || Path.GetExtension(files[i]) == ".sfm" || Path.GetExtension(files[i]) == ".u")
                {
                    Debug.WriteLine("File: " + files[i]);
                    pcc = MEPackageHandler.OpenME1Package(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;
                            Debug.WriteLine("Generating information for " + 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));
                            }
                        }
                    }
                    pcc.Release();
                }
            }
            File.WriteAllText(Application.StartupPath + "//exec//ME1ObjectInfo.json", JsonConvert.SerializeObject(new { Classes = Classes, Structs = Structs, Enums = Enums }));
            MessageBox.Show("Done");
        }
예제 #11
0
 public static void LoadSavedTlkList()
 {
     if (File.Exists(LoadedTLKsPath))
     {
         List <(int, string)> files = JsonConvert.DeserializeObject <List <(int, string)> >(File.ReadAllText(LoadedTLKsPath));
         foreach ((int exportnum, string filename) in files)
         {
             LoadTlkData(filename, exportnum);
         }
     }
     else
     {
         string path = ME1Directory.cookedPath + @"Packages\Dialog\GlobalTlk.upk";
         try
         {
             ME1Package pcc = MEPackageHandler.OpenME1Package(path);
             tlkList.Add(new TalkFile(pcc, 1));
         }
         catch (Exception)
         {
             return;
         }
     }
 }
예제 #12
0
 public void LoadME1Package(string s)
 {
     Pcc?.Release(winForm: this);
     Pcc = MEPackageHandler.OpenME1Package(s, winForm: this);
 }
        //call this method to regenerate ME1ObjectInfo.json
        //Takes a long time (10 to 20 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> >();
            SequenceObjects = new Dictionary <string, SequenceObjectInfo>();
            foreach (string file in MELoadedFiles.GetOfficialFiles(MEGame.ME1))
            {
                if (Path.GetExtension(file) == ".upk" || Path.GetExtension(file) == ".sfm" || Path.GetExtension(file) == ".u")
                {
                    Debug.WriteLine($"File: {file}");
                    using IMEPackage pcc = MEPackageHandler.OpenME1Package(file);
                    for (int j = 1; j <= pcc.ExportCount; j++)
                    {
                        ExportEntry exportEntry = pcc.GetUExport(j);
                        string      className   = exportEntry.ClassName;
                        if (className == "Enum")
                        {
                            generateEnumValues(exportEntry);
                        }
                        else if (className == "Class")
                        {
                            string objectName = exportEntry.ObjectName;
                            Debug.WriteLine($"Generating information for {objectName}");
                            if (!Classes.ContainsKey(objectName))
                            {
                                Classes.Add(objectName, generateClassInfo(exportEntry));
                            }
                        }
                        else if (className == "ScriptStruct")
                        {
                            string objectName = exportEntry.ObjectName;
                            if (!Structs.ContainsKey(exportEntry.ObjectName))
                            {
                                Structs.Add(objectName, generateClassInfo(exportEntry, isStruct: true));
                            }
                        }
                        else if (exportEntry.IsOrInheritsFrom("SequenceObject"))
                        {
                            if (!SequenceObjects.TryGetValue(className, out SequenceObjectInfo seqObjInfo))
                            {
                                seqObjInfo = new SequenceObjectInfo();
                                SequenceObjects.Add(className, seqObjInfo);
                            }

                            int objInstanceVersion = exportEntry.GetProperty <IntProperty>("ObjInstanceVersion");
                            if (objInstanceVersion > seqObjInfo.ObjInstanceVersion)
                            {
                                seqObjInfo.ObjInstanceVersion = objInstanceVersion;
                            }
                        }
                    }
                }
            }

            //CUSTOM ADDITIONS
            Classes["LightMapTexture2D"] = new ClassInfo
            {
                baseClass   = "Texture2D",
                exportIndex = 0,
                pccPath     = UnrealObjectInfo.Me3ExplorerCustomNativeAdditionsName
            };

            Classes["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>("ForceDoubleSidedShadowVolumes", 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)),
                    new KeyValuePair <string, PropertyInfo>("SoundCue",                      new PropertyInfo(PropertyType.ObjectProperty, "SoundCue")),
                }
            };


            File.WriteAllText(jsonPath, JsonConvert.SerializeObject(new { SequenceObjects, Classes, Structs, Enums }, Formatting.Indented));
        }
        //call this method to regenerate ME1ObjectInfo.json
        //Takes a long time (10 to 20 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 = ME1Directory.gamePath;

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

            foreach (string file in files)
            {
                if (Path.GetExtension(file) == ".upk" || Path.GetExtension(file) == ".sfm" || Path.GetExtension(file) == ".u")
                {
                    Debug.WriteLine("File: " + file);
                    using (ME1Package pcc = MEPackageHandler.OpenME1Package(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);
                            }
                            else if (exportEntry.ClassName == "Class")
                            {
                                objectName = exportEntry.ObjectName;
                                Debug.WriteLine("Generating information for " + 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));
                                }
                            }
                        }
                    }
                }
            }

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

            Classes.Add("LightMapTexture2D", info);


            File.WriteAllText(jsonPath, JsonConvert.SerializeObject(new { Classes = Classes, Structs = Structs, Enums = Enums }, Formatting.Indented));
            MessageBox.Show("Done");
        }