From a195d4dac7f146f3283c0f814e89416b2cea81b5 Mon Sep 17 00:00:00 2001 From: VaDiM Date: Sun, 3 May 2026 16:00:45 +0300 Subject: [PATCH] Rework options a bit --- AssetStudio/AssetsManager.cs | 81 ++--- AssetStudio/AssetsManagerOptions.cs | 31 ++ AssetStudio/BundleFile.cs | 19 +- AssetStudio/Classes/Mesh.cs | 8 +- AssetStudio/Classes/PPtr.cs | 4 +- AssetStudio/CustomOptions/Asmo/OptionsFile.cs | 2 +- .../CustomOptions/CustomBundleOptions.cs | 16 +- .../CustomOptions/CustomMeshOptions.cs | 2 +- ...mportOptions.cs => GameSpecificOptions.cs} | 36 +- AssetStudio/ResourceReader.cs | 6 +- AssetStudio/SerializedFile.cs | 6 +- AssetStudioCLI/Studio.cs | 14 +- AssetStudioGUI/AssetStudioGUIForm.Designer.cs | 240 +++++++------ AssetStudioGUI/AssetStudioGUIForm.cs | 113 ++++--- AssetStudioGUI/AssetStudioGUIForm.resx | 6 +- ...esigner.cs => GameOptionsForm.Designer.cs} | 126 ++----- ...mportOptionsForm.cs => GameOptionsForm.cs} | 85 ++--- ...tOptionsForm.resx => GameOptionsForm.resx} | 3 + .../Properties/Settings.Designer.cs | 10 +- AssetStudioGUI/Properties/Settings.settings | 4 +- AssetStudioGUI/StudioOptionsForm.Designer.cs | 319 ++++++++++++++++++ AssetStudioGUI/StudioOptionsForm.cs | 95 ++++++ AssetStudioGUI/StudioOptionsForm.resx | 126 +++++++ 23 files changed, 894 insertions(+), 458 deletions(-) create mode 100644 AssetStudio/AssetsManagerOptions.cs rename AssetStudio/CustomOptions/{ImportOptions.cs => GameSpecificOptions.cs} (77%) rename AssetStudioGUI/{ImportOptionsForm.Designer.cs => GameOptionsForm.Designer.cs} (78%) rename AssetStudioGUI/{ImportOptionsForm.cs => GameOptionsForm.cs} (63%) rename AssetStudioGUI/{ImportOptionsForm.resx => GameOptionsForm.resx} (96%) create mode 100644 AssetStudioGUI/StudioOptionsForm.Designer.cs create mode 100644 AssetStudioGUI/StudioOptionsForm.cs create mode 100644 AssetStudioGUI/StudioOptionsForm.resx diff --git a/AssetStudio/AssetsManager.cs b/AssetStudio/AssetsManager.cs index e7c7f92..acf190f 100644 --- a/AssetStudio/AssetsManager.cs +++ b/AssetStudio/AssetsManager.cs @@ -1,5 +1,4 @@ using AssetStudio.Addons.CubismLive2D; -using AssetStudio.CustomOptions; using AssetStudio.CustomOptions.Asmo; using System; using System.Collections.Concurrent; @@ -16,16 +15,14 @@ namespace AssetStudio { public class AssetsManager { - public bool LoadViaTypeTree = true; - public bool MeshLazyLoad = true; - public UnityVersion AutoLegacyVersion = null; - public ImportOptions Options = new ImportOptions(); - public readonly List> OptionLoaders = new List>(); + public readonly AssetsManagerOptions Options = new AssetsManagerOptions(); public readonly List AssetsFileList = new List(); - internal Dictionary assetsFileIndexCache = new Dictionary(StringComparer.OrdinalIgnoreCase); - internal ConcurrentDictionary resourceFileReaders = new ConcurrentDictionary(StringComparer.OrdinalIgnoreCase); + internal UnityVersion AutoLegacyVersion = null; + internal Dictionary AssetsFileIndexCache = new Dictionary(StringComparer.OrdinalIgnoreCase); + internal ConcurrentDictionary ResourceFileReaders = new ConcurrentDictionary(StringComparer.OrdinalIgnoreCase); + private readonly List> optionLoaders = new List>(); private readonly List importFiles = new List(); private readonly HashSet filteredAssetTypesList = new HashSet(); private readonly HashSet importFilesHash = new HashSet(StringComparer.OrdinalIgnoreCase); @@ -34,7 +31,17 @@ namespace AssetStudio public AssetsManager() { - OptionLoaders.Add(LoadImportOptions); + AddOptionsLoader(Options.LoadGameSpecificOptionsFromFile); + } + + public void AddOptionsLoader(Action loader) + { + optionLoaders.Add(loader); + } + + public void ClearOptionLoaders() + { + optionLoaders.Clear(); } public void SetAssetFilter(params ClassIDType[] classIDTypes) @@ -291,7 +298,7 @@ namespace AssetStudio catch (Exception e) { Logger.Warning($"Failed to read assets file \"{reader.FullPath}\" from {Path.GetFileName(originalPath)}\n{e}"); - resourceFileReaders.TryAdd(reader.FileName, reader); + ResourceFileReaders.TryAdd(reader.FileName, reader); } } else @@ -375,7 +382,7 @@ namespace AssetStudio } else { - resourceFileReaders.TryAdd(file.fileName, subReader); + ResourceFileReaders.TryAdd(file.fileName, subReader); } } return true; @@ -403,7 +410,7 @@ namespace AssetStudio LoadWebFile(subReader); break; case FileType.ResourceFile: - resourceFileReaders.TryAdd(file.fileName, subReader); + ResourceFileReaders.TryAdd(file.fileName, subReader); break; } } @@ -504,7 +511,7 @@ namespace AssetStudio if (entryReader.FileType == FileType.ResourceFile) { entryReader.Position = 0; - resourceFileReaders.TryAdd(entry.Name, entryReader); + ResourceFileReaders.TryAdd(entry.Name, entryReader); } Progress.Report(++k, progressCount); } @@ -542,7 +549,7 @@ namespace AssetStudio if (optionsFile == null) continue; - foreach (var optionsLoader in OptionLoaders) + foreach (var optionsLoader in optionLoaders) { optionsLoader(optionsFile); } @@ -572,34 +579,18 @@ namespace AssetStudio } } - private void LoadImportOptions(OptionsFile optionsFile) + private void CheckStrippedVersion(SerializedFile assetsFile, UnityVersion bundleUnityVer = null) { - try - { - var importOptions = ImportOptions.FromOptionsFile(optionsFile); - if (importOptions == null) - return; - Options = importOptions; - Logger.Info("Import options successfully loaded."); - } - catch (Exception e) - { - Logger.Warning($"Error while reading import options\n{e}"); - } - } - - public void CheckStrippedVersion(SerializedFile assetsFile, UnityVersion bundleUnityVer = null) - { - if (assetsFile.version.IsStripped && Options.CustomUnityVersion == null) + if (assetsFile.version.IsStripped && Options.GameSpecific.CustomUnityVersion == null) { var msg = "The asset's Unity version has been stripped, please set the version in the options."; if (bundleUnityVer != null && !bundleUnityVer.IsStripped) msg += $"\n\nAssumed Unity version based on asset bundle: {bundleUnityVer}"; throw new NotSupportedException(msg); } - if (Options.CustomUnityVersion != null) + if (Options.GameSpecific.CustomUnityVersion != null) { - assetsFile.version = Options.CustomUnityVersion; + assetsFile.version = Options.GameSpecific.CustomUnityVersion; } } @@ -612,19 +603,19 @@ namespace AssetStudio } AssetsFileList.Clear(); - foreach (var resourceFileReader in resourceFileReaders) + foreach (var resourceFileReader in ResourceFileReaders) { resourceFileReader.Value.Close(); } - resourceFileReaders.Clear(); + ResourceFileReaders.Clear(); - assetsFileIndexCache.Clear(); + AssetsFileIndexCache.Clear(); } private void ReadAssets() { var serializedVer = AssetsFileList[0].header.m_Version; - if (serializedVer <= SerializedFileFormatVersion.Unknown_6 && serializedVer >= SerializedFileFormatVersion.Unknown_5 && AutoLegacyVersion == null && Options.CustomUnityVersion == null) + if (serializedVer <= SerializedFileFormatVersion.Unknown_6 && serializedVer >= SerializedFileFormatVersion.Unknown_5 && AutoLegacyVersion == null && Options.GameSpecific.CustomUnityVersion == null) { var versions = serializedVer == SerializedFileFormatVersion.Unknown_6 ? "'2.1.0f1', '2.5.0f1', '2.6.0f1'" @@ -650,8 +641,10 @@ namespace AssetStudio Progress.Reset(); foreach (var assetsFile in AssetsFileList) { - if (AutoLegacyVersion != null && Options.CustomUnityVersion == null) + if (AutoLegacyVersion != null && Options.GameSpecific.CustomUnityVersion == null) + { assetsFile.version = AutoLegacyVersion; + } JsonConverterHelper.AssetsFile = assetsFile; foreach (var objectInfo in assetsFile.m_Objects) @@ -664,14 +657,14 @@ namespace AssetStudio try { Object obj = null; - var loadViaTypeTree = objectReader.serializedType?.m_Type != null && LoadViaTypeTree; + var parseByTypeTree = objectReader.serializedType?.m_Type != null && Options.ParseByTypeTree; switch (objectReader.type) { case ClassIDType.Animation: obj = new Animation(objectReader); break; case ClassIDType.AnimationClip when objectReader.version >= (1, 5): - obj = loadViaTypeTree + obj = parseByTypeTree ? new AnimationClip(objectReader, TypeTreeHelper.ReadTypeByteArray(objectReader.serializedType.m_Type, objectReader), jsonOptions, objectInfo) : new AnimationClip(objectReader); break; @@ -703,7 +696,7 @@ namespace AssetStudio obj = new GameObject(objectReader); break; case ClassIDType.Material: - obj = loadViaTypeTree + obj = parseByTypeTree ? new Material(objectReader, TypeTreeHelper.ReadTypeByteArray(objectReader.serializedType.m_Type, objectReader), jsonOptions) : new Material(objectReader); break; @@ -752,12 +745,12 @@ namespace AssetStudio obj = new TextAsset(objectReader); break; case ClassIDType.Texture2D: - obj = loadViaTypeTree + obj = parseByTypeTree ? new Texture2D(objectReader, TypeTreeHelper.ReadTypeByteArray(objectReader.serializedType.m_Type, objectReader), jsonOptions) : new Texture2D(objectReader); break; case ClassIDType.Texture2DArray: - obj = loadViaTypeTree + obj = parseByTypeTree ? new Texture2DArray(objectReader, TypeTreeHelper.ReadTypeByteArray(objectReader.serializedType.m_Type, objectReader), jsonOptions) : new Texture2DArray(objectReader); break; diff --git a/AssetStudio/AssetsManagerOptions.cs b/AssetStudio/AssetsManagerOptions.cs new file mode 100644 index 0000000..d2b6945 --- /dev/null +++ b/AssetStudio/AssetsManagerOptions.cs @@ -0,0 +1,31 @@ +using AssetStudio.CustomOptions; +using AssetStudio.CustomOptions.Asmo; +using System; + +namespace AssetStudio +{ + public class AssetsManagerOptions + { + public readonly GameSpecificOptions GameSpecific = new GameSpecificOptions(); + + public bool ParseByTypeTree { get; set; } = true; + public bool MeshPreProcessing { get; set; } + public bool DecompressToDisk { get; set; } + public string CustomCachePath { get; set; } + + internal void LoadGameSpecificOptionsFromFile(OptionsFile optionsFile) + { + try + { + if (!GameSpecific.FromFile(optionsFile)) + return; + + Logger.Info("Game-specific options successfully loaded."); + } + catch (Exception e) + { + Logger.Warning($"Error while reading the game-specific options\n{e}"); + } + } + } +} diff --git a/AssetStudio/BundleFile.cs b/AssetStudio/BundleFile.cs index 8adf0c1..131d612 100644 --- a/AssetStudio/BundleFile.cs +++ b/AssetStudio/BundleFile.cs @@ -1,5 +1,4 @@ -using AssetStudio.CustomOptions; -using System; +using System; using System.IO; using System.Linq; @@ -45,7 +44,7 @@ namespace AssetStudio { public readonly bool IsDataAfterBundle; private static TempFileStream _sharedTempFileStream; - private readonly ImportOptions.CustomBundleOptions _bundleOptions; + private readonly AssetsManagerOptions _studioOptions; public class Header { @@ -78,9 +77,9 @@ namespace AssetStudio private StorageBlock[] m_BlocksInfo; private Node[] m_DirectoryInfo; - public BundleFile(FileReader reader, ImportOptions importOptions, bool isMultiBundle = false) + public BundleFile(FileReader reader, AssetsManagerOptions studioOptions, bool isMultiBundle = false) { - _bundleOptions = importOptions.BundleOptions; + _studioOptions = studioOptions; m_Header = new Header(); m_Header.signature = reader.ReadStringToNull(); m_Header.version = reader.ReadUInt32(); @@ -113,7 +112,7 @@ namespace AssetStudio IsDataAfterBundle = streamSize - bundleSize > 200; var unityVer = m_Header.unityRevision; - var customUnityVer = importOptions.CustomUnityVersion; + var customUnityVer = studioOptions.GameSpecific.CustomUnityVersion; if (customUnityVer != null) { if (!unityVer.IsStripped && customUnityVer != unityVer) @@ -181,12 +180,12 @@ namespace AssetStudio private Stream CreateBlocksStream() { var uncompressedSizeSum = m_BlocksInfo.Sum(x => x.uncompressedSize); - if (uncompressedSizeSum < int.MaxValue && !_bundleOptions.DecompressToDisk) + if (uncompressedSizeSum < int.MaxValue && !_studioOptions.DecompressToDisk) return new MemoryStream((int)uncompressedSizeSum); if (_sharedTempFileStream == null || !_sharedTempFileStream.CanRead) { - var cachePath = _bundleOptions.CustomCachePath; + var cachePath = _studioOptions.CustomCachePath; if (string.IsNullOrEmpty(cachePath) || !Directory.Exists(cachePath)) { throw new NotSupportedException("Cache directory wasn't found. Make sure that the specified path is correct."); @@ -306,7 +305,7 @@ namespace AssetStudio blocksInfoBytes = reader.ReadBytes(compressedSize); } - var customBlockInfoCompression = _bundleOptions.CustomBlockInfoCompression; + var customBlockInfoCompression = _studioOptions.GameSpecific.Bundles.CustomBlockInfoCompression; var compressionType = (CompressionType)(m_Header.flags & ArchiveFlags.CompressionTypeMask); if (customBlockInfoCompression == CompressionType.Auto) { @@ -408,7 +407,7 @@ namespace AssetStudio private Stream ReadBlocks(FileReader reader) { - var customBlockCompression = _bundleOptions.CustomBlockCompression; + var customBlockCompression = _studioOptions.GameSpecific.Bundles.CustomBlockCompression; var blocksStream = CreateBlocksStream(); var blocksCompression = m_BlocksInfo.Max(x => (CompressionType)(x.flags & StorageBlockFlags.CompressionTypeMask)); var blockSize = (int)m_BlocksInfo.Max(x => x.uncompressedSize); diff --git a/AssetStudio/Classes/Mesh.cs b/AssetStudio/Classes/Mesh.cs index 11e98d6..4459005 100644 --- a/AssetStudio/Classes/Mesh.cs +++ b/AssetStudio/Classes/Mesh.cs @@ -745,9 +745,9 @@ namespace AssetStudio var m_KeepIndices = reader.ReadBoolean(); } - var tuanjieParsingMode = reader.assetsFile.assetsManager.Options.MeshOptions.TuanjieMeshParsingMode; - var useSharedClusterData = tuanjieParsingMode == ImportOptions.CustomMeshOptions.MeshParsingMode.Tuanjie - || (tuanjieParsingMode == ImportOptions.CustomMeshOptions.MeshParsingMode.Auto && reader.version < (2022, 3, 61, 2)); + var tuanjieParsingMode = reader.assetsFile.assetsManager.Options.GameSpecific.Meshes.TuanjieMeshParsingMode; + var useSharedClusterData = tuanjieParsingMode == GameSpecificOptions.CustomMeshOptions.MeshParsingMode.Tuanjie + || (tuanjieParsingMode == GameSpecificOptions.CustomMeshOptions.MeshParsingMode.Auto && reader.version < (2022, 3, 61, 2)); if (version.IsTuanjie && useSharedClusterData) { if (version < (2022, 3, 48, 3)) //2022.3.48t3(1.4.0) down @@ -932,7 +932,7 @@ namespace AssetStudio //m_MeshLodInfo = new MeshLodInfo(reader) //6000.2 and up - if (!assetsFile.assetsManager.MeshLazyLoad) + if (assetsFile.assetsManager.Options.MeshPreProcessing) ProcessData(); } diff --git a/AssetStudio/Classes/PPtr.cs b/AssetStudio/Classes/PPtr.cs index 3d13840..01893b4 100644 --- a/AssetStudio/Classes/PPtr.cs +++ b/AssetStudio/Classes/PPtr.cs @@ -40,7 +40,7 @@ namespace AssetStudio { var assetsManager = _assetsFile.assetsManager; var assetsFileList = assetsManager.AssetsFileList; - var assetsFileIndexCache = assetsManager.assetsFileIndexCache; + var assetsFileIndexCache = assetsManager.AssetsFileIndexCache; if (_index == -2) { @@ -127,7 +127,7 @@ namespace AssetStudio var assetsManager = _assetsFile.assetsManager; var assetsFileList = assetsManager.AssetsFileList; - var assetsFileIndexCache = assetsManager.assetsFileIndexCache; + var assetsFileIndexCache = assetsManager.AssetsFileIndexCache; if (!assetsFileIndexCache.TryGetValue(name, out _index)) { diff --git a/AssetStudio/CustomOptions/Asmo/OptionsFile.cs b/AssetStudio/CustomOptions/Asmo/OptionsFile.cs index e143598..990022e 100644 --- a/AssetStudio/CustomOptions/Asmo/OptionsFile.cs +++ b/AssetStudio/CustomOptions/Asmo/OptionsFile.cs @@ -5,7 +5,7 @@ namespace AssetStudio.CustomOptions.Asmo { public class OptionsFile { - private static readonly byte[] OptionsFileSign = new byte[] { 0x41, 0x53, 0x4D, 0x4F }; //ASMO + private static readonly byte[] OptionsFileSign = { 0x41, 0x53, 0x4D, 0x4F }; //ASMO public static readonly string Extension = ".asmo"; public byte[] Signature { get; private set; } = OptionsFileSign; diff --git a/AssetStudio/CustomOptions/CustomBundleOptions.cs b/AssetStudio/CustomOptions/CustomBundleOptions.cs index 5ac2da1..34ffabf 100644 --- a/AssetStudio/CustomOptions/CustomBundleOptions.cs +++ b/AssetStudio/CustomOptions/CustomBundleOptions.cs @@ -1,13 +1,11 @@ namespace AssetStudio.CustomOptions { - public partial class ImportOptions + public partial class GameSpecificOptions { public sealed class CustomBundleOptions { private CompressionType _customBlockCompression = CompressionType.Auto; private CompressionType _customBlockInfoCompression = CompressionType.Auto; - private string _customCachePath; - private bool _decompressToDisk; public CompressionType CustomBlockCompression { @@ -21,18 +19,6 @@ set => _customBlockInfoCompression = SetOption(nameof(CustomBlockInfoCompression), value, _customBlockInfoCompression); } - public string CustomCachePath - { - get => _customCachePath; - set => _customCachePath = SetOption(nameof(CustomCachePath), value, _customCachePath); - } - - public bool DecompressToDisk - { - get => _decompressToDisk; - set => _decompressToDisk = SetOption(nameof(DecompressToDisk), value, _decompressToDisk); - } - public CustomBundleOptions() { } } } diff --git a/AssetStudio/CustomOptions/CustomMeshOptions.cs b/AssetStudio/CustomOptions/CustomMeshOptions.cs index cd201ce..c373084 100644 --- a/AssetStudio/CustomOptions/CustomMeshOptions.cs +++ b/AssetStudio/CustomOptions/CustomMeshOptions.cs @@ -1,6 +1,6 @@ namespace AssetStudio.CustomOptions { - public partial class ImportOptions + public partial class GameSpecificOptions { public sealed class CustomMeshOptions { diff --git a/AssetStudio/CustomOptions/ImportOptions.cs b/AssetStudio/CustomOptions/GameSpecificOptions.cs similarity index 77% rename from AssetStudio/CustomOptions/ImportOptions.cs rename to AssetStudio/CustomOptions/GameSpecificOptions.cs index 5a158b0..a21f5f4 100644 --- a/AssetStudio/CustomOptions/ImportOptions.cs +++ b/AssetStudio/CustomOptions/GameSpecificOptions.cs @@ -8,19 +8,19 @@ using System.Text.Json.Serialization; namespace AssetStudio.CustomOptions { - public partial class ImportOptions + public partial class GameSpecificOptions { private static JsonSerializerOptions jsonOptions; - private static string fileName = "ImportOptions"; + private static string fileName = "GameOptions"; private UnityVersion _customUnityVer; public event EventHandler UnityVersionChanged; - public CustomBundleOptions BundleOptions { get; set; } - public CustomMeshOptions MeshOptions { get; set; } + public CustomBundleOptions Bundles { get; set; } + public CustomMeshOptions Meshes { get; set; } public UnityVersion CustomUnityVersion { get => _customUnityVer; set => SetUnityVersion(value); } - static ImportOptions() + static GameSpecificOptions() { jsonOptions = new JsonSerializerOptions { @@ -29,19 +29,19 @@ namespace AssetStudio.CustomOptions }; } - public ImportOptions() + public GameSpecificOptions() { - BundleOptions = new CustomBundleOptions(); - MeshOptions = new CustomMeshOptions(); + Bundles = new CustomBundleOptions(); + Meshes = new CustomMeshOptions(); CustomUnityVersion = null; } - public static ImportOptions FromOptionsFile(OptionsFile optionsFile) + public bool FromFile(OptionsFile optionsFile) { if (optionsFile.Reserved != 0) { - Logger.Debug("Skipped. Not an import options file."); - return null; + Logger.Debug("Skipped. Not a GameOptions file."); + return false; } var utf8Bytes = Convert.FromBase64String(Encoding.ASCII.GetString(optionsFile.Data)); @@ -49,7 +49,12 @@ namespace AssetStudio.CustomOptions if (optionsFile.DataCrc != dataCrc) throw new IOException("Options file data is corrupted."); - return JsonSerializer.Deserialize(utf8Bytes, jsonOptions); + var parsedOptions = JsonSerializer.Deserialize(utf8Bytes, jsonOptions); + Bundles = parsedOptions.Bundles; + Meshes = parsedOptions.Meshes; + CustomUnityVersion = parsedOptions.CustomUnityVersion; + + return true; } public void SaveToFile(string outputFolder) @@ -78,6 +83,7 @@ namespace AssetStudio.CustomOptions { if (_customUnityVer == value) return; + if (value == null) { _customUnityVer = null; @@ -85,6 +91,7 @@ namespace AssetStudio.CustomOptions Logger.Info("- Specified Unity version: None"); return; } + if (string.IsNullOrEmpty(value.BuildType)) { throw new NotSupportedException("Specified Unity version is not in a correct format.\n" + @@ -92,7 +99,10 @@ namespace AssetStudio.CustomOptions "Example: 2022.3.2f1"); } _customUnityVer = value; - UnityVersionChanged?.Invoke(this, EventArgs.Empty); + if (UnityVersionChanged == null) + return; + + UnityVersionChanged.Invoke(this, EventArgs.Empty); Logger.Info($"- Specified Unity version: {_customUnityVer}"); } diff --git a/AssetStudio/ResourceReader.cs b/AssetStudio/ResourceReader.cs index 51e1f63..64e5aa6 100644 --- a/AssetStudio/ResourceReader.cs +++ b/AssetStudio/ResourceReader.cs @@ -45,7 +45,7 @@ namespace AssetStudio if (needSearch) { var resourceFileName = Path.GetFileName(path); - if (assetsFile.assetsManager.resourceFileReaders.TryGetValue(resourceFileName, out reader)) + if (assetsFile.assetsManager.ResourceFileReaders.TryGetValue(resourceFileName, out reader)) { needSearch = false; return reader; @@ -63,12 +63,12 @@ namespace AssetStudio if (File.Exists(resourceFilePath)) { needSearch = false; - if (assetsFile.assetsManager.resourceFileReaders.TryGetValue(resourceFileName, out reader)) + if (assetsFile.assetsManager.ResourceFileReaders.TryGetValue(resourceFileName, out reader)) { return reader; } reader = new BinaryReader(File.OpenRead(resourceFilePath)); - assetsFile.assetsManager.resourceFileReaders.TryAdd(resourceFileName, reader); + assetsFile.assetsManager.ResourceFileReaders.TryAdd(resourceFileName, reader); return reader; } throw new FileNotFoundException($"Can't find the resource file {resourceFileName}"); diff --git a/AssetStudio/SerializedFile.cs b/AssetStudio/SerializedFile.cs index f1f749e..b2219c4 100644 --- a/AssetStudio/SerializedFile.cs +++ b/AssetStudio/SerializedFile.cs @@ -91,13 +91,13 @@ namespace AssetStudio var verStr = reader.ReadStringToNull(); if (!UnityVersion.TryParse(verStr, out version)) { - if (assetsManager.Options.CustomUnityVersion == null) + if (assetsManager.Options.GameSpecific.CustomUnityVersion == null) { Logger.Warning($"Failed to parse Unity version: \"{verStr}\""); version = new UnityVersion(); return; } - version = assetsManager.Options.CustomUnityVersion; + version = assetsManager.Options.GameSpecific.CustomUnityVersion; reader.Position = versionPos + version.ToString().Length + 1; } } @@ -463,7 +463,7 @@ namespace AssetStudio foreach (var hashStr in hashes) { var serializedType = ExtractedTypeTreeHashes[hashStr]; - if (assetsManager.resourceFileReaders.TryGetValue(hashStr, out var binaryReader)) + if (assetsManager.ResourceFileReaders.TryGetValue(hashStr, out var binaryReader)) { var fileReader = (FileReader)binaryReader; fileReader.Endian = EndianType.LittleEndian; diff --git a/AssetStudioCLI/Studio.cs b/AssetStudioCLI/Studio.cs index 5935ba4..3639aa5 100644 --- a/AssetStudioCLI/Studio.cs +++ b/AssetStudioCLI/Studio.cs @@ -30,13 +30,13 @@ namespace AssetStudioCLI Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo("en-US"); Progress.Default = new Progress(ShowCurProgressValue); Progress.SetInstance(1, new Progress(ShowCurProgressValue)); - assetsManager.LoadViaTypeTree = !CLIOptions.f_avoidLoadingViaTypetree.Value; - assetsManager.Options.CustomUnityVersion = CLIOptions.o_unityVersion.Value; - assetsManager.Options.BundleOptions.CustomBlockInfoCompression = CLIOptions.o_bundleBlockInfoCompression.Value; - assetsManager.Options.BundleOptions.CustomBlockCompression = CLIOptions.o_bundleBlockCompression.Value; - assetsManager.Options.BundleOptions.CustomCachePath = CLIOptions.o_cachePath.Value; - assetsManager.Options.BundleOptions.DecompressToDisk = CLIOptions.f_decompressToDisk.Value; - assetsManager.OptionLoaders.Clear(); + assetsManager.Options.ParseByTypeTree = !CLIOptions.f_avoidLoadingViaTypetree.Value; + assetsManager.Options.GameSpecific.CustomUnityVersion = CLIOptions.o_unityVersion.Value; + assetsManager.Options.GameSpecific.Bundles.CustomBlockInfoCompression = CLIOptions.o_bundleBlockInfoCompression.Value; + assetsManager.Options.GameSpecific.Bundles.CustomBlockCompression = CLIOptions.o_bundleBlockCompression.Value; + assetsManager.Options.CustomCachePath = CLIOptions.o_cachePath.Value; + assetsManager.Options.DecompressToDisk = CLIOptions.f_decompressToDisk.Value; + assetsManager.ClearOptionLoaders(); } private static void ShowCurProgressValue(int value) diff --git a/AssetStudioGUI/AssetStudioGUIForm.Designer.cs b/AssetStudioGUI/AssetStudioGUIForm.Designer.cs index e4c9a3c..a666464 100644 --- a/AssetStudioGUI/AssetStudioGUIForm.Designer.cs +++ b/AssetStudioGUI/AssetStudioGUIForm.Designer.cs @@ -39,23 +39,23 @@ this.extractFolderToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.optionsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.displayAll = new System.Windows.Forms.ToolStripMenuItem(); - this.useAssetLoadingViaTypetreeToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.meshLazyLoadToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.assetLoadingToolStripSeparator = new System.Windows.Forms.ToolStripSeparator(); + this.parseByTypetreeToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.decompressBundlesToDiskToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.buildSceneHierarchyToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.moreStudioOptionsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.optionsMenuSeparator = new System.Windows.Forms.ToolStripSeparator(); this.enablePreview = new System.Windows.Forms.ToolStripMenuItem(); this.displayInfo = new System.Windows.Forms.ToolStripMenuItem(); this.autoPlayAudioAssetsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.useDumpTreeViewToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.buildTreeStructureToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.importOptionsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.optionsMenuSeparator2 = new System.Windows.Forms.ToolStripSeparator(); + this.gameOptionsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.customUnityVersionToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.specifyUnityVersionTextBox = new System.Windows.Forms.ToolStripTextBox(); - this.bundleDecompressionToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.alwaysDecompressToDiskToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.importOptionsToolStripSeparator = new System.Windows.Forms.ToolStripSeparator(); - this.saveOptionsToDiskToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.importOptionsToolStripSeparator2 = new System.Windows.Forms.ToolStripSeparator(); - this.moreOptionsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.gameOptionsToolStripSeparator = new System.Windows.Forms.ToolStripSeparator(); + this.saveGameOptionsToDiskToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.gameOptionsToolStripSeparator2 = new System.Windows.Forms.ToolStripSeparator(); + this.moreGameOptionsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.showExpOpt = new System.Windows.Forms.ToolStripMenuItem(); this.modelToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.exportAllObjectssplitToolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem(); @@ -239,90 +239,110 @@ // loadFileToolStripMenuItem // this.loadFileToolStripMenuItem.Name = "loadFileToolStripMenuItem"; - this.loadFileToolStripMenuItem.Size = new System.Drawing.Size(144, 22); - this.loadFileToolStripMenuItem.Text = "Load file"; + this.loadFileToolStripMenuItem.Size = new System.Drawing.Size(153, 22); + this.loadFileToolStripMenuItem.Text = "Load file..."; this.loadFileToolStripMenuItem.Click += new System.EventHandler(this.loadFile_Click); // // loadFolderToolStripMenuItem // this.loadFolderToolStripMenuItem.Name = "loadFolderToolStripMenuItem"; - this.loadFolderToolStripMenuItem.Size = new System.Drawing.Size(144, 22); - this.loadFolderToolStripMenuItem.Text = "Load folder"; + this.loadFolderToolStripMenuItem.Size = new System.Drawing.Size(153, 22); + this.loadFolderToolStripMenuItem.Text = "Load folder..."; this.loadFolderToolStripMenuItem.Click += new System.EventHandler(this.loadFolder_Click); // // toolStripMenuItem1 // this.toolStripMenuItem1.Name = "toolStripMenuItem1"; - this.toolStripMenuItem1.Size = new System.Drawing.Size(141, 6); + this.toolStripMenuItem1.Size = new System.Drawing.Size(150, 6); // // extractFileToolStripMenuItem // this.extractFileToolStripMenuItem.Name = "extractFileToolStripMenuItem"; - this.extractFileToolStripMenuItem.Size = new System.Drawing.Size(144, 22); - this.extractFileToolStripMenuItem.Text = "Extract file"; + this.extractFileToolStripMenuItem.Size = new System.Drawing.Size(153, 22); + this.extractFileToolStripMenuItem.Text = "Extract file..."; this.extractFileToolStripMenuItem.Click += new System.EventHandler(this.extractFileToolStripMenuItem_Click); // // extractFolderToolStripMenuItem // this.extractFolderToolStripMenuItem.Name = "extractFolderToolStripMenuItem"; - this.extractFolderToolStripMenuItem.Size = new System.Drawing.Size(144, 22); - this.extractFolderToolStripMenuItem.Text = "Extract folder"; + this.extractFolderToolStripMenuItem.Size = new System.Drawing.Size(153, 22); + this.extractFolderToolStripMenuItem.Text = "Extract folder..."; this.extractFolderToolStripMenuItem.Click += new System.EventHandler(this.extractFolderToolStripMenuItem_Click); // // optionsToolStripMenuItem // this.optionsToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { this.displayAll, - this.useAssetLoadingViaTypetreeToolStripMenuItem, - this.meshLazyLoadToolStripMenuItem, - this.assetLoadingToolStripSeparator, + this.parseByTypetreeToolStripMenuItem, + this.decompressBundlesToDiskToolStripMenuItem, + this.buildSceneHierarchyToolStripMenuItem, + this.moreStudioOptionsToolStripMenuItem, + this.optionsMenuSeparator, this.enablePreview, this.displayInfo, this.autoPlayAudioAssetsToolStripMenuItem, this.useDumpTreeViewToolStripMenuItem, - this.buildTreeStructureToolStripMenuItem, - this.importOptionsToolStripMenuItem, + this.optionsMenuSeparator2, + this.gameOptionsToolStripMenuItem, this.showExpOpt}); this.optionsToolStripMenuItem.Name = "optionsToolStripMenuItem"; this.optionsToolStripMenuItem.Size = new System.Drawing.Size(61, 20); this.optionsToolStripMenuItem.Text = "Options"; + this.optionsToolStripMenuItem.DropDownOpening += new System.EventHandler(this.optionsToolStripMenuItem_DropDownOpening); // // displayAll // this.displayAll.CheckOnClick = true; this.displayAll.Name = "displayAll"; - this.displayAll.Size = new System.Drawing.Size(243, 22); + this.displayAll.Size = new System.Drawing.Size(241, 22); this.displayAll.Text = "Display all assets"; this.displayAll.ToolTipText = "Check this option will display all types assets. Not extractable assets can expor" + "t the RAW file."; this.displayAll.CheckedChanged += new System.EventHandler(this.displayAll_CheckedChanged); // - // useAssetLoadingViaTypetreeToolStripMenuItem + // parseByTypetreeToolStripMenuItem // - this.useAssetLoadingViaTypetreeToolStripMenuItem.Checked = true; - this.useAssetLoadingViaTypetreeToolStripMenuItem.CheckOnClick = true; - this.useAssetLoadingViaTypetreeToolStripMenuItem.CheckState = System.Windows.Forms.CheckState.Checked; - this.useAssetLoadingViaTypetreeToolStripMenuItem.Name = "useAssetLoadingViaTypetreeToolStripMenuItem"; - this.useAssetLoadingViaTypetreeToolStripMenuItem.Size = new System.Drawing.Size(243, 22); - this.useAssetLoadingViaTypetreeToolStripMenuItem.Text = "Parse assets using their typetree"; - this.useAssetLoadingViaTypetreeToolStripMenuItem.ToolTipText = "(Applies to assets with typetree included). Slower but can parse non-standard ass" + - "ets. Only for Texture2D, AnimationClip and Material assets for now."; - this.useAssetLoadingViaTypetreeToolStripMenuItem.CheckedChanged += new System.EventHandler(this.useAssetLoadingViaTypetreeToolStripMenuItem_CheckedChanged); + this.parseByTypetreeToolStripMenuItem.Checked = true; + this.parseByTypetreeToolStripMenuItem.CheckOnClick = true; + this.parseByTypetreeToolStripMenuItem.CheckState = System.Windows.Forms.CheckState.Checked; + this.parseByTypetreeToolStripMenuItem.Name = "parseByTypetreeToolStripMenuItem"; + this.parseByTypetreeToolStripMenuItem.Size = new System.Drawing.Size(241, 22); + this.parseByTypetreeToolStripMenuItem.Text = "Parse assets using their typetree"; + this.parseByTypetreeToolStripMenuItem.ToolTipText = "(Applies to assets with typetree included)\r\nSlower but can parse non-standard ass" + + "ets.\r\nOnly for Texture2D, AnimationClip and Material assets for now."; + this.parseByTypetreeToolStripMenuItem.CheckedChanged += new System.EventHandler(this.parseByTypetreeToolStripMenuItem_CheckedChanged); // - // meshLazyLoadToolStripMenuItem + // decompressBundlesToDiskToolStripMenuItem // - this.meshLazyLoadToolStripMenuItem.Checked = true; - this.meshLazyLoadToolStripMenuItem.CheckOnClick = true; - this.meshLazyLoadToolStripMenuItem.CheckState = System.Windows.Forms.CheckState.Checked; - this.meshLazyLoadToolStripMenuItem.Name = "meshLazyLoadToolStripMenuItem"; - this.meshLazyLoadToolStripMenuItem.Size = new System.Drawing.Size(243, 22); - this.meshLazyLoadToolStripMenuItem.Text = "Use lazy loading for Mesh assets"; - this.meshLazyLoadToolStripMenuItem.CheckedChanged += new System.EventHandler(this.meshLazyLoadToolStripMenuItem_CheckedChanged); + this.decompressBundlesToDiskToolStripMenuItem.CheckOnClick = true; + this.decompressBundlesToDiskToolStripMenuItem.Name = "decompressBundlesToDiskToolStripMenuItem"; + this.decompressBundlesToDiskToolStripMenuItem.Size = new System.Drawing.Size(241, 22); + this.decompressBundlesToDiskToolStripMenuItem.Text = "Decompress bundles to disk"; + this.decompressBundlesToDiskToolStripMenuItem.ToolTipText = "If not selected, any bundles less than 2GB will be decompressed to RAM"; + this.decompressBundlesToDiskToolStripMenuItem.CheckedChanged += new System.EventHandler(this.decompressBundlesToDiskToolStripMenuItem_CheckedChanged); // - // assetLoadingToolStripSeparator + // buildSceneHierarchyToolStripMenuItem // - this.assetLoadingToolStripSeparator.Name = "assetLoadingToolStripSeparator"; - this.assetLoadingToolStripSeparator.Size = new System.Drawing.Size(240, 6); + this.buildSceneHierarchyToolStripMenuItem.Checked = true; + this.buildSceneHierarchyToolStripMenuItem.CheckOnClick = true; + this.buildSceneHierarchyToolStripMenuItem.CheckState = System.Windows.Forms.CheckState.Checked; + this.buildSceneHierarchyToolStripMenuItem.Name = "buildSceneHierarchyToolStripMenuItem"; + this.buildSceneHierarchyToolStripMenuItem.Size = new System.Drawing.Size(241, 22); + this.buildSceneHierarchyToolStripMenuItem.Text = "Build scene hierarchy"; + this.buildSceneHierarchyToolStripMenuItem.ToolTipText = "You can disable tree structure building if you don\'t use the Scene Hierarchy tab"; + this.buildSceneHierarchyToolStripMenuItem.CheckedChanged += new System.EventHandler(this.buildSceneHierarchyToolStripMenuItem_CheckedChanged); + // + // moreStudioOptionsToolStripMenuItem + // + this.moreStudioOptionsToolStripMenuItem.Name = "moreStudioOptionsToolStripMenuItem"; + this.moreStudioOptionsToolStripMenuItem.Size = new System.Drawing.Size(241, 22); + this.moreStudioOptionsToolStripMenuItem.Text = "More options..."; + this.moreStudioOptionsToolStripMenuItem.Click += new System.EventHandler(this.moreStudioOptionsToolStripMenuItem_Click); + // + // optionsMenuSeparator + // + this.optionsMenuSeparator.Name = "optionsMenuSeparator"; + this.optionsMenuSeparator.Size = new System.Drawing.Size(238, 6); // // enablePreview // @@ -330,7 +350,7 @@ this.enablePreview.CheckOnClick = true; this.enablePreview.CheckState = System.Windows.Forms.CheckState.Checked; this.enablePreview.Name = "enablePreview"; - this.enablePreview.Size = new System.Drawing.Size(243, 22); + this.enablePreview.Size = new System.Drawing.Size(241, 22); this.enablePreview.Text = "Enable preview"; this.enablePreview.ToolTipText = "Toggle the loading and preview of readable assets, such as images, sounds, text, " + "etc.\r\nDisable preview if you have performance or compatibility issues."; @@ -342,7 +362,7 @@ this.displayInfo.CheckOnClick = true; this.displayInfo.CheckState = System.Windows.Forms.CheckState.Checked; this.displayInfo.Name = "displayInfo"; - this.displayInfo.Size = new System.Drawing.Size(243, 22); + this.displayInfo.Size = new System.Drawing.Size(241, 22); this.displayInfo.Text = "Display asset information"; this.displayInfo.ToolTipText = "Toggle the overlay that shows information about each asset, eg. image size, forma" + "t, audio bitrate, etc."; @@ -352,7 +372,7 @@ // this.autoPlayAudioAssetsToolStripMenuItem.CheckOnClick = true; this.autoPlayAudioAssetsToolStripMenuItem.Name = "autoPlayAudioAssetsToolStripMenuItem"; - this.autoPlayAudioAssetsToolStripMenuItem.Size = new System.Drawing.Size(243, 22); + this.autoPlayAudioAssetsToolStripMenuItem.Size = new System.Drawing.Size(241, 22); this.autoPlayAudioAssetsToolStripMenuItem.Text = "Autoplay audio assets"; this.autoPlayAudioAssetsToolStripMenuItem.ToolTipText = "Autoplay AudioClip assets when selected"; this.autoPlayAudioAssetsToolStripMenuItem.CheckedChanged += new System.EventHandler(this.autoPlayAudioAssetsToolStripMenuItem_CheckedChanged); @@ -361,37 +381,29 @@ // this.useDumpTreeViewToolStripMenuItem.CheckOnClick = true; this.useDumpTreeViewToolStripMenuItem.Name = "useDumpTreeViewToolStripMenuItem"; - this.useDumpTreeViewToolStripMenuItem.Size = new System.Drawing.Size(243, 22); + this.useDumpTreeViewToolStripMenuItem.Size = new System.Drawing.Size(241, 22); this.useDumpTreeViewToolStripMenuItem.Text = "Use tree view to display dump"; this.useDumpTreeViewToolStripMenuItem.CheckedChanged += new System.EventHandler(this.useDumpTreeViewToolStripMenuItem_CheckedChanged); // - // buildTreeStructureToolStripMenuItem + // optionsMenuSeparator2 // - this.buildTreeStructureToolStripMenuItem.Checked = true; - this.buildTreeStructureToolStripMenuItem.CheckOnClick = true; - this.buildTreeStructureToolStripMenuItem.CheckState = System.Windows.Forms.CheckState.Checked; - this.buildTreeStructureToolStripMenuItem.Name = "buildTreeStructureToolStripMenuItem"; - this.buildTreeStructureToolStripMenuItem.Size = new System.Drawing.Size(243, 22); - this.buildTreeStructureToolStripMenuItem.Text = "Build tree structure"; - this.buildTreeStructureToolStripMenuItem.ToolTipText = "You can disable tree structure building if you don\'t use the Scene Hierarchy tab"; - this.buildTreeStructureToolStripMenuItem.CheckedChanged += new System.EventHandler(this.buildTreeStructureToolStripMenuItem_CheckedChanged); + this.optionsMenuSeparator2.Name = "optionsMenuSeparator2"; + this.optionsMenuSeparator2.Size = new System.Drawing.Size(238, 6); // - // importOptionsToolStripMenuItem + // gameOptionsToolStripMenuItem // - this.importOptionsToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.gameOptionsToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { this.customUnityVersionToolStripMenuItem, this.specifyUnityVersionTextBox, - this.bundleDecompressionToolStripMenuItem, - this.alwaysDecompressToDiskToolStripMenuItem, - this.importOptionsToolStripSeparator, - this.saveOptionsToDiskToolStripMenuItem, - this.importOptionsToolStripSeparator2, - this.moreOptionsToolStripMenuItem}); - this.importOptionsToolStripMenuItem.Name = "importOptionsToolStripMenuItem"; - this.importOptionsToolStripMenuItem.Size = new System.Drawing.Size(243, 22); - this.importOptionsToolStripMenuItem.Text = "Import options"; - this.importOptionsToolStripMenuItem.DropDownClosed += new System.EventHandler(this.importOptions_DropDownClose); - this.importOptionsToolStripMenuItem.DropDownOpened += new System.EventHandler(this.importOptions_DropDownOpened); + this.gameOptionsToolStripSeparator, + this.saveGameOptionsToDiskToolStripMenuItem, + this.gameOptionsToolStripSeparator2, + this.moreGameOptionsToolStripMenuItem}); + this.gameOptionsToolStripMenuItem.Name = "gameOptionsToolStripMenuItem"; + this.gameOptionsToolStripMenuItem.Size = new System.Drawing.Size(241, 22); + this.gameOptionsToolStripMenuItem.Text = "Game-specific options"; + this.gameOptionsToolStripMenuItem.DropDownClosed += new System.EventHandler(this.gameOptions_DropDownClose); + this.gameOptionsToolStripMenuItem.DropDownOpened += new System.EventHandler(this.gameOptions_DropDownOpened); // // customUnityVersionToolStripMenuItem // @@ -410,56 +422,38 @@ this.specifyUnityVersionTextBox.Size = new System.Drawing.Size(100, 23); this.specifyUnityVersionTextBox.ToolTipText = "Specify full Unity version, including letters at the end\r\nExample: 2022.3.2f1"; // - // bundleDecompressionToolStripMenuItem + // gameOptionsToolStripSeparator // - this.bundleDecompressionToolStripMenuItem.Enabled = false; - this.bundleDecompressionToolStripMenuItem.Name = "bundleDecompressionToolStripMenuItem"; - this.bundleDecompressionToolStripMenuItem.ShowShortcutKeys = false; - this.bundleDecompressionToolStripMenuItem.Size = new System.Drawing.Size(213, 22); - this.bundleDecompressionToolStripMenuItem.Text = "Bundle Decompression"; + this.gameOptionsToolStripSeparator.Name = "gameOptionsToolStripSeparator"; + this.gameOptionsToolStripSeparator.Overflow = System.Windows.Forms.ToolStripItemOverflow.Never; + this.gameOptionsToolStripSeparator.Size = new System.Drawing.Size(210, 6); // - // alwaysDecompressToDiskToolStripMenuItem + // saveGameOptionsToDiskToolStripMenuItem // - this.alwaysDecompressToDiskToolStripMenuItem.CheckOnClick = true; - this.alwaysDecompressToDiskToolStripMenuItem.Name = "alwaysDecompressToDiskToolStripMenuItem"; - this.alwaysDecompressToDiskToolStripMenuItem.ShowShortcutKeys = false; - this.alwaysDecompressToDiskToolStripMenuItem.Size = new System.Drawing.Size(213, 22); - this.alwaysDecompressToDiskToolStripMenuItem.Text = "Always decompress to disk"; - this.alwaysDecompressToDiskToolStripMenuItem.ToolTipText = "If not selected, any bundles less than 2GB will be decompressed to RAM"; - this.alwaysDecompressToDiskToolStripMenuItem.Click += new System.EventHandler(this.alwaysDecompressToDiskToolStripMenuItem_Click); + this.saveGameOptionsToDiskToolStripMenuItem.Name = "saveGameOptionsToDiskToolStripMenuItem"; + this.saveGameOptionsToDiskToolStripMenuItem.ShowShortcutKeys = false; + this.saveGameOptionsToDiskToolStripMenuItem.Size = new System.Drawing.Size(213, 22); + this.saveGameOptionsToDiskToolStripMenuItem.Text = "Save current options to disk"; + this.saveGameOptionsToDiskToolStripMenuItem.Click += new System.EventHandler(this.saveOptionsToDiskToolStripMenuItem_Click); // - // importOptionsToolStripSeparator + // gameOptionsToolStripSeparator2 // - this.importOptionsToolStripSeparator.Name = "importOptionsToolStripSeparator"; - this.importOptionsToolStripSeparator.Overflow = System.Windows.Forms.ToolStripItemOverflow.Never; - this.importOptionsToolStripSeparator.Size = new System.Drawing.Size(210, 6); + this.gameOptionsToolStripSeparator2.Name = "gameOptionsToolStripSeparator2"; + this.gameOptionsToolStripSeparator2.Overflow = System.Windows.Forms.ToolStripItemOverflow.Never; + this.gameOptionsToolStripSeparator2.Size = new System.Drawing.Size(210, 6); // - // saveOptionsToDiskToolStripMenuItem + // moreGameOptionsToolStripMenuItem // - this.saveOptionsToDiskToolStripMenuItem.Name = "saveOptionsToDiskToolStripMenuItem"; - this.saveOptionsToDiskToolStripMenuItem.ShowShortcutKeys = false; - this.saveOptionsToDiskToolStripMenuItem.Size = new System.Drawing.Size(213, 22); - this.saveOptionsToDiskToolStripMenuItem.Text = "Save current options to disk"; - this.saveOptionsToDiskToolStripMenuItem.Click += new System.EventHandler(this.saveOptionsToDiskToolStripMenuItem_Click); - // - // importOptionsToolStripSeparator2 - // - this.importOptionsToolStripSeparator2.Name = "importOptionsToolStripSeparator2"; - this.importOptionsToolStripSeparator2.Overflow = System.Windows.Forms.ToolStripItemOverflow.Never; - this.importOptionsToolStripSeparator2.Size = new System.Drawing.Size(210, 6); - // - // moreOptionsToolStripMenuItem - // - this.moreOptionsToolStripMenuItem.Name = "moreOptionsToolStripMenuItem"; - this.moreOptionsToolStripMenuItem.Size = new System.Drawing.Size(213, 22); - this.moreOptionsToolStripMenuItem.Text = "More options..."; - this.moreOptionsToolStripMenuItem.Click += new System.EventHandler(this.moreOptionsToolStripMenuItem_Click); + this.moreGameOptionsToolStripMenuItem.Name = "moreGameOptionsToolStripMenuItem"; + this.moreGameOptionsToolStripMenuItem.Size = new System.Drawing.Size(213, 22); + this.moreGameOptionsToolStripMenuItem.Text = "More options..."; + this.moreGameOptionsToolStripMenuItem.Click += new System.EventHandler(this.moreGameOptionsToolStripMenuItem_Click); // // showExpOpt // this.showExpOpt.Name = "showExpOpt"; - this.showExpOpt.Size = new System.Drawing.Size(243, 22); - this.showExpOpt.Text = "Export options"; + this.showExpOpt.Size = new System.Drawing.Size(241, 22); + this.showExpOpt.Text = "Export options..."; this.showExpOpt.Click += new System.EventHandler(this.showExpOpt_Click); // // modelToolStripMenuItem @@ -1851,7 +1845,7 @@ private System.Windows.Forms.ListView assetListView; private System.Windows.Forms.ToolStripMenuItem showConsoleToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem writeLogToFileToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem buildTreeStructureToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem buildSceneHierarchyToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem exportL2DWithClipsToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem exportAsLive2DModelToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem live2DCubismModelsToolStripMenuItem; @@ -1862,8 +1856,8 @@ private System.Windows.Forms.ToolStripMenuItem exportL2DWithFadeToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem l2DModelWithFadeListToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem exportL2DWithFadeLstToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem useAssetLoadingViaTypetreeToolStripMenuItem; - private System.Windows.Forms.ToolStripSeparator assetLoadingToolStripSeparator; + private System.Windows.Forms.ToolStripMenuItem parseByTypetreeToolStripMenuItem; + private System.Windows.Forms.ToolStripSeparator optionsMenuSeparator; private System.Windows.Forms.TreeView dumpTreeView; private System.Windows.Forms.ContextMenuStrip dumpTreeViewContextMenuStrip; private System.Windows.Forms.ToolStripMenuItem tvCopyValToolStripMenuItem; @@ -1878,19 +1872,19 @@ private System.Windows.Forms.Label FMODaudioChannelsLabel; private System.Windows.Forms.ToolStripMenuItem autoPlayAudioAssetsToolStripMenuItem; private System.Windows.Forms.CheckBox sceneExactSearchCheckBox; - private System.Windows.Forms.ToolStripMenuItem importOptionsToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem gameOptionsToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem customUnityVersionToolStripMenuItem; private System.Windows.Forms.ToolStripTextBox specifyUnityVersionTextBox; - private System.Windows.Forms.ToolStripMenuItem bundleDecompressionToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem alwaysDecompressToDiskToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem saveOptionsToDiskToolStripMenuItem; - private System.Windows.Forms.ToolStripSeparator importOptionsToolStripSeparator2; - private System.Windows.Forms.ToolStripMenuItem meshLazyLoadToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem saveGameOptionsToDiskToolStripMenuItem; + private System.Windows.Forms.ToolStripSeparator gameOptionsToolStripSeparator2; private System.Windows.Forms.Panel panel2; private System.Windows.Forms.ToolStripMenuItem tvCopyNameToolStripMenuItem; - private System.Windows.Forms.ToolStripSeparator importOptionsToolStripSeparator; - private System.Windows.Forms.ToolStripMenuItem moreOptionsToolStripMenuItem; + private System.Windows.Forms.ToolStripSeparator gameOptionsToolStripSeparator; + private System.Windows.Forms.ToolStripMenuItem moreGameOptionsToolStripMenuItem; private System.Windows.Forms.ToolStripStatusLabel unityVersionStatusLabel; + private System.Windows.Forms.ToolStripMenuItem moreStudioOptionsToolStripMenuItem; + private System.Windows.Forms.ToolStripSeparator optionsMenuSeparator2; + private System.Windows.Forms.ToolStripMenuItem decompressBundlesToDiskToolStripMenuItem; } } diff --git a/AssetStudioGUI/AssetStudioGUIForm.cs b/AssetStudioGUI/AssetStudioGUIForm.cs index cee4904..d5c4e63 100644 --- a/AssetStudioGUI/AssetStudioGUIForm.cs +++ b/AssetStudioGUI/AssetStudioGUIForm.cs @@ -37,7 +37,7 @@ namespace AssetStudioGUI private DirectBitmap imageTexture; private string tempClipboard; private bool isDarkMode; - private ImportOptionsForm importOptionsForm; + private GameOptionsForm gameOptionsForm; #region FMODControl private FMOD.System system; @@ -135,7 +135,7 @@ namespace AssetStudioGUI Thread.CurrentThread.CurrentCulture = new CultureInfo("en-US"); ConsoleWindow.RunConsole(Properties.Settings.Default.showConsole); InitializeComponent(); - ApplyColorTheme(out isDarkMode); + ApplyColorTheme(); var appAssembly = typeof(Program).Assembly.GetName(); guiTitle = $"{appAssembly.Name} v{appAssembly.Version}"; @@ -143,25 +143,27 @@ namespace AssetStudioGUI delayTimer = new System.Timers.Timer(800); delayTimer.Elapsed += delayTimer_Elapsed; + displayAll.Checked = Properties.Settings.Default.displayAll; - displayInfo.Checked = Properties.Settings.Default.displayInfo; + parseByTypetreeToolStripMenuItem.Checked = Properties.Settings.Default.useTypetreeLoading; + decompressBundlesToDiskToolStripMenuItem.Checked = Properties.Settings.Default.decompressToDisk; + buildSceneHierarchyToolStripMenuItem.Checked = Properties.Settings.Default.buildTreeStructure; enablePreview.Checked = Properties.Settings.Default.enablePreview; - showConsoleToolStripMenuItem.Checked = Properties.Settings.Default.showConsole; - buildTreeStructureToolStripMenuItem.Checked = Properties.Settings.Default.buildTreeStructure; - useAssetLoadingViaTypetreeToolStripMenuItem.Checked = Properties.Settings.Default.useTypetreeLoading; - useDumpTreeViewToolStripMenuItem.Checked = Properties.Settings.Default.useDumpTreeView; + displayInfo.Checked = Properties.Settings.Default.displayInfo; autoPlayAudioAssetsToolStripMenuItem.Checked = Properties.Settings.Default.autoplayAudio; - meshLazyLoadToolStripMenuItem.Checked = Properties.Settings.Default.meshLazyLoad; - assetsManager.Options.BundleOptions.DecompressToDisk = Properties.Settings.Default.decompressToDisk; - assetsManager.Options.BundleOptions.CustomCachePath = GetCachePath(); - assetsManager.Options.UnityVersionChanged += OnUnityVersionChanged; - unityVersionStatusLabel.Visible = false; + useDumpTreeViewToolStripMenuItem.Checked = Properties.Settings.Default.useDumpTreeView; + + assetsManager.Options.CustomCachePath = GetCachePath(); + assetsManager.Options.MeshPreProcessing = Properties.Settings.Default.meshPreProcessing; + assetsManager.Options.GameSpecific.UnityVersionChanged += OnUnityVersionChanged; + FbxInitOrLoadOptions(Properties.Settings.Default.fbxSettings); + FMODinit(); listSearchFilterMode.SelectedIndex = 0; - FbxInitOptions(Properties.Settings.Default.fbxSettings); logger = new GUILogger(StatusStripUpdate); Logger.Default = logger; + showConsoleToolStripMenuItem.Checked = Properties.Settings.Default.showConsole; writeLogToFileToolStripMenuItem.Checked = Properties.Settings.Default.useFileLogger; progressBarTextFont = new System.Drawing.Font(FontFamily.GenericSansSerif, 8); @@ -175,6 +177,8 @@ namespace AssetStudioGUI Progress.Default = new Progress(SetProgressBarValue); Progress.SetInstance(index: 1, new Progress(SetProgressBarStringValue)); Studio.StatusStripUpdate = StatusStripUpdate; + + unityVersionStatusLabel.Visible = false; } private static string GetCachePath() @@ -2309,9 +2313,17 @@ namespace AssetStudioGUI Logger.Verbose("Closing AssetStudio"); } - private void buildTreeStructureToolStripMenuItem_CheckedChanged(object sender, EventArgs e) + private void decompressBundlesToDiskToolStripMenuItem_CheckedChanged(object sender, EventArgs e) { - Properties.Settings.Default.buildTreeStructure = buildTreeStructureToolStripMenuItem.Checked; + var isEnabled = decompressBundlesToDiskToolStripMenuItem.Checked; + assetsManager.Options.DecompressToDisk = isEnabled; + Properties.Settings.Default.decompressToDisk = isEnabled; + Properties.Settings.Default.Save(); + } + + private void buildSceneHierarchyToolStripMenuItem_CheckedChanged(object sender, EventArgs e) + { + Properties.Settings.Default.buildTreeStructure = buildSceneHierarchyToolStripMenuItem.Checked; Properties.Settings.Default.Save(); } @@ -2448,17 +2460,25 @@ namespace AssetStudioGUI } } - private void importOptions_DropDownClose(object sender, EventArgs e) + private void optionsToolStripMenuItem_DropDownOpening(object sender, EventArgs e) + { + displayAll.Checked = Properties.Settings.Default.displayAll; + parseByTypetreeToolStripMenuItem.Checked = assetsManager.Options.ParseByTypeTree; + decompressBundlesToDiskToolStripMenuItem.Checked = assetsManager.Options.DecompressToDisk; + buildSceneHierarchyToolStripMenuItem.Checked = Properties.Settings.Default.buildTreeStructure; + } + + private void gameOptions_DropDownClose(object sender, EventArgs e) { if (string.IsNullOrEmpty(specifyUnityVersionTextBox.Text)) { - assetsManager.Options.CustomUnityVersion = null; + assetsManager.Options.GameSpecific.CustomUnityVersion = null; return; } try { - assetsManager.Options.CustomUnityVersion = new UnityVersion(specifyUnityVersionTextBox.Text); + assetsManager.Options.GameSpecific.CustomUnityVersion = new UnityVersion(specifyUnityVersionTextBox.Text); } catch (Exception ex) { @@ -2466,27 +2486,18 @@ namespace AssetStudioGUI } } - private void importOptions_DropDownOpened(object sender, EventArgs e) + private void gameOptions_DropDownOpened(object sender, EventArgs e) { - if (assetsManager.Options.CustomUnityVersion != null) + if (assetsManager.Options.GameSpecific.CustomUnityVersion != null) { - specifyUnityVersionTextBox.Text = assetsManager.Options.CustomUnityVersion.FullVersion; + specifyUnityVersionTextBox.Text = assetsManager.Options.GameSpecific.CustomUnityVersion.FullVersion; } - alwaysDecompressToDiskToolStripMenuItem.Checked = assetsManager.Options.BundleOptions.DecompressToDisk; //highDpi workaround var font = customUnityVersionToolStripMenuItem.Font; specifyUnityVersionTextBox.Font = font; } - private void alwaysDecompressToDiskToolStripMenuItem_Click(object sender, EventArgs e) - { - var isEnabled = alwaysDecompressToDiskToolStripMenuItem.Checked; - assetsManager.Options.BundleOptions.DecompressToDisk = isEnabled; - Properties.Settings.Default.decompressToDisk = isEnabled; - Properties.Settings.Default.Save(); - } - private void saveOptionsToDiskToolStripMenuItem_Click(object sender, EventArgs e) { var saveFolderDialog = new OpenFolderDialog(); @@ -2494,21 +2505,20 @@ namespace AssetStudioGUI if (saveFolderDialog.ShowDialog(this) == DialogResult.OK) { var savePath = saveFolderDialog.Folder; - assetsManager.Options.SaveToFile(savePath); + assetsManager.Options.GameSpecific.SaveToFile(savePath); } } - private void useAssetLoadingViaTypetreeToolStripMenuItem_CheckedChanged(object sender, EventArgs e) + private void parseByTypetreeToolStripMenuItem_CheckedChanged(object sender, EventArgs e) { - var isEnabled = useAssetLoadingViaTypetreeToolStripMenuItem.Checked; - assetsManager.LoadViaTypeTree = isEnabled; + var isEnabled = parseByTypetreeToolStripMenuItem.Checked; + assetsManager.Options.ParseByTypeTree = isEnabled; Properties.Settings.Default.useTypetreeLoading = isEnabled; Properties.Settings.Default.Save(); } - private void ApplyColorTheme(out bool isDarkMode) + private void ApplyColorTheme() { - isDarkMode = false; if (SystemInformation.HighContrast) return; @@ -2678,14 +2688,7 @@ namespace AssetStudioGUI Properties.Settings.Default.Save(); } - private void meshLazyLoadToolStripMenuItem_CheckedChanged(object sender, EventArgs e) - { - Properties.Settings.Default.meshLazyLoad = meshLazyLoadToolStripMenuItem.Checked; - assetsManager.MeshLazyLoad = meshLazyLoadToolStripMenuItem.Checked; - Properties.Settings.Default.Save(); - } - - private static void FbxInitOptions(string base64String) + private static void FbxInitOrLoadOptions(string base64String) { if (string.IsNullOrEmpty(base64String)) { @@ -2699,22 +2702,28 @@ namespace AssetStudioGUI } } - private void moreOptionsToolStripMenuItem_Click(object sender, EventArgs e) + private void moreGameOptionsToolStripMenuItem_Click(object sender, EventArgs e) { - if (importOptionsForm == null || importOptionsForm.IsDisposed) + if (gameOptionsForm == null || gameOptionsForm.IsDisposed) { - importOptionsForm = new ImportOptionsForm(assetsManager); - importOptionsForm.Show(this); + gameOptionsForm = new GameOptionsForm(assetsManager.Options.GameSpecific); + gameOptionsForm.Show(this); } else { - importOptionsForm.Focus(); + gameOptionsForm.Focus(); } } + private void moreStudioOptionsToolStripMenuItem_Click(object sender, EventArgs e) + { + var studioOptions = new StudioOptionsForm(assetsManager.Options); + studioOptions.ShowDialog(this); + } + private void OnUnityVersionChanged(object s, EventArgs e) { - if (assetsManager.Options.CustomUnityVersion == null) + if (assetsManager.Options.GameSpecific.CustomUnityVersion == null) { specifyUnityVersionTextBox.Text = ""; unityVersionStatusLabel.Text = ""; @@ -2722,14 +2731,14 @@ namespace AssetStudioGUI } else { - unityVersionStatusLabel.Text = assetsManager.Options.CustomUnityVersion.FullVersion; + unityVersionStatusLabel.Text = assetsManager.Options.GameSpecific.CustomUnityVersion.FullVersion; unityVersionStatusLabel.Visible = true; } } private void unityVersionStatusLabel_DoubleClick(object sender, EventArgs e) { - assetsManager.Options.CustomUnityVersion = null; + assetsManager.Options.GameSpecific.CustomUnityVersion = null; } #region FMOD diff --git a/AssetStudioGUI/AssetStudioGUIForm.resx b/AssetStudioGUI/AssetStudioGUIForm.resx index fa337eb..cd1b776 100644 --- a/AssetStudioGUI/AssetStudioGUIForm.resx +++ b/AssetStudioGUI/AssetStudioGUIForm.resx @@ -120,9 +120,6 @@ 312, 17 - - 432, 17 - abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWYZ 1234567890.:,;'\"(!?)+-*/= @@ -141,6 +138,9 @@ The quick brown fox jumps over the lazy dog. 1234567890 The quick brown fox jumps over the lazy dog. 1234567890 + + 432, 17 + 775, 21 diff --git a/AssetStudioGUI/ImportOptionsForm.Designer.cs b/AssetStudioGUI/GameOptionsForm.Designer.cs similarity index 78% rename from AssetStudioGUI/ImportOptionsForm.Designer.cs rename to AssetStudioGUI/GameOptionsForm.Designer.cs index 7ec60cf..65f604f 100644 --- a/AssetStudioGUI/ImportOptionsForm.Designer.cs +++ b/AssetStudioGUI/GameOptionsForm.Designer.cs @@ -1,6 +1,6 @@ namespace AssetStudioGUI { - partial class ImportOptionsForm + partial class GameOptionsForm { /// /// Required designer variable. @@ -29,9 +29,6 @@ private void InitializeComponent() { this.components = new System.ComponentModel.Container(); - this.cachePathLabel = new System.Windows.Forms.Label(); - this.cachePathSelectButton = new System.Windows.Forms.Button(); - this.cachePathResetButton = new System.Windows.Forms.Button(); this.unityVersionGroupBox = new System.Windows.Forms.GroupBox(); this.legacyUnityVersionComboBox = new System.Windows.Forms.ComboBox(); this.legacyUnityVersionLabel = new System.Windows.Forms.Label(); @@ -42,8 +39,6 @@ this.customBlockCompressionLabel = new System.Windows.Forms.Label(); this.customBlockInfoCompressionComboBox = new System.Windows.Forms.ComboBox(); this.customBlockInfoCompressionLabel = new System.Windows.Forms.Label(); - this.cacheFreeSpaceLabel = new System.Windows.Forms.Label(); - this.alwaysDecompressToDiskCheckBox = new System.Windows.Forms.CheckBox(); this.toolTip1 = new System.Windows.Forms.ToolTip(this.components); this.closeButton = new System.Windows.Forms.Button(); this.saveToDiskButton = new System.Windows.Forms.Button(); @@ -51,9 +46,8 @@ this.tabControl1 = new System.Windows.Forms.TabControl(); this.tabPage1 = new System.Windows.Forms.TabPage(); this.tabPage2 = new System.Windows.Forms.TabPage(); - this.cacheGroupBox = new System.Windows.Forms.GroupBox(); this.tabPage3 = new System.Windows.Forms.TabPage(); - this.groupBox1 = new System.Windows.Forms.GroupBox(); + this.tuanjieGroupBox = new System.Windows.Forms.GroupBox(); this.panel1 = new System.Windows.Forms.Panel(); this.tMeshModeUnityRadioButton = new System.Windows.Forms.RadioButton(); this.tMeshModeTuanjieRadioButton = new System.Windows.Forms.RadioButton(); @@ -64,41 +58,11 @@ this.tabControl1.SuspendLayout(); this.tabPage1.SuspendLayout(); this.tabPage2.SuspendLayout(); - this.cacheGroupBox.SuspendLayout(); this.tabPage3.SuspendLayout(); - this.groupBox1.SuspendLayout(); + this.tuanjieGroupBox.SuspendLayout(); this.panel1.SuspendLayout(); this.SuspendLayout(); // - // cachePathLabel - // - this.cachePathLabel.AutoEllipsis = true; - this.cachePathLabel.Location = new System.Drawing.Point(6, 19); - this.cachePathLabel.Name = "cachePathLabel"; - this.cachePathLabel.Size = new System.Drawing.Size(348, 20); - this.cachePathLabel.TabIndex = 0; - this.cachePathLabel.Text = "Cache directory: "; - // - // cachePathSelectButton - // - this.cachePathSelectButton.Location = new System.Drawing.Point(9, 42); - this.cachePathSelectButton.Name = "cachePathSelectButton"; - this.cachePathSelectButton.Size = new System.Drawing.Size(60, 25); - this.cachePathSelectButton.TabIndex = 1; - this.cachePathSelectButton.Text = "Select"; - this.cachePathSelectButton.UseVisualStyleBackColor = false; - this.cachePathSelectButton.Click += new System.EventHandler(this.cachePathSelectButton_Click); - // - // cachePathResetButton - // - this.cachePathResetButton.Location = new System.Drawing.Point(75, 42); - this.cachePathResetButton.Name = "cachePathResetButton"; - this.cachePathResetButton.Size = new System.Drawing.Size(60, 25); - this.cachePathResetButton.TabIndex = 2; - this.cachePathResetButton.Text = "Reset"; - this.cachePathResetButton.UseVisualStyleBackColor = false; - this.cachePathResetButton.Click += new System.EventHandler(this.cachePathResetButton_Click); - // // unityVersionGroupBox // this.unityVersionGroupBox.Controls.Add(this.legacyUnityVersionComboBox); @@ -166,10 +130,10 @@ this.decompressionGroupBox.Controls.Add(this.customBlockInfoCompressionComboBox); this.decompressionGroupBox.Controls.Add(this.customBlockInfoCompressionLabel); this.decompressionGroupBox.Dock = System.Windows.Forms.DockStyle.Top; - this.decompressionGroupBox.Location = new System.Drawing.Point(3, 126); + this.decompressionGroupBox.Location = new System.Drawing.Point(3, 3); this.decompressionGroupBox.Name = "decompressionGroupBox"; this.decompressionGroupBox.Size = new System.Drawing.Size(357, 92); - this.decompressionGroupBox.TabIndex = 1; + this.decompressionGroupBox.TabIndex = 0; this.decompressionGroupBox.TabStop = false; this.decompressionGroupBox.Text = "Decompression options"; // @@ -221,27 +185,6 @@ this.customBlockInfoCompressionLabel.TabIndex = 0; this.customBlockInfoCompressionLabel.Text = "BlockInfo compression type"; // - // cacheFreeSpaceLabel - // - this.cacheFreeSpaceLabel.AutoSize = true; - this.cacheFreeSpaceLabel.Location = new System.Drawing.Point(160, 47); - this.cacheFreeSpaceLabel.Name = "cacheFreeSpaceLabel"; - this.cacheFreeSpaceLabel.Size = new System.Drawing.Size(91, 15); - this.cacheFreeSpaceLabel.TabIndex = 3; - this.cacheFreeSpaceLabel.Text = "Available space:"; - // - // alwaysDecompressToDiskCheckBox - // - this.alwaysDecompressToDiskCheckBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.alwaysDecompressToDiskCheckBox.Location = new System.Drawing.Point(9, 82); - this.alwaysDecompressToDiskCheckBox.Name = "alwaysDecompressToDiskCheckBox"; - this.alwaysDecompressToDiskCheckBox.Size = new System.Drawing.Size(345, 19); - this.alwaysDecompressToDiskCheckBox.TabIndex = 4; - this.alwaysDecompressToDiskCheckBox.Text = "Always decompress asset bundles to disk (cache dir)"; - this.toolTip1.SetToolTip(this.alwaysDecompressToDiskCheckBox, "If not selected, any bundles less than 2GB will be decompressed to RAM"); - this.alwaysDecompressToDiskCheckBox.UseVisualStyleBackColor = true; - // // closeButton // this.closeButton.AutoSize = true; @@ -310,7 +253,6 @@ // this.tabPage2.BackColor = System.Drawing.SystemColors.Menu; this.tabPage2.Controls.Add(this.decompressionGroupBox); - this.tabPage2.Controls.Add(this.cacheGroupBox); this.tabPage2.Location = new System.Drawing.Point(4, 24); this.tabPage2.Name = "tabPage2"; this.tabPage2.Padding = new System.Windows.Forms.Padding(3); @@ -318,44 +260,28 @@ this.tabPage2.TabIndex = 1; this.tabPage2.Text = "Asset Bundles"; // - // cacheGroupBox - // - this.cacheGroupBox.AutoSize = true; - this.cacheGroupBox.Controls.Add(this.alwaysDecompressToDiskCheckBox); - this.cacheGroupBox.Controls.Add(this.cacheFreeSpaceLabel); - this.cacheGroupBox.Controls.Add(this.cachePathLabel); - this.cacheGroupBox.Controls.Add(this.cachePathSelectButton); - this.cacheGroupBox.Controls.Add(this.cachePathResetButton); - this.cacheGroupBox.Dock = System.Windows.Forms.DockStyle.Top; - this.cacheGroupBox.Location = new System.Drawing.Point(3, 3); - this.cacheGroupBox.Name = "cacheGroupBox"; - this.cacheGroupBox.Size = new System.Drawing.Size(357, 123); - this.cacheGroupBox.TabIndex = 0; - this.cacheGroupBox.TabStop = false; - this.cacheGroupBox.Text = "Disk cache"; - // // tabPage3 // this.tabPage3.AutoScroll = true; this.tabPage3.BackColor = System.Drawing.SystemColors.Menu; - this.tabPage3.Controls.Add(this.groupBox1); + this.tabPage3.Controls.Add(this.tuanjieGroupBox); this.tabPage3.Location = new System.Drawing.Point(4, 24); this.tabPage3.Name = "tabPage3"; this.tabPage3.Size = new System.Drawing.Size(363, 291); this.tabPage3.TabIndex = 2; this.tabPage3.Text = "Meshes"; // - // groupBox1 + // tuanjieGroupBox // - this.groupBox1.AutoSize = true; - this.groupBox1.Controls.Add(this.panel1); - this.groupBox1.Controls.Add(this.label1); - this.groupBox1.Location = new System.Drawing.Point(3, 3); - this.groupBox1.Name = "groupBox1"; - this.groupBox1.Size = new System.Drawing.Size(357, 82); - this.groupBox1.TabIndex = 0; - this.groupBox1.TabStop = false; - this.groupBox1.Text = "Tuanjie"; + this.tuanjieGroupBox.AutoSize = true; + this.tuanjieGroupBox.Controls.Add(this.panel1); + this.tuanjieGroupBox.Controls.Add(this.label1); + this.tuanjieGroupBox.Location = new System.Drawing.Point(3, 3); + this.tuanjieGroupBox.Name = "tuanjieGroupBox"; + this.tuanjieGroupBox.Size = new System.Drawing.Size(357, 82); + this.tuanjieGroupBox.TabIndex = 0; + this.tuanjieGroupBox.TabStop = false; + this.tuanjieGroupBox.Text = "Tuanjie engine"; // // panel1 // @@ -432,10 +358,10 @@ this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog; this.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3); this.MaximizeBox = false; - this.Name = "ImportOptionsForm"; + this.Name = "GameOptionsForm"; this.ShowIcon = false; this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; - this.Text = "Import options"; + this.Text = "Game-specific options"; this.unityVersionGroupBox.ResumeLayout(false); this.unityVersionGroupBox.PerformLayout(); this.decompressionGroupBox.ResumeLayout(false); @@ -443,13 +369,10 @@ this.tabControl1.ResumeLayout(false); this.tabPage1.ResumeLayout(false); this.tabPage2.ResumeLayout(false); - this.tabPage2.PerformLayout(); - this.cacheGroupBox.ResumeLayout(false); - this.cacheGroupBox.PerformLayout(); this.tabPage3.ResumeLayout(false); this.tabPage3.PerformLayout(); - this.groupBox1.ResumeLayout(false); - this.groupBox1.PerformLayout(); + this.tuanjieGroupBox.ResumeLayout(false); + this.tuanjieGroupBox.PerformLayout(); this.panel1.ResumeLayout(false); this.panel1.PerformLayout(); this.ResumeLayout(false); @@ -458,10 +381,6 @@ } #endregion - - private System.Windows.Forms.Label cachePathLabel; - private System.Windows.Forms.Button cachePathSelectButton; - private System.Windows.Forms.Button cachePathResetButton; private System.Windows.Forms.GroupBox unityVersionGroupBox; private System.Windows.Forms.GroupBox decompressionGroupBox; private System.Windows.Forms.ToolTip toolTip1; @@ -471,19 +390,16 @@ private System.Windows.Forms.Label customUnityVersionLabel; private System.Windows.Forms.ComboBox customBlockCompressionComboBox; private System.Windows.Forms.Label customBlockCompressionLabel; - private System.Windows.Forms.CheckBox alwaysDecompressToDiskCheckBox; private System.Windows.Forms.Button closeButton; private System.Windows.Forms.Button saveToDiskButton; private System.Windows.Forms.Button applyButton; - private System.Windows.Forms.Label cacheFreeSpaceLabel; private System.Windows.Forms.Label legacyUnityVersionLabel; private System.Windows.Forms.TabControl tabControl1; private System.Windows.Forms.TabPage tabPage1; private System.Windows.Forms.TabPage tabPage2; - private System.Windows.Forms.GroupBox cacheGroupBox; private System.Windows.Forms.ComboBox legacyUnityVersionComboBox; private System.Windows.Forms.TabPage tabPage3; - private System.Windows.Forms.GroupBox groupBox1; + private System.Windows.Forms.GroupBox tuanjieGroupBox; private System.Windows.Forms.Label label1; private System.Windows.Forms.Panel panel1; private System.Windows.Forms.RadioButton tMeshModeUnityRadioButton; diff --git a/AssetStudioGUI/ImportOptionsForm.cs b/AssetStudioGUI/GameOptionsForm.cs similarity index 63% rename from AssetStudioGUI/ImportOptionsForm.cs rename to AssetStudioGUI/GameOptionsForm.cs index c4fa474..d553b15 100644 --- a/AssetStudioGUI/ImportOptionsForm.cs +++ b/AssetStudioGUI/GameOptionsForm.cs @@ -1,39 +1,32 @@ using AssetStudio; using AssetStudio.CustomOptions; using System; -using System.Diagnostics; -using System.IO; using System.Linq; using System.Windows.Forms; namespace AssetStudioGUI { - public partial class ImportOptionsForm : Form + public partial class GameOptionsForm : Form { private static readonly string SampleVersion = "e.g. 2022.3.2f1"; - private readonly AssetsManager _assetsManager; - private string _cachePath; + private readonly GameSpecificOptions _gameOptions; - public ImportOptionsForm(AssetsManager assetsManager) + public GameOptionsForm(GameSpecificOptions gameOptions) { InitializeComponent(); - _assetsManager = assetsManager; - if (assetsManager.Options.CustomUnityVersion != null) + _gameOptions = gameOptions; + if (gameOptions.CustomUnityVersion != null) { - customUnityVersionTextBox.Text = assetsManager.Options.CustomUnityVersion.FullVersion; + customUnityVersionTextBox.Text = gameOptions.CustomUnityVersion.FullVersion; } else { ResetUnityVersionTextBox(); } legacyUnityVersionComboBox.SelectedIndex = SetLegacyUnityVersionComboBoxIndex(); - cachePathLabel.AutoSize = IsWine; //to disable AutoEllipsis in Wine - _cachePath = _assetsManager.Options.BundleOptions.CustomCachePath; - DisplayCachePath(); - alwaysDecompressToDiskCheckBox.Checked = assetsManager.Options.BundleOptions.DecompressToDisk; - customBlockInfoCompressionComboBox.SelectedIndex = SetCompressionComboBoxIndex(assetsManager.Options.BundleOptions.CustomBlockInfoCompression); - customBlockCompressionComboBox.SelectedIndex = SetCompressionComboBoxIndex(assetsManager.Options.BundleOptions.CustomBlockCompression); - var tMeshMode = assetsManager.Options.MeshOptions.TuanjieMeshParsingMode; + customBlockInfoCompressionComboBox.SelectedIndex = SetCompressionComboBoxIndex(gameOptions.Bundles.CustomBlockInfoCompression); + customBlockCompressionComboBox.SelectedIndex = SetCompressionComboBoxIndex(gameOptions.Bundles.CustomBlockCompression); + var tMeshMode = gameOptions.Meshes.TuanjieMeshParsingMode; ((RadioButton)panel1.Controls.Cast().First(x => x.TabIndex == (int)tMeshMode)).Checked = true; } @@ -41,13 +34,13 @@ namespace AssetStudioGUI { if (string.IsNullOrEmpty(customUnityVersionTextBox.Text) || customUnityVersionTextBox.Text == SampleVersion) { - _assetsManager.Options.CustomUnityVersion = null; + _gameOptions.CustomUnityVersion = null; } else { try { - _assetsManager.Options.CustomUnityVersion = new UnityVersion(customUnityVersionTextBox.Text); + _gameOptions.CustomUnityVersion = new UnityVersion(customUnityVersionTextBox.Text); legacyUnityVersionComboBox.SelectedIndex = SetLegacyUnityVersionComboBoxIndex(); } catch (Exception ex) @@ -56,22 +49,13 @@ namespace AssetStudioGUI } } - _assetsManager.Options.BundleOptions.CustomCachePath = _cachePath; - Properties.Settings.Default.cachePath = _cachePath; - var blockCompression = GetCustomCompressionTypes(customBlockCompressionComboBox.SelectedIndex); - _assetsManager.Options.BundleOptions.CustomBlockCompression = blockCompression; + _gameOptions.Bundles.CustomBlockCompression = blockCompression; var blockInfoCompression = GetCustomCompressionTypes(customBlockInfoCompressionComboBox.SelectedIndex); - _assetsManager.Options.BundleOptions.CustomBlockInfoCompression = blockInfoCompression; - - var decompressToDisk = alwaysDecompressToDiskCheckBox.Checked; - _assetsManager.Options.BundleOptions.DecompressToDisk = decompressToDisk; - Properties.Settings.Default.decompressToDisk = decompressToDisk; + _gameOptions.Bundles.CustomBlockInfoCompression = blockInfoCompression; var tMeshModeIndex = ((RadioButton)panel1.Controls.Cast().First(x => ((RadioButton)x).Checked)).TabIndex; - _assetsManager.Options.MeshOptions.TuanjieMeshParsingMode = (ImportOptions.CustomMeshOptions.MeshParsingMode)tMeshModeIndex; - - Properties.Settings.Default.Save(); + _gameOptions.Meshes.TuanjieMeshParsingMode = (GameSpecificOptions.CustomMeshOptions.MeshParsingMode)tMeshModeIndex; } #region General @@ -129,7 +113,7 @@ namespace AssetStudioGUI private int SetLegacyUnityVersionComboBoxIndex() { - var version = _assetsManager.Options.CustomUnityVersion; + var version = _gameOptions.CustomUnityVersion; switch (version?.Major) { @@ -173,33 +157,6 @@ namespace AssetStudioGUI default: throw new NotSupportedException(); } } - - private void DisplayCachePath() - { - cachePathLabel.Text = $"Cache directory: {_cachePath}"; - toolTip1.SetToolTip(cachePathLabel, _cachePath); - var driveInfo = new DriveInfo(Directory.GetDirectoryRoot(_cachePath)); - cacheFreeSpaceLabel.Text = $"Available space: {driveInfo.AvailableFreeSpace * 1.0f / 0x40000000:.00}GB"; - } - - private void cachePathSelectButton_Click(object sender, EventArgs e) - { - var cachePathFolderDialog = new OpenFolderDialog(); - cachePathFolderDialog.Title = "Select the cache directory"; - if (cachePathFolderDialog.ShowDialog(this) != DialogResult.OK) - return; - - _cachePath = cachePathFolderDialog.Folder; - DisplayCachePath(); - } - - private void cachePathResetButton_Click(object sender, EventArgs e) - { - _cachePath = Path.Combine(Directory.GetCurrentDirectory(), "temp"); - if (!Directory.Exists(_cachePath)) - Directory.CreateDirectory(_cachePath); - DisplayCachePath(); - } #endregion private void saveToDiskButton_Click(object sender, EventArgs e) @@ -210,20 +167,18 @@ namespace AssetStudioGUI if (saveFolderDialog.ShowDialog(this) == DialogResult.OK) { var savePath = saveFolderDialog.Folder; - _assetsManager.Options.SaveToFile(savePath); + _gameOptions.SaveToFile(savePath); } } - private void closeButton_Click(object sender, EventArgs e) - { - Close(); - } - private void applyButton_Click(object sender, EventArgs e) { ApplyOptions(); } - private static bool IsWine => Process.GetProcessesByName("winlogon").Length == 0; + private void closeButton_Click(object sender, EventArgs e) + { + Close(); + } } } diff --git a/AssetStudioGUI/ImportOptionsForm.resx b/AssetStudioGUI/GameOptionsForm.resx similarity index 96% rename from AssetStudioGUI/ImportOptionsForm.resx rename to AssetStudioGUI/GameOptionsForm.resx index df8339b..d54ad1e 100644 --- a/AssetStudioGUI/ImportOptionsForm.resx +++ b/AssetStudioGUI/GameOptionsForm.resx @@ -120,4 +120,7 @@ 17, 17 + + 17, 17 + \ No newline at end of file diff --git a/AssetStudioGUI/Properties/Settings.Designer.cs b/AssetStudioGUI/Properties/Settings.Designer.cs index 1dbb31d..3f40ec4 100644 --- a/AssetStudioGUI/Properties/Settings.Designer.cs +++ b/AssetStudioGUI/Properties/Settings.Designer.cs @@ -12,7 +12,7 @@ namespace AssetStudioGUI.Properties { [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "17.14.0.0")] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "18.5.0.0")] internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); @@ -349,13 +349,13 @@ namespace AssetStudioGUI.Properties { [global::System.Configuration.UserScopedSettingAttribute()] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - [global::System.Configuration.DefaultSettingValueAttribute("True")] - public bool meshLazyLoad { + [global::System.Configuration.DefaultSettingValueAttribute("False")] + public bool meshPreProcessing { get { - return ((bool)(this["meshLazyLoad"])); + return ((bool)(this["meshPreProcessing"])); } set { - this["meshLazyLoad"] = value; + this["meshPreProcessing"] = value; } } diff --git a/AssetStudioGUI/Properties/Settings.settings b/AssetStudioGUI/Properties/Settings.settings index 3d89255..729f2d0 100644 --- a/AssetStudioGUI/Properties/Settings.settings +++ b/AssetStudioGUI/Properties/Settings.settings @@ -83,8 +83,8 @@ False - - True + + False False diff --git a/AssetStudioGUI/StudioOptionsForm.Designer.cs b/AssetStudioGUI/StudioOptionsForm.Designer.cs new file mode 100644 index 0000000..9ab5117 --- /dev/null +++ b/AssetStudioGUI/StudioOptionsForm.Designer.cs @@ -0,0 +1,319 @@ +namespace AssetStudioGUI +{ + partial class StudioOptionsForm + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.components = new System.ComponentModel.Container(); + this.tabControl1 = new System.Windows.Forms.TabControl(); + this.tabPage1 = new System.Windows.Forms.TabPage(); + this.guiComponentsGroupBox = new System.Windows.Forms.GroupBox(); + this.buildSceneHierarchyCheckBox = new System.Windows.Forms.CheckBox(); + this.cacheGroupBox = new System.Windows.Forms.GroupBox(); + this.alwaysDecompressToDiskCheckBox = new System.Windows.Forms.CheckBox(); + this.cacheFreeSpaceLabel = new System.Windows.Forms.Label(); + this.cachePathLabel = new System.Windows.Forms.Label(); + this.cachePathSelectButton = new System.Windows.Forms.Button(); + this.cachePathResetButton = new System.Windows.Forms.Button(); + this.tabPage2 = new System.Windows.Forms.TabPage(); + this.groupBox2 = new System.Windows.Forms.GroupBox(); + this.meshPreProcessingCheckBox = new System.Windows.Forms.CheckBox(); + this.parseByTypetreeCheckBox = new System.Windows.Forms.CheckBox(); + this.toolTip1 = new System.Windows.Forms.ToolTip(this.components); + this.OKbutton = new System.Windows.Forms.Button(); + this.Cancel = new System.Windows.Forms.Button(); + this.displayAllCheckBox = new System.Windows.Forms.CheckBox(); + this.tabControl1.SuspendLayout(); + this.tabPage1.SuspendLayout(); + this.guiComponentsGroupBox.SuspendLayout(); + this.cacheGroupBox.SuspendLayout(); + this.tabPage2.SuspendLayout(); + this.groupBox2.SuspendLayout(); + this.SuspendLayout(); + // + // tabControl1 + // + this.tabControl1.Controls.Add(this.tabPage1); + this.tabControl1.Controls.Add(this.tabPage2); + this.tabControl1.Location = new System.Drawing.Point(12, 12); + this.tabControl1.Margin = new System.Windows.Forms.Padding(12); + this.tabControl1.Name = "tabControl1"; + this.tabControl1.SelectedIndex = 0; + this.tabControl1.Size = new System.Drawing.Size(371, 333); + this.tabControl1.TabIndex = 0; + // + // tabPage1 + // + this.tabPage1.BackColor = System.Drawing.SystemColors.Menu; + this.tabPage1.Controls.Add(this.guiComponentsGroupBox); + this.tabPage1.Controls.Add(this.cacheGroupBox); + this.tabPage1.Location = new System.Drawing.Point(4, 24); + this.tabPage1.Name = "tabPage1"; + this.tabPage1.Padding = new System.Windows.Forms.Padding(3); + this.tabPage1.Size = new System.Drawing.Size(363, 305); + this.tabPage1.TabIndex = 0; + this.tabPage1.Text = "General"; + // + // guiComponentsGroupBox + // + this.guiComponentsGroupBox.AutoSize = true; + this.guiComponentsGroupBox.Controls.Add(this.buildSceneHierarchyCheckBox); + this.guiComponentsGroupBox.Dock = System.Windows.Forms.DockStyle.Top; + this.guiComponentsGroupBox.Location = new System.Drawing.Point(3, 126); + this.guiComponentsGroupBox.Name = "guiComponentsGroupBox"; + this.guiComponentsGroupBox.Size = new System.Drawing.Size(357, 63); + this.guiComponentsGroupBox.TabIndex = 1; + this.guiComponentsGroupBox.TabStop = false; + this.guiComponentsGroupBox.Text = "GUI components"; + // + // buildSceneHierarchyCheckBox + // + this.buildSceneHierarchyCheckBox.AutoSize = true; + this.buildSceneHierarchyCheckBox.Checked = true; + this.buildSceneHierarchyCheckBox.CheckState = System.Windows.Forms.CheckState.Checked; + this.buildSceneHierarchyCheckBox.Location = new System.Drawing.Point(6, 22); + this.buildSceneHierarchyCheckBox.Name = "buildSceneHierarchyCheckBox"; + this.buildSceneHierarchyCheckBox.Size = new System.Drawing.Size(138, 19); + this.buildSceneHierarchyCheckBox.TabIndex = 0; + this.buildSceneHierarchyCheckBox.Text = "Build scene hierarchy"; + this.toolTip1.SetToolTip(this.buildSceneHierarchyCheckBox, "You can disable tree structure building if you don\'t use the Scene Hierarchy tab"); + this.buildSceneHierarchyCheckBox.UseVisualStyleBackColor = true; + // + // cacheGroupBox + // + this.cacheGroupBox.AutoSize = true; + this.cacheGroupBox.Controls.Add(this.alwaysDecompressToDiskCheckBox); + this.cacheGroupBox.Controls.Add(this.cacheFreeSpaceLabel); + this.cacheGroupBox.Controls.Add(this.cachePathLabel); + this.cacheGroupBox.Controls.Add(this.cachePathSelectButton); + this.cacheGroupBox.Controls.Add(this.cachePathResetButton); + this.cacheGroupBox.Dock = System.Windows.Forms.DockStyle.Top; + this.cacheGroupBox.Location = new System.Drawing.Point(3, 3); + this.cacheGroupBox.Name = "cacheGroupBox"; + this.cacheGroupBox.Size = new System.Drawing.Size(357, 123); + this.cacheGroupBox.TabIndex = 0; + this.cacheGroupBox.TabStop = false; + this.cacheGroupBox.Text = "Disk cache"; + // + // alwaysDecompressToDiskCheckBox + // + this.alwaysDecompressToDiskCheckBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.alwaysDecompressToDiskCheckBox.Location = new System.Drawing.Point(9, 82); + this.alwaysDecompressToDiskCheckBox.Name = "alwaysDecompressToDiskCheckBox"; + this.alwaysDecompressToDiskCheckBox.Size = new System.Drawing.Size(345, 19); + this.alwaysDecompressToDiskCheckBox.TabIndex = 4; + this.alwaysDecompressToDiskCheckBox.Text = "Decompress asset bundles to disk (cache dir)"; + this.toolTip1.SetToolTip(this.alwaysDecompressToDiskCheckBox, "If not selected, any bundles less than 2GB will be decompressed to RAM"); + this.alwaysDecompressToDiskCheckBox.UseVisualStyleBackColor = true; + // + // cacheFreeSpaceLabel + // + this.cacheFreeSpaceLabel.AutoSize = true; + this.cacheFreeSpaceLabel.Location = new System.Drawing.Point(160, 47); + this.cacheFreeSpaceLabel.Name = "cacheFreeSpaceLabel"; + this.cacheFreeSpaceLabel.Size = new System.Drawing.Size(91, 15); + this.cacheFreeSpaceLabel.TabIndex = 3; + this.cacheFreeSpaceLabel.Text = "Available space:"; + // + // cachePathLabel + // + this.cachePathLabel.AutoEllipsis = true; + this.cachePathLabel.Location = new System.Drawing.Point(6, 19); + this.cachePathLabel.Name = "cachePathLabel"; + this.cachePathLabel.Size = new System.Drawing.Size(348, 20); + this.cachePathLabel.TabIndex = 0; + this.cachePathLabel.Text = "Cache directory: "; + // + // cachePathSelectButton + // + this.cachePathSelectButton.Location = new System.Drawing.Point(9, 42); + this.cachePathSelectButton.Name = "cachePathSelectButton"; + this.cachePathSelectButton.Size = new System.Drawing.Size(60, 25); + this.cachePathSelectButton.TabIndex = 1; + this.cachePathSelectButton.Text = "Select"; + this.cachePathSelectButton.UseVisualStyleBackColor = false; + this.cachePathSelectButton.Click += new System.EventHandler(this.cachePathSelectButton_Click); + // + // cachePathResetButton + // + this.cachePathResetButton.Location = new System.Drawing.Point(75, 42); + this.cachePathResetButton.Name = "cachePathResetButton"; + this.cachePathResetButton.Size = new System.Drawing.Size(60, 25); + this.cachePathResetButton.TabIndex = 2; + this.cachePathResetButton.Text = "Reset"; + this.cachePathResetButton.UseVisualStyleBackColor = false; + this.cachePathResetButton.Click += new System.EventHandler(this.cachePathResetButton_Click); + // + // tabPage2 + // + this.tabPage2.BackColor = System.Drawing.SystemColors.Menu; + this.tabPage2.Controls.Add(this.groupBox2); + this.tabPage2.Location = new System.Drawing.Point(4, 24); + this.tabPage2.Name = "tabPage2"; + this.tabPage2.Padding = new System.Windows.Forms.Padding(3); + this.tabPage2.Size = new System.Drawing.Size(363, 305); + this.tabPage2.TabIndex = 1; + this.tabPage2.Text = "Assets"; + // + // groupBox2 + // + this.groupBox2.AutoSize = true; + this.groupBox2.Controls.Add(this.displayAllCheckBox); + this.groupBox2.Controls.Add(this.parseByTypetreeCheckBox); + this.groupBox2.Controls.Add(this.meshPreProcessingCheckBox); + this.groupBox2.Dock = System.Windows.Forms.DockStyle.Top; + this.groupBox2.Location = new System.Drawing.Point(3, 3); + this.groupBox2.Name = "groupBox2"; + this.groupBox2.Size = new System.Drawing.Size(357, 113); + this.groupBox2.TabIndex = 3; + this.groupBox2.TabStop = false; + this.groupBox2.Text = "Asset parsing"; + // + // meshPreProcessingCheckBox + // + this.meshPreProcessingCheckBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.meshPreProcessingCheckBox.Location = new System.Drawing.Point(6, 47); + this.meshPreProcessingCheckBox.Name = "meshPreProcessingCheckBox"; + this.meshPreProcessingCheckBox.Size = new System.Drawing.Size(348, 19); + this.meshPreProcessingCheckBox.TabIndex = 2; + this.meshPreProcessingCheckBox.Text = "Pre-process Mesh assets during loading"; + this.toolTip1.SetToolTip(this.meshPreProcessingCheckBox, "Requires more RAM"); + this.meshPreProcessingCheckBox.UseVisualStyleBackColor = true; + // + // parseByTypetreeCheckBox + // + this.parseByTypetreeCheckBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.parseByTypetreeCheckBox.Checked = true; + this.parseByTypetreeCheckBox.CheckState = System.Windows.Forms.CheckState.Checked; + this.parseByTypetreeCheckBox.Location = new System.Drawing.Point(6, 72); + this.parseByTypetreeCheckBox.Name = "parseByTypetreeCheckBox"; + this.parseByTypetreeCheckBox.Size = new System.Drawing.Size(348, 19); + this.parseByTypetreeCheckBox.TabIndex = 1; + this.parseByTypetreeCheckBox.Text = "Parse assets using their typetree"; + this.parseByTypetreeCheckBox.UseVisualStyleBackColor = true; + // + // OKbutton + // + this.OKbutton.AutoSize = true; + this.OKbutton.BackColor = System.Drawing.SystemColors.ButtonFace; + this.OKbutton.Location = new System.Drawing.Point(201, 354); + this.OKbutton.Margin = new System.Windows.Forms.Padding(3, 3, 3, 6); + this.OKbutton.Name = "OKbutton"; + this.OKbutton.Size = new System.Drawing.Size(88, 27); + this.OKbutton.TabIndex = 1; + this.OKbutton.Text = "OK"; + this.OKbutton.UseVisualStyleBackColor = false; + this.OKbutton.Click += new System.EventHandler(this.OKbutton_Click); + // + // Cancel + // + this.Cancel.AutoSize = true; + this.Cancel.BackColor = System.Drawing.SystemColors.ButtonFace; + this.Cancel.DialogResult = System.Windows.Forms.DialogResult.Cancel; + this.Cancel.Location = new System.Drawing.Point(295, 354); + this.Cancel.Margin = new System.Windows.Forms.Padding(3, 6, 3, 6); + this.Cancel.Name = "Cancel"; + this.Cancel.Size = new System.Drawing.Size(88, 27); + this.Cancel.TabIndex = 2; + this.Cancel.Text = "Cancel"; + this.Cancel.UseVisualStyleBackColor = false; + this.Cancel.Click += new System.EventHandler(this.Cancel_Click); + // + // displayAllCheckBox + // + this.displayAllCheckBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.displayAllCheckBox.Location = new System.Drawing.Point(6, 22); + this.displayAllCheckBox.Name = "displayAllCheckBox"; + this.displayAllCheckBox.Size = new System.Drawing.Size(348, 19); + this.displayAllCheckBox.TabIndex = 3; + this.displayAllCheckBox.Text = "Display all assets"; + this.toolTip1.SetToolTip(this.displayAllCheckBox, "Check this option will display all types assets. Not extractable assets can expor" + + "t the RAW file."); + this.displayAllCheckBox.UseVisualStyleBackColor = true; + // + // StudioOptionsForm + // + this.AcceptButton = this.OKbutton; + this.AutoScaleDimensions = new System.Drawing.SizeF(96F, 96F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Dpi; + this.AutoSize = true; + this.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; + this.BackColor = System.Drawing.SystemColors.Menu; + this.CancelButton = this.Cancel; + this.ClientSize = new System.Drawing.Size(395, 393); + this.Controls.Add(this.OKbutton); + this.Controls.Add(this.Cancel); + this.Controls.Add(this.tabControl1); + this.Font = new System.Drawing.Font("Segoe UI", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle; + this.MaximizeBox = false; + this.MinimizeBox = false; + this.Name = "StudioOptionsForm"; + this.ShowIcon = false; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; + this.Text = "Studio options"; + this.tabControl1.ResumeLayout(false); + this.tabPage1.ResumeLayout(false); + this.tabPage1.PerformLayout(); + this.guiComponentsGroupBox.ResumeLayout(false); + this.guiComponentsGroupBox.PerformLayout(); + this.cacheGroupBox.ResumeLayout(false); + this.cacheGroupBox.PerformLayout(); + this.tabPage2.ResumeLayout(false); + this.tabPage2.PerformLayout(); + this.groupBox2.ResumeLayout(false); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private System.Windows.Forms.TabControl tabControl1; + private System.Windows.Forms.TabPage tabPage1; + private System.Windows.Forms.TabPage tabPage2; + private System.Windows.Forms.GroupBox cacheGroupBox; + private System.Windows.Forms.CheckBox alwaysDecompressToDiskCheckBox; + private System.Windows.Forms.Label cacheFreeSpaceLabel; + private System.Windows.Forms.Label cachePathLabel; + private System.Windows.Forms.Button cachePathSelectButton; + private System.Windows.Forms.Button cachePathResetButton; + private System.Windows.Forms.CheckBox parseByTypetreeCheckBox; + private System.Windows.Forms.CheckBox buildSceneHierarchyCheckBox; + private System.Windows.Forms.GroupBox guiComponentsGroupBox; + private System.Windows.Forms.GroupBox groupBox2; + private System.Windows.Forms.CheckBox meshPreProcessingCheckBox; + private System.Windows.Forms.ToolTip toolTip1; + private System.Windows.Forms.Button OKbutton; + private System.Windows.Forms.Button Cancel; + private System.Windows.Forms.CheckBox displayAllCheckBox; + } +} \ No newline at end of file diff --git a/AssetStudioGUI/StudioOptionsForm.cs b/AssetStudioGUI/StudioOptionsForm.cs new file mode 100644 index 0000000..4fb6a49 --- /dev/null +++ b/AssetStudioGUI/StudioOptionsForm.cs @@ -0,0 +1,95 @@ +using AssetStudio; +using System; +using System.Diagnostics; +using System.IO; +using System.Windows.Forms; + +namespace AssetStudioGUI +{ + public partial class StudioOptionsForm : Form + { + private readonly AssetsManagerOptions _studioOptions; + private string _cachePath; + + public StudioOptionsForm(AssetsManagerOptions studioOptions) + { + InitializeComponent(); + _studioOptions = studioOptions; + + cachePathLabel.AutoSize = IsWine; //to disable AutoEllipsis in Wine + _cachePath = _studioOptions.CustomCachePath; + DisplayCachePath(); + alwaysDecompressToDiskCheckBox.Checked = studioOptions.DecompressToDisk; + buildSceneHierarchyCheckBox.Checked = Properties.Settings.Default.buildTreeStructure; + + displayAllCheckBox.Checked = Properties.Settings.Default.displayAll; + meshPreProcessingCheckBox.Checked = _studioOptions.MeshPreProcessing; + parseByTypetreeCheckBox.Checked = _studioOptions.ParseByTypeTree; + } + + private void DisplayCachePath() + { + cachePathLabel.Text = $"Cache directory: {_cachePath}"; + toolTip1.SetToolTip(cachePathLabel, _cachePath); + var driveInfo = new DriveInfo(Directory.GetDirectoryRoot(_cachePath)); + cacheFreeSpaceLabel.Text = $"Available space: {driveInfo.AvailableFreeSpace * 1.0f / 0x40000000:.00}GB"; + } + + private void cachePathSelectButton_Click(object sender, EventArgs e) + { + var cachePathFolderDialog = new OpenFolderDialog(); + cachePathFolderDialog.Title = "Select the cache directory"; + if (cachePathFolderDialog.ShowDialog(this) != DialogResult.OK) + return; + + _cachePath = cachePathFolderDialog.Folder; + DisplayCachePath(); + } + + private void cachePathResetButton_Click(object sender, EventArgs e) + { + _cachePath = Path.Combine(Directory.GetCurrentDirectory(), "temp"); + if (!Directory.Exists(_cachePath)) + Directory.CreateDirectory(_cachePath); + DisplayCachePath(); + } + + private void OKbutton_Click(object sender, EventArgs e) + { + #region General + _studioOptions.CustomCachePath = _cachePath; + Properties.Settings.Default.cachePath = _cachePath; + + var decompressToDisk = alwaysDecompressToDiskCheckBox.Checked; + _studioOptions.DecompressToDisk = decompressToDisk; + Properties.Settings.Default.decompressToDisk = decompressToDisk; + + Properties.Settings.Default.buildTreeStructure = buildSceneHierarchyCheckBox.Checked; + #endregion + + #region Assets + Properties.Settings.Default.displayAll = displayAllCheckBox.Checked; + + var meshPreProcessing = meshPreProcessingCheckBox.Checked; + _studioOptions.MeshPreProcessing = meshPreProcessing; + Properties.Settings.Default.meshPreProcessing = meshPreProcessing; + + var parseByTypeTree = parseByTypetreeCheckBox.Checked; + _studioOptions.ParseByTypeTree = parseByTypeTree; + Properties.Settings.Default.useTypetreeLoading = parseByTypeTree; + #endregion + + Properties.Settings.Default.Save(); + DialogResult = DialogResult.OK; + Close(); + } + + private void Cancel_Click(object sender, EventArgs e) + { + DialogResult = DialogResult.Cancel; + Close(); + } + + private static bool IsWine => Process.GetProcessesByName("winlogon").Length == 0; + } +} diff --git a/AssetStudioGUI/StudioOptionsForm.resx b/AssetStudioGUI/StudioOptionsForm.resx new file mode 100644 index 0000000..d54ad1e --- /dev/null +++ b/AssetStudioGUI/StudioOptionsForm.resx @@ -0,0 +1,126 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + 17, 17 + + + 17, 17 + + \ No newline at end of file