Skip to content

Commit 427aea9

Browse files
committed
reenabled the logging + XAPK Support
1 parent 6397f9e commit 427aea9

File tree

3 files changed

+76
-4
lines changed

3 files changed

+76
-4
lines changed

Source/AssetRipper.GUI/MainWindow.ViewModel.cs

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -454,6 +454,65 @@ public async void ShowOpenFileDialog()
454454
}
455455
}
456456

457+
//Called from UI
458+
public async void ShowOpenFileDialogXAPK()
459+
{
460+
FilePickerOpenOptions options = new() { AllowMultiple = false };
461+
IReadOnlyList<IStorageFile> fileList = await MainWindow.Instance.StorageProvider.OpenFilePickerAsync(options);
462+
463+
string[] result = fileList.Select(f => f.Path.LocalPath)
464+
.Where(s => !string.IsNullOrEmpty(s))
465+
.ToArray();
466+
467+
if (result.Length < 1) return;
468+
469+
_ = Task.Run(() =>
470+
{
471+
string xapkExtractPath = "temp/XAPK_" + DateTime.Now.ToString("yyyyMMddHHmm");
472+
Directory.CreateDirectory(xapkExtractPath);
473+
474+
try
475+
{
476+
Logger.Log(LogType.Info, LogCategory.Import, $"Decompressing '{result[0]}'");
477+
478+
if (!File.Exists(result[0]))
479+
{
480+
Logger.Log(LogType.Error, LogCategory.Import, $"File '{result[0]}' does not exist.");
481+
throw new Exception($"File '{result[0]}' does not exist. Have you tried importing multiple folders?");
482+
}
483+
484+
LoadingText = "Decompressing " + result[0];
485+
486+
ZipFile.ExtractToDirectory(result[0], xapkExtractPath, true);
487+
488+
// Post Extract
489+
if (!Directory.Exists(Path.Combine(xapkExtractPath, "Android/obb")))
490+
throw new Exception("Unable to find Android/obb directory");
491+
492+
string? packageName = Path.GetFileName(Directory.GetDirectories(Path.Combine(xapkExtractPath, "Android/obb"))[0]);
493+
494+
if (packageName == null) throw new Exception("Package name is null");
495+
Logger.Log(LogType.Info, LogCategory.Import, packageName);
496+
497+
string obbFile = Directory.GetFiles(Path.Combine(xapkExtractPath, "Android/obb", packageName))[0];
498+
499+
string xapkPostExtractPath = "temp/XAPK_POST_" + DateTime.Now.ToString("yyyyMMddHHmm");
500+
Directory.CreateDirectory(xapkPostExtractPath);
501+
502+
ZipFile.ExtractToDirectory(obbFile, xapkPostExtractPath, true);
503+
504+
ZipFile.ExtractToDirectory(Path.Combine(xapkExtractPath, packageName + ".apk"), xapkPostExtractPath, true);
505+
506+
DoLoad([xapkPostExtractPath]);
507+
}
508+
catch (Exception ex)
509+
{
510+
LoadingText = string.Empty;
511+
this.ShowPopup($"Exception on importing XAPK: {ex.Message}", MainWindow.Instance.LocalizationManager["error"]);
512+
}
513+
});
514+
}
515+
457516
//Called from UI
458517
public async void ShowOpenFolderDialog()
459518
{

Source/AssetRipper.GUI/MainWindow.axaml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,19 @@
6464
</MultiBinding>
6565
</MenuItem.IsEnabled>
6666
</MenuItem>
67+
68+
<!--File->Open XAPK-->
69+
<MenuItem Header="Open XAPK (EXPEREMENTAL)" Command="{Binding ShowOpenFileDialogXAPK}">
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>
6780

6881

6982
<MenuItem Header="{i18n:Localize menu_file_reset}" Command="{Binding Reset}">

Source/AssetRipper.Import/Structure/Assembly/Serializable/SerializableStructure.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -111,14 +111,14 @@ public bool TryRead(ref EndianSpanReader reader, UnityVersion version, TransferI
111111
catch (Exception ex)
112112
{
113113
LogMonoBehaviorReadException(this, ex);
114-
//WriteDebug(ref reader);
115-
//return false;
114+
WriteDebug(ref reader);
115+
return false;
116116
}
117117
if (reader.Position != reader.Length)
118118
{
119119
LogMonoBehaviourMismatch(this, reader.Position, reader.Length);
120-
//WriteDebug(ref reader);
121-
//return false;
120+
WriteDebug(ref reader);
121+
return false;
122122
}
123123
return true;
124124
}

0 commit comments

Comments
 (0)