예제 #1
0
        private void option1ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            foreach (ListViewItem item in listView1.SelectedItems)
            {
                string name = Path.GetDirectoryName(file) + "\\" + item.SubItems[0].Text;

                if (item.Tag.GetType().Equals(typeof(TextureArchive)))
                {
                    TextureArchive texfile = (TextureArchive)item.Tag;
                    efile.ExtractFile(texfile.stream, name);
                }
                if (item.Tag.GetType().Equals(typeof(PacFile)))
                {
                    PacFile pacfile = (PacFile)item.Tag;
                    efile.ExtractFile(pacfile.stream, name);
                }
                if (item.Tag.GetType().Equals(typeof(PACHFile)))
                {
                    PACHFile pachfile = (PACHFile)item.Tag;
                    efile.ExtractFile(pachfile.stream, name);
                }
                if (item.Tag.GetType().Equals(typeof(PACH)))
                {
                    PACH pachcontainer = (PACH)item.Tag;
                    efile.ExtractFile(pachcontainer.PACHFiles[0].stream, name);
                }
            }
        }
예제 #2
0
 private void extractAll(TreeNode treeNode, string path)
 {
     if (treeNode.Tag.GetType().Equals(typeof(PACHFile)))
     {
         PACHFile pfile = (PACHFile)treeNode.Tag;
         if (pfile.SubContainer != null)
         {
             foreach (PACHFile sfile in pfile.SubContainer.PACHFiles)
             {
                 if (sfile.SubContainer == null && sfile.TexContainer == null)
                 {
                     var filepath = Path.GetDirectoryName(file) + "\\" + path + "\\" + sfile.id;
                     efile.ExtractFile(sfile.stream, filepath);
                 }
             }
         }
         if (pfile.TexContainer != null)
         {
             foreach (TextureArchive sfile in pfile.TexContainer)
             {
                 var name     = sfile.alignedstring.Replace("\0", string.Empty).Trim() + "." + sfile.extension.Replace("\0", string.Empty).Trim();
                 var filepath = Path.GetDirectoryName(file) + "\\" + path + "\\" + name;
                 efile.ExtractFile(sfile.stream, filepath);
             }
         }
     }
     if (treeNode.Tag.GetType().Equals(typeof(PacFile)))
     {
         PacFile pfile = (PacFile)treeNode.Tag;
         if (pfile.PACHContainer != null)
         {
             foreach (PACHFile sfile in pfile.PACHContainer.PACHFiles)
             {
                 if (sfile.SubContainer == null && sfile.TexContainer == null)
                 {
                     var filepath = Path.GetDirectoryName(file) + "\\" + path + "\\" + sfile.id;
                     efile.ExtractFile(sfile.stream, filepath);
                 }
             }
         }
     }
 }
예제 #3
0
        PacFile ReadPacFile()
        {
            var pacfile = new PacFile();

            if (pacFile.header.id == "EPK8")
            {
                pacfile.id = new string(pacStream.ReadChars(8));
            }
            else if (pacFile.header.id == "EPAC")
            {
                pacfile.id = new string(pacStream.ReadChars(4));
            }
            else
            {
                //PACH??
            }

            pacStream.ReadBytes(3);
            pacfile.size = (int)pacStream.ReadUInt32();
            pacStream.ReadByte();
            return(pacfile);
        }
예제 #4
0
        PacFile ReadPacFile()
        {
            var pacfile = new PacFile();

            if (pacFile.header.id == "EPK8")
            {
                pacfile.id = new string(pacStream.ReadChars(8));
            }
            else if (pacFile.header.id == "EPAC")
            {
                pacfile.id = new string(pacStream.ReadChars(4));
            }
            else
            {
                //PACH??
            }

            pacStream.ReadBytes(3);
            pacfile.size = (int)pacStream.ReadUInt32();
            pacStream.ReadByte();
            return pacfile;
        }
예제 #5
0
        //Check the node type and populate the listview based on it.
        void treeView1_NodeMouseClick(object sender, TreeNodeMouseClickEventArgs e)
        {
            TreeNode newSelected = e.Node;

            listView1.Items.Clear();
            ListViewItem item = null;

            ListViewItem.ListViewSubItem[] subItems;


            //right click = extract all menu.
            if (e.Button == MouseButtons.Right)
            {
                if (newSelected.Bounds.Contains(e.Location) == true)
                {
                    contextMenuStrip2.Show(Cursor.Position);
                }
            }

            if (newSelected.Tag != null)
            {
                if (newSelected.Tag.GetType().Equals(typeof(TextureArchive[])))
                {
                    //TextureArchive textures
                    TextureArchive[] textures = (TextureArchive[])newSelected.Tag;
                    foreach (var texture in textures)
                    {
                        var file = texture.alignedstring.Replace("\0", string.Empty).Trim() + "." + texture.extension.Replace("\0", string.Empty).Trim();

                        item     = new ListViewItem(file, 2);
                        item.Tag = texture;
                        subItems = new ListViewItem.ListViewSubItem[]
                        {
                            new ListViewItem.ListViewSubItem(item, texture.extension)
                            , new ListViewItem.ListViewSubItem(item, texture.size.ToString())
                        };
                        item.SubItems.AddRange(subItems);
                        listView1.Items.Add(item);
                    }
                }
                else if (newSelected.Tag.GetType().Equals(typeof(PacDir)))
                {
                    PacDir nodeDirInfo = (PacDir)newSelected.Tag;

                    if (nodeDirInfo.PacFiles != null)
                    {
                        foreach (var file in nodeDirInfo.PacFiles)
                        {
                            item     = new ListViewItem(file.id, 2);
                            item.Tag = file;
                            subItems = new ListViewItem.ListViewSubItem[]
                            {
                                new ListViewItem.ListViewSubItem(item, file.PACHContainer.id.ToString())  //Header of the contained file
                                , new ListViewItem.ListViewSubItem(item, file.size.ToString())
                            };
                            item.SubItems.AddRange(subItems);
                            listView1.Items.Add(item);
                        }
                    }
                }
                else if (newSelected.Tag.GetType().Equals(typeof(PACH)))
                {
                    PACH nodeDirInfo = (PACH)newSelected.Tag;

                    if (nodeDirInfo.PACHFiles != null)
                    {
                        foreach (var file in nodeDirInfo.PACHFiles)
                        {
                            var subFileText = new byte[4];
                            Array.Copy(file.stream, 0, subFileText, 0, 4);
                            var name = System.Text.Encoding.UTF8.GetString(subFileText);

                            item     = new ListViewItem(file.id, 1);
                            item.Tag = file;
                            subItems = new ListViewItem.ListViewSubItem[]
                            {
                                new ListViewItem.ListViewSubItem(item, name) //Type
                                , new ListViewItem.ListViewSubItem(item, file.size.ToString())
                            };
                            item.SubItems.AddRange(subItems);
                            listView1.Items.Add(item);
                        }
                    }
                }
                else if (newSelected.Tag.GetType().Equals(typeof(PACHFile)))
                {
                    PACHFile nodeDirInfo = (PACHFile)newSelected.Tag;
                    if (nodeDirInfo.SubContainer != null) //more pach files...
                    {
                        foreach (PACHFile subFile in nodeDirInfo.SubContainer.PACHFiles)
                        {
                            var subFileText = new byte[4];
                            Array.Copy(subFile.stream, 0, subFileText, 0, 4);
                            var name = System.Text.Encoding.UTF8.GetString(subFileText);

                            item     = new ListViewItem(subFile.id, 1);
                            item.Tag = subFile;
                            subItems = new ListViewItem.ListViewSubItem[]
                            {
                                new ListViewItem.ListViewSubItem(item, name)  //Type
                                , new ListViewItem.ListViewSubItem(item, subFile.size.ToString())
                            };
                            item.SubItems.AddRange(subItems);
                            listView1.Items.Add(item);
                        }
                    }
                    else if (nodeDirInfo.TexContainer != null) // Texture files
                    {
                        foreach (TextureArchive subFile in nodeDirInfo.TexContainer)
                        {
                            var file = subFile.alignedstring.Replace("\0", string.Empty).Trim() + "." + subFile.extension.Replace("\0", string.Empty).Trim();

                            item     = new ListViewItem(file, 2);
                            item.Tag = subFile;
                            subItems = new ListViewItem.ListViewSubItem[]
                            {
                                new ListViewItem.ListViewSubItem(item, subFile.extension)  //Header of the contained file
                                , new ListViewItem.ListViewSubItem(item, subFile.size.ToString())
                            };
                            item.SubItems.AddRange(subItems);
                            listView1.Items.Add(item);
                        }
                    }
                    else //Everything else
                    {
                        var subFileText = new byte[4];
                        Array.Copy(nodeDirInfo.stream, 0, subFileText, 0, 4);
                        var name = System.Text.Encoding.UTF8.GetString(subFileText);

                        item     = new ListViewItem(nodeDirInfo.id, 1);
                        item.Tag = nodeDirInfo;
                        subItems = new ListViewItem.ListViewSubItem[]
                        {
                            new ListViewItem.ListViewSubItem(item, name) //Type
                            , new ListViewItem.ListViewSubItem(item, nodeDirInfo.size.ToString())
                        };
                        item.SubItems.AddRange(subItems);
                        listView1.Items.Add(item);
                    }
                }
                else if (newSelected.Tag.GetType().Equals(typeof(PacFile)))
                {
                    PacFile nodeDirInfo = (PacFile)newSelected.Tag;

                    if (nodeDirInfo.PACHContainer.PACHFiles != null)
                    {
                        foreach (var file in nodeDirInfo.PACHContainer.PACHFiles)
                        {
                            var subFileText = new byte[4];
                            Array.Copy(file.stream, 0, subFileText, 0, 4);
                            var name = System.Text.Encoding.UTF8.GetString(subFileText);

                            item     = new ListViewItem(file.id, 1);
                            item.Tag = file;
                            subItems = new ListViewItem.ListViewSubItem[]
                            {
                                new ListViewItem.ListViewSubItem(item, name) //Type
                                , new ListViewItem.ListViewSubItem(item, file.size.ToString())
                            };
                            item.SubItems.AddRange(subItems);
                            listView1.Items.Add(item);
                        }
                    }
                }
            }
            listView1.AutoResizeColumns(ColumnHeaderAutoResizeStyle.HeaderSize);
        }
예제 #6
0
 private void GetPACFileDirectories(PacFile[] subDirs, TreeNode nodeToAddTo)
 {
     TreeNode aNode;
     foreach (PacFile pacFile in subDirs)
     {
         if (pacFile.PACHContainer.id == "PACH")
         {
             aNode = new TreeNode(pacFile.id, 0, 0);
             aNode.Tag = pacFile;
             aNode.ImageKey = "Container";
             if (pacFile.PACHContainer != null)
             {
                 GetPACHFileDirectories(pacFile.PACHContainer.PACHFiles, aNode);
             }
             nodeToAddTo.Nodes.Add(aNode);
         }
     }
 }