Example #1
0
        public static void ExtractResourceFromTVNode(String BIFNameIn, TreeNode selNode, String pathContext, SaveFileDialog saveResourceDialog)
        {
            String             BIFname  = BIFNameIn;
            BIF_KEYTABLE_ENTRY nodeData = ((BIF_KEYTABLE_ENTRY)selNode.Tag);
            String             RESname  = nodeData.ResourceName;

            try
            {
                DialogResult dr = DialogResult.Abort;

                MemoryStream ms = BIF_DATA.getFileDataFromBIF(pathContext + BIFname, nodeData.ResourceID);

                if (saveResourceDialog != null)
                {
                    saveResourceDialog.FileName = BIF_Utility.makeNewResName(nodeData.ResourceName, nodeData.ResourceType);
                    dr = saveResourceDialog.ShowDialog();
                }

                if (saveResourceDialog == null || dr == System.Windows.Forms.DialogResult.OK)
                {
                    StreamWriter sw = new StreamWriter(new FileStream(BIF_Utility.makeNewResName(nodeData.ResourceName, nodeData.ResourceType), FileMode.Create));
                    ms.Position = 0;
                    BIF_Utility.StreamCopyTo(ms, sw.BaseStream);
                    sw.Close();
                }
            }
            catch (FileNotFoundException fnf_ee)
            {
                MessageBox.Show("There was a problem retreiving the file from the BIF archive: \r\n"
                                + fnf_ee.Message + "\r\nHint: Voice localization files for The Witcher DLC (e.g. M1_3_00.bif ) are stored in the voices subdirectory.",
                                "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            catch (Exception ee)
            {
                MessageBox.Show("There was a problem retreiving the file from the BIF archive: \r\n"
                                + ee.Message + "",
                                "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Example #2
0
        private void treeView1_NodeMouseDoubleClick(object sender, TreeNodeMouseClickEventArgs e)
        {
            TreeNode selNode = BIFTreeView.SelectedNode;

            if (selNode != null && selNode.Parent != null)
            {
                String             BIFname  = selNode.Parent.Text;
                BIF_KEYTABLE_ENTRY nodeData = ((BIF_KEYTABLE_ENTRY)selNode.Tag);
                String             RESname  = nodeData.ResourceName;

                try
                {
                    MemoryStream ms = BIF_DATA.getFileDataFromBIF(pathContext + BIFname, nodeData.ResourceID);

                    saveResourceDialog.FileName = BIF_Utility.makeNewResName(nodeData.ResourceName, nodeData.ResourceType);
                    DialogResult dr = saveResourceDialog.ShowDialog();

                    if (dr == System.Windows.Forms.DialogResult.OK)
                    {
                        StreamWriter sw = new StreamWriter(new FileStream(saveResourceDialog.FileName, FileMode.Create));
                        ms.Position = 0;
                        BIF_Utility.StreamCopyTo(ms, sw.BaseStream);
                        sw.Close();
                    }
                }
                catch (FileNotFoundException fnf_ee)
                {
                    MessageBox.Show("There was a problem retreiving the file from the BIF archive: \r\n"
                                    + fnf_ee.Message + "\r\nHint: Voice localization files for The Witcher DLC (e.g. M1_3_00.bif ) are stored in the voices subdirectory.",
                                    "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                catch (Exception ee)
                {
                    MessageBox.Show("There was a problem extracting the selected file: \r\n"
                                    + ee.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }
Example #3
0
        public BIF_KEY(String filename)
        {
            BinaryReader br = new BinaryReader(new FileStream(filename, FileMode.Open));

            signature = br.ReadChars(4);
            version   = br.ReadChars(4);

            FILETABLE_ENTRIES = br.ReadUInt32();
            KEYTABLE_ENTRIES  = br.ReadUInt32();
            br.ReadBytes(4);

            FILETABLE_OFFSET = br.ReadUInt32();
            KEYTABLE_OFFSET  = br.ReadUInt32();
            BUILD_YEAR      += br.ReadUInt32();
            BUILD_DAY        = br.ReadUInt32();

            // MessageBox.Show(this+"");


            br.BaseStream.Seek(FILETABLE_OFFSET, SeekOrigin.Begin);

            for (int i = 0; i < FILETABLE_ENTRIES; i++)
            {
                FILETABLE.Add(new BIF_FILETABLE_ENTRY(br));
            }

            br.BaseStream.Seek(KEYTABLE_OFFSET, SeekOrigin.Begin);

            for (int i = 0; i < KEYTABLE_ENTRIES; i++)
            {
                BIF_KEYTABLE_ENTRY key = new BIF_KEYTABLE_ENTRY(br);
                FILETABLE[(int)key.ResourceIdx].ownedResources.Add(key);
            }

            br.Close();
        }
Example #4
0
        public BIF_KEY(String filename)
        {
            BinaryReader br = new BinaryReader(new FileStream(filename, FileMode.Open));

            signature = br.ReadChars(4);
            version = br.ReadChars(4);

            FILETABLE_ENTRIES = br.ReadUInt32();
            KEYTABLE_ENTRIES = br.ReadUInt32();
            br.ReadBytes(4);

            FILETABLE_OFFSET = br.ReadUInt32();
            KEYTABLE_OFFSET = br.ReadUInt32();
            BUILD_YEAR += br.ReadUInt32();
            BUILD_DAY = br.ReadUInt32();

               // MessageBox.Show(this+"");

            br.BaseStream.Seek(FILETABLE_OFFSET, SeekOrigin.Begin);

            for (int i = 0; i < FILETABLE_ENTRIES; i++)
            {
                FILETABLE.Add(new BIF_FILETABLE_ENTRY(br));
            }

            br.BaseStream.Seek(KEYTABLE_OFFSET, SeekOrigin.Begin);

            for (int i = 0; i < KEYTABLE_ENTRIES; i++)
            {
                BIF_KEYTABLE_ENTRY key = new BIF_KEYTABLE_ENTRY(br);
                FILETABLE[(int)key.ResourceIdx].ownedResources.Add(key);
            }

            br.Close();
        }