Example #1
0
        public int ExportBundleDir(ICollection <ItemModel> fis, string path)
        {
            int count = 0;

            foreach (var fi in fis)
            {
                if (fi is NotExistModel)
                {
                    continue;
                }
                var br = fi.Record as BundleRecord;
                if (br == null) // is directory
                {
                    count += ExportBundleDir(fi.ChildItems, path);
                }
                else // is bundle
                {
                    var root = new FolderModel("Bundles2");
                    foreach (var f in br.Files)
                    {
                        BuildTree(root, f.path, f);
                    }
                    var s = br.Bundle.Read();
                    count += ExportDir(root.ChildItems, path, s);
                    s.Close();
                }
            }
            return(count);
        }
Example #2
0
        public void BuildTree(ItemModel root, string path, object file)
        {
            if (file is BundleRecord)
            {
                foreach (var f in ((BundleRecord)file).Files)
                {
                    if (ic.Hashes[f.Hash].ToLower().Contains(filtered))
                    {
                        loadedBundles.Add((BundleRecord)file);
                        goto S;
                    }
                }
                return;
            }
            else if (!path.ToLower().Contains(filtered))
            {
                return;
            }
S:
            var SplittedPath = path.Split('/');
            ItemModel parent = root;

            for (int i = 0; i < SplittedPath.Length; i++)
            {
                var name   = SplittedPath[i];
                var isFile = (i + 1 == SplittedPath.Length);
                var next   = parent.GetChildItem(name);
                if (next is null)
                { //No exist node, Build a new node
                    if (isFile)
                    {
                        next = new FileModel(name)
                        {
                            Record = file
                        }
                    }
                    ;
                    else
                    {
                        next = new FolderModel(name);
                    }
                    parent.AddChildItem(next);
                }
                parent = next;
            }
        }
Example #3
0
        private void OnTreeView1SelectedChanged(object sender, RoutedPropertyChangedEventArgs <object> e)
        {
            var tvi = GetSelectedBundle();

            if (tvi == null) //No Selected
            {
                View2.Items.Clear();
                ButtonExport.IsEnabled = false;
                offsetView.Text        = "";
                sizeView.Text          = "";
                noView.Text            = "";
                return;
            }
            var br = tvi.Record as BundleRecord;

            if (br == null) //Selected Directory
            {
                View2.Items.Clear();
                ButtonExport.IsEnabled = true;
                offsetView.Text        = "";
                sizeView.Text          = "";
                noView.Text            = "";
            }
            else //Selected Bundle File
            {
                offsetView.Text = br.indexOffset.ToString();
                sizeView.Text   = br.UncompressedSize.ToString();
                noView.Text     = br.bundleIndex.ToString();
                var root = new FolderModel("Bundles2");
                foreach (var f in br.Files)
                {
                    BuildTree(root, ic.Hashes[f.Hash], f);
                }
                View2.Items.Clear();
                View2.Items.Add(root);
                View2.ItemContainerGenerator.ContainerFromIndex(0)?.SetValue(TreeViewItem.IsExpandedProperty, true);
                if (tvi is FileModel)
                {
                    ButtonExport.IsEnabled = true;
                }
                else
                {
                    ButtonExport.IsEnabled = false;
                }
            }
        }
Example #4
0
        private void OnTreeView1SelectedChanged(object sender, RoutedPropertyChangedEventArgs <object> e)
        {
            var tvi = GetSelectedBundle();

            if (tvi == null) //No Selected
            {
                ButtonAdd.IsEnabled = false;
                return;
            }
            var br = tvi.Record as BundleRecord;

            if (br == null) //Selected Directory
            {
                ButtonAdd.IsEnabled = false;
            }
            else //Selected Bundle File
            {
                if (moveD != null)
                {
                    MoveD(br);
                }
                if (moveF != null)
                {
                    MoveF(br);
                }
                offsetView.Text = br.indexOffset.ToString();
                sizeView.Text   = br.Size.ToString();
                noView.Text     = br.bundleIndex.ToString();
                var root = new FolderModel();
                foreach (var f in br.Files)
                {
                    BuildTree(root, ic.Hashes.ContainsKey(f.Hash) ? ic.Hashes[f.Hash] : null, f);
                }
                View2.Items.Clear();
                foreach (var t in root.ChildItems)
                {
                    View2.Items.Add(t);
                }
                ButtonAdd.IsEnabled = true;
            }
        }
Example #5
0
        public async void UpdateBundleList()
        {
            var root = new FolderModel("Bundles2");

            loadedBundles.Clear();
            View2.Items.Clear();
            foreach (var b in ic.Bundles)
            {
                if (File.Exists(b.Name))
                {
                    BuildTree(root, b.Name, b);
                }
                else if (ShowAll.IsChecked == true)
                {
                    BuildNotExistTree(root, b.Name, b);
                }
            }
            View1.Items.Clear();
            View1.Items.Add(root);
            ButtonAdd.IsEnabled = true;
            await System.Threading.Tasks.Task.Delay(1); //Update UI

            View1.ItemContainerGenerator.ContainerFromItem(root)?.SetValue(TreeViewItem.IsExpandedProperty, true);
        }
Example #6
0
        private void OnLoaded(object sender, RoutedEventArgs e)
        {
            if (!File.Exists("LibBundle.dll"))
            {
                MessageBox.Show("File not found: LibBundle.dll", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                Close();
                return;
            }
            if (!File.Exists("oo2core_8_win64.dll"))
            {
                MessageBox.Show("File not found: oo2core_8_win64.dll", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                Close();
                return;
            }
            string indexPath;

            if (Environment.GetCommandLineArgs().Length > 1 && Path.GetFileName(Environment.GetCommandLineArgs()[1]) == "_.index.bin")
            {
                indexPath = Environment.GetCommandLineArgs()[1];
            }
            else
            {
                var ofd = new OpenFileDialog
                {
                    DefaultExt = "bin",
                    FileName   = "_.index.bin",
                    Filter     = "GGG Bundle index|_.index.bin"
                };
S:
                if (ofd.ShowDialog() == true)
                {
                    if (ofd.SafeFileName != "_.index.bin")
                    {
                        MessageBox.Show("You must select _.index.bin!", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                        goto S;
                    }
                    indexPath = ofd.FileName;
                }
                else
                {
                    Close();
                    return;
                }
            }

            Environment.CurrentDirectory = Path.GetDirectoryName(indexPath);
            var root = new FolderModel();

            ic = new IndexContainer("_.index.bin");
            foreach (var b in ic.Bundles)
            {
                if (File.Exists(b.Name))
                {
                    BuildTree(root, b.Name, b);
                }
            }
            foreach (var tvi in root.ChildItems)
            {
                View1.Items.Add(tvi);
            }
            ButtonReplaceAll.IsEnabled = true;
        }