public frmAssetBrowser(List <IWitcherArchive> archives) { InitializeComponent(); pathlistview.AutoResizeColumns(ColumnHeaderAutoResizeStyle.ColumnContent); pathlistview.AutoResizeColumns(ColumnHeaderAutoResizeStyle.HeaderSize); Managers = archives; RootNode = new WitcherTreeNode(); RootNode.Name = "Root"; foreach (var arch in archives) { if (arch == null) { continue; } FileList.AddRange(arch.FileList); RootNode.Directories[arch.RootNode.Name] = arch.RootNode; arch.RootNode.Parent = RootNode; extensionCB.Items.Add(arch.TypeName); extensionCB.SelectedIndex = 0; filetypeCB.Items.AddRange(arch.Extensions.ToArray()); filetypeCB.SelectedIndex = 0; for (int i = 0; i < arch.AutocompleteSource.Count; i++) { SearchBox.AutoCompleteCustomSource.Add(arch.AutocompleteSource[i]); } } }
/// <summary> /// Rebuilds the soundcache tree structure also rebuilds NOTE: Filelist,autocomplete,extensions /// </summary> public void RebuildRootNode() { RootNode = new WitcherTreeNode(); RootNode.Name = new TextureCache().TypeName; foreach (var item in Items) { var currentNode = RootNode; var parts = item.Key.Split('\\'); for (var i = 0; i < parts.Length - 1; i++) { if (!currentNode.Directories.ContainsKey(parts[i])) { var newNode = new WitcherTreeNode { Parent = currentNode, Name = parts[i] }; currentNode.Directories.Add(parts[i], newNode); currentNode = newNode; } else { currentNode = currentNode.Directories[parts[i]]; } } currentNode.Files.Add(parts[parts.Length - 1], item.Value); } RebuildFileList(); RebuildExtensions(); RebuildAutoCompleteSource(); }
public frmAssetBrowser(List <IWitcherArchiveManager> managers) { InitializeComponent(); this.Icon = UIController.GetThemedWkitIcon(); pathlistview.AutoResizeColumns(ColumnHeaderAutoResizeStyle.ColumnContent); pathlistview.AutoResizeColumns(ColumnHeaderAutoResizeStyle.HeaderSize); Managers = managers; RootNode = new WitcherTreeNode(); RootNode.Name = "Root"; foreach (var manager in managers) { if (manager == null) { continue; } FileList.AddRange(manager.FileList.Where(_ => _ != null)); RootNode.Directories[manager.RootNode.Name] = manager.RootNode; manager.RootNode.Parent = RootNode; bundleExtensionCB.Items.Add(manager.TypeName); bundleExtensionCB.SelectedIndex = 0; for (int i = 0; i < manager.AutocompleteSource.Count; i++) { SearchBox.AutoCompleteCustomSource.Add(manager.AutocompleteSource[i]); } // fill in all file extensions FillFileExtensionCB(manager); } }
public WitcherListViewItem(IWitcherFile wf) { IsDirectory = false; Node = new WitcherTreeNode(); Node.Name = Path.Combine("Root", wf.Bundle.TypeName, Path.GetDirectoryName(wf.Name)); FullPath = wf.Name; this.Text = wf.Name; }
private void OpenNode(WitcherTreeNode node, bool reset = false) { if (ActiveNode == node && !reset) { return; } ActiveNode = node; UpdatePathPanel(); fileListView.Items.Clear(); List <WitcherListViewItem> res = new List <WitcherListViewItem>(); if (node.Parent != null) { res.Add(new WitcherListViewItem { Node = node.Parent, Text = "..", IsDirectory = true, ImageKey = "FolderOpened" }); } res.AddRange(node.Directories.OrderBy(x => x.Key).Select(item => new WitcherListViewItem { Node = item.Value, Text = item.Key, IsDirectory = true, ImageKey = "FolderOpened" })); foreach (var item in node.Files.OrderBy(x => x.Key)) { var lastItem = item.Value[item.Value.Count - 1]; var listItem = new WitcherListViewItem { Node = node, RelativePath = lastItem.Name, Text = item.Key, IsDirectory = false, ImageKey = GetImageKey(item.Key) }; listItem.SubItems.Add(lastItem.Size.ToString()); listItem.SubItems.Add($"{(100 - (int) (lastItem.ZSize / (float) lastItem.Size * 100.0f))}%"); listItem.SubItems.Add(lastItem.CompressionType); listItem.SubItems.Add(lastItem.Bundle.TypeName.ToString()); res.Add(listItem); } fileListView.Items.AddRange(res.ToArray()); }
/// <summary> /// Deep search for files /// </summary> /// <param name="mainnode">The rootnode to get the files from</param> /// <returns></returns> public List <IWitcherFile> GetFiles(WitcherTreeNode mainnode) { var bundfiles = new List <IWitcherFile>(); if (mainnode?.Files != null) { foreach (var wfile in mainnode.Files) { bundfiles.AddRange(wfile.Value); } bundfiles.AddRange(mainnode.Directories.Values.SelectMany(GetFiles)); } return(bundfiles); }
private void CreateRootFileList() { var rootNode = new WitcherTreeNode { Name = "Root" }; foreach (var archive in Archives) { rootNode.Directories[archive.RootNode.Name] = archive.RootNode; archive.RootNode.Parent = rootNode; } RootItem = new AssetExplorerItem(rootNode.Name, rootNode.FullPath, rootNode.Files.Values.SelectMany(x => x).ToList(), rootNode.Directories.Values.ToList(), 1); }
/// <summary> /// Recursively collects files into an array, descending depth first from a given root node. /// </summary> /// <param name="root">Root node.</param> /// <returns>Array of collected files.</returns> public WitcherListViewItem[] CollectFiles(WitcherTreeNode root) { var collectedFilesList = new List <WitcherListViewItem>(); foreach (var fileList in root.Files) { foreach (var file in fileList.Value) { collectedFilesList.Add(new WitcherListViewItem(file)); } } foreach (var dr in root.Directories) { collectedFilesList.AddRange(CollectFiles(dr.Value)); } return(collectedFilesList.ToArray()); }