Exemple #1
0
        public void SetAuthorDetails()
        {
            archivedfile authorFile = embeddedArc.GetFileByName("/info.txt");

            saveFileEditor.author.Text     = "Author: None";
            saveFileEditor.authorNote.Text = "Author's note: None";

            if (authorFile != null)
            {
                authorFile.ReadFile();

                string authorFileText = "";

                for (int i = 0; i < authorFile.filebytes.Length; i++)
                {
                    authorFileText += (char)authorFile.filebytes[i];
                }

                string[] splitAuthorFile = authorFileText.Replace("\r", "").Split('\n');

                saveFileEditor.author.Text = "Author: " + splitAuthorFile[0];

                if (splitAuthorFile.Length > 1)
                {
                    saveFileEditor.authorNote.Text = "Author's note: " + splitAuthorFile[1].Replace("[newline]", "\n");
                }
            }
        }
Exemple #2
0
        public void ExportFolder(TreeNode topnode)
        {
            NodesForBatchExport = new List <TreeNode>();

            NodesForBatchExport.Add(topnode);

            RecursivelyAddChildrenToExportList(topnode);

            //now we should have all child, grandchild, etc folders

            SaveFileDialog saveFileDialog1 = new SaveFileDialog();

            saveFileDialog1.FileName = "Save here";

            saveFileDialog1.Title           = "Choose folder";
            saveFileDialog1.CheckPathExists = true;
            saveFileDialog1.Filter          = "Directory |directory";

            if (saveFileDialog1.ShowDialog() == DialogResult.OK)
            {
                Console.WriteLine(saveFileDialog1.FileName);
                foreach (TreeNode folder in NodesForBatchExport)
                {
                    foreach (TreeNode child in folder.Nodes)
                    {
                        if (form1.treeNodesAndArchivedFiles.ContainsKey(child)) //if it's a file
                        {
                            archivedfile file = form1.treeNodesAndArchivedFiles[child];

                            string path;
                            if (file.filename[0] == '/')
                            {
                                path = Path.GetDirectoryName(saveFileDialog1.FileName) + file.filename.Replace('/', '\\');
                            }
                            else
                            {
                                path = Path.GetDirectoryName(saveFileDialog1.FileName) + "\\" + file.filename.Replace('/', '\\');
                            }

                            if (file.filename == "FILENAME_NOT_SET")
                            {
                                path = Path.GetDirectoryName(saveFileDialog1.FileName) + "\\Names_not_found\\" + file.hash + "." + file.filemagic;
                            }

                            Console.WriteLine(path);
                            file.ReadFile();

                            file.Export(form1.GetOrMakeDirectoryForFileName(path.Replace('/', '\\').Replace(".luc", ".lua")));
                        }
                    }
                }
            }
        }
Exemple #3
0
        public void GetDownloadableMissionName()
        {
            archivedfile downloadstrings = embeddedArc.GetFileByName("/strings/downloadstrings.st");

            if (downloadstrings == null)
            {
                Console.WriteLine("downloadstrings was not found in that arc!");
            }
            else
            {
                downloadstrings.ReadFile();
                saveFileEditor.downloadableMissionNameDisplay.Text = "Downloadable Mission: " + downloadstrings.STstrings[0];
            }
        }
Exemple #4
0
        private void compareArcs_Click(object sender, EventArgs e)
        {
            OpenFileDialog openFileDialog1 = new OpenFileDialog();

            openFileDialog1.Title           = "Select first arc file";
            openFileDialog1.CheckFileExists = true;
            openFileDialog1.CheckPathExists = true;

            openFileDialog1.Filter = "1PP archives (*.arc)|*.arc";
            if (openFileDialog1.ShowDialog() == DialogResult.OK)
            {
                OpenFileDialog openFileDialog2 = new OpenFileDialog();

                openFileDialog2.Title           = "Select second arc file";
                openFileDialog2.CheckFileExists = true;
                openFileDialog2.CheckPathExists = true;

                openFileDialog1.Filter = "1PP archives (*.arc)|*.arc";
                if (openFileDialog2.ShowDialog() == DialogResult.OK)
                {
                    arcfile arc1 = new arcfile();
                    arc1.arcname   = Path.GetFileName(openFileDialog1.FileName);
                    arc1.filename  = openFileDialog1.FileName;
                    arc1.filebytes = File.ReadAllBytes(openFileDialog1.FileName);
                    arc1.form1     = form1;
                    arc1.ReadArc();

                    arcfile arc2 = new arcfile();
                    arc2.arcname   = Path.GetFileName(openFileDialog2.FileName);
                    arc2.filename  = openFileDialog2.FileName;
                    arc2.filebytes = File.ReadAllBytes(openFileDialog2.FileName);
                    arc2.form1     = form1;
                    arc2.ReadArc();

                    List <string> report = new List <string>();

                    foreach (archivedfile f in arc1.archivedfiles)
                    {
                        if (arc2.GetFileWithHash(f.hash) == null)
                        { //if arc2 straight up doesn't have it
                            string evaluatedFilename = f.filename;
                            if (f.filename == "FILENAME_NOT_SET")
                            {
                                evaluatedFilename = f.hash.ToString();
                            }

                            report.Add("File " + evaluatedFilename + " was present in " + Path.GetFileNameWithoutExtension(arc1.filename) + ", but not " + Path.GetFileNameWithoutExtension(arc2.filename) + "!");
                        }
                        else
                        {
                            archivedfile equivalent = arc2.GetFileWithHash(f.hash);
                            if (equivalent != null)
                            {
                                f.ReadFile();
                                equivalent.ReadFile();
                                if (f.filebytes.Length != equivalent.filebytes.Length)
                                { //if it's present in both, but with different filesizes
                                    string evaluatedFilename = f.filename;
                                    if (f.filename == "FILENAME_NOT_SET")
                                    {
                                        evaluatedFilename = f.hash.ToString();
                                    }

                                    report.Add("File " + evaluatedFilename + " was present in both archives, but is a different size in " + Path.GetFileNameWithoutExtension(arc2.filename) + "!");
                                }
                            }
                        }
                    }

                    foreach (archivedfile f in arc2.archivedfiles)
                    {
                        if (arc1.GetFileWithHash(f.hash) == null)
                        { //if arc1 straight up doesn't have it
                            string evaluatedFilename = f.filename;
                            if (f.filename == "FILENAME_NOT_SET")
                            {
                                evaluatedFilename = f.hash.ToString();
                            }
                            report.Add("File " + evaluatedFilename + " was present in " + Path.GetFileNameWithoutExtension(arc2.filename) + ", but not " + Path.GetFileNameWithoutExtension(arc1.filename) + "!");
                        }
                        //don't need to do the second part again because it was already two-way
                    }

                    SaveFileDialog saveFileDialog1 = new SaveFileDialog();
                    saveFileDialog1.Filter = ".txt files (*.txt)|*.txt";
                    saveFileDialog1.Title  = "Save report";

                    if (saveFileDialog1.ShowDialog() == DialogResult.OK)
                    {
                        File.WriteAllLines(saveFileDialog1.FileName, report.ToArray());
                    }
                }
            }
        }