Ejemplo n.º 1
0
 /// <summary>
 /// Loads specified bank file
 /// </summary>
 /// <param name="filename"></param>
 private void _LoadBnk(string filename)
 {
     _Bank = new Bnk {
         Name = filename
     };
     _Bank.Read();
 }
Ejemplo n.º 2
0
        /// <summary>
        /// Opens current entry in file list
        /// </summary>
        public void OpenSelectedEntry()
        {
            if (fileListView.SelectedItems.Count == 1)
            {
                Cursor = Cursors.WaitCursor;

                ListViewItem currentItem = fileListView.SelectedItems[0];
                Object       tag         = currentItem.Tag;

                try
                {
                    if (tag is FileSystemInfo)
                    {
                        // File or directory
                        string path = ((tag as FileSystemInfo).FullName);

                        try
                        {
                            _Refresh(path);
                            CurrentFolder = path;
                        }
                        catch (NotImplementedException ex)
                        {
                            // Not applicable -> entry will be opened with default assos
                            __SystemRun(path);
                        }
                    }
                    else if (tag is PackedFile)
                    {
                        // Packed file -> it must be extracted first
                        // Reloads BNK to get correct contents
                        Bnk parentBnk = new Bnk {
                            Name = CurrentFolder
                        };
                        parentBnk.Read();

                        PackedFile updatedPackedFile = parentBnk.GetPackedFile((tag as PackedFile).Id);
                        // TODO handle temporary folder
                        string path = @"T:\COMMUN\" + updatedPackedFile.Name;
                        Bnk.Extract(updatedPackedFile, path);

                        // Opens with default file associations for now
                        __SystemRun(path);
                    }
                }

                catch (Exception ex)
                {
                    MessageBox.Show(this, ex.Message);
                }
                finally
                {
                    Cursor = Cursors.Default;
                }
            }
        }
Ejemplo n.º 3
0
        private void repackBtn_Click(object sender, EventArgs ea)
        {
            if (_Bank != null)
            {
                folderBrowserDlg.Description = "Select a directory to repack...";

                DialogResult dr = folderBrowserDlg.ShowDialog(this);

                if (dr == DialogResult.OK)
                {
                    string   bnkDir         = folderBrowserDlg.SelectedPath;
                    string[] splittedPath   = bnkDir.Split('\\');
                    string   bnkDefaultName = splittedPath[splittedPath.Length - 1];

                    // Target BNK selection
                    saveFileDialog.Filter   = "TDU banks (*.bnk)|*.bnk";
                    saveFileDialog.Title    = "Repack to BNK file...";
                    saveFileDialog.FileName = bnkDefaultName;

                    dr = saveFileDialog.ShowDialog(this);

                    if (dr == DialogResult.OK)
                    {
                        try
                        {
                            Cursor = Cursors.WaitCursor;

                            // Updates Bnk contents
                            _Bank.Repack(bnkDir);
                            // Commit to disk
                            _Bank.SaveAs(saveFileDialog.FileName);
                            // Reloads current file
                            _Bank.Read();

                            MessageBox.Show(this, "Repack Succeeded!");
                        }
                        catch (Exception e)
                        {
                            _Log.Error(FailureHandler.GetStackTrace(e));
                            MessageBox.Show(this, e.Message);
                        }
                        finally
                        {
                            Cursor = Cursors.Default;
                        }
                    }
                }
            }
        }
Ejemplo n.º 4
0
        public void TestBnkAllExtracting()
        {
            Bnk bnk1 = _LoadBnk1();
            Bnk bnk2 = _LoadBnk2();
            Bnk bnk3 = _LoadBnk3();

            Context.GameProduct = Context.Product.TDU2;
            bnk1.Read();
            bnk1.ExtractAll(@"E:\Docs\Bureau Vista\California");

            bnk2.Read();
            bnk2.ExtractAll(@"E:\Docs\Bureau Vista\CCXR");

            Context.GameProduct = Context.Product.TDU;
            bnk3.Read();
            bnk3.ExtractAll(@"E:\Docs\Bureau Vista\300_C");
        }
Ejemplo n.º 5
0
        public void TestBnkReading()
        {
            // TDU2 mode
            Context.GameProduct = Context.Product.TDU2;
            Bnk bnk1 = _LoadBnk1();

            bnk1.Read();

            Assert.IsNotNull(bnk1);

            // TDU mode
            Context.GameProduct = Context.Product.TDU;
            Bnk bnk3 = _LoadBnk3();

            bnk3.Read();

            Assert.IsNotNull(bnk3);
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Methode to redefine to return all entries
        /// </summary>
        /// <param name="path"></param>
        /// <returns></returns>
        public override List <ListViewItem> GetEntries(string path)
        {
            List <ListViewItem> items = new List <ListViewItem>();

            // Opens BNK file
            Bnk bank = new Bnk {
                Name = path
            };

            bank.Read();

            // Reads contents
            foreach (PackedFile f in bank.PackedFiles)
            {
                ListViewItem item = new ListViewItem(f.Name, 4)
                {
                    Tag = f
                };
                items.Add(item);
            }

            return(items);
        }