From e19d7b91feb78072b96f1fe26eb1edccc1245fef Mon Sep 17 00:00:00 2001 From: Razmoth <32140579+Razmoth@users.noreply.github.com> Date: Sat, 27 Jan 2024 20:42:18 +0400 Subject: [PATCH] v1.36.00 --- .github/workflows/build.yml | 26 +- AssetStudio.CLI/App.config | 3 +- AssetStudio.CLI/AssetStudio.CLI.csproj | 8 +- AssetStudio.CLI/Components/CommandLine.cs | 5 - AssetStudio.CLI/Exporter.cs | 4 +- AssetStudio.CLI/Program.cs | 27 +- AssetStudio.CLI/Settings.cs | 1 + AssetStudio.CLI/Studio.cs | 41 ++- .../AssetStudio.FBXWrapper.csproj | 8 +- AssetStudio.GUI/App.config | 5 +- AssetStudio.GUI/AssetStudio.GUI.csproj | 8 +- AssetStudio.GUI/ExportOptions.Designer.cs | 311 +++++++++--------- AssetStudio.GUI/ExportOptions.cs | 126 ++++--- AssetStudio.GUI/ExportOptions.resx | 9 - AssetStudio.GUI/Exporter.cs | 6 +- AssetStudio.GUI/MainForm.cs | 9 +- .../Properties/Settings.Designer.cs | 12 + AssetStudio.GUI/Properties/Settings.settings | 3 + AssetStudio.GUI/Studio.cs | 37 ++- .../AssetStudio.PInvoke.csproj | 8 +- .../AssetStudio.Utility.csproj | 8 +- AssetStudio.Utility/ModelConverter.cs | 7 +- AssetStudio/AssetStudio.csproj | 8 +- AssetStudio/AssetsHelper.cs | 46 +-- AssetStudio/AssetsManager.cs | 60 ++-- AssetStudio/TypeFlags.cs | 46 +++ 26 files changed, 484 insertions(+), 348 deletions(-) create mode 100644 AssetStudio/TypeFlags.cs diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 0027061..399b89c 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -22,23 +22,17 @@ jobs: - name: Nuget Restore run: nuget restore - - name: Build .Net6 - run: msbuild /t:AssetStudio_GUI:publish /p:Configuration=Release /p:TargetFramework=net6.0-windows /p:SelfContained=false /verbosity:minimal - - name: Build .Net7 run: msbuild /t:AssetStudio_GUI:publish /p:Configuration=Release /p:TargetFramework=net7.0-windows /p:SelfContained=false /verbosity:minimal - - name: Build .Net6 CLI - run: msbuild /t:AssetStudio_CLI:publish /p:Configuration=Release /p:TargetFramework=net6.0-windows /p:SelfContained=false /verbosity:minimal + - name: Build .Net8 + run: msbuild /t:AssetStudio_GUI:publish /p:Configuration=Release /p:TargetFramework=net8.0-windows /p:SelfContained=false /verbosity:minimal - name: Build .Net7 CLI run: msbuild /t:AssetStudio_CLI:publish /p:Configuration=Release /p:TargetFramework=net7.0-windows /p:SelfContained=false /verbosity:minimal - - name: Upload .Net6 Artifact - uses: actions/upload-artifact@v3 - with: - name: net6.0-${{ github.sha }} - path: AssetStudio.GUI/bin/Release/net6.0-windows/publish + - name: Build .Net8 CLI + run: msbuild /t:AssetStudio_CLI:publish /p:Configuration=Release /p:TargetFramework=net8.0-windows /p:SelfContained=false /verbosity:minimal - name: Upload .Net7 Artifact uses: actions/upload-artifact@v3 @@ -46,14 +40,20 @@ jobs: name: net7.0-${{ github.sha }} path: AssetStudio.GUI/bin/Release/net7.0-windows/publish - - name: Upload .Net6 CLI Artifact + - name: Upload .Net8 Artifact uses: actions/upload-artifact@v3 with: - name: net6.0-${{ github.sha }} - path: AssetStudio.GUI/bin/Release/net6.0-windows/publish + name: net8.0-${{ github.sha }} + path: AssetStudio.GUI/bin/Release/net8.0-windows/publish - name: Upload .Net7 CLI Artifact uses: actions/upload-artifact@v3 with: name: net7.0-${{ github.sha }} path: AssetStudio.GUI/bin/Release/net7.0-windows/publish + + - name: Upload .Net8 CLI Artifact + uses: actions/upload-artifact@v3 + with: + name: net8.0-${{ github.sha }} + path: AssetStudio.GUI/bin/Release/net8.0-windows/publish diff --git a/AssetStudio.CLI/App.config b/AssetStudio.CLI/App.config index 6c15388..e82a742 100644 --- a/AssetStudio.CLI/App.config +++ b/AssetStudio.CLI/App.config @@ -22,6 +22,7 @@ - + + \ No newline at end of file diff --git a/AssetStudio.CLI/AssetStudio.CLI.csproj b/AssetStudio.CLI/AssetStudio.CLI.csproj index 1352128..7f86f5a 100644 --- a/AssetStudio.CLI/AssetStudio.CLI.csproj +++ b/AssetStudio.CLI/AssetStudio.CLI.csproj @@ -1,11 +1,11 @@  Exe - net6.0-windows;net7.0-windows + net7.0-windows;net8.0-windows Resources\as.ico - 1.00.00 - 1.00.00 - 1.00.00 + 1.36.00 + 1.36.00 + 1.36.00 Copyright © Razmoth 2022; Copyright © Perfare 2018-2022 ..\AssetStudio.GUI\bin diff --git a/AssetStudio.CLI/Components/CommandLine.cs b/AssetStudio.CLI/Components/CommandLine.cs index 4c64667..13b70f0 100644 --- a/AssetStudio.CLI/Components/CommandLine.cs +++ b/AssetStudio.CLI/Components/CommandLine.cs @@ -33,7 +33,6 @@ public static RootCommand RegisterOptions() optionsBinder.UnityVersion, optionsBinder.GroupAssetsType, optionsBinder.AssetExportType, - optionsBinder.Model, optionsBinder.Key, optionsBinder.AIFile, optionsBinder.DummyDllFolder, @@ -61,7 +60,6 @@ public class Options 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; } public DirectoryInfo DummyDllFolder { get; set; } @@ -84,7 +82,6 @@ public class OptionsBinder : BinderBase public readonly Option UnityVersion; public readonly Option GroupAssetsType; public readonly Option AssetExportType; - public readonly Option Model; public readonly Option Key; public readonly Option AIFile; public readonly Option DummyDllFolder; @@ -106,7 +103,6 @@ public OptionsBinder() 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(); Input = new Argument("input_path", "Input file/folder.").LegalFilePathsOnly(); @@ -200,7 +196,6 @@ protected override Options GetBoundValue(BindingContext bindingContext) => 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), DummyDllFolder = bindingContext.ParseResult.GetValueForOption(DummyDllFolder), diff --git a/AssetStudio.CLI/Exporter.cs b/AssetStudio.CLI/Exporter.cs index 6ec097b..1a42248 100644 --- a/AssetStudio.CLI/Exporter.cs +++ b/AssetStudio.CLI/Exporter.cs @@ -366,7 +366,7 @@ public static bool ExportAnimator(AssetItem item, string exportPath, List>(Properties.Settings.Default.uvs), - texs = JsonConvert.DeserializeObject>(Properties.Settings.Default.texs), + texs = JsonConvert.DeserializeObject>(Properties.Settings.Default.texs), }; var convert = animationList != null ? new ModelConverter(m_Animator, options, animationList.Select(x => (AnimationClip)x.Asset).ToArray()) @@ -392,7 +392,7 @@ public static bool ExportGameObject(GameObject gameObject, string exportPath, Li game = Studio.Game, collectAnimations = Properties.Settings.Default.collectAnimations, uvs = JsonConvert.DeserializeObject>(Properties.Settings.Default.uvs), - texs = JsonConvert.DeserializeObject>(Properties.Settings.Default.texs), + texs = JsonConvert.DeserializeObject>(Properties.Settings.Default.texs), }; var convert = animationList != null ? new ModelConverter(gameObject, options, animationList.Select(x => (AnimationClip)x.Asset).ToArray()) diff --git a/AssetStudio.CLI/Program.cs b/AssetStudio.CLI/Program.cs index 7f62c9f..43890c8 100644 --- a/AssetStudio.CLI/Program.cs +++ b/AssetStudio.CLI/Program.cs @@ -4,6 +4,7 @@ using System.Linq; using System.Threading; using AssetStudio.CLI.Properties; +using Newtonsoft.Json; using static AssetStudio.CLI.Studio; namespace AssetStudio.CLI @@ -44,10 +45,34 @@ public static void Run(Options o) AssetsHelper.Minimal = Settings.Default.minimalAssetMap; AssetsHelper.SetUnityVersion(o.UnityVersion); + if (o.TypeFilter == null) + { + TypeFlags.SetTypes(JsonConvert.DeserializeObject>(Settings.Default.types)); + } + else + { + foreach (var type in o.TypeFilter) + { + TypeFlags.SetType(type, true, true); + } + + if (ClassIDType.GameObject.CanExport() || ClassIDType.Animator.CanExport()) + { + TypeFlags.SetType(ClassIDType.Texture2D, true, false); + if (ClassIDType.GameObject.CanExport()) + { + TypeFlags.SetType(ClassIDType.Animator, true, false); + } + else if(ClassIDType.Animator.CanExport()) + { + TypeFlags.SetType(ClassIDType.GameObject, true, false); + } + } + } + assetsManager.Silent = o.Silent; assetsManager.Game = game; assetsManager.SpecifyUnityVersion = o.UnityVersion; - ModelOnly = o.Model; o.Output.Create(); if (o.Key != default) diff --git a/AssetStudio.CLI/Settings.cs b/AssetStudio.CLI/Settings.cs index d1db43c..e769c84 100644 --- a/AssetStudio.CLI/Settings.cs +++ b/AssetStudio.CLI/Settings.cs @@ -55,6 +55,7 @@ public class Settings public bool enableFileLogging => AppSettings.Get("enableFileLogging", false); public bool minimalAssetMap => AppSettings.Get("minimalAssetMap", true); public bool allowDuplicates => AppSettings.Get("allowDuplicates", false); + public string types => AppSettings.Get("types", string.Empty); public string texs => AppSettings.Get("texs", string.Empty); public string uvs => AppSettings.Get("uvs", string.Empty); diff --git a/AssetStudio.CLI/Studio.cs b/AssetStudio.CLI/Studio.cs index 15e7e71..9d5d485 100644 --- a/AssetStudio.CLI/Studio.cs +++ b/AssetStudio.CLI/Studio.cs @@ -25,7 +25,6 @@ public enum MapOpType internal static class Studio { public static Game Game; - public static bool ModelOnly = false; public static bool SkipContainer = false; public static AssetsManager assetsManager = new AssetsManager() { ResolveDependencies = false }; public static AssemblyLoader assemblyLoader = new AssemblyLoader(); @@ -286,25 +285,25 @@ public static void ProcessAssetData(Object asset, ClassIDType[] typeFilters, Reg switch (asset) { case GameObject m_GameObject: - exportable = ModelOnly && m_GameObject.HasModel(); + exportable = ClassIDType.GameObject.CanExport() && m_GameObject.HasModel(); break; case Texture2D m_Texture2D: if (!string.IsNullOrEmpty(m_Texture2D.m_StreamData?.path)) assetItem.FullSize = asset.byteSize + m_Texture2D.m_StreamData.size; - exportable = !ModelOnly; + exportable = ClassIDType.Texture2D.CanExport(); break; case AudioClip m_AudioClip: if (!string.IsNullOrEmpty(m_AudioClip.m_Source)) assetItem.FullSize = asset.byteSize + m_AudioClip.m_Size; - exportable = !ModelOnly; + exportable = ClassIDType.AudioClip.CanExport(); break; case VideoClip m_VideoClip: if (!string.IsNullOrEmpty(m_VideoClip.m_OriginalPath)) - assetItem.FullSize = asset.byteSize + (long)m_VideoClip.m_ExternalResources.m_Size; - exportable = !ModelOnly; + assetItem.FullSize = asset.byteSize + m_VideoClip.m_ExternalResources.m_Size; + exportable = ClassIDType.VideoClip.CanExport(); break; case MonoBehaviour m_MonoBehaviour: - exportable = !ModelOnly && assemblyLoader.Loaded; + exportable = ClassIDType.MonoBehaviour.CanExport(); break; case AssetBundle m_AssetBundle: foreach (var m_Container in m_AssetBundle.m_Container) @@ -317,30 +316,36 @@ public static void ProcessAssetData(Object asset, ClassIDType[] typeFilters, Reg containers.Add((m_AssetBundle.m_PreloadTable[k], m_Container.Key)); } } + + exportable = ClassIDType.AssetBundle.CanExport(); break; case IndexObject m_IndexObject: foreach (var index in m_IndexObject.AssetMap) { mihoyoBinDataNames.Add((index.Value.Object, index.Key)); } + + exportable = ClassIDType.IndexObject.CanExport(); break; case ResourceManager m_ResourceManager: foreach (var m_Container in m_ResourceManager.m_Container) { containers.Add((m_Container.Value, m_Container.Key)); } + + exportable = ClassIDType.GameObject.CanExport(); break; - case Mesh _: - case TextAsset _: - case AnimationClip _: - case Font _: - case MovieTexture _: - case Sprite _: - case Material _: - case MiHoYoBinData _: - case Shader _: - case Animator _: - exportable = !ModelOnly; + case Mesh _ when ClassIDType.Mesh.CanExport(): + case TextAsset _ when ClassIDType.TextAsset.CanExport(): + case AnimationClip _ when ClassIDType.Font.CanExport(): + case Font _ when ClassIDType.GameObject.CanExport(): + case MovieTexture _ when ClassIDType.MovieTexture.CanExport(): + case Sprite _ when ClassIDType.Sprite.CanExport(): + case Material _ when ClassIDType.Material.CanExport(): + case MiHoYoBinData _ when ClassIDType.MiHoYoBinData.CanExport(): + case Shader _ when ClassIDType.Shader.CanExport(): + case Animator _ when ClassIDType.Animator.CanExport(): + exportable = true; break; } if (assetItem.Text == "") diff --git a/AssetStudio.FBXWrapper/AssetStudio.FBXWrapper.csproj b/AssetStudio.FBXWrapper/AssetStudio.FBXWrapper.csproj index ab58cf1..820d175 100644 --- a/AssetStudio.FBXWrapper/AssetStudio.FBXWrapper.csproj +++ b/AssetStudio.FBXWrapper/AssetStudio.FBXWrapper.csproj @@ -1,11 +1,11 @@ - net6.0;net7.0 + net7.0;net8.0 true - 1.00.00 - 1.00.00 - 1.00.00 + 1.36.00 + 1.36.00 + 1.36.00 Copyright © Perfare 2018-2022; Copyright © hozuki 2020 embedded diff --git a/AssetStudio.GUI/App.config b/AssetStudio.GUI/App.config index 522d918..6295852 100644 --- a/AssetStudio.GUI/App.config +++ b/AssetStudio.GUI/App.config @@ -107,11 +107,14 @@ True - {} + {"0": "", "1": "", "2": "", "3": "", "4": "", "5": "", "6": "", "7": ""} {"UV0":{"Item1":true,"Item2":0},"UV1":{"Item1":true,"Item2":1},"UV2":{"Item1":false,"Item2":0},"UV3":{"Item1":false,"Item2":0},"UV4":{"Item1":false,"Item2":0},"UV5":{"Item1":false,"Item2":0},"UV6":{"Item1":false,"Item2":0},"UV7":{"Item1":false,"Item2":0}} + + {"Animation":{"Item1":true,"Item2":false},"AnimationClip":{"Item1":true,"Item2":true},"Animator":{"Item1":true,"Item2":true},"AnimatorController":{"Item1":true,"Item2":false},"AnimatorOverrideController":{"Item1":true,"Item2":false},"AssetBundle":{"Item1":true,"Item2":false},"AudioClip":{"Item1":true,"Item2":true},"Avatar":{"Item1":true,"Item2":false},"Font":{"Item1":true,"Item2":true},"GameObject":{"Item1":true,"Item2":false},"IndexObject":{"Item1":true,"Item2":false},"Material":{"Item1":true,"Item2":true},"Mesh":{"Item1":true,"Item2":true},"MeshFilter":{"Item1":true,"Item2":false},"MeshRenderer":{"Item1":true,"Item2":false},"MiHoYoBinData":{"Item1":true,"Item2":true},"MonoBehaviour":{"Item1":true,"Item2":true},"MonoScript":{"Item1":true,"Item2":false},"MovieTexture":{"Item1":true,"Item2":true},"PlayerSettings":{"Item1":true,"Item2":false},"RectTransform":{"Item1":true,"Item2":false},"Shader":{"Item1":true,"Item2":true},"SkinnedMeshRenderer":{"Item1":true,"Item2":false},"Sprite":{"Item1":true,"Item2":true},"SpriteAtlas":{"Item1":true,"Item2":false},"TextAsset":{"Item1":true,"Item2":true},"Texture2D":{"Item1":true,"Item2":true},"Transform":{"Item1":true,"Item2":false},"VideoClip":{"Item1":true,"Item2":true},"ResourceManager":{"Item1":true,"Item2":false}} + False diff --git a/AssetStudio.GUI/AssetStudio.GUI.csproj b/AssetStudio.GUI/AssetStudio.GUI.csproj index b9cd7f3..0290b45 100644 --- a/AssetStudio.GUI/AssetStudio.GUI.csproj +++ b/AssetStudio.GUI/AssetStudio.GUI.csproj @@ -2,12 +2,12 @@ WinExe - net6.0-windows;net7.0-windows + net7.0-windows;net8.0-windows true Resources\as.ico - 1.00.00 - 1.00.00 - 1.00.00 + 1.36.00 + 1.36.00 + 1.36.00 Copyright © Razmoth 2022; Copyright © Perfare 2018-2022 embedded diff --git a/AssetStudio.GUI/ExportOptions.Designer.cs b/AssetStudio.GUI/ExportOptions.Designer.cs index 67f3f67..90af953 100644 --- a/AssetStudio.GUI/ExportOptions.Designer.cs +++ b/AssetStudio.GUI/ExportOptions.Designer.cs @@ -34,22 +34,20 @@ protected override void Dispose(bool disposing) private void InitializeComponent() { components = new System.ComponentModel.Container(); - DataGridViewCellStyle dataGridViewCellStyle1 = new DataGridViewCellStyle(); - DataGridViewCellStyle dataGridViewCellStyle2 = new DataGridViewCellStyle(); - DataGridViewCellStyle dataGridViewCellStyle3 = new DataGridViewCellStyle(); - DataGridViewCellStyle dataGridViewCellStyle6 = new DataGridViewCellStyle(); - DataGridViewCellStyle dataGridViewCellStyle7 = new DataGridViewCellStyle(); - DataGridViewCellStyle dataGridViewCellStyle8 = new DataGridViewCellStyle(); - DataGridViewCellStyle dataGridViewCellStyle4 = new DataGridViewCellStyle(); - DataGridViewCellStyle dataGridViewCellStyle5 = new DataGridViewCellStyle(); OKbutton = new Button(); Cancel = new Button(); groupBox1 = new GroupBox(); + texNameTextBox = new TextBox(); + label10 = new Label(); + texTypeComboBox = new ComboBox(); + uvTypesComboBox = new ComboBox(); + uvEnabledCheckBox = new CheckBox(); + uvsComboBox = new ComboBox(); + canExportCheckBox = new CheckBox(); + label8 = new Label(); + canParseCheckBox = new CheckBox(); + typesComboBox = new ComboBox(); label6 = new Label(); - uvsGridView = new DataGridView(); - UVName = new DataGridViewTextBoxColumn(); - UVEnabled = new DataGridViewCheckBoxColumn(); - UVType = new DataGridViewComboBoxColumn(); minimalAssetMap = new CheckBox(); assetGroupOptions = new ComboBox(); label7 = new Label(); @@ -66,10 +64,6 @@ private void InitializeComponent() converttexture = new CheckBox(); collectAnimations = new CheckBox(); groupBox2 = new GroupBox(); - label9 = new Label(); - texsGridView = new DataGridView(); - TexName = new DataGridViewTextBoxColumn(); - TexType = new DataGridViewComboBoxColumn(); exportBlendShape = new CheckBox(); exportAnimations = new CheckBox(); scaleFactor = new NumericUpDown(); @@ -89,11 +83,9 @@ private void InitializeComponent() exportUvsTooltip = new ToolTip(components); keyToolTip = new ToolTip(components); groupBox1.SuspendLayout(); - ((System.ComponentModel.ISupportInitialize)uvsGridView).BeginInit(); ((System.ComponentModel.ISupportInitialize)key).BeginInit(); panel1.SuspendLayout(); groupBox2.SuspendLayout(); - ((System.ComponentModel.ISupportInitialize)texsGridView).BeginInit(); ((System.ComponentModel.ISupportInitialize)scaleFactor).BeginInit(); ((System.ComponentModel.ISupportInitialize)boneSize).BeginInit(); ((System.ComponentModel.ISupportInitialize)filterPrecision).BeginInit(); @@ -101,7 +93,7 @@ private void InitializeComponent() // // OKbutton // - OKbutton.Location = new System.Drawing.Point(480, 439); + OKbutton.Location = new System.Drawing.Point(480, 428); OKbutton.Margin = new Padding(4); OKbutton.Name = "OKbutton"; OKbutton.Size = new System.Drawing.Size(88, 26); @@ -113,7 +105,7 @@ private void InitializeComponent() // Cancel // Cancel.DialogResult = DialogResult.Cancel; - Cancel.Location = new System.Drawing.Point(576, 439); + Cancel.Location = new System.Drawing.Point(576, 428); Cancel.Margin = new Padding(4); Cancel.Name = "Cancel"; Cancel.Size = new System.Drawing.Size(88, 26); @@ -125,8 +117,17 @@ private void InitializeComponent() // groupBox1 // groupBox1.AutoSize = true; + groupBox1.Controls.Add(texNameTextBox); + groupBox1.Controls.Add(label10); + groupBox1.Controls.Add(texTypeComboBox); + groupBox1.Controls.Add(uvTypesComboBox); + groupBox1.Controls.Add(uvEnabledCheckBox); + groupBox1.Controls.Add(uvsComboBox); + groupBox1.Controls.Add(canExportCheckBox); + groupBox1.Controls.Add(label8); + groupBox1.Controls.Add(canParseCheckBox); + groupBox1.Controls.Add(typesComboBox); groupBox1.Controls.Add(label6); - groupBox1.Controls.Add(uvsGridView); groupBox1.Controls.Add(minimalAssetMap); groupBox1.Controls.Add(assetGroupOptions); groupBox1.Controls.Add(label7); @@ -141,56 +142,125 @@ private void InitializeComponent() groupBox1.Margin = new Padding(4); groupBox1.Name = "groupBox1"; groupBox1.Padding = new Padding(4); - groupBox1.Size = new System.Drawing.Size(271, 419); + groupBox1.Size = new System.Drawing.Size(271, 420); groupBox1.TabIndex = 9; groupBox1.TabStop = false; groupBox1.Text = "Export"; // + // texNameTextBox + // + texNameTextBox.Location = new System.Drawing.Point(119, 374); + texNameTextBox.Name = "texNameTextBox"; + texNameTextBox.Size = new System.Drawing.Size(141, 23); + texNameTextBox.TabIndex = 37; + texNameTextBox.LostFocus += TexNameTextBox_LostFocus; + // + // label10 + // + label10.AutoSize = true; + label10.Location = new System.Drawing.Point(7, 356); + label10.Margin = new Padding(4, 0, 4, 0); + label10.Name = "label10"; + label10.Size = new System.Drawing.Size(142, 15); + label10.TabIndex = 36; + label10.Text = "Texture mapping options:"; + // + // texTypeComboBox + // + texTypeComboBox.DropDownStyle = ComboBoxStyle.DropDownList; + texTypeComboBox.FormattingEnabled = true; + texTypeComboBox.Items.AddRange(new object[] { "Diffuse", "NormalMap", "Specular", "Bump", "Ambient", "Emissive", "Reflection", "Displacement" }); + texTypeComboBox.Location = new System.Drawing.Point(7, 374); + texTypeComboBox.Name = "texTypeComboBox"; + texTypeComboBox.Size = new System.Drawing.Size(106, 23); + texTypeComboBox.TabIndex = 35; + texTypeComboBox.SelectedIndexChanged += TexTypeComboBox_SelectedIndexChanged; + // + // uvTypesComboBox + // + uvTypesComboBox.DropDownStyle = ComboBoxStyle.DropDownList; + uvTypesComboBox.FormattingEnabled = true; + uvTypesComboBox.Items.AddRange(new object[] { "Diffuse", "NormalMap", "Specular", "Bump", "Ambient", "Emissive", "Reflection", "Displacement" }); + uvTypesComboBox.Location = new System.Drawing.Point(88, 330); + uvTypesComboBox.Name = "uvTypesComboBox"; + uvTypesComboBox.Size = new System.Drawing.Size(106, 23); + uvTypesComboBox.TabIndex = 34; + uvTypesComboBox.SelectedIndexChanged += uvTypesComboBox_SelectedIndexChanged; + // + // uvEnabledCheckBox + // + uvEnabledCheckBox.AutoSize = true; + uvEnabledCheckBox.Location = new System.Drawing.Point(200, 334); + uvEnabledCheckBox.Name = "uvEnabledCheckBox"; + uvEnabledCheckBox.Size = new System.Drawing.Size(60, 19); + uvEnabledCheckBox.TabIndex = 33; + uvEnabledCheckBox.Text = "Export"; + uvEnabledCheckBox.UseVisualStyleBackColor = true; + uvEnabledCheckBox.CheckedChanged += uvEnabledCheckBox_CheckedChanged; + // + // uvsComboBox + // + uvsComboBox.DropDownStyle = ComboBoxStyle.DropDownList; + uvsComboBox.FormattingEnabled = true; + uvsComboBox.Items.AddRange(new object[] { "UV0", "UV1", "UV2", "UV3", "UV4", "UV5", "UV6", "UV7" }); + uvsComboBox.Location = new System.Drawing.Point(7, 330); + uvsComboBox.Name = "uvsComboBox"; + uvsComboBox.Size = new System.Drawing.Size(75, 23); + uvsComboBox.TabIndex = 32; + uvsComboBox.SelectedIndexChanged += uvsComboBox_SelectedIndexChanged; + // + // canExportCheckBox + // + canExportCheckBox.AutoSize = true; + canExportCheckBox.Location = new System.Drawing.Point(200, 290); + canExportCheckBox.Name = "canExportCheckBox"; + canExportCheckBox.Size = new System.Drawing.Size(60, 19); + canExportCheckBox.TabIndex = 31; + canExportCheckBox.Text = "Export"; + canExportCheckBox.UseVisualStyleBackColor = true; + canExportCheckBox.CheckedChanged += CanExportCheckBox_CheckedChanged; + // + // label8 + // + label8.AutoSize = true; + label8.Location = new System.Drawing.Point(7, 268); + label8.Margin = new Padding(4, 0, 4, 0); + label8.Name = "label8"; + label8.Size = new System.Drawing.Size(132, 15); + label8.TabIndex = 30; + label8.Text = "Selected unity type can:"; + // + // canParseCheckBox + // + canParseCheckBox.AutoSize = true; + canParseCheckBox.Location = new System.Drawing.Point(140, 290); + canParseCheckBox.Name = "canParseCheckBox"; + canParseCheckBox.Size = new System.Drawing.Size(54, 19); + canParseCheckBox.TabIndex = 29; + canParseCheckBox.Text = "Parse"; + canParseCheckBox.UseVisualStyleBackColor = true; + canParseCheckBox.CheckedChanged += CanParseCheckBox_CheckedChanged; + // + // typesComboBox + // + typesComboBox.DropDownStyle = ComboBoxStyle.DropDownList; + typesComboBox.FormattingEnabled = true; + typesComboBox.Items.AddRange(new object[] { ClassIDType.Animation, ClassIDType.AnimationClip, ClassIDType.Animator, ClassIDType.AnimatorController, ClassIDType.AnimatorOverrideController, ClassIDType.AssetBundle, ClassIDType.AudioClip, ClassIDType.Avatar, ClassIDType.Font, ClassIDType.GameObject, ClassIDType.IndexObject, ClassIDType.Material, ClassIDType.Mesh, ClassIDType.MeshFilter, ClassIDType.MeshRenderer, ClassIDType.MiHoYoBinData, ClassIDType.MonoBehaviour, ClassIDType.MonoScript, ClassIDType.MovieTexture, ClassIDType.PlayerSettings, ClassIDType.RectTransform, ClassIDType.Shader, ClassIDType.SkinnedMeshRenderer, ClassIDType.Sprite, ClassIDType.SpriteAtlas, ClassIDType.TextAsset, ClassIDType.Texture2D, ClassIDType.Transform, ClassIDType.VideoClip, ClassIDType.ResourceManager }); + typesComboBox.Location = new System.Drawing.Point(7, 286); + typesComboBox.Name = "typesComboBox"; + typesComboBox.Size = new System.Drawing.Size(127, 23); + typesComboBox.TabIndex = 28; + typesComboBox.SelectedIndexChanged += TypesComboBox_SelectedIndexChanged; + // // label6 // label6.AutoSize = true; - label6.Location = new System.Drawing.Point(101, 275); + label6.Location = new System.Drawing.Point(9, 312); label6.Margin = new Padding(4, 0, 4, 0); label6.Name = "label6"; - label6.Size = new System.Drawing.Size(73, 15); + label6.Size = new System.Drawing.Size(119, 15); label6.TabIndex = 27; - label6.Text = "UV Mapping"; - // - // uvsGridView - // - uvsGridView.AllowUserToAddRows = false; - uvsGridView.AllowUserToDeleteRows = false; - uvsGridView.AllowUserToResizeRows = false; - uvsGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; - uvsGridView.Columns.AddRange(new DataGridViewColumn[] { UVName, UVEnabled, UVType }); - uvsGridView.Location = new System.Drawing.Point(8, 293); - uvsGridView.Name = "uvsGridView"; - uvsGridView.RowHeadersVisible = false; - dataGridViewCellStyle1.Alignment = DataGridViewContentAlignment.MiddleCenter; - uvsGridView.RowsDefaultCellStyle = dataGridViewCellStyle1; - uvsGridView.RowTemplate.Height = 25; - uvsGridView.Size = new System.Drawing.Size(255, 103); - uvsGridView.TabIndex = 18; - // - // UVName - // - UVName.HeaderText = "Name"; - UVName.Name = "UVName"; - UVName.ReadOnly = true; - UVName.Width = 50; - // - // UVEnabled - // - UVEnabled.HeaderText = "Enabled"; - UVEnabled.Name = "UVEnabled"; - UVEnabled.Width = 60; - // - // UVType - // - UVType.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; - UVType.HeaderText = "Type"; - UVType.Name = "UVType"; - UVType.Items.AddRange(typeMap.Values.ToArray()); + label6.Text = "UV mapping options:"; // // minimalAssetMap // @@ -373,8 +443,6 @@ private void InitializeComponent() // groupBox2 // groupBox2.AutoSize = true; - groupBox2.Controls.Add(label9); - groupBox2.Controls.Add(texsGridView); groupBox2.Controls.Add(collectAnimations); groupBox2.Controls.Add(exportBlendShape); groupBox2.Controls.Add(exportAnimations); @@ -396,80 +464,11 @@ private void InitializeComponent() groupBox2.Margin = new Padding(4); groupBox2.Name = "groupBox2"; groupBox2.Padding = new Padding(4); - groupBox2.Size = new System.Drawing.Size(379, 419); + groupBox2.Size = new System.Drawing.Size(380, 236); groupBox2.TabIndex = 11; groupBox2.TabStop = false; groupBox2.Text = "Fbx"; // - // label9 - // - label9.AutoSize = true; - label9.Location = new System.Drawing.Point(133, 230); - label9.Margin = new Padding(4, 0, 4, 0); - label9.Name = "label9"; - label9.Size = new System.Drawing.Size(96, 15); - label9.TabIndex = 28; - label9.Text = "Texture Mapping"; - // - // texsGridView - // - texsGridView.AllowUserToResizeColumns = false; - texsGridView.AllowUserToResizeRows = false; - dataGridViewCellStyle2.Alignment = DataGridViewContentAlignment.MiddleCenter; - texsGridView.AlternatingRowsDefaultCellStyle = dataGridViewCellStyle2; - dataGridViewCellStyle3.Alignment = DataGridViewContentAlignment.MiddleCenter; - dataGridViewCellStyle3.BackColor = System.Drawing.SystemColors.Control; - dataGridViewCellStyle3.Font = new System.Drawing.Font("Segoe UI", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point); - dataGridViewCellStyle3.ForeColor = System.Drawing.SystemColors.WindowText; - dataGridViewCellStyle3.SelectionBackColor = System.Drawing.SystemColors.Highlight; - dataGridViewCellStyle3.SelectionForeColor = System.Drawing.SystemColors.HighlightText; - dataGridViewCellStyle3.WrapMode = DataGridViewTriState.True; - texsGridView.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle3; - texsGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.DisableResizing; - texsGridView.Columns.AddRange(new DataGridViewColumn[] { TexName, TexType }); - dataGridViewCellStyle6.Alignment = DataGridViewContentAlignment.MiddleCenter; - dataGridViewCellStyle6.BackColor = System.Drawing.SystemColors.Window; - dataGridViewCellStyle6.Font = new System.Drawing.Font("Segoe UI", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point); - dataGridViewCellStyle6.ForeColor = System.Drawing.SystemColors.ControlText; - dataGridViewCellStyle6.SelectionBackColor = System.Drawing.SystemColors.Highlight; - dataGridViewCellStyle6.SelectionForeColor = System.Drawing.SystemColors.HighlightText; - dataGridViewCellStyle6.WrapMode = DataGridViewTriState.False; - texsGridView.DefaultCellStyle = dataGridViewCellStyle6; - texsGridView.Location = new System.Drawing.Point(7, 248); - texsGridView.Name = "texsGridView"; - dataGridViewCellStyle7.Alignment = DataGridViewContentAlignment.MiddleCenter; - dataGridViewCellStyle7.BackColor = System.Drawing.SystemColors.Control; - dataGridViewCellStyle7.Font = new System.Drawing.Font("Segoe UI", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point); - dataGridViewCellStyle7.ForeColor = System.Drawing.SystemColors.WindowText; - dataGridViewCellStyle7.SelectionBackColor = System.Drawing.SystemColors.Highlight; - dataGridViewCellStyle7.SelectionForeColor = System.Drawing.SystemColors.HighlightText; - dataGridViewCellStyle7.WrapMode = DataGridViewTriState.True; - texsGridView.RowHeadersDefaultCellStyle = dataGridViewCellStyle7; - texsGridView.RowHeadersWidthSizeMode = DataGridViewRowHeadersWidthSizeMode.DisableResizing; - dataGridViewCellStyle8.Alignment = DataGridViewContentAlignment.MiddleCenter; - texsGridView.RowsDefaultCellStyle = dataGridViewCellStyle8; - texsGridView.RowTemplate.Height = 25; - texsGridView.Size = new System.Drawing.Size(365, 148); - texsGridView.TabIndex = 27; - // - // TexName - // - TexName.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; - dataGridViewCellStyle4.Alignment = DataGridViewContentAlignment.MiddleCenter; - TexName.DefaultCellStyle = dataGridViewCellStyle4; - TexName.HeaderText = "Name"; - TexName.Name = "TexName"; - TexName.Resizable = DataGridViewTriState.False; - // - // TexType - // - dataGridViewCellStyle5.Alignment = DataGridViewContentAlignment.MiddleCenter; - TexType.DefaultCellStyle = dataGridViewCellStyle5; - TexType.HeaderText = "Type"; - TexType.Name = "TexType"; - TexType.Items.AddRange(typeMap.Values.ToArray()); - TexType.Resizable = DataGridViewTriState.False; - // // exportBlendShape // exportBlendShape.AutoSize = true; @@ -500,7 +499,7 @@ private void InitializeComponent() // scaleFactor.DecimalPlaces = 2; scaleFactor.Increment = new decimal(new int[] { 1, 0, 0, 131072 }); - scaleFactor.Location = new System.Drawing.Point(103, 185); + scaleFactor.Location = new System.Drawing.Point(102, 189); scaleFactor.Margin = new Padding(4); scaleFactor.Name = "scaleFactor"; scaleFactor.Size = new System.Drawing.Size(59, 23); @@ -511,7 +510,7 @@ private void InitializeComponent() // label5 // label5.AutoSize = true; - label5.Location = new System.Drawing.Point(9, 189); + label5.Location = new System.Drawing.Point(8, 193); label5.Margin = new Padding(4, 0, 4, 0); label5.Name = "label5"; label5.Size = new System.Drawing.Size(67, 15); @@ -523,7 +522,7 @@ private void InitializeComponent() fbxFormat.DropDownStyle = ComboBoxStyle.DropDownList; fbxFormat.FormattingEnabled = true; fbxFormat.Items.AddRange(new object[] { "Binary", "Ascii" }); - fbxFormat.Location = new System.Drawing.Point(272, 121); + fbxFormat.Location = new System.Drawing.Point(271, 125); fbxFormat.Margin = new Padding(4); fbxFormat.Name = "fbxFormat"; fbxFormat.Size = new System.Drawing.Size(70, 23); @@ -532,7 +531,7 @@ private void InitializeComponent() // label4 // label4.AutoSize = true; - label4.Location = new System.Drawing.Point(189, 125); + label4.Location = new System.Drawing.Point(188, 129); label4.Margin = new Padding(4, 0, 4, 0); label4.Name = "label4"; label4.Size = new System.Drawing.Size(65, 15); @@ -544,7 +543,7 @@ private void InitializeComponent() fbxVersion.DropDownStyle = ComboBoxStyle.DropDownList; fbxVersion.FormattingEnabled = true; fbxVersion.Items.AddRange(new object[] { "6.1", "7.1", "7.2", "7.3", "7.4", "7.5" }); - fbxVersion.Location = new System.Drawing.Point(272, 153); + fbxVersion.Location = new System.Drawing.Point(271, 157); fbxVersion.Margin = new Padding(4); fbxVersion.Name = "fbxVersion"; fbxVersion.Size = new System.Drawing.Size(70, 23); @@ -553,7 +552,7 @@ private void InitializeComponent() // label3 // label3.AutoSize = true; - label3.Location = new System.Drawing.Point(189, 157); + label3.Location = new System.Drawing.Point(188, 161); label3.Margin = new Padding(4, 0, 4, 0); label3.Name = "label3"; label3.Size = new System.Drawing.Size(65, 15); @@ -562,7 +561,7 @@ private void InitializeComponent() // // boneSize // - boneSize.Location = new System.Drawing.Point(103, 153); + boneSize.Location = new System.Drawing.Point(102, 157); boneSize.Margin = new Padding(4); boneSize.Name = "boneSize"; boneSize.Size = new System.Drawing.Size(59, 23); @@ -572,7 +571,7 @@ private void InitializeComponent() // label2 // label2.AutoSize = true; - label2.Location = new System.Drawing.Point(9, 157); + label2.Location = new System.Drawing.Point(8, 161); label2.Margin = new Padding(4, 0, 4, 0); label2.Name = "label2"; label2.Size = new System.Drawing.Size(54, 15); @@ -584,7 +583,7 @@ private void InitializeComponent() exportSkins.AutoSize = true; exportSkins.Checked = true; exportSkins.CheckState = CheckState.Checked; - exportSkins.Location = new System.Drawing.Point(94, 17); + exportSkins.Location = new System.Drawing.Point(154, 17); exportSkins.Margin = new Padding(4); exportSkins.Name = "exportSkins"; exportSkins.Size = new System.Drawing.Size(89, 19); @@ -595,7 +594,7 @@ private void InitializeComponent() // label1 // label1.AutoSize = true; - label1.Location = new System.Drawing.Point(9, 125); + label1.Location = new System.Drawing.Point(8, 129); label1.Margin = new Padding(4, 0, 4, 0); label1.Name = "label1"; label1.Size = new System.Drawing.Size(81, 15); @@ -606,7 +605,7 @@ private void InitializeComponent() // filterPrecision.DecimalPlaces = 2; filterPrecision.Increment = new decimal(new int[] { 1, 0, 0, 131072 }); - filterPrecision.Location = new System.Drawing.Point(103, 123); + filterPrecision.Location = new System.Drawing.Point(102, 127); filterPrecision.Margin = new Padding(4); filterPrecision.Name = "filterPrecision"; filterPrecision.Size = new System.Drawing.Size(59, 23); @@ -629,7 +628,7 @@ private void InitializeComponent() exportAllNodes.AutoSize = true; exportAllNodes.Checked = true; exportAllNodes.CheckState = CheckState.Checked; - exportAllNodes.Location = new System.Drawing.Point(191, 17); + exportAllNodes.Location = new System.Drawing.Point(7, 96); exportAllNodes.Margin = new Padding(4); exportAllNodes.Name = "exportAllNodes"; exportAllNodes.Size = new System.Drawing.Size(110, 19); @@ -656,7 +655,7 @@ private void InitializeComponent() AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F); AutoScaleMode = AutoScaleMode.Font; CancelButton = Cancel; - ClientSize = new System.Drawing.Size(677, 480); + ClientSize = new System.Drawing.Size(677, 467); Controls.Add(groupBox2); Controls.Add(groupBox1); Controls.Add(Cancel); @@ -673,13 +672,11 @@ private void InitializeComponent() TopMost = true; groupBox1.ResumeLayout(false); groupBox1.PerformLayout(); - ((System.ComponentModel.ISupportInitialize)uvsGridView).EndInit(); ((System.ComponentModel.ISupportInitialize)key).EndInit(); panel1.ResumeLayout(false); panel1.PerformLayout(); groupBox2.ResumeLayout(false); groupBox2.PerformLayout(); - ((System.ComponentModel.ISupportInitialize)texsGridView).EndInit(); ((System.ComponentModel.ISupportInitialize)scaleFactor).EndInit(); ((System.ComponentModel.ISupportInitialize)boneSize).EndInit(); ((System.ComponentModel.ISupportInitialize)filterPrecision).EndInit(); @@ -725,14 +722,16 @@ private void InitializeComponent() private System.Windows.Forms.ToolTip keyToolTip; private System.Windows.Forms.CheckBox minimalAssetMap; private System.Windows.Forms.Label label7; - private System.Windows.Forms.DataGridView texsGridView; - private Label label9; - private DataGridViewTextBoxColumn TexName; - private DataGridViewComboBoxColumn TexType; private Label label6; - private DataGridView uvsGridView; - private DataGridViewTextBoxColumn UVName; - private DataGridViewCheckBoxColumn UVEnabled; - private DataGridViewComboBoxColumn UVType; + private Label label8; + private CheckBox canParseCheckBox; + private ComboBox typesComboBox; + private CheckBox canExportCheckBox; + private ComboBox uvTypesComboBox; + private CheckBox uvEnabledCheckBox; + private ComboBox uvsComboBox; + private Label label10; + private ComboBox texTypeComboBox; + private TextBox texNameTextBox; } } diff --git a/AssetStudio.GUI/ExportOptions.cs b/AssetStudio.GUI/ExportOptions.cs index cab4beb..87219a6 100644 --- a/AssetStudio.GUI/ExportOptions.cs +++ b/AssetStudio.GUI/ExportOptions.cs @@ -8,17 +8,9 @@ namespace AssetStudio.GUI { public partial class ExportOptions : Form { - private Dictionary typeMap = new Dictionary() - { - { 0, "Diffuse" }, - { 1, "NormalMap" }, - { 2, "Specular" }, - { 3, "Bump" }, - { 4, "Ambient" }, - { 5, "Emissive" }, - { 6, "Reflection" }, - { 7, "Displacement" }, - }; + private Dictionary types = new Dictionary(); + private Dictionary uvs = new Dictionary(); + private Dictionary texs = new Dictionary(); public ExportOptions() { InitializeComponent(); @@ -51,23 +43,12 @@ public ExportOptions() encrypted.Checked = Properties.Settings.Default.encrypted; key.Value = Properties.Settings.Default.key; minimalAssetMap.Checked = Properties.Settings.Default.minimalAssetMap; - var uvs = JsonConvert.DeserializeObject>(Properties.Settings.Default.uvs); - foreach (var uv in uvs) - { - var rowIdx = uvsGridView.Rows.Add(); - - uvsGridView.Rows[rowIdx].Cells["UVName"].Value = uv.Key; - uvsGridView.Rows[rowIdx].Cells["UVEnabled"].Value = uv.Value.Item1; - uvsGridView.Rows[rowIdx].Cells["UVType"].Value = typeMap[uv.Value.Item2]; - } - var texs = JsonConvert.DeserializeObject>(Properties.Settings.Default.texs); - foreach (var tex in texs) - { - var rowIdx = texsGridView.Rows.Add(); - - texsGridView.Rows[rowIdx].Cells["TexName"].Value = tex.Key; - texsGridView.Rows[rowIdx].Cells["TexType"].Value = typeMap[tex.Value]; - } + types = JsonConvert.DeserializeObject>(Properties.Settings.Default.types); + uvs = JsonConvert.DeserializeObject>(Properties.Settings.Default.uvs); + texs = JsonConvert.DeserializeObject>(Properties.Settings.Default.texs); + typesComboBox.SelectedIndex = 0; + uvsComboBox.SelectedIndex = 0; + texTypeComboBox.SelectedIndex = 0; } private void OKbutton_Click(object sender, EventArgs e) @@ -100,33 +81,88 @@ private void OKbutton_Click(object sender, EventArgs e) Properties.Settings.Default.encrypted = encrypted.Checked; Properties.Settings.Default.key = (byte)key.Value; Properties.Settings.Default.minimalAssetMap = minimalAssetMap.Checked; - var uvs = new Dictionary(); - foreach (DataGridViewRow row in uvsGridView.Rows) - { - var name = row.Cells["UVName"].Value as string; - var enabled = (bool)row.Cells["UVEnabled"].Value; - var type = row.Cells["UVType"].Value as string; - if (string.IsNullOrEmpty(name) || string.IsNullOrEmpty(type)) continue; - uvs.Add(name, (enabled, typeMap.FirstOrDefault(x => x.Value == type).Key)); - } + Properties.Settings.Default.types = JsonConvert.SerializeObject(types); Properties.Settings.Default.uvs = JsonConvert.SerializeObject(uvs); - var texs = new Dictionary(); - foreach (DataGridViewRow row in texsGridView.Rows) - { - var name = row.Cells["TexName"].Value as string; - var type = row.Cells["TexType"].Value as string; - if (string.IsNullOrEmpty(name) || string.IsNullOrEmpty(type)) continue; - texs.Add(name, typeMap.FirstOrDefault(x => x.Value == type).Key); - } Properties.Settings.Default.texs = JsonConvert.SerializeObject(texs); Properties.Settings.Default.Save(); MiHoYoBinData.Key = (byte)key.Value; MiHoYoBinData.Encrypted = encrypted.Checked; AssetsHelper.Minimal = Properties.Settings.Default.minimalAssetMap; + TypeFlags.SetTypes(types); DialogResult = DialogResult.OK; Close(); } + private void TypesComboBox_SelectedIndexChanged(object sender, EventArgs e) + { + if (sender is ComboBox comboBox && types.TryGetValue((ClassIDType)comboBox.SelectedItem, out var param)) + { + canParseCheckBox.Checked = param.Item1; + canExportCheckBox.Checked = param.Item2; + } + } + + private void CanParseCheckBox_CheckedChanged(object sender, EventArgs e) + { + if (sender is CheckBox checkBox && types.TryGetValue((ClassIDType)typesComboBox.SelectedItem, out var param)) + { + param.Item1 = checkBox.Checked; + types[(ClassIDType)typesComboBox.SelectedItem] = (param.Item1, param.Item2); + } + } + + private void CanExportCheckBox_CheckedChanged(object sender, EventArgs e) + { + if (sender is CheckBox checkBox && types.TryGetValue((ClassIDType)typesComboBox.SelectedItem, out var param)) + { + param.Item2 = checkBox.Checked; + types[(ClassIDType)typesComboBox.SelectedItem] = (param.Item1, param.Item2); + } + } + + private void uvsComboBox_SelectedIndexChanged(object sender, EventArgs e) + { + if (sender is ComboBox comboBox && uvs.TryGetValue(comboBox.SelectedItem.ToString(), out var param)) + { + uvEnabledCheckBox.Checked = param.Item1; + uvTypesComboBox.SelectedIndex = param.Item2; + } + } + + private void uvEnabledCheckBox_CheckedChanged(object sender, EventArgs e) + { + if (sender is CheckBox checkBox && uvs.TryGetValue(uvsComboBox.SelectedItem.ToString(), out var param)) + { + param.Item1 = checkBox.Checked; + uvs[uvsComboBox.SelectedItem.ToString()] = (param.Item1, param.Item2); + } + } + + private void uvTypesComboBox_SelectedIndexChanged(object sender, EventArgs e) + { + if (sender is ComboBox comboBox && uvs.TryGetValue(uvsComboBox.SelectedItem.ToString(), out var param)) + { + param.Item2 = comboBox.SelectedIndex; + uvs[uvsComboBox.SelectedItem.ToString()] = (param.Item1, param.Item2); + } + } + + private void TexTypeComboBox_SelectedIndexChanged(object sender, EventArgs e) + { + if (sender is ComboBox comboBox && texs.TryGetValue(comboBox.SelectedIndex, out var name)) + { + texNameTextBox.Text = name; + } + } + + private void TexNameTextBox_LostFocus(object sender, EventArgs e) + { + if (sender is TextBox textBox && texs.ContainsKey(texTypeComboBox.SelectedIndex)) + { + texs[texTypeComboBox.SelectedIndex] = textBox.Text; + } + } + private void Cancel_Click(object sender, EventArgs e) { DialogResult = DialogResult.Cancel; diff --git a/AssetStudio.GUI/ExportOptions.resx b/AssetStudio.GUI/ExportOptions.resx index c378442..dec925d 100644 --- a/AssetStudio.GUI/ExportOptions.resx +++ b/AssetStudio.GUI/ExportOptions.resx @@ -117,15 +117,6 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - True - - - True - - - True - 162, 17 diff --git a/AssetStudio.GUI/Exporter.cs b/AssetStudio.GUI/Exporter.cs index 29086d6..740766b 100644 --- a/AssetStudio.GUI/Exporter.cs +++ b/AssetStudio.GUI/Exporter.cs @@ -365,7 +365,7 @@ public static bool ExportAnimator(AssetItem item, string exportPath, List>(Properties.Settings.Default.uvs), - texs = JsonConvert.DeserializeObject>(Properties.Settings.Default.texs), + texs = JsonConvert.DeserializeObject>(Properties.Settings.Default.texs), }; var convert = animationList != null ? new ModelConverter(m_Animator, options, animationList.Select(x => (AnimationClip)x.Asset).ToArray()) @@ -391,7 +391,7 @@ public static bool ExportGameObject(GameObject gameObject, string exportPath, Li game = Studio.Game, collectAnimations = Properties.Settings.Default.collectAnimations, uvs = JsonConvert.DeserializeObject>(Properties.Settings.Default.uvs), - texs = JsonConvert.DeserializeObject>(Properties.Settings.Default.texs), + texs = JsonConvert.DeserializeObject>(Properties.Settings.Default.texs), }; var convert = animationList != null ? new ModelConverter(gameObject, options, animationList.Select(x => (AnimationClip)x.Asset).ToArray()) @@ -416,7 +416,7 @@ public static void ExportGameObjectMerge(List gameObject, string exp game = Studio.Game, collectAnimations = Properties.Settings.Default.collectAnimations, uvs = JsonConvert.DeserializeObject>(Properties.Settings.Default.uvs), - texs = JsonConvert.DeserializeObject>(Properties.Settings.Default.texs), + texs = JsonConvert.DeserializeObject>(Properties.Settings.Default.texs), }; var convert = animationList != null ? new ModelConverter(rootName, gameObject, options, animationList.Select(x => (AnimationClip)x.Asset).ToArray()) diff --git a/AssetStudio.GUI/MainForm.cs b/AssetStudio.GUI/MainForm.cs index a812d56..d5c8def 100644 --- a/AssetStudio.GUI/MainForm.cs +++ b/AssetStudio.GUI/MainForm.cs @@ -160,6 +160,7 @@ private void InitalizeOptions() specifyGame.SelectedIndex = Properties.Settings.Default.selectedGame; specifyGame.SelectedIndexChanged += new EventHandler(specifyGame_SelectedIndexChanged); Studio.Game = GameManager.GetGame(Properties.Settings.Default.selectedGame); + TypeFlags.SetTypes(JsonConvert.DeserializeObject>(Properties.Settings.Default.types)); Logger.Info($"Target Game type is {Studio.Game.Type}"); if (Studio.Game.Type.IsUnityCN()) @@ -175,6 +176,10 @@ private void InitalizeOptions() Properties.Settings.Default.selectedCABMapName = ""; Properties.Settings.Default.Save(); } + else + { + MapNameComboBox.Text = Properties.Settings.Default.selectedCABMapName; + } } } private void MainForm_DragEnter(object sender, DragEventArgs e) @@ -1303,7 +1308,7 @@ private void PreviewGameObject(GameObject m_GameObject) game = Studio.Game, collectAnimations = Properties.Settings.Default.collectAnimations, uvs = JsonConvert.DeserializeObject>(Properties.Settings.Default.uvs), - texs = JsonConvert.DeserializeObject>(Properties.Settings.Default.texs), + texs = JsonConvert.DeserializeObject>(Properties.Settings.Default.texs), }; var model = new ModelConverter(m_GameObject, options, Array.Empty()); PreviewModel(model); @@ -1316,7 +1321,7 @@ private void PreviewAnimator(Animator m_Animator) game = Studio.Game, collectAnimations = Properties.Settings.Default.collectAnimations, uvs = JsonConvert.DeserializeObject>(Properties.Settings.Default.uvs), - texs = JsonConvert.DeserializeObject>(Properties.Settings.Default.texs), + texs = JsonConvert.DeserializeObject>(Properties.Settings.Default.texs), }; var model = new ModelConverter(m_Animator, options, Array.Empty()); PreviewModel(model); diff --git a/AssetStudio.GUI/Properties/Settings.Designer.cs b/AssetStudio.GUI/Properties/Settings.Designer.cs index eb7c55c..d3cd12d 100644 --- a/AssetStudio.GUI/Properties/Settings.Designer.cs +++ b/AssetStudio.GUI/Properties/Settings.Designer.cs @@ -481,5 +481,17 @@ public int loggerEventType { this["loggerEventType"] = value; } } + + [global::System.Configuration.UserScopedSettingAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.DefaultSettingValueAttribute(@"{""Animation"":{""Item1"":true,""Item2"":false},""AnimationClip"":{""Item1"":true,""Item2"":true},""Animator"":{""Item1"":true,""Item2"":true},""AnimatorController"":{""Item1"":true,""Item2"":false},""AnimatorOverrideController"":{""Item1"":true,""Item2"":false},""AssetBundle"":{""Item1"":true,""Item2"":false},""AudioClip"":{""Item1"":true,""Item2"":true},""Avatar"":{""Item1"":true,""Item2"":false},""Font"":{""Item1"":true,""Item2"":true},""GameObject"":{""Item1"":true,""Item2"":false},""IndexObject"":{""Item1"":true,""Item2"":false},""Material"":{""Item1"":true,""Item2"":true},""Mesh"":{""Item1"":true,""Item2"":true},""MeshFilter"":{""Item1"":true,""Item2"":false},""MeshRenderer"":{""Item1"":true,""Item2"":false},""MiHoYoBinData"":{""Item1"":true,""Item2"":true},""MonoBehaviour"":{""Item1"":true,""Item2"":true},""MonoScript"":{""Item1"":true,""Item2"":false},""MovieTexture"":{""Item1"":true,""Item2"":true},""PlayerSettings"":{""Item1"":true,""Item2"":false},""RectTransform"":{""Item1"":true,""Item2"":false},""Shader"":{""Item1"":true,""Item2"":true},""SkinnedMeshRenderer"":{""Item1"":true,""Item2"":false},""Sprite"":{""Item1"":true,""Item2"":true},""SpriteAtlas"":{""Item1"":true,""Item2"":false},""TextAsset"":{""Item1"":true,""Item2"":true},""Texture2D"":{""Item1"":true,""Item2"":true},""Transform"":{""Item1"":true,""Item2"":false},""VideoClip"":{""Item1"":true,""Item2"":true},""ResourceManager"":{""Item1"":true,""Item2"":false}}")] + public string types { + get { + return ((string)(this["types"])); + } + set { + this["types"] = value; + } + } } } diff --git a/AssetStudio.GUI/Properties/Settings.settings b/AssetStudio.GUI/Properties/Settings.settings index 5aa83b0..c149645 100644 --- a/AssetStudio.GUI/Properties/Settings.settings +++ b/AssetStudio.GUI/Properties/Settings.settings @@ -116,5 +116,8 @@ 30 + + {"Animation":{"Item1":true,"Item2":false},"AnimationClip":{"Item1":true,"Item2":true},"Animator":{"Item1":true,"Item2":true},"AnimatorController":{"Item1":true,"Item2":false},"AnimatorOverrideController":{"Item1":true,"Item2":false},"AssetBundle":{"Item1":true,"Item2":false},"AudioClip":{"Item1":true,"Item2":true},"Avatar":{"Item1":true,"Item2":false},"Font":{"Item1":true,"Item2":true},"GameObject":{"Item1":true,"Item2":false},"IndexObject":{"Item1":true,"Item2":false},"Material":{"Item1":true,"Item2":true},"Mesh":{"Item1":true,"Item2":true},"MeshFilter":{"Item1":true,"Item2":false},"MeshRenderer":{"Item1":true,"Item2":false},"MiHoYoBinData":{"Item1":true,"Item2":true},"MonoBehaviour":{"Item1":true,"Item2":true},"MonoScript":{"Item1":true,"Item2":false},"MovieTexture":{"Item1":true,"Item2":true},"PlayerSettings":{"Item1":true,"Item2":false},"RectTransform":{"Item1":true,"Item2":false},"Shader":{"Item1":true,"Item2":true},"SkinnedMeshRenderer":{"Item1":true,"Item2":false},"Sprite":{"Item1":true,"Item2":true},"SpriteAtlas":{"Item1":true,"Item2":false},"TextAsset":{"Item1":true,"Item2":true},"Texture2D":{"Item1":true,"Item2":true},"Transform":{"Item1":true,"Item2":false},"VideoClip":{"Item1":true,"Item2":true},"ResourceManager":{"Item1":true,"Item2":false}} + \ No newline at end of file diff --git a/AssetStudio.GUI/Studio.cs b/AssetStudio.GUI/Studio.cs index 353f15f..e10d8b0 100644 --- a/AssetStudio.GUI/Studio.cs +++ b/AssetStudio.GUI/Studio.cs @@ -257,20 +257,21 @@ public static (string, List) BuildAssetData() case Texture2D m_Texture2D: if (!string.IsNullOrEmpty(m_Texture2D.m_StreamData?.path)) assetItem.FullSize = asset.byteSize + m_Texture2D.m_StreamData.size; - exportable = true; + exportable = ClassIDType.Texture2D.CanExport(); break; case AudioClip m_AudioClip: if (!string.IsNullOrEmpty(m_AudioClip.m_Source)) assetItem.FullSize = asset.byteSize + m_AudioClip.m_Size; - exportable = true; + exportable = ClassIDType.AudioClip.CanExport(); break; case VideoClip m_VideoClip: if (!string.IsNullOrEmpty(m_VideoClip.m_OriginalPath)) - assetItem.FullSize = asset.byteSize + (long)m_VideoClip.m_ExternalResources.m_Size; - exportable = true; + assetItem.FullSize = asset.byteSize + m_VideoClip.m_ExternalResources.m_Size; + exportable = ClassIDType.VideoClip.CanExport(); break; case PlayerSettings m_PlayerSettings: productName = m_PlayerSettings.productName; + exportable = ClassIDType.PlayerSettings.CanExport(); break; case AssetBundle m_AssetBundle: if (!SkipContainer) @@ -286,30 +287,36 @@ public static (string, List) BuildAssetData() } } } + + exportable = ClassIDType.AssetBundle.CanExport(); break; case IndexObject m_IndexObject: foreach(var index in m_IndexObject.AssetMap) { mihoyoBinDataNames.Add((index.Value.Object, index.Key)); } + + exportable = ClassIDType.IndexObject.CanExport(); break; case ResourceManager m_ResourceManager: foreach (var m_Container in m_ResourceManager.m_Container) { containers.Add((m_Container.Value, m_Container.Key)); } + + exportable = ClassIDType.ResourceManager.CanExport(); break; - case Mesh _: - case TextAsset _: - case AnimationClip _: - case Font _: - case MovieTexture _: - case Sprite _: - case Material _: - case MiHoYoBinData _: - case Shader _: - case Animator _: - case MonoBehaviour _: + case Mesh _ when ClassIDType.Mesh.CanExport(): + case TextAsset _ when ClassIDType.TextAsset.CanExport(): + case AnimationClip _ when ClassIDType.AnimationClip.CanExport(): + case Font _ when ClassIDType.Font.CanExport(): + case MovieTexture _ when ClassIDType.MovieTexture.CanExport(): + case Sprite _ when ClassIDType.Sprite.CanExport(): + case Material _ when ClassIDType.Material.CanExport(): + case MiHoYoBinData _ when ClassIDType.MiHoYoBinData.CanExport(): + case Shader _ when ClassIDType.Shader.CanExport(): + case Animator _ when ClassIDType.Animator.CanExport(): + case MonoBehaviour _ when ClassIDType.MonoBehaviour.CanExport(): exportable = true; break; } diff --git a/AssetStudio.PInvoke/AssetStudio.PInvoke.csproj b/AssetStudio.PInvoke/AssetStudio.PInvoke.csproj index 525d56b..86e9438 100644 --- a/AssetStudio.PInvoke/AssetStudio.PInvoke.csproj +++ b/AssetStudio.PInvoke/AssetStudio.PInvoke.csproj @@ -1,10 +1,10 @@ - net6.0;net7.0 - 1.00.00 - 1.00.00 - 1.00.00 + net7.0;net8.0 + 1.36.00 + 1.36.00 + 1.36.00 Copyright © Perfare 2020-2022; Copyright © hozuki 2020 embedded diff --git a/AssetStudio.Utility/AssetStudio.Utility.csproj b/AssetStudio.Utility/AssetStudio.Utility.csproj index d61cba9..675023c 100644 --- a/AssetStudio.Utility/AssetStudio.Utility.csproj +++ b/AssetStudio.Utility/AssetStudio.Utility.csproj @@ -1,10 +1,10 @@ - net6.0;net7.0 - 1.00.00 - 1.00.00 - 1.00.00 + net7.0;net8.0 + 1.36.00 + 1.36.00 + 1.36.00 Copyright © Perfare 2018-2022 embedded true diff --git a/AssetStudio.Utility/ModelConverter.cs b/AssetStudio.Utility/ModelConverter.cs index 6700aed..8a542c5 100644 --- a/AssetStudio.Utility/ModelConverter.cs +++ b/AssetStudio.Utility/ModelConverter.cs @@ -712,8 +712,9 @@ private ImportedMaterial ConvertMaterial(Material mat) iMat.Textures.Add(texture); int dest = -1; - if (options.texs.TryGetValue(texEnv.Key, out var targetDest)) - dest = targetDest; + var entry = options.texs.FirstOrDefault(x => x.Value == texEnv.Key); + if (!entry.Equals(default)) + dest = entry.Key; else if (texEnv.Key == "_MainTex") dest = 0; else if (texEnv.Key == "_BumpMap") @@ -1173,7 +1174,7 @@ public record Options public Game game; public bool collectAnimations; public Dictionary uvs; - public Dictionary texs; + public Dictionary texs; } } } diff --git a/AssetStudio/AssetStudio.csproj b/AssetStudio/AssetStudio.csproj index 03ef9c2..9024066 100644 --- a/AssetStudio/AssetStudio.csproj +++ b/AssetStudio/AssetStudio.csproj @@ -1,10 +1,10 @@ - net6.0;net7.0 - 1.00.00 - 1.00.00 - 1.00.00 + net7.0;net8.0 + 1.36.00 + 1.36.00 + 1.36.00 Copyright © Razmoth 2022; Copyright © Perfare 2018-2022 embedded diff --git a/AssetStudio/AssetsHelper.cs b/AssetStudio/AssetsHelper.cs index 4c97deb..0b365a4 100644 --- a/AssetStudio/AssetsHelper.cs +++ b/AssetStudio/AssetsHelper.cs @@ -361,12 +361,12 @@ private static void BuildAssetMap(string file, List assets, ClassIDT Container = "" }; - var exportable = true; + var exportable = false; try { switch (objectReader.type) { - case ClassIDType.AssetBundle: + case ClassIDType.AssetBundle when ClassIDType.AssetBundle.CanParse(): var assetBundle = new AssetBundle(objectReader); foreach (var m_Container in assetBundle.m_Container) { @@ -378,33 +378,38 @@ private static void BuildAssetMap(string file, List assets, ClassIDT containers.Add((assetBundle.m_PreloadTable[k], m_Container.Key)); } } + obj = null; asset.Name = assetBundle.m_Name; - exportable = !Minimal; + exportable = ClassIDType.AssetBundle.CanExport(); break; - case ClassIDType.GameObject: + case ClassIDType.GameObject when ClassIDType.GameObject.CanParse(): var gameObject = new GameObject(objectReader); obj = gameObject; asset.Name = gameObject.m_Name; - exportable = !Minimal; + exportable = ClassIDType.GameObject.CanExport(); break; - case ClassIDType.Shader: + case ClassIDType.Shader when ClassIDType.Shader.CanParse(): asset.Name = objectReader.ReadAlignedString(); if (string.IsNullOrEmpty(asset.Name)) { var m_parsedForm = new SerializedShader(objectReader); asset.Name = m_parsedForm.m_Name; } + + exportable = ClassIDType.Shader.CanExport(); break; - case ClassIDType.Animator: + case ClassIDType.Animator when ClassIDType.Animator.CanParse(): var component = new PPtr(objectReader); animators.Add((component, asset)); + exportable = ClassIDType.Animator.CanExport(); break; - case ClassIDType.MiHoYoBinData: + case ClassIDType.MiHoYoBinData when ClassIDType.MiHoYoBinData.CanParse(): var MiHoYoBinData = new MiHoYoBinData(objectReader); obj = MiHoYoBinData; + exportable = ClassIDType.MiHoYoBinData.CanExport(); break; - case ClassIDType.IndexObject: + case ClassIDType.IndexObject when ClassIDType.IndexObject.CanParse(): var indexObject = new IndexObject(objectReader); obj = null; foreach (var index in indexObject.AssetMap) @@ -412,19 +417,20 @@ private static void BuildAssetMap(string file, List assets, ClassIDT mihoyoBinDataNames.Add((index.Value.Object, index.Key)); } asset.Name = "IndexObject"; - exportable = !Minimal; + exportable = ClassIDType.IndexObject.CanExport(); break; - case ClassIDType.Font: - case ClassIDType.Material: - case ClassIDType.Texture: - case ClassIDType.Mesh: - case ClassIDType.Sprite: - case ClassIDType.TextAsset: - case ClassIDType.Texture2D: - case ClassIDType.VideoClip: - case ClassIDType.AudioClip: - case ClassIDType.AnimationClip: + case ClassIDType.Font when ClassIDType.Font.CanExport(): + case ClassIDType.Material when ClassIDType.Material.CanExport(): + case ClassIDType.Texture when ClassIDType.Texture.CanExport(): + case ClassIDType.Mesh when ClassIDType.Mesh.CanExport(): + case ClassIDType.Sprite when ClassIDType.Sprite.CanExport(): + case ClassIDType.TextAsset when ClassIDType.TextAsset.CanExport(): + case ClassIDType.Texture2D when ClassIDType.Texture2D.CanExport(): + case ClassIDType.VideoClip when ClassIDType.VideoClip.CanExport(): + case ClassIDType.AudioClip when ClassIDType.AudioClip.CanExport(): + case ClassIDType.AnimationClip when ClassIDType.AnimationClip.CanExport(): asset.Name = objectReader.ReadAlignedString(); + exportable = true; break; default: asset.Name = objectReader.type.ToString(); diff --git a/AssetStudio/AssetsManager.cs b/AssetStudio/AssetsManager.cs index e7675c2..ae73a49 100644 --- a/AssetStudio/AssetsManager.cs +++ b/AssetStudio/AssetsManager.cs @@ -646,36 +646,36 @@ private void ReadAssets() { Object obj = objectReader.type switch { - ClassIDType.Animation => new Animation(objectReader), - ClassIDType.AnimationClip => new AnimationClip(objectReader), - ClassIDType.Animator => new Animator(objectReader), - ClassIDType.AnimatorController => new AnimatorController(objectReader), - ClassIDType.AnimatorOverrideController => new AnimatorOverrideController(objectReader), - ClassIDType.AssetBundle => new AssetBundle(objectReader), - ClassIDType.AudioClip => new AudioClip(objectReader), - ClassIDType.Avatar => new Avatar(objectReader), - ClassIDType.Font => new Font(objectReader), - ClassIDType.GameObject => new GameObject(objectReader), - ClassIDType.IndexObject => new IndexObject(objectReader), - ClassIDType.Material => new Material(objectReader), - ClassIDType.Mesh => new Mesh(objectReader), - ClassIDType.MeshFilter => new MeshFilter(objectReader), - ClassIDType.MeshRenderer => new MeshRenderer(objectReader), - ClassIDType.MiHoYoBinData => new MiHoYoBinData(objectReader), - ClassIDType.MonoBehaviour => new MonoBehaviour(objectReader), - ClassIDType.MonoScript => new MonoScript(objectReader), - ClassIDType.MovieTexture => new MovieTexture(objectReader), - ClassIDType.PlayerSettings => new PlayerSettings(objectReader), - ClassIDType.RectTransform => new RectTransform(objectReader), - ClassIDType.Shader => new Shader(objectReader), - ClassIDType.SkinnedMeshRenderer => new SkinnedMeshRenderer(objectReader), - ClassIDType.Sprite => new Sprite(objectReader), - ClassIDType.SpriteAtlas => new SpriteAtlas(objectReader), - ClassIDType.TextAsset => new TextAsset(objectReader), - ClassIDType.Texture2D => new Texture2D(objectReader), - ClassIDType.Transform => new Transform(objectReader), - ClassIDType.VideoClip => new VideoClip(objectReader), - ClassIDType.ResourceManager => new ResourceManager(objectReader), + ClassIDType.Animation when ClassIDType.Animation.CanParse() => new Animation(objectReader), + ClassIDType.AnimationClip when ClassIDType.AnimationClip.CanParse() => new AnimationClip(objectReader), + ClassIDType.Animator when ClassIDType.Animator.CanParse() => new Animator(objectReader), + ClassIDType.AnimatorController when ClassIDType.AnimatorController.CanParse() => new AnimatorController(objectReader), + ClassIDType.AnimatorOverrideController when ClassIDType.AnimatorOverrideController.CanParse() => new AnimatorOverrideController(objectReader), + ClassIDType.AssetBundle when ClassIDType.AssetBundle.CanParse() => new AssetBundle(objectReader), + ClassIDType.AudioClip when ClassIDType.AudioClip.CanParse() => new AudioClip(objectReader), + ClassIDType.Avatar when ClassIDType.Avatar.CanParse() => new Avatar(objectReader), + ClassIDType.Font when ClassIDType.Font.CanParse() => new Font(objectReader), + ClassIDType.GameObject when ClassIDType.GameObject.CanParse() => new GameObject(objectReader), + ClassIDType.IndexObject when ClassIDType.IndexObject.CanParse() => new IndexObject(objectReader), + ClassIDType.Material when ClassIDType.Material.CanParse() => new Material(objectReader), + ClassIDType.Mesh when ClassIDType.Mesh.CanParse() => new Mesh(objectReader), + ClassIDType.MeshFilter when ClassIDType.MeshFilter.CanParse() => new MeshFilter(objectReader), + ClassIDType.MeshRenderer when ClassIDType.MeshRenderer.CanParse() => new MeshRenderer(objectReader), + ClassIDType.MiHoYoBinData when ClassIDType.MiHoYoBinData.CanParse() => new MiHoYoBinData(objectReader), + ClassIDType.MonoBehaviour when ClassIDType.MonoBehaviour.CanParse() => new MonoBehaviour(objectReader), + ClassIDType.MonoScript when ClassIDType.MonoScript.CanParse() => new MonoScript(objectReader), + ClassIDType.MovieTexture when ClassIDType.MovieTexture.CanParse() => new MovieTexture(objectReader), + ClassIDType.PlayerSettings when ClassIDType.PlayerSettings.CanParse() => new PlayerSettings(objectReader), + ClassIDType.RectTransform when ClassIDType.RectTransform.CanParse() => new RectTransform(objectReader), + ClassIDType.Shader when ClassIDType.Shader.CanParse() => new Shader(objectReader), + ClassIDType.SkinnedMeshRenderer when ClassIDType.SkinnedMeshRenderer.CanParse() => new SkinnedMeshRenderer(objectReader), + ClassIDType.Sprite when ClassIDType.Sprite.CanParse() => new Sprite(objectReader), + ClassIDType.SpriteAtlas when ClassIDType.SpriteAtlas.CanParse() => new SpriteAtlas(objectReader), + ClassIDType.TextAsset when ClassIDType.TextAsset.CanParse() => new TextAsset(objectReader), + ClassIDType.Texture2D when ClassIDType.Texture2D.CanParse() => new Texture2D(objectReader), + ClassIDType.Transform when ClassIDType.Transform.CanParse() => new Transform(objectReader), + ClassIDType.VideoClip when ClassIDType.VideoClip.CanParse() => new VideoClip(objectReader), + ClassIDType.ResourceManager when ClassIDType.ResourceManager.CanParse() => new ResourceManager(objectReader), _ => new Object(objectReader), }; assetsFile.AddObject(obj); diff --git a/AssetStudio/TypeFlags.cs b/AssetStudio/TypeFlags.cs new file mode 100644 index 0000000..fda55ac --- /dev/null +++ b/AssetStudio/TypeFlags.cs @@ -0,0 +1,46 @@ +using System.Collections.Generic; + +namespace AssetStudio; +public static class TypeFlags +{ + private static Dictionary Types; + + public static void SetTypes(Dictionary types) + { + Types = types; + } + + public static void SetType(ClassIDType type, bool parse, bool export) + { + Types ??= new Dictionary(); + Types[type] = (parse, export); + } + + public static bool CanParse(this ClassIDType type) + { + if (Types == null) + { + return true; + } + else if (Types.TryGetValue(type, out var param)) + { + return param.Item1; + } + + return false; + } + + public static bool CanExport(this ClassIDType type) + { + if (Types == null) + { + return true; + } + else if (Types.TryGetValue(type, out var param)) + { + return param.Item2; + } + + return false; + } +}