ToTree() public method

public ToTree ( ) : TreeNode
return System.Windows.Forms.TreeNode
示例#1
0
 private void openSFAR(string filename)
 {
     try
     {
         
         DLC = new DLCPackage(filename);
         treeView1.Nodes.Clear();
         treeView1.Nodes.Add(DLC.ToTree());
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.ToString());
     }
 }
示例#2
0
        private void replaceFile(String filename, int n)
        {
            DLC.ReplaceEntry(filename, n);

            DLC = new DLCPackage(DLC.MyFileName);
            treeView1.Nodes.Clear();
            treeView1.Nodes.Add(DLC.ToTree());
            SearchNode(filename, treeView1.Nodes[0]);
            if (!automated)
            {
                MessageBox.Show("File Replaced.");
            }
            else
            {
                System.Diagnostics.Debug.WriteLine("Injection complete.");
            }
        }
示例#3
0
 private void rebuildSFARToolStripMenuItem_Click(object sender, EventArgs e)
 {
     if (DLC == null)
         return;
     DebugOutput.StartDebugger("DLCEditor2");
     DLC.ReBuild();
     DLC = new DLCPackage(DLC.MyFileName);
     treeView1.Nodes.Clear();
     treeView1.Nodes.Add(DLC.ToTree());
     MessageBox.Show("SFAR Rebuilt.");
 }
示例#4
0
 private DLCPackage openSFAR2(String filename)
 {
     try
     {
         BitConverter.IsLittleEndian = true;
         DLC = new DLCPackage(filename);
         treeView1.Nodes.Clear();
         treeView1.Nodes.Add(DLC.ToTree());
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.ToString());
     }
     return DLC;
 }
示例#5
0
 private void deleteSelectedToolStripMenuItem_Click(object sender, EventArgs e)
 {
     TreeNode t = treeView1.SelectedNode;
     if (DLC == null || t == null || t.Parent == null || t.Parent.Text != "FileEntries")
         return;
     if (MessageBox.Show("Are you sure to delete this File?", "DLCEditor2", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
     {
         int n = t.Index;
         DLC.DeleteEntry(n);
         DLC = new DLCPackage(DLC.MyFileName);
         treeView1.Nodes.Clear();
         treeView1.Nodes.Add(DLC.ToTree());
         MessageBox.Show("File Deleted.");
     }
 }
示例#6
0
        public DLCEditor2()
        {
            InitializeComponent();

            //FemShep's Mod Manager 3 automator for DLCEditor2.
            string[] arguments = Environment.GetCommandLineArgs();
            if (arguments.Length > 2)
            {
                try
                {
                    string cmdCommand = arguments[1];
                    if (cmdCommand.Equals("-dlcinject", StringComparison.Ordinal))
                    {
                        if (arguments.Length % 2 != 1 || arguments.Length < 5)
                        {
                            MessageBox.Show("Wrong number of arguments for the -dlcinject switch.:\nSyntax is: <exe> -dlcinject SFARPATH SEARCHTERM NEWFILEPATH [SEARCHTERM2 NEWFILEPATH2]...", "ME3 DLCEditor2 Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                            return;
                        }
                        string dlcFileName = arguments[2];
                        int numfiles = (arguments.Length - 3) / 2;

                        string[] filesToReplace = new String[numfiles];
                        string[] newFiles = new String[numfiles];

                        int argnum = 3; //starts at 3
                        for (int i = 0; i < filesToReplace.Length; i++)
                        {
                            filesToReplace[i] = arguments[argnum];
                            argnum++;
                            newFiles[i] = arguments[argnum];
                            argnum++;
                        }
                        automated = true;
                        if (File.Exists(dlcFileName))
                        {
                            openSFAR(dlcFileName);
                        }
                        else
                        {
                            System.Diagnostics.Debug.WriteLine("dlcFilename does not exist: " + dlcFileName);
                            MessageBox.Show("Failed to autoinject: DLC file does not exist: " + dlcFileName, "ME3Explorer DLCEditor2 Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                            Application.Exit();
                            return;
                        }
                        //SFAR was opened.
                        //Now we search for the element to replace so it is selected...
                        for (int i = 0; i < numfiles; i++)
                        {
                            selectSearchedElement(filesToReplace[i]);
                            //the element is now selected, hopefully.
                            TreeNode t = treeView1.SelectedNode;
                            if (DLC == null || t == null || t.Parent == null || t.Parent.Text != "FileEntries")
                            {
                                MessageBox.Show("DLCEditor2 automator encountered an error: the file to replace does not exist or the tree has not been initialized.", "ME3 DLCEditor2 Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                                return;
                            }
                            replaceFile(newFiles[i], t.Index);
                        }
                    }
                    else if (cmdCommand.Equals("-dlcextract", StringComparison.Ordinal))
                    {
                        if (arguments.Length != 5)
                        {
                            //-2 for me3explorer & -dlcextract
                            MessageBox.Show("Wrong number of arguments for the -dlcinject switch.:\nSyntax is: <exe> -dlcextract SFARPATH SEARCHTERM EXTRACTIONPATH", "ME3 DLCEditor2 Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                            Application.Exit();
                            return;
                        }
                        automated = true;
                        string dlcFileName = arguments[2];
                        string searchTerm = arguments[3];
                        string extractionPath = arguments[4];
                        if (File.Exists(dlcFileName))
                        {
                            openSFAR(dlcFileName);
                        }
                        else
                        {
                            System.Diagnostics.Debug.WriteLine("dlcFilename does not exist: " + dlcFileName);
                            MessageBox.Show("Failed to autoextract: DLC file does not exist: " + dlcFileName, "ME3Explorer DLCEditor2 Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                            Application.Exit();
                            return;
                        }
                        //SFAR was opened.
                        //Now we search for the element to extract so it is selected...
                        selectSearchedElement(searchTerm);
                        //the element is now selected, hopefully.
                        TreeNode t = treeView1.SelectedNode;
                        if (DLC == null || t == null || t.Parent == null || t.Parent.Text != "FileEntries")
                        {
                            MessageBox.Show("DLCEditor2 extraction automator encountered an error:\nThe file to replace does not exist or the tree has not been initialized.", "DLCEditor2 Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                            Application.Exit();
                            return;
                        }
                        extractFile(t.Index, extractionPath);
                    }
                    else if (cmdCommand.Equals("-dlcaddfiles", StringComparison.Ordinal))
                    {
                        if (arguments.Length % 2 != 1 || arguments.Length < 5)
                        {
                            MessageBox.Show("Wrong number of arguments for the -dlcaddfiles switch.:\nSyntax is: <exe> -dlcinject SFARPATH INTERNALPATH NEWFILEPATH [INTERNALPATH2 NEWFILEPATH2]...", "ME3 DLCEditor2 Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                            Application.Exit();
                            return;
                        }

                        automated = true;
                        string dlcFileName = arguments[2];

                        int numfiles = (arguments.Length - 3) / 2;
                        string[] internalPaths = new String[numfiles];
                        string[] sourcePaths = new String[numfiles];

                        int argnum = 3; //starts at 3
                        for (int i = 0; i < internalPaths.Length; i++)
                        {
                            internalPaths[i] = arguments[argnum];
                            argnum++;
                            sourcePaths[i] = arguments[argnum];
                            argnum++;
                        }

                        if (File.Exists(dlcFileName))
                        {
                            openSFAR(dlcFileName);
                        }
                        else
                        {
                            System.Diagnostics.Debug.WriteLine("DLC does not exist: " + dlcFileName);
                            MessageBox.Show("Failed to autoadd: DLC file does not exist: " + dlcFileName, "ME3Explorer DLCEditor2 Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                            Application.Exit();
                            return;
                        }
                        //SFAR was opened.
                        for (int i = 0; i < internalPaths.Length; i++)
                        {
                            System.Diagnostics.Debug.WriteLine("Adding file quick: " + sourcePaths[i] + " " + internalPaths[i]);
                            DLC.AddFileQuick(sourcePaths[i], internalPaths[i]);
                            DLC = new DLCPackage(DLC.MyFileName);
                            treeView1.Nodes.Clear();
                            treeView1.Nodes.Add(DLC.ToTree());
                        }
                    }
                    else if (cmdCommand.Equals("-dlcremovefiles", StringComparison.Ordinal))
                    {
                        if (arguments.Length < 4)
                        {
                            //-2 for me3explorer & -dlcextract
                            MessageBox.Show("Wrong number of arguments for the -dlcremovefiles switch.:\nSyntax is: <exe> -dlcinject SFARPATH INTERNALPATH [INTERNALPATH2]...", "ME3 DLCEditor2 Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                            Application.Exit();
                            return;
                        }
                        automated = true;
                        string dlcFileName = arguments[2];

                        int numfiles = (arguments.Length - 3);

                        string[] filesToRemove = new String[numfiles];

                        int argnum = 3; //starts at 3
                        for (int i = 0; i < filesToRemove.Length; i++)
                        {
                            filesToRemove[i] = arguments[argnum];
                            argnum++;
                        }

                        if (File.Exists(dlcFileName))
                        {
                            openSFAR(dlcFileName);
                        }
                        else
                        {
                            System.Diagnostics.Debug.WriteLine("DLC does not exist: " + dlcFileName);
                            MessageBox.Show("Failed to autoremove: DLC file does not exist: " + dlcFileName, "ME3Explorer DLCEditor2 Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                            Application.Exit();
                            return;
                        }
                        //SFAR was opened.
                        for (int i = 0; i < filesToRemove.Length; i++)
                        {
                            selectSearchedElement(filesToRemove[i]);
                            //the element is now selected, hopefully.
                            TreeNode t = treeView1.SelectedNode;
                            if (DLC == null || t == null || t.Parent == null || t.Parent.Text != "FileEntries")
                            {
                                MessageBox.Show("DLCEditor2 file removal automator encountered an error:\nThe file to remove does not exist or the tree has not been initialized.", "DLCEditor2 Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                                Application.Exit();
                                return;
                            }
                            DLC.DeleteEntry(t.Index);
                            DLC = new DLCPackage(DLC.MyFileName);
                            treeView1.Nodes.Clear();
                            treeView1.Nodes.Add(DLC.ToTree());
                        }
                    }
                    else if (cmdCommand.Equals("-dlcunpack", StringComparison.Ordinal) || cmdCommand.Equals("-dlcunpack-nodebug", StringComparison.Ordinal))
                    {
                        if (arguments.Length != 4)
                        {
                            MessageBox.Show("Wrong number of arguments for automated DLC unpacking:\nSyntax is: <exe> -dlcinject SFARPATH EXTRACTIONPATH", "ME3 DLCEditor2 Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                            return;
                        }

                        string sfarPath = arguments[2];
                        autoUnpackFolder = arguments[3];

                        automated = true;
                        if (File.Exists(sfarPath))
                        {
                            openSFAR(sfarPath);
                        }
                        else
                        {
                            System.Diagnostics.Debug.WriteLine("DLC does not exist: " + sfarPath);
                            MessageBox.Show("Failed to autounpack: DLC file does not exist: " + sfarPath, "ME3Explorer DLCEditor2 Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                            Application.Exit();
                            return;
                        }
                        //SFAR was opened.
                        if (cmdCommand.Equals("-dlcunpack"))
                        {
                            DebugOutput.StartDebugger("DLC Editor 2"); //open debugging window since this operation takes a long time. The main debugger won't start as this will exit before that code can be reached
                        }
                        //Simulate Unpack operation click.
                        unpackSFARToolStripMenuItem.PerformClick();
                    }
                }
                catch (FileNotFoundException exc)
                {
                    MessageBox.Show("Failed to run DLCEditor2 Automator with the specified parameters.\n\nA file not found error occured while trying to automate a task.\n" + exc.Message, "DLC Editor2 Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    Environment.Exit(1);
                    Application.Exit();
                }
                Environment.Exit(0);
                Application.Exit();
            }
            DebugOutput.StartDebugger("DLC Editor 2"); //open debugging window AFTER automation. Otherwise it pops up all weirdlike.
        }
示例#7
0
        private void addFileToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (DLC == null)
                return;
            OpenFileDialog d = new OpenFileDialog();
            d.Filter = "*.*|*.*";
            string p = Path.GetDirectoryName(DLC.Files[0].FileName) + "\\";
            if (d.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                string path = p + Path.GetFileName(d.FileName);
                path = path.Replace('\\', '/');
                string result = Microsoft.VisualBasic.Interaction.InputBox("Please enter the path with name that the file will have inside the DLC", "ME3 Explorer", path, 0, 0);
                if (result == "")
                    return;
                path = result;
                System.Diagnostics.Debug.WriteLine("Adding file quick: " + d.FileName + " " + path);

                DLC.AddFileQuick(d.FileName, path);
                DLC = new DLCPackage(DLC.MyFileName);
                treeView1.Nodes.Clear();
                treeView1.Nodes.Add(DLC.ToTree());
                SearchNode(result, treeView1.Nodes[0]);
                MessageBox.Show("File added.");
            }
        }
示例#8
0
        private void replaceFile(string filename, int n)
        {
            DLC.ReplaceEntry(filename, n);

            DLC = new DLCPackage(DLC.FileName);
            treeView1.Nodes.Clear();
            treeView1.Nodes.Add(DLC.ToTree());
            SearchNode(filename, treeView1.Nodes[0]);
        }