示例#1
0
 public void CreateModJobs()
 {
     if (isEdited)
     {
         byte[] buff = Vector3ToBuff(location);
         int f = -1;
         for (int i = 0; i < Props.Count; i++)
             if (pcc.getNameEntry(Props[i].Name) == "location")
             {
                 f = i;
                 break;
             };
         if (f != -1)//has prop
         {
             int off = Props[f].offend - 12;
             for (int i = 0; i < 12; i++)
                 data[off + i] = buff[i];
         }
         else//have to add prop
         {
             DebugOutput.PrintLn(MyIndex + " : cant find location property");
         }
         KFreonLib.Scripting.ModMaker.ModJob mj = new KFreonLib.Scripting.ModMaker.ModJob();
         string currfile = Path.GetFileName(pcc.pccFileName);
         mj.data = data;
         mj.Name = "Binary Replacement for file \"" + currfile + "\" in Object #" + MyIndex + " with " + data.Length + " bytes of data";
         string lc = Path.GetDirectoryName(Application.ExecutablePath);
         string template = System.IO.File.ReadAllText(lc + "\\exec\\JobTemplate_Binary2.txt");
         template = template.Replace("**m1**", MyIndex.ToString());
         template = template.Replace("**m2**", currfile);
         mj.Script = template;
         KFreonLib.Scripting.ModMaker.JobList.Add(mj);
         DebugOutput.PrintLn("Created Mod job : " + mj.Name);
     }
 }
示例#2
0
        public double GetRequiredSize()
        {
            var folders     = Directory.EnumerateDirectories(ME3Directory.DLCPath);
            var extracted   = folders.Where(folder => Directory.EnumerateFiles(folder, "*", SearchOption.AllDirectories).Any(file => file.EndsWith("pcconsoletoc.bin", StringComparison.OrdinalIgnoreCase)));
            var unextracted = folders.Except(extracted);

            double size = 0;

            foreach (var folder in unextracted)
            {
                if (folder.Contains("__metadata"))
                {
                    continue;
                }

                try
                {
                    FileInfo info = new FileInfo(Directory.EnumerateFiles(folder, "*", SearchOption.AllDirectories).Where(file => file.EndsWith(".sfar", StringComparison.OrdinalIgnoreCase)).First());
                    size += info.Length * 1.1; // KFreon: Fudge factor for decompression
                }
                catch (Exception e)
                {
                    DebugOutput.PrintLn(e.Message);
                }
            }
            return(size);
        }
示例#3
0
        private void warrantyVoiderMethodToolStripMenuItem_Click(object sender, EventArgs e)
        {
            FolderBrowserDialog d = new FolderBrowserDialog();

            if (d.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                string folder   = d.SelectedPath + "\\";
                string loc      = Path.GetDirectoryName(Application.ExecutablePath);
                string template = System.IO.File.ReadAllText(loc + "\\exec\\template.code");
                DebugOutput.Clear();
                DebugOutput.PrintLn("Generating SDK into folder: " + folder);
                foreach (ClassDef c in Classes)
                {
                    if (c.props.Count > 1 && !c.name.StartsWith("Default_"))
                    {
                        string file = folder + c.name + ".cs";
                        DebugOutput.PrintLn(".\\" + c.name + ".cs generated...");
                        FileStream fs  = new FileStream(file, FileMode.Create, FileAccess.Write);
                        string     tmp = template;
                        tmp = tmp.Replace("**CLASSNAME**", c.name);
                        tmp = GenerateProps(tmp, c);
                        tmp = GenerateLoadSwitch(tmp, c);
                        tmp = GenerateTree(tmp, c);
                        for (int i = 0; i < tmp.Length; i++)
                        {
                            fs.WriteByte((byte)tmp[i]);
                        }
                        fs.Close();
                    }
                }
                MessageBox.Show("Done.");
            }
        }
示例#4
0
        public void ReadFile()
        {
            Memory.Seek(0, 0);
            uint magic = (uint)ReadInt(Memory);

            if (magic != 0x3AB70C13)
            {
                DebugOutput.PrintLn("Not a SFAR File.  DEBUG: in tocbin");
                return;
            }
            Memory.Seek(8, 0);
            int count = ReadInt(Memory);

            Memory.Seek(0xC + 8 * count, 0);
            Entries = new List <Entry>();
            int blocksize = 0;
            int pos       = (int)Memory.Position;

            do
            {
                Entry e = new Entry();
                e.offset = pos;
                Memory.Seek(pos, 0);
                blocksize = ReadInt16(Memory);
                Memory.Seek(pos + 0x4, 0);
                e.size = ReadInt(Memory);
                Memory.Seek(pos + 0x1C, 0);
                e.name = ReadString(Memory);
                pos   += blocksize;
                Entries.Add(e);
            }while (blocksize != 0);
        }
示例#5
0
        private void ReadExports(MemoryStream fs)
        {
            DebugOutput.PrintLn("Reading Exports...");
            fs.Seek(ExportOffset, SeekOrigin.Begin);
            exports = new List <ME1ExportEntry>();
            byte[] buffer;

            for (int i = 0; i < ExportCount; i++)
            {
                long start = fs.Position;

                fs.Seek(40, SeekOrigin.Current);
                int count = fs.ReadValueS32();
                fs.Seek(4 + count * 12, SeekOrigin.Current);
                count = fs.ReadValueS32();
                fs.Seek(4 + count * 4, SeekOrigin.Current);
                fs.Seek(16, SeekOrigin.Current);
                long end = fs.Position;
                fs.Seek(start, SeekOrigin.Begin);

                ME1ExportEntry exp = new ME1ExportEntry(this, fs.ReadBytes((int)(end - start)), (uint)start);
                buffer = new byte[exp.DataSize];
                fs.Seek(exp.DataOffset, SeekOrigin.Begin);
                fs.Read(buffer, 0, buffer.Length);
                exp.Data             = buffer;
                exp.DataChanged      = false;
                exp.Index            = i;
                exp.PropertyChanged += exportChanged;
                exports.Add(exp);
                fs.Seek(end, SeekOrigin.Begin);
            }
        }
示例#6
0
        public TreeNode ToTreeSimple(int nr)
        {
            TreeNode t = new TreeNode("#" + nr + " Level");

            DebugOutput.PrintLn("Generating Tree...");
            for (int i = 0; i < Objects.Count(); i++)
            {
                int index = Objects[i];
                if (index > 0)
                {
                    IExportEntry e = pcc.Exports[index];
                    DebugOutput.PrintLn((i + 1) + " / " + Objects.Count + " : \"" + e.ObjectName + "\" - \"" + e.ClassName + "\"");
                    switch (e.ClassName)
                    {
                    default:
                        string s = "#" + index + " : \"";
                        s += e.ObjectName + "\" CLASS : \"";
                        s += e.ClassName + "\"";
                        TreeNode t1 = new TreeNode(s);
                        t.Nodes.Add(t1);
                        break;
                    }
                }
                else
                {
                    TreeNode t1 = new TreeNode("#" + index + " : NOT IMPLEMENTED");
                    t.Nodes.Add(t1);
                }
            }
            return(t);
        }
示例#7
0
        private void SetupStuff(int game, string DLCPath, string CookedPath)
        {
            List <string> things = KFreonLib.Misc.Methods.GetInstalledDLC(DLCPath);

            // KFreon: Add basegame
            DLCInfo basegame = new DLCInfo("BaseGame", CookedPath, game);

            DLCs.Add(basegame);

            if (things.Count == 0)
            {
                DebugOutput.PrintLn("No DLC Detected.");
                StatusUpdater.UpdateText("No DLC Detected!");
            }
            else
            {
                foreach (string folder in things)
                {
                    string name = KFreonLib.Misc.Methods.GetDLCNameFromPath(folder);
                    if (name != null)
                    {
                        DLCs.Add(new DLCInfo(name, folder, game));
                    }
                }
            }

            // KFreon: Check if there's a custtextures.tfc -> Indicates texture modding. NOT a guarantee though.
            if (DLCs[0].Files.Where(t => t.ToLowerInvariant().Contains("custtextures")).Any())
            {
                MessageBox.Show("Possible texture mods detected." + Environment.NewLine + "Scans indicate presence of custtextures#.tfc, which itself indicates texture mods have been made." + Environment.NewLine + "It is STRONGLY recommended to cancel this setup and vanilla your game (see Instructions).", "*Shepards EDI Airlock joke face*", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
        }
示例#8
0
        /// <summary>
        /// Gets .mod build version, current toolset build version, and a boolean showing if they match.
        /// Returns: Current toolset version.
        /// Outs: .mod version, bool showing if matching.
        /// </summary>
        /// <param name="version">Version area extracted from .mod. May NOT be version if .mod is outdated.</param>
        /// <param name="newversion">OUT: .mod build version if applicable.</param>
        /// <param name="validVers">OUT: True if .mod supported by current toolset.</param>
        /// <returns>Current toolset build version.</returns>
        private static string GetVersion(string version, out string newversion, out bool validVers)
        {
            validVers = false;

            // KFreon: Get .mod version bits and check if valid version.
            List <string> modVersion = new List <string>(version.Split('.'));

            if (modVersion.Count == 4)
            {
                validVers = true;
            }


            List <string> ExecutingVersion = new List <string>(System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString().Split('.'));

            DebugOutput.PrintLn("Current Version: " + String.Join(".", ExecutingVersion) + "    Mod built with version: " + String.Join(".", modVersion));

            newversion = "";
            try
            {
                modVersion.RemoveAt(modVersion.Count - 1);
                modVersion.RemoveAt(modVersion.Count - 1);
                newversion = String.Join(".", modVersion);
            }
            catch (Exception e)
            {
                DebugOutput.PrintLn("Version parse failed: " + e.Message);
            }


            ExecutingVersion.RemoveAt(ExecutingVersion.Count - 1);
            ExecutingVersion.RemoveAt(ExecutingVersion.Count - 1);

            return(String.Join(".", ExecutingVersion));
        }
示例#9
0
        public ME2PCCObject(String path)
        {
            lzo      = new SaltLZOHelper();
            fullname = path;
            BitConverter.IsLittleEndian = true;
            DebugOutput.PrintLn("Load file : " + path);
            pccFileName = Path.GetFullPath(path);
            MemoryStream tempStream = new MemoryStream();

            if (!File.Exists(pccFileName))
            {
                throw new FileNotFoundException("PCC file not found");
            }
            using (FileStream fs = new FileStream(pccFileName, FileMode.Open, FileAccess.Read))
            {
                FileInfo tempInfo = new FileInfo(pccFileName);
                tempStream.WriteFromStream(fs, tempInfo.Length);
                if (tempStream.Length != tempInfo.Length)
                {
                    throw new FileLoadException("File not fully read in. Try again later");
                }
            }

            LoadHelper(tempStream);
        }
示例#10
0
 private void ReadNames(MemoryStream fs)
 {
     DebugOutput.PrintLn("Reading Names...");
     fs.Seek(NameOffset, SeekOrigin.Begin);
     Names = new List <string>();
     for (int i = 0; i < NameCount; i++)
     {
         int    len = fs.ReadValueS32();
         string s   = "";
         if (len > 0)
         {
             s = fs.ReadString((uint)(len - 1));
             fs.Seek(9, SeekOrigin.Current);
         }
         else
         {
             len *= -1;
             for (int j = 0; j < len - 1; j++)
             {
                 s += (char)fs.ReadByte();
                 fs.ReadByte();
             }
             fs.Seek(10, SeekOrigin.Current);
         }
         Names.Add(s);
     }
 }
 public void SaveChanges()
 {
     if (isEdited)
     {
         Matrix  m    = MyMatrix;
         Vector3 loc  = new Vector3(m.M41, m.M42, m.M43);
         byte[]  buff = Vector3ToBuff(loc);
         int     f    = -1;
         for (int i = 0; i < Props.Count; i++)
         {
             if (pcc.getNameEntry(Props[i].Name) == "location")
             {
                 f = i;
                 break;
             }
         }
         ;
         if (f != -1)//has prop
         {
             int off = Props[f].offend - 12;
             for (int i = 0; i < 12; i++)
             {
                 data[off + i] = buff[i];
             }
         }
         else//have to add prop
         {
             DebugOutput.PrintLn(MyIndex + " : cant find location property");
         }
         pcc.Exports[MyIndex].Data = data;
     }
 }
示例#12
0
        public void SaveToFile(string path)
        {
            listsStream.Seek(0, SeekOrigin.End); // Write names
            NameOffset = (int)listsStream.Position;
            //NameCount = Names.Where(nam => nam != null).Count();
            NameCount = Names.Count;
            foreach (String name in Names)
            {
                if (name != null)
                {
                    listsStream.WriteValueS32(name.Length + 1);
                    listsStream.WriteString(name);
                }
                else
                {
                    listsStream.WriteValueS32(1);
                }
                listsStream.WriteByte(0);
                listsStream.WriteValueS32(-14);
            }

            DebugOutput.PrintLn("Writing pcc to: " + path + "\nRefreshing header to stream...");
            listsStream.Seek(0, SeekOrigin.Begin);
            listsStream.WriteBytes(header);
            DebugOutput.PrintLn("Opening filestream and writing to disk...");
            using (FileStream fs = new FileStream(path, FileMode.Create, FileAccess.Write))
                listsStream.WriteTo(fs);
        }
示例#13
0
        private void saveDBToolStripMenuItem_Click(object sender, EventArgs e)
        {
            SaveFileDialog d = new SaveFileDialog();

            d.Filter = "*.sdb|*.sdb";
            if (d.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                FileStream fs = new FileStream(d.FileName, FileMode.Create, FileAccess.Write);

                byte[] buff = BitConverter.GetBytes(database.Count());
                DebugOutput.PrintLn("Creating file in memory...");
                fs.Write(buff, 0, 4);
                MemoryStream m = new MemoryStream();
                foreach (ScriptEntry ent in database)
                {
                    WriteString(m, ent.file);
                    WriteString(m, ent.name);
                    WriteString(m, ent.script);
                }
                buff = m.ToArray();
                DebugOutput.PrintLn("Saving to disk...");
                fs.Write(buff, 0, buff.Length);
                fs.Close();
                MessageBox.Show("Done.");
            }
        }
示例#14
0
        public static void SaveSettings(List <string> BIOGames)
        {
            try
            {
                if (!String.IsNullOrEmpty(BIOGames[0]))
                {
                    Properties.Settings.Default.ME1Directory = BIOGames[0];
                    ME1Directory.gamePath = BIOGames[0];
                }

                if (!String.IsNullOrEmpty(BIOGames[1]))
                {
                    Properties.Settings.Default.ME2Directory = BIOGames[1];
                    ME2Directory.gamePath = BIOGames[1];
                }

                if (!String.IsNullOrEmpty(BIOGames[2]))
                {
                    Properties.Settings.Default.ME3Directory = BIOGames[2];
                    ME3Directory.gamePath = BIOGames[2];
                }

                Properties.Settings.Default.Save();
            }
            catch (Exception e)
            {
                DebugOutput.PrintLn("Error saving pathing: " + e.Message);
            }
        }
示例#15
0
        public bool ExtractAllDLC()
        {
            bool   retval      = true;
            string DLCBasePath = ME3Directory.DLCPath;

            DebugOutput.PrintLn("DLC Path: " + DLCBasePath);
            List <string> files = new List <string>(Directory.EnumerateFiles(DLCBasePath, "Default.sfar", SearchOption.AllDirectories));

            foreach (string file in files)
            {
                string[] parts = file.Split('\\');
                if (parts[parts.Length - 2].ToLower() != "cookedpcconsole")
                {
                    DebugOutput.PrintLn(file + "  doesn't look correct. SFAR in the wrong place?");
                    retval = false;
                    continue;
                }


                if (file != "")
                {
                    DLCPackage DLC = openSFAR2(file);
                    unpackSFAR(DLC);
                }
            }
            DebugOutput.PrintLn("All DLCs Done.");
            return(retval);
        }
示例#16
0
        public void SaveToFile(string path)
        {
            listsStream.Seek(ExportDataEnd, SeekOrigin.Begin); // Write names
            NameOffset = (int)listsStream.Position;
            NameCount  = Names.Count;
            foreach (String name in Names)
            {
                listsStream.WriteValueS32(name.Length + 1);
                listsStream.WriteString(name);
                listsStream.WriteByte(0);
                listsStream.WriteValueS32(-14);
            }

            ExportCount  = Exports.Count;
            ExportOffset = (int)listsStream.Position;
            foreach (ExportEntry exp in Exports)
            {
                listsStream.WriteBytes(exp.Info);
            }

            DebugOutput.PrintLn("Writing pcc to: " + path + "\nRefreshing header to stream...");
            listsStream.Seek(0, SeekOrigin.Begin);
            listsStream.WriteBytes(header);
            DebugOutput.PrintLn("Opening filestream and writing to disk...");
            using (FileStream fs = new FileStream(path, FileMode.Create, FileAccess.Write))
            {
                listsStream.WriteTo(fs);
            }
        }
示例#17
0
        private void ReadExports(MemoryStream fs)
        {
            DebugOutput.PrintLn("Reading Exports...");
            fs.Seek(ExportOffset, SeekOrigin.Begin);
            Exports = new List <ExportEntry>();

            for (int i = 0; i < ExportCount; i++)
            {
                long        start = fs.Position;
                ExportEntry exp   = new ExportEntry();
                exp.pccRef     = this;
                exp.infoOffset = (int)start;

                fs.Seek(40, SeekOrigin.Current);
                int count = fs.ReadValueS32();
                fs.Seek(4 + count * 12, SeekOrigin.Current);
                count = fs.ReadValueS32();
                fs.Seek(4 + count * 4, SeekOrigin.Current);
                fs.Seek(16, SeekOrigin.Current);
                long end = fs.Position;
                fs.Seek(start, SeekOrigin.Begin);
                exp.info = fs.ReadBytes((int)(end - start));
                Exports.Add(exp);
                fs.Seek(end, SeekOrigin.Begin);

                if (LastExport == null || exp.DataOffset > LastExport.DataOffset)
                {
                    LastExport = exp;
                }
            }
        }
示例#18
0
 public void Render()
 {
     if (device == null)
     {
         return;
     }
     try
     {
         device.Clear(ClearFlags.Target, System.Drawing.Color.White, 1.0f, 0);
         device.Clear(ClearFlags.ZBuffer, System.Drawing.Color.Black, 1.0f, 0);
         device.BeginScene();
         device.Lights[0].Type       = LightType.Directional;
         device.Lights[0].Diffuse    = Color.White;
         device.Lights[0].Range      = 100000;
         device.Lights[0].Direction  = -DirectXGlobal.Cam.dir;
         device.Lights[0].Enabled    = true;
         device.Transform.Projection = Matrix.PerspectiveFovLH((float)Math.PI / 4, 1.0f, 1.0f, 1000000.0f);
         device.Transform.View       = Matrix.LookAtLH(DirectXGlobal.Cam.pos, DirectXGlobal.Cam.pos + DirectXGlobal.Cam.dir, new Vector3(0.0f, 0.0f, 1.0f));
         foreach (Levelfile l in Levels)
         {
             l.level.Render(device);
         }
         device.EndScene();
         device.Present();
     }
     catch (Exception e)
     {
         DebugOutput.PrintLn("DIRECT X ERROR: " + e.Message);
     }
 }
示例#19
0
 private void startToolStripMenuItem_Click(object sender, EventArgs e)
 {
     if (AllFiles.Count == 0 || Rules.Count == 0)
     {
         return;
     }
     DebugOutput.StartDebugger("Batch Renamer");
     foreach (string file in AllFiles)
     {
         string s = Path.GetFileName(file);
         foreach (string rule in Rules)
         {
             string[] s2 = rule.Split(':');
             if (s2.Length != 2)
             {
                 continue;
             }
             s = s.Replace(s2[0], s2[1]);
         }
         s = Path.GetDirectoryName(file) + "\\" + s;
         try
         {
             DebugOutput.PrintLn("Trying to move \nfrom:\t" + file + "\nto:\t" + s);
             File.Move(file, s);
             DebugOutput.PrintLn("Success");
         }
         catch (Exception ex)
         {
             DebugOutput.PrintLn("Error : " + ex.ToString());
         }
     }
     MessageBox.Show("Done.");
 }
 public void CreateModJobs()
 {
     if (isEdited)
     {
         int pos = Props[Props.Count - 1].offend;
         for (int i = 0; i < Matrices.Count; i++)
         {
             byte[] buff = MatrixToBuff(Matrices[i]);
             for (int j = 0; j < 64; j++)
             {
                 data[pos + j] = buff[j];
             }
             pos += 64;
         }
         KFreonLib.Scripting.ModMaker.ModJob mj = new KFreonLib.Scripting.ModMaker.ModJob();
         string currfile = Path.GetFileName(pcc.FileName);
         mj.data = data;
         mj.Name = "Binary Replacement for file \"" + currfile + "\" in Object #" + MyIndex + " with " + data.Length + " bytes of data";
         string loc      = Path.GetDirectoryName(Application.ExecutablePath);
         string template = System.IO.File.ReadAllText(loc + "\\exec\\JobTemplate_Binary2.txt");
         template  = template.Replace("**m1**", MyIndex.ToString());
         template  = template.Replace("**m2**", currfile);
         mj.Script = template;
         KFreonLib.Scripting.ModMaker.JobList.Add(mj);
         DebugOutput.PrintLn("Created Mod job : " + mj.Name);
     }
 }
示例#21
0
 private void LoadExports()
 {
     DebugOutput.PrintLn("Prefetching Export Name Data...");
     for (int i = 0; i < ExportCount; i++)
     {
         Exports[i].hasChanged = false;
         Exports[i].ObjectName = Names[Exports[i].ObjectNameID];
     }
     for (int i = 0; i < ExportCount; i++)
     {
         Exports[i].PackageFullName = FollowLink(Exports[i].LinkID);
         if (String.IsNullOrEmpty(Exports[i].PackageFullName))
         {
             Exports[i].PackageFullName = "Base Package";
         }
         else if (Exports[i].PackageFullName[Exports[i].PackageFullName.Length - 1] == '.')
         {
             Exports[i].PackageFullName = Exports[i].PackageFullName.Remove(Exports[i].PackageFullName.Length - 1);
         }
     }
     for (int i = 0; i < ExportCount; i++)
     {
         Exports[i].ClassName = GetClass(Exports[i].ClassNameID);
     }
 }
示例#22
0
 public void DeleteEntry(int Index)
 {
     try
     {
         FileStream fs = new FileStream(FileName, FileMode.Open, FileAccess.Read);
         DebugOutput.PrintLn("Searching TOC...");
         int f = FindTOC();
         if (f == -1)
         {
             return;
         }
         DebugOutput.PrintLn("Found TOC, deleting line...");
         MemoryStream m = DecompressEntry(f, fs);
         fs.Close();
         FileEntryStruct e    = Files[Index];
         string          toc  = Encoding.UTF8.GetString(m.ToArray(), 0, (int)m.Length);
         string          file = e.FileName + "\r\n";
         toc = toc.Replace(file, "");
         DebugOutput.PrintLn("Replacing TOC...");
         ReplaceEntry(Encoding.ASCII.GetBytes(toc), f);
         DebugOutput.PrintLn("Deleting Entry from Filelist...");
         List <FileEntryStruct> l = new List <FileEntryStruct>();
         l.AddRange(Files);
         l.RemoveAt(Index);
         Files = l.ToArray();
         Header.FileCount--;
         DebugOutput.PrintLn("Rebuilding...");
         ReBuild();
         DebugOutput.PrintLn("Done.");
     }
     catch (Exception ex)
     {
         DebugOutput.PrintLn("ERROR\n" + ex.Message);
     }
 }
示例#23
0
        private void DoStuff()
        {
            Predicate <string> adder = t => !t.EndsWith("backup") && !t.EndsWith(".tfc") && !t.EndsWith(".sfar");

            ProgressUpdater.ChangeProgressBar(0, MainListView.Items.Count);
            for (int i = 0; i < MainListView.Items.Count; i++)
            {
                if (cts.IsCancellationRequested)
                {
                    DebugOutput.PrintLn("Extraction cancelled!");
                    return;
                }
                bool ischecked = false;
                this.Invoke(new Action(() => ischecked = MainListView.GetItemChecked(i)));
                if (ischecked)
                {
                    DLCInfo dlc = DLCs[i];
                    if (dlc.isBaseGame == false)
                    {
                        if (dlc.isBackupPresent && dlc.UseExtracted == false)
                        {
                            // KFreon: Delete extracted and restore from backup
                            StatusUpdater.UpdateText("Deleting old files and restoring backup for: " + dlc.Name);
                            File.Delete(dlc.sfar);
                            dlc.ExtractedFiles.ForEach(t => File.Delete(t));
                            File.Copy(dlc.BackupFileName, dlc.sfar);
                        }
                        else if (dlc.BackupRequested == true)
                        {
                            // KFreon: Backup sfar
                            StatusUpdater.UpdateText("Backing up: " + dlc.Name);
                            File.Copy(dlc.sfar, Path.ChangeExtension(dlc.sfar, ".backup"));
                        }
                        else if (dlc.UseExtracted == true)
                        {
                            FilesToAddToTree.AddRange(dlc.Files.Where(a => adder(a)));
                            ProgressUpdater.IncrementBar();
                            continue;
                        }

                        // KFreon: Extract
                        StatusUpdater.UpdateText("Extracting DLC: " + dlc.Name);

                        if (File.Exists(dlc.sfar))
                        {
                            DLCExtractHelper(dlc.sfar);
                            dlc.GetFiles();
                        }
                        else
                        {
                            DebugOutput.PrintLn("DLC: " + dlc.sfar + "  failed.");
                        }
                    }
                    FilesToAddToTree.AddRange(dlc.Files.Where(a => adder(a)));
                }
                ProgressUpdater.IncrementBar();
            }
        }
示例#24
0
 public void SaveAllChanges()
 {
     DebugOutput.PrintLn("Saving all changes to files...");
     foreach (Levelfile l in Levels)
     {
         l.level.SaveChanges();
     }
     DebugOutput.PrintLn("Done.");
 }
示例#25
0
 private void updateTOCToolStripMenuItem_Click(object sender, EventArgs e)
 {
     if (DLC != null)
     {
         DLC.UpdateTOCbin();
         DebugOutput.PrintLn("Done.");
         MessageBox.Show("Done.");
     }
 }
示例#26
0
 public void Export3DS(Lib3dsFile f)
 {
     if (STMC != null)
     {
         DebugOutput.PrintLn("Exported " + pcc.Exports[MyIndex].ObjectName + " #" + MyIndex, false);
         STMC.Export3DS(f, MyMatrix);
     }
     DebugOutput.PrintLn("IA done.");
 }
示例#27
0
        public bool ImportFromPSA(string path)
        {
            PSAFile psa = new PSAFile();

            psa.ImportPSA(path);
            PSAFile.PSAData d = psa.data;
            DebugOutput.PrintLn("Checking data...");
            if (d.Bones.Count != SetData.TrackBoneNames.Count)
            {
                MessageBox.Show("Cant import: different count of bones");
                return(false);
            }
            for (int i = 0; i < SetData.TrackBoneNames.Count; i++)
            {
                if (d.Bones[i].name != SetData.TrackBoneNames[i])
                {
                    MessageBox.Show("Cant import: couldnt match all bones");
                    return(false);
                }
            }
            if (d.Infos.Count != Sequences.Count)
            {
                MessageBox.Show("Cant import: different count of sequences");
                return(false);
            }
            for (int i = 0; i < Sequences.Count; i++)
            {
                AnimSequence ans = new AnimSequence(pcc, Sequences[i]);
                if (d.Infos[i].name != pcc.getNameEntry(ans.SequenceName))
                {
                    MessageBox.Show("Cant import: couldnt match all sequences");
                    return(false);
                }
            }
            int pos = 0;

            for (int i = 0; i < Sequences.Count; i++)
            {
                DebugOutput.PrintLn("Importing into AnimSequence #" + Sequences[i] + " ...");
                AnimSequence        ans = new AnimSequence(pcc, Sequences[i]);
                PSAFile.PSAAnimInfo inf = d.Infos[i];
                List <Vector3>      loc = new List <Vector3>();
                List <Vector4>      rot = new List <Vector4>();
                for (int j = 0; j < inf.TotalBones; j++)
                {
                    PSAFile.PSAAnimKeys key = d.Keys[pos + j];
                    loc.Add(key.location.ToVector3());
                    rot.Add(key.rotation.ToVector4());
                }
                ans.ImportKeys(loc.ToArray(), rot.ToArray(), inf.NumRawFrames);
                ans.SaveChanges();
                pos += inf.KeyQuotum;
            }
            pcc.saveToFile();
            return(true);
        }
示例#28
0
        public static List <string> EnumerateGameFiles(int GameVersion, string searchPath, bool recurse = true, Predicate <string> predicate = null)
        {
            List <string> files = new List <string>();

            files = Directory.EnumerateFiles(searchPath, "*", recurse ? SearchOption.AllDirectories : SearchOption.TopDirectoryOnly).ToList();
            DebugOutput.PrintLn("Enumerated files for: " + GameVersion);
            files = EnumerateGameFiles(GameVersion, files, predicate);
            DebugOutput.PrintLn("Filtered gamefiles for: " + GameVersion);
            return(files);
        }
示例#29
0
        public ME2PCCObject(String path, MemoryStream tempStream)
        {
            lzo      = new SaltLZOHelper();
            fullname = path;
            BitConverter.IsLittleEndian = true;
            DebugOutput.PrintLn("Load file : " + path);
            pccFileName = Path.GetFullPath(path);

            LoadHelper(tempStream);
        }
示例#30
0
        public void CreateDataBase()
        {
            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;
            }
            FileStream fs       = new FileStream(DataBaseFile, FileMode.Create, FileAccess.Write);
            string     pathcook = ME3Directory.cookedPath;

            DebugOutput.Clear();
            DebugOutput.PrintLn("Levelbase.cs: Loading files from :" + pathcook);
            string[] files = Directory.GetFiles(pathcook, "*.pcc");
            for (int i = 0; i < files.Length; i++)
            {
                string file = files[i];
                DebugOutput.PrintLn(i + "/" + (files.Length - 1) + " Scanning : " + Path.GetFileName(file));
                PCCObject pcc = new PCCObject(file);
                for (int j = 0; j < pcc.Exports.Count(); j++)
                {
                    PCCObject.ExportEntry e = pcc.Exports[j];
                    if (e.ClassName == "Level")
                    {
                        Level   l     = new Level(pcc, j, true);
                        DBEntry entry = new DBEntry();
                        entry.filepath = file;
                        entry.index    = j;
                        entry.count    = l.Objects.Count();
                        database.Add(entry);
                        //foreach(int idx in l.Objects)
                        //    if (pcc.isExport(idx) && pcc.Exports[idx].ClassName == "BioPlaypenVolumeAdditive")
                        //        DebugOutput.PrintLn("#############################found");
                        DebugOutput.PrintLn("\tfound Level with " + entry.count + " Objects");
                    }
                }
            }
            database.Sort((a, b) => a.filepath.CompareTo(b.filepath));
            BitConverter.IsLittleEndian = true;
            byte[] buff = BitConverter.GetBytes(database.Count());
            fs.Write(buff, 0, 4);
            foreach (DBEntry e in database)
            {
                buff = BitConverter.GetBytes(e.index);
                fs.Write(buff, 0, 4);
                buff = BitConverter.GetBytes(e.count);
                fs.Write(buff, 0, 4);
                buff = BitConverter.GetBytes(e.filepath.Length);
                fs.Write(buff, 0, 4);
                foreach (char c in e.filepath)
                {
                    fs.WriteByte((byte)c);
                }
            }
            fs.Close();
        }