コード例 #1
0
        private void mnuContextNodeExtractOriginal_Click(object sender, EventArgs e)
        {
            TreeNode n = tvwFilelistNormal.SelectedNode;

            if (n != null)
            {
                DirectoryNode d_node = (DirectoryNode)n.Tag;
                if (d_node.Leaf != null)
                {
                    PiggLeaf     leaf      = d_node.Leaf;
                    PiggLeafInfo leaf_info = leaf.PiggReferences[leaf.PiggReferences.Count - 1];
                    PiggTexture  tex       = new PiggTexture(leaf_info);
                    string       ext       = Path.GetExtension(tex.Filename).ToLower();

                    string filter = Utility.ExtToDescriptive(ext) +
                                    " files (*" + ext + ")|*" + ext + "|";
                    filter                 += "All files (*.*)|*.*";
                    dlgSave.Filter          = filter;
                    dlgSave.FilterIndex     = 1;
                    dlgSave.FileName        = Path.GetFileName(tex.Filename);
                    dlgSave.OverwritePrompt = true;
                    if (dlgSave.ShowDialog() == DialogResult.OK)
                    {
                        FileStream fs = new FileStream(dlgSave.FileName, FileMode.Create, FileAccess.Write, FileShare.Write);
                        tex.Extract(fs, TextureExtractType.Original);
                        fs.Close();
                    }
                }
            }
        }
コード例 #2
0
ファイル: PiggFile.cs プロジェクト: broxen/piggtools
        /// <summary>
        /// Reads and populates this object from a pigg data file.
        /// </summary>
        private void ReadPiggFile()
        {
            if (FullPath == null)
            {
                return;
            }

            FileStream   fs     = File.Open(FullPath, FileMode.Open, FileAccess.Read);
            BinaryReader reader = new BinaryReader(fs);

            // Read the Pigg file header
            this.Header = new PiggFileHeader(reader);

            // Read the Pigg file string table
            fs.Seek(this.Header.DirectoryEntries * 0x30, SeekOrigin.Current);
            long string_table_offset = fs.Position;

            this.StringTable = new PiggFileStringTable(reader);

            // --- Read the directory entry table -----------------------------------
            fs.Seek(this.Header.Size, SeekOrigin.Begin);
            string err_msg = @"Invalid directory entry format within Pigg File " +
                             "at offset {0:x8}.";

            for (int i = 0; i < this.Header.DirectoryEntries; i++)
            {
                PiggFileDirectoryEntry entry = new PiggFileDirectoryEntry(reader);
                PiggLeaf leaf =
                    PiggLeaf.AddLeaf(RootNode, this.StringTable[entry.StringIndex]);
                PiggLeafInfo leaf_info = new PiggLeafInfo(this, entry);
                leaf.Parent.AddCapacity(leaf_info.UncompressedSize);
                leaf.PiggReferences.Add(leaf_info);
            }

            // --- Read the secondary entry table -----------------------------------

            fs.Seek(string_table_offset + 0x0c + this.StringTable.Size, SeekOrigin.Begin);
            if (reader.ReadInt32() != (int)PiggFileMarker.SecondaryTable)
            {
                throw new FormatException(string.Format(err_msg,
                                                        reader.BaseStream.Position - sizeof(Int32)));
            }
            int secondary_entry_count = reader.ReadInt32();
            int secondary_entry_size  = reader.ReadInt32();



            fs.Close();
        }
コード例 #3
0
 public DirectoryNode(PiggLeaf Leaf)
 {
     Initialize();
     this.Leaf = Leaf;
 }
コード例 #4
0
 private void UpdateExtractProgress(PiggLeaf leaf)
 {
     m_extract_progress.Value++;
     m_extract_label.Text = string.Format("Extracting: {0}%", m_extract_progress.Value * 100 / m_extract_leaf_total);
     staStatus.Refresh();
 }