|
10 | 10 | using Avalonia.Threading; |
11 | 11 | using System.Collections.ObjectModel; |
12 | 12 | using System.Diagnostics; |
| 13 | +using System.IO.Compression; |
13 | 14 |
|
14 | 15 | namespace AssetRipper.GUI |
15 | 16 | { |
@@ -172,6 +173,36 @@ public void OnFileDropped(DragEventArgs e) |
172 | 173 | DoLoad(filesDropped); |
173 | 174 | } |
174 | 175 |
|
| 176 | + private void DoLoadArchives(string[]? filesDropped) |
| 177 | + { |
| 178 | + if (!Directory.Exists("temp")) |
| 179 | + { |
| 180 | + Directory.CreateDirectory("temp"); |
| 181 | + } |
| 182 | + |
| 183 | + string path = "temp/ZIP_COMBINE_" + DateTime.Now.ToString("yyyyMMddHHmm"); |
| 184 | + |
| 185 | + if (filesDropped == null || filesDropped.Length < 1) |
| 186 | + { |
| 187 | + return; |
| 188 | + } |
| 189 | + |
| 190 | + try |
| 191 | + { |
| 192 | + foreach(string v in filesDropped) |
| 193 | + { |
| 194 | + Logger.Log(LogType.Info, LogCategory.Import, $"Unzipping '{v}'"); |
| 195 | + ZipFile.ExtractToDirectory(v, path, true); |
| 196 | + } |
| 197 | + |
| 198 | + DoLoad([path]); |
| 199 | + } |
| 200 | + catch (Exception ex) |
| 201 | + { |
| 202 | + this.ShowPopup($"Exception on combining archives: {ex.Message}", MainWindow.Instance.LocalizationManager["error"]); |
| 203 | + } |
| 204 | + } |
| 205 | + |
175 | 206 | private void DoLoad(string[]? filesDropped) |
176 | 207 | { |
177 | 208 | if (filesDropped == null || filesDropped.Length < 1) |
@@ -404,6 +435,22 @@ public async void ShowOpenFileDialog() |
404 | 435 | } |
405 | 436 | } |
406 | 437 |
|
| 438 | + //Called from UI |
| 439 | + public async void ShowOpenFileDialogZipArchives() |
| 440 | + { |
| 441 | + FilePickerOpenOptions options = new() { AllowMultiple = true }; |
| 442 | + IReadOnlyList<IStorageFile> fileList = await MainWindow.Instance.StorageProvider.OpenFilePickerAsync(options); |
| 443 | + |
| 444 | + string[] result = fileList.Select(f => f.Path.LocalPath) |
| 445 | + .Where(s => !string.IsNullOrEmpty(s)) |
| 446 | + .ToArray(); |
| 447 | + |
| 448 | + if (result.Length > 0) |
| 449 | + { |
| 450 | + DoLoadArchives(result); |
| 451 | + } |
| 452 | + } |
| 453 | + |
407 | 454 | //Called from UI |
408 | 455 | public async void ShowOpenFolderDialog() |
409 | 456 | { |
|
0 commit comments