/// <summary> /// Handler to remove a missing file from the list /// </summary> /// <param name="sender">display name of the file</param> /// <param name="args"></param> private void OnRemoveAsset(object sender, EventArgs args) { var filePath = sender as string; var item = MissingAssets.FirstOrDefault(file => file.FullFilePath == filePath); if (item != null) { MissingAssets.Remove(item); _logger.Debug($"Removed {item.FileName} from missing asset list"); } }
private void CheckMissingAssets(string newFolderPath) { _logger.Debug($"checking for missing assets in new folder: [{newFolderPath}]"); foreach (var missingAsset in MissingAssets.ToList()) { if (missingAsset.FileName.StartsWith(newFolderPath, StringComparison.InvariantCultureIgnoreCase) || missingAsset.FullFilePath.StartsWith(newFolderPath, StringComparison.InvariantCultureIgnoreCase)) { _logger.Debug($"no longer missing -> [{missingAsset.FileName} :: {missingAsset.FullFilePath}]"); // if our file path starts with the new folder we are adding then we can remove it from the missing list MissingAssets.Remove(missingAsset); } } }
/// <summary> /// Get the assets from the scene and make sure they exist in the project directory. Any /// that don't add them to the missing asset list. Any folders we encounter we add to the /// asset folder list. /// </summary> /// <param name="projectFolderFiles"></param> private async Task <bool> ProcessSceneFiles(IReadOnlyDictionary <string, List <string> > projectFolderFiles) { Status.Text = "Loading assets from the scene file, this can take a while"; var sceneFiles = await _maxRequestHandler.GetFoundSceneAssets(); // TODO: Debug ... remove foreach log. _logger.Debug($"found '{sceneFiles.Count}' scene assets"); foreach (var asset in sceneFiles) { var assetName = Path.GetFileName(asset.FileName) ?? ""; if (projectFolderFiles.ContainsKey(assetName)) { // found a file with the same name in the project directory, get the locations as it could exist in more than one folder on disk var locations = projectFolderFiles[assetName]; if (string.IsNullOrEmpty(locations.Find(file => file == asset.FullFilePath))) { // the filename exists in the project direrctory, but not with the same path // see if we can match up any directories and make a guess if its the correct one. _logger.Debug($"Did not find: {asset.FullFilePath}, locations: {locations.Count}"); var matchingDirCount = AssetWrangler.FindMatchingDirectories(asset.FullFilePath, locations); if (matchingDirCount == 0) { // add it to the missing asset list for the user to find MissingAssets.Add(asset); _logger.Debug($"Add to missing asset list: {asset.FileName} :: {asset.FullFilePath}"); } else { _logger.Debug($"Found partial match for [{asset.FullFilePath}] in [{string.Join(":::", locations)}] with '{matchingDirCount}' matching dirs"); } } else { // no else needed as we found it and it matches the path. do nothing. _logger.Debug($"Found in project directory: {asset.FullFilePath}"); } } else { // asset was not found in project directory, but Max has a reference to it elsewhere. add folder to collection _logger.Debug($"Asset '{assetName}' was not found in project directory, but Max has a reference to it elsewhere: [{asset.FullFilePath}] -> [{asset.FileName}]"); SafeAddAssetFolder(Path.GetDirectoryName(asset.FullFilePath)); } } AssetSpinnerVisibility = Visibility.Collapsed; return(true); }
/// <summary> /// Find and add any missing scene assets to the list /// </summary> private async Task <bool> ProcessMissingAssets() { Status.Text = "Loading missing assets from the scene file"; var missing = await _maxRequestHandler.GetMissingAssets(); MissingAssets.AddRange(missing); _logger.Debug($"found '{missing.Count}' missing assets"); foreach (var asset in missing) { _logger.Debug($"missing -> {asset.FileName} --- {asset.FullFilePath}"); } MissingSpinnerVisibility = Visibility.Collapsed; return(true); }