private async void AskLoadCompressedBundle(BundleFileInstance bundleInst) { const string fileOption = "File"; const string memoryOption = "Memory"; const string cancelOption = "Cancel"; string result = await MessageBoxUtil.ShowDialogCustom( this, "Note", "This bundle is compressed. Decompress to file or memory?", fileOption, memoryOption, cancelOption); if (result == fileOption) { SaveFileDialog sfd = new SaveFileDialog(); sfd.Title = "Save as..."; sfd.Filters = new List <FileDialogFilter>() { new FileDialogFilter() { Name = "All files", Extensions = new List <string>() { "*" } } }; string savePath; while (true) { savePath = await sfd.ShowAsync(this); if (savePath == "" || savePath == null) { return; } if (Path.GetFullPath(savePath) == Path.GetFullPath(bundleInst.path)) { await MessageBoxUtil.ShowDialog(this, "File in use", "Since this file is already open in UABEA, you must pick a new file name (sorry!)"); continue; } else { break; } } DecompressToFile(bundleInst, savePath); } else if (result == memoryOption) { DecompressToMemory(bundleInst); } else //if (result == cancelOption || result == closeOption) { return; } LoadBundle(bundleInst); }
private async Task AskForLocationAndCompress() { if (bundleInst != null) { //temporary, maybe I should just write to a memory stream or smth //edit: looks like uabe just asks you to open a file instead of //using your currently opened one, so that may be the workaround if (changesMade) { ButtonResult continueWithChanges = await MessageBoxUtil.ShowDialog( this, "Note", "You've modified this file, but only file before changes is loaded. If you want to compress the file with " + "changes, please close this bundle and open the new file. Click Ok to compress the file without changes.", ButtonEnum.OkCancel); if (continueWithChanges == ButtonResult.Cancel) { return; } } SaveFileDialog sfd = new SaveFileDialog(); sfd.Title = "Save as..."; string file = await sfd.ShowAsync(this); if (file == null) { return; } const string lz4Option = "LZ4"; const string lzmaOption = "LZMA"; const string cancelOption = "Cancel"; string result = await MessageBoxUtil.ShowDialogCustom( this, "Note", "What compression method do you want to use?\nLZ4: Faster but larger size\nLZMA: Slower but smaller size", lz4Option, lzmaOption, cancelOption); AssetBundleCompressionType compType = result switch { lz4Option => AssetBundleCompressionType.LZ4, lzmaOption => AssetBundleCompressionType.LZMA, _ => AssetBundleCompressionType.NONE }; if (compType != AssetBundleCompressionType.NONE) { CompressBundle(bundleInst, file, compType); } } else { await MessageBoxUtil.ShowDialog(this, "Note", "Please open a bundle file before using compress."); } }
private async void AskLoadCompressedBundle(BundleFileInstance bundleInst) { const string fileOption = "File"; const string memoryOption = "Memory"; const string cancelOption = "Cancel"; string result = await MessageBoxUtil.ShowDialogCustom( this, "Note", "This bundle is compressed. Decompress to file or memory?", fileOption, memoryOption, cancelOption); if (result == fileOption) { SaveFileDialog sfd = new SaveFileDialog(); sfd.Title = "Save as..."; sfd.Filters = new List <FileDialogFilter>() { new FileDialogFilter() { Name = "All files", Extensions = new List <string>() { "*" } } }; string savePath = await sfd.ShowAsync(this); if (savePath == null) { return; } DecompressToFile(bundleInst, savePath); } else if (result == memoryOption) { DecompressToMemory(bundleInst); } else //if (result == cancelOption || result == closeOption) { return; } LoadBundle(bundleInst); }