Skip to content

Commit 02ab861

Browse files
committed
Improved multifile support
1 parent 3784327 commit 02ab861

File tree

7 files changed

+44
-53
lines changed

7 files changed

+44
-53
lines changed

Localizations/en_US.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@
115115
"menu_export_selected_type": "Export all Files of Selected Type",
116116
"menu_file": "File",
117117
"menu_file_exit": "Exit",
118-
"menu_file_open_file": "Open File",
118+
"menu_file_open_file": "Open File(s)",
119119
"menu_file_open_folder": "Open Folder",
120120
"menu_file_reset": "Reset",
121121
"menu_language": "Language",

Localizations/ru.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@
112112
"menu_export_selected_type": "Экспортировать Файлы Выбранного Типа",
113113
"menu_file": "Файл",
114114
"menu_file_exit": "Выйти",
115-
"menu_file_open_file": "Открыть файл",
115+
"menu_file_open_file": "Открыть файл(ы)",
116116
"menu_file_open_folder": "Открыть папку",
117117
"menu_file_reset": "Сбросить",
118118
"menu_language": "Язык",

Source/AssetRipper.GUI/MainWindow.ViewModel.cs

Lines changed: 38 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -175,32 +175,44 @@ public void OnFileDropped(DragEventArgs e)
175175

176176
private void DoLoadArchives(string[]? filesDropped)
177177
{
178-
if (!Directory.Exists("temp"))
179-
{
180-
Directory.CreateDirectory("temp");
181-
}
182-
183-
string path = "temp/ZIP_COMBINE_" + DateTime.Now.ToString("yyyyMMddHHmm");
184-
185178
if (filesDropped == null || filesDropped.Length < 1)
186179
{
187180
return;
188181
}
189182

190-
try
183+
new Thread(() =>
191184
{
192-
foreach(string v in filesDropped)
185+
string path = "temp/ZIP_COMBINE_" + DateTime.Now.ToString("yyyyMMddHHmm");
186+
187+
try
193188
{
194-
Logger.Log(LogType.Info, LogCategory.Import, $"Unzipping '{v}'");
195-
ZipFile.ExtractToDirectory(v, path, true);
196-
}
189+
foreach (string v in filesDropped)
190+
{
191+
Logger.Log(LogType.Info, LogCategory.Import, $"Decompressing '{v}'");
197192

198-
DoLoad([path]);
199-
}
200-
catch (Exception ex)
193+
if (!File.Exists(v))
194+
{
195+
Logger.Log(LogType.Error, LogCategory.Import, $"File '{v}' does not exist.");
196+
throw new Exception($"File '{v}' does not exist. Have you tried importing multiple folders?");
197+
}
198+
199+
LoadingText = "Decompressing " + v;
200+
201+
ZipFile.ExtractToDirectory(v, path, true);
202+
}
203+
204+
DoLoad([path]);
205+
}
206+
catch (Exception ex)
207+
{
208+
LoadingText = string.Empty;
209+
this.ShowPopup($"Exception on combining archives: {ex.Message}", MainWindow.Instance.LocalizationManager["error"]);
210+
}
211+
})
201212
{
202-
this.ShowPopup($"Exception on combining archives: {ex.Message}", MainWindow.Instance.LocalizationManager["error"]);
203-
}
213+
IsBackground = true,
214+
Name = "Background Decompressing Thread"
215+
}.Start();
204216
}
205217

206218
private void DoLoad(string[]? filesDropped)
@@ -210,13 +222,20 @@ private void DoLoad(string[]? filesDropped)
210222
return;
211223
}
212224

225+
// multi zip support
226+
if (filesDropped.Length > 1)
227+
{
228+
DoLoadArchives(filesDropped);
229+
return;
230+
}
231+
232+
string gamePath = filesDropped[0];
233+
213234
_ripper.ResetData();
214235
SelectedAsset?.Dispose();
215236
SelectedAsset = null;
216237
_assetContainer = null;
217238

218-
string gamePath = filesDropped[0];
219-
220239
HasFile = true;
221240
HasLoaded = false;
222241
Dispatcher.UIThread.Post(() => AssetFiles.Clear(), DispatcherPriority.Send);
@@ -435,22 +454,6 @@ public async void ShowOpenFileDialog()
435454
}
436455
}
437456

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-
454457
//Called from UI
455458
public async void ShowOpenFolderDialog()
456459
{

Source/AssetRipper.GUI/MainWindow.axaml

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
<!--File Menu-->
4040
<MenuItem Header="{i18n:Localize menu_file}">
4141

42-
<!--File->Open File-->
42+
<!--File->Open File(s)-->
4343
<MenuItem Header="{i18n:Localize menu_file_open_file}" Command="{Binding ShowOpenFileDialog}">
4444
<MenuItem.IsEnabled>
4545
<MultiBinding Converter="{x:Static BoolConverters.And}">
@@ -65,19 +65,6 @@
6565
</MenuItem.IsEnabled>
6666
</MenuItem>
6767

68-
<!--File->Import Multiple (Zip Archives)-->
69-
<MenuItem Header="Import Multiple (Zip Archives)" Command="{Binding ShowOpenFileDialogZipArchives}">
70-
<MenuItem.IsEnabled>
71-
<MultiBinding Converter="{x:Static BoolConverters.And}">
72-
<Binding Path="!IsExporting" />
73-
<MultiBinding Converter="{x:Static BoolConverters.Or}">
74-
<Binding Path="!HasFile" />
75-
<Binding Path="HasLoaded" />
76-
</MultiBinding>
77-
</MultiBinding>
78-
</MenuItem.IsEnabled>
79-
</MenuItem>
80-
8168

8269
<MenuItem Header="{i18n:Localize menu_file_reset}" Command="{Binding Reset}">
8370
<MenuItem.IsEnabled>

Source/AssetRipper.GUI/MainWindow.axaml.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ public MainWindow()
3333
#endif
3434

3535
AddHandler(DragDrop.DropEvent, (sender, args) => VM.OnFileDropped(args));
36+
37+
VM.ShaderExportMode = Export.UnityProjects.Configuration.ShaderExportMode.Decompile;
3638
}
3739

3840
protected override void OnDataContextChanged(EventArgs e)

build-and-run.cmd

Lines changed: 0 additions & 2 deletions
This file was deleted.

build.cmd

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
dotnet build

0 commit comments

Comments
 (0)