From 43f3f52be302b95682976d4dde40631d697e709b Mon Sep 17 00:00:00 2001 From: Razmoth <32140579+Razmoth@users.noreply.github.com> Date: Sat, 18 Nov 2023 18:24:12 +0400 Subject: [PATCH] - [CLI] added `export_type` option, #35. --- AssetStudio.CLI/Components/CommandLine.cs | 6 ++++ AssetStudio.CLI/Program.cs | 2 +- AssetStudio.CLI/Studio.cs | 37 ++++++++++++++++------- AssetStudio.GUI/Studio.cs | 8 ----- AssetStudio/ExportType.cs | 10 ++++++ 5 files changed, 43 insertions(+), 20 deletions(-) create mode 100644 AssetStudio/ExportType.cs diff --git a/AssetStudio.CLI/Components/CommandLine.cs b/AssetStudio.CLI/Components/CommandLine.cs index c3a082e..1619a6b 100644 --- a/AssetStudio.CLI/Components/CommandLine.cs +++ b/AssetStudio.CLI/Components/CommandLine.cs @@ -32,6 +32,7 @@ namespace AssetStudio.CLI optionsBinder.MapName, optionsBinder.UnityVersion, optionsBinder.GroupAssetsType, + optionsBinder.AssetExportType, optionsBinder.Model, optionsBinder.Key, optionsBinder.AIFile, @@ -59,6 +60,7 @@ namespace AssetStudio.CLI public string MapName { get; set; } public string UnityVersion { get; set; } public AssetGroupOption GroupAssetsType { get; set; } + public ExportType AssetExportType { get; set; } public bool Model { get; set; } public byte Key { get; set; } public FileInfo AIFile { get; set; } @@ -81,6 +83,7 @@ namespace AssetStudio.CLI public readonly Option MapName; public readonly Option UnityVersion; public readonly Option GroupAssetsType; + public readonly Option AssetExportType; public readonly Option Model; public readonly Option Key; public readonly Option AIFile; @@ -103,6 +106,7 @@ namespace AssetStudio.CLI MapName = new Option("--map_name", () => "assets_map", "Specify AssetMap file name."); UnityVersion = new Option("--unity_version", "Specify Unity version."); GroupAssetsType = new Option("--group_assets", "Specify how exported assets should be grouped."); + AssetExportType = new Option("--export_type", "Specify how assets should be exported."); Model = new Option("--models", "Enable to export models only"); AIFile = new Option("--ai_file", "Specify asset_index json file path (to recover GI containers).").LegalFilePathsOnly(); DummyDllFolder = new Option("--dummy_dlls", "Specify DummyDll path.").LegalFilePathsOnly(); @@ -150,6 +154,7 @@ namespace AssetStudio.CLI GameName.FromAmong(GameManager.GetGameNames()); GroupAssetsType.SetDefaultValue(AssetGroupOption.ByType); + AssetExportType.SetDefaultValue(ExportType.Convert); MapOp.SetDefaultValue(MapOpType.None); MapType.SetDefaultValue(ExportListType.XML); KeyIndex.SetDefaultValue(0); @@ -193,6 +198,7 @@ namespace AssetStudio.CLI MapName = bindingContext.ParseResult.GetValueForOption(MapName), UnityVersion = bindingContext.ParseResult.GetValueForOption(UnityVersion), GroupAssetsType = bindingContext.ParseResult.GetValueForOption(GroupAssetsType), + AssetExportType = bindingContext.ParseResult.GetValueForOption(AssetExportType), Model = bindingContext.ParseResult.GetValueForOption(Model), Key = bindingContext.ParseResult.GetValueForOption(Key), AIFile = bindingContext.ParseResult.GetValueForOption(AIFile), diff --git a/AssetStudio.CLI/Program.cs b/AssetStudio.CLI/Program.cs index defc344..f08128e 100644 --- a/AssetStudio.CLI/Program.cs +++ b/AssetStudio.CLI/Program.cs @@ -114,7 +114,7 @@ namespace AssetStudio.CLI if (assetsManager.assetsFileList.Count > 0) { BuildAssetData(o.TypeFilter, o.NameFilter, o.ContainerFilter, ref i); - ExportAssets(o.Output.FullName, exportableAssets, o.GroupAssetsType); + ExportAssets(o.Output.FullName, exportableAssets, o.GroupAssetsType, o.AssetExportType); } exportableAssets.Clear(); assetsManager.Clear(); diff --git a/AssetStudio.CLI/Studio.cs b/AssetStudio.CLI/Studio.cs index 9600f43..0413619 100644 --- a/AssetStudio.CLI/Studio.cs +++ b/AssetStudio.CLI/Studio.cs @@ -22,14 +22,6 @@ namespace AssetStudio.CLI All = Both | Load, } - public enum AssetGroupOption - { - ByType, - ByContainer, - BySource, - None, - } - internal static class Studio { public static Game Game; @@ -364,7 +356,7 @@ namespace AssetStudio.CLI } } - public static void ExportAssets(string savePath, List toExportAssets, AssetGroupOption assetGroupOption) + public static void ExportAssets(string savePath, List toExportAssets, AssetGroupOption assetGroupOption, ExportType exportType) { int toExportCount = toExportAssets.Count; int exportedCount = 0; @@ -404,9 +396,32 @@ namespace AssetStudio.CLI Logger.Info($"[{exportedCount}/{toExportCount}] Exporting {asset.TypeString}: {asset.Text}"); try { - if (ExportConvertFile(asset, exportPath)) + switch (exportType) { - exportedCount++; + case ExportType.Raw: + if (ExportRawFile(asset, exportPath)) + { + exportedCount++; + } + break; + case ExportType.Dump: + if (ExportDumpFile(asset, exportPath)) + { + exportedCount++; + } + break; + case ExportType.Convert: + if (ExportConvertFile(asset, exportPath)) + { + exportedCount++; + } + break; + case ExportType.JSON: + if (ExportJSONFile(asset, exportPath)) + { + exportedCount++; + } + break; } } catch (Exception ex) diff --git a/AssetStudio.GUI/Studio.cs b/AssetStudio.GUI/Studio.cs index c4040ef..79da5ec 100644 --- a/AssetStudio.GUI/Studio.cs +++ b/AssetStudio.GUI/Studio.cs @@ -11,14 +11,6 @@ using static AssetStudio.GUI.Exporter; namespace AssetStudio.GUI { - internal enum ExportType - { - Convert, - Raw, - Dump, - JSON - } - internal enum ExportFilter { All, diff --git a/AssetStudio/ExportType.cs b/AssetStudio/ExportType.cs new file mode 100644 index 0000000..9776c95 --- /dev/null +++ b/AssetStudio/ExportType.cs @@ -0,0 +1,10 @@ +namespace AssetStudio +{ + public enum ExportType + { + Convert, + Raw, + Dump, + JSON + } +}