mirror of
https://github.com/aelurum/AssetStudio.git
synced 2026-11-15 19:28:48 -05:00
Some refactor for customBundleOptions
This commit is contained in:
@@ -310,7 +310,7 @@ namespace AssetStudio
|
|||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var bundleFile = new BundleFile(bundleReader, Options.BundleOptions);
|
var bundleFile = new BundleFile(bundleReader, Options);
|
||||||
isLoaded = LoadBundleFiles(bundleReader, bundleFile, originalPath);
|
isLoaded = LoadBundleFiles(bundleReader, bundleFile, originalPath);
|
||||||
if (!isLoaded)
|
if (!isLoaded)
|
||||||
return false;
|
return false;
|
||||||
@@ -331,7 +331,7 @@ namespace AssetStudio
|
|||||||
bundleReader.FileName = $"{reader.FileName}_0x{bundleStream.Offset:X}";
|
bundleReader.FileName = $"{reader.FileName}_0x{bundleStream.Offset:X}";
|
||||||
}
|
}
|
||||||
Logger.Info($"[MultiBundle] Loading \"{reader.FileName}\" from offset: 0x{bundleStream.Offset:X}");
|
Logger.Info($"[MultiBundle] Loading \"{reader.FileName}\" from offset: 0x{bundleStream.Offset:X}");
|
||||||
bundleFile = new BundleFile(bundleReader, Options.BundleOptions, isMultiBundle: true);
|
bundleFile = new BundleFile(bundleReader, Options, isMultiBundle: true);
|
||||||
isLoaded = LoadBundleFiles(bundleReader, bundleFile, originalPath ?? reader.FullPath);
|
isLoaded = LoadBundleFiles(bundleReader, bundleFile, originalPath ?? reader.FullPath);
|
||||||
}
|
}
|
||||||
return isLoaded;
|
return isLoaded;
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
using System;
|
using AssetStudio.CustomOptions;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Collections.Generic;
|
|
||||||
using AssetStudio.CustomOptions;
|
|
||||||
|
|
||||||
namespace AssetStudio
|
namespace AssetStudio
|
||||||
{
|
{
|
||||||
@@ -45,7 +45,7 @@ namespace AssetStudio
|
|||||||
public class BundleFile
|
public class BundleFile
|
||||||
{
|
{
|
||||||
public readonly bool IsDataAfterBundle;
|
public readonly bool IsDataAfterBundle;
|
||||||
private readonly CustomBundleOptions _bundleOptions;
|
private readonly ImportOptions.CustomBundleOptions _bundleOptions;
|
||||||
|
|
||||||
public class Header
|
public class Header
|
||||||
{
|
{
|
||||||
@@ -80,9 +80,9 @@ namespace AssetStudio
|
|||||||
|
|
||||||
public List<StreamFile> fileList;
|
public List<StreamFile> fileList;
|
||||||
|
|
||||||
public BundleFile(FileReader reader, CustomBundleOptions bundleOptions, bool isMultiBundle = false)
|
public BundleFile(FileReader reader, ImportOptions importOptions, bool isMultiBundle = false)
|
||||||
{
|
{
|
||||||
_bundleOptions = bundleOptions;
|
_bundleOptions = importOptions.BundleOptions;
|
||||||
m_Header = new Header();
|
m_Header = new Header();
|
||||||
m_Header.signature = reader.ReadStringToNull();
|
m_Header.signature = reader.ReadStringToNull();
|
||||||
m_Header.version = reader.ReadUInt32();
|
m_Header.version = reader.ReadUInt32();
|
||||||
@@ -115,7 +115,7 @@ namespace AssetStudio
|
|||||||
IsDataAfterBundle = streamSize - bundleSize > 200;
|
IsDataAfterBundle = streamSize - bundleSize > 200;
|
||||||
|
|
||||||
var unityVer = m_Header.unityRevision;
|
var unityVer = m_Header.unityRevision;
|
||||||
var customUnityVer = _bundleOptions.Options.CustomUnityVersion;
|
var customUnityVer = importOptions.CustomUnityVersion;
|
||||||
if (customUnityVer != null)
|
if (customUnityVer != null)
|
||||||
{
|
{
|
||||||
if (!unityVer.IsStripped && customUnityVer != unityVer)
|
if (!unityVer.IsStripped && customUnityVer != unityVer)
|
||||||
|
|||||||
@@ -1,40 +1,38 @@
|
|||||||
namespace AssetStudio.CustomOptions
|
namespace AssetStudio.CustomOptions
|
||||||
{
|
{
|
||||||
public class CustomBundleOptions
|
public partial class ImportOptions
|
||||||
{
|
{
|
||||||
private CompressionType _customBlockCompression = CompressionType.Auto;
|
public sealed class CustomBundleOptions
|
||||||
private CompressionType _customBlockInfoCompression = CompressionType.Auto;
|
|
||||||
private bool _decompressToDisk;
|
|
||||||
|
|
||||||
public ImportOptions Options;
|
|
||||||
|
|
||||||
public CompressionType CustomBlockCompression
|
|
||||||
{
|
{
|
||||||
get => _customBlockCompression;
|
private CompressionType _customBlockCompression = CompressionType.Auto;
|
||||||
set => _customBlockCompression = SetOption(nameof(CustomBlockCompression), value);
|
private CompressionType _customBlockInfoCompression = CompressionType.Auto;
|
||||||
}
|
private bool _decompressToDisk;
|
||||||
public CompressionType CustomBlockInfoCompression
|
|
||||||
{
|
|
||||||
get => _customBlockInfoCompression;
|
|
||||||
set => _customBlockInfoCompression = SetOption(nameof(CustomBlockInfoCompression), value);
|
|
||||||
}
|
|
||||||
public bool DecompressToDisk
|
|
||||||
{
|
|
||||||
get => _decompressToDisk;
|
|
||||||
set => _decompressToDisk = SetOption(nameof(DecompressToDisk), value);
|
|
||||||
}
|
|
||||||
|
|
||||||
public CustomBundleOptions() { }
|
public CompressionType CustomBlockCompression
|
||||||
|
{
|
||||||
|
get => _customBlockCompression;
|
||||||
|
set => _customBlockCompression = SetOption(nameof(CustomBlockCompression), value);
|
||||||
|
}
|
||||||
|
|
||||||
public CustomBundleOptions(ImportOptions importOptions)
|
public CompressionType CustomBlockInfoCompression
|
||||||
{
|
{
|
||||||
Options = importOptions;
|
get => _customBlockInfoCompression;
|
||||||
}
|
set => _customBlockInfoCompression = SetOption(nameof(CustomBlockInfoCompression), value);
|
||||||
|
}
|
||||||
|
|
||||||
private static T SetOption<T>(string option, T value)
|
public bool DecompressToDisk
|
||||||
{
|
{
|
||||||
Logger.Info($"- {option}: {value}");
|
get => _decompressToDisk;
|
||||||
return value;
|
set => _decompressToDisk = SetOption(nameof(DecompressToDisk), value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public CustomBundleOptions() { }
|
||||||
|
|
||||||
|
private static T SetOption<T>(string option, T value)
|
||||||
|
{
|
||||||
|
Logger.Info($"- {option}: {value}");
|
||||||
|
return value;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ using System.Text.Json.Serialization;
|
|||||||
|
|
||||||
namespace AssetStudio.CustomOptions
|
namespace AssetStudio.CustomOptions
|
||||||
{
|
{
|
||||||
public class ImportOptions
|
public partial class ImportOptions
|
||||||
{
|
{
|
||||||
private static JsonSerializerOptions jsonOptions;
|
private static JsonSerializerOptions jsonOptions;
|
||||||
private static string fileName = "ImportOptions";
|
private static string fileName = "ImportOptions";
|
||||||
@@ -28,7 +28,7 @@ namespace AssetStudio.CustomOptions
|
|||||||
|
|
||||||
public ImportOptions()
|
public ImportOptions()
|
||||||
{
|
{
|
||||||
BundleOptions = new CustomBundleOptions(this);
|
BundleOptions = new CustomBundleOptions();
|
||||||
CustomUnityVersion = null;
|
CustomUnityVersion = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -100,7 +100,7 @@ namespace AssetStudioCLI
|
|||||||
var count = 0;
|
var count = 0;
|
||||||
var bundleStream = new OffsetStream(reader);
|
var bundleStream = new OffsetStream(reader);
|
||||||
var bundleReader = new FileReader(reader.FullPath, bundleStream);
|
var bundleReader = new FileReader(reader.FullPath, bundleStream);
|
||||||
var bundleFile = new BundleFile(bundleReader, assetsManager.Options.BundleOptions);
|
var bundleFile = new BundleFile(bundleReader, assetsManager.Options);
|
||||||
var extractPath = Path.Combine(savePath, reader.FileName + "_unpacked");
|
var extractPath = Path.Combine(savePath, reader.FileName + "_unpacked");
|
||||||
if (bundleFile.fileList.Count > 0)
|
if (bundleFile.fileList.Count > 0)
|
||||||
{
|
{
|
||||||
@@ -119,7 +119,7 @@ namespace AssetStudioCLI
|
|||||||
bundleReader.FileName = $"{reader.FileName}_0x{bundleStream.Offset:X}";
|
bundleReader.FileName = $"{reader.FileName}_0x{bundleStream.Offset:X}";
|
||||||
}
|
}
|
||||||
Logger.Info($"[MultiBundle] Decompressing \"{reader.FileName}\" from offset: 0x{bundleStream.Offset:X}..");
|
Logger.Info($"[MultiBundle] Decompressing \"{reader.FileName}\" from offset: 0x{bundleStream.Offset:X}..");
|
||||||
bundleFile = new BundleFile(bundleReader, assetsManager.Options.BundleOptions, isMultiBundle: true);
|
bundleFile = new BundleFile(bundleReader, assetsManager.Options, isMultiBundle: true);
|
||||||
if (bundleFile.fileList.Count > 0)
|
if (bundleFile.fileList.Count > 0)
|
||||||
{
|
{
|
||||||
count += ExtractStreamFile(extractPath, bundleFile.fileList);
|
count += ExtractStreamFile(extractPath, bundleFile.fileList);
|
||||||
|
|||||||
@@ -140,7 +140,7 @@ namespace AssetStudioGUI
|
|||||||
var count = 0;
|
var count = 0;
|
||||||
var bundleStream = new OffsetStream(reader);
|
var bundleStream = new OffsetStream(reader);
|
||||||
var bundleReader = new FileReader(reader.FullPath, bundleStream);
|
var bundleReader = new FileReader(reader.FullPath, bundleStream);
|
||||||
var bundleFile = new BundleFile(bundleReader, assetsManager.Options.BundleOptions);
|
var bundleFile = new BundleFile(bundleReader, assetsManager.Options);
|
||||||
var extractPath = Path.Combine(savePath, reader.FileName + "_unpacked");
|
var extractPath = Path.Combine(savePath, reader.FileName + "_unpacked");
|
||||||
if (bundleFile.fileList.Count > 0)
|
if (bundleFile.fileList.Count > 0)
|
||||||
{
|
{
|
||||||
@@ -159,7 +159,7 @@ namespace AssetStudioGUI
|
|||||||
bundleReader.FileName = $"{reader.FileName}_0x{bundleStream.Offset:X}";
|
bundleReader.FileName = $"{reader.FileName}_0x{bundleStream.Offset:X}";
|
||||||
}
|
}
|
||||||
Logger.Info($"[MultiBundle] Decompressing \"{reader.FileName}\" from offset: 0x{bundleStream.Offset:X}..");
|
Logger.Info($"[MultiBundle] Decompressing \"{reader.FileName}\" from offset: 0x{bundleStream.Offset:X}..");
|
||||||
bundleFile = new BundleFile(bundleReader, assetsManager.Options.BundleOptions, isMultiBundle: true);
|
bundleFile = new BundleFile(bundleReader, assetsManager.Options, isMultiBundle: true);
|
||||||
if (bundleFile.fileList.Count > 0)
|
if (bundleFile.fileList.Count > 0)
|
||||||
{
|
{
|
||||||
count += ExtractStreamFile(extractPath, bundleFile.fileList);
|
count += ExtractStreamFile(extractPath, bundleFile.fileList);
|
||||||
|
|||||||
Reference in New Issue
Block a user