diff --git a/AssetStudioCLI/Studio.cs b/AssetStudioCLI/Studio.cs index 14c3e9a..ec1fc62 100644 --- a/AssetStudioCLI/Studio.cs +++ b/AssetStudioCLI/Studio.cs @@ -1188,7 +1188,7 @@ namespace AssetStudioCLI } var baseDestPath = Path.Combine(CLIOptions.o_outputFolder.Value, "Live2DOutput"); var modelGroupOption = CLIOptions.o_l2dGroupOption.Value; - var l2dOptions = new Live2DOptions() + var extractorOptions = new Live2DExtractorOptions() { MotionMode = CLIOptions.o_l2dMotionMode.Value, ForceBezier = CLIOptions.f_l2dForceBezier.Value, @@ -1218,7 +1218,7 @@ namespace AssetStudioCLI Logger.Info($"[{modelCounter + 1}/{totalModelCount}] Exporting Live2D from: \"{srcContainer.Color(Ansi.BrightCyan)}\"..."); try { - var cubismExtractor = new Live2DExtractor(assetGroupKvp.Value, cubismModel, l2dOptions); + var cubismExtractor = new Live2DExtractor(assetGroupKvp.Value, cubismModel, extractorOptions); var fileName = string.IsNullOrEmpty(mocMono.assetsFile.originalPath) ? Path.GetFileNameWithoutExtension(mocMono.assetsFile.fileName) : Path.GetFileNameWithoutExtension(mocMono.assetsFile.originalPath); @@ -1237,7 +1237,7 @@ namespace AssetStudioCLI modelPath = modelName; break; default: //ContainerPath - var container = l2dOptions.SearchByFilename && cubismModel != null + var container = extractorOptions.SearchByFilename && cubismModel != null ? cubismModel.Container : srcContainer; container = container == mocMono.assetsFile.fullName diff --git a/AssetStudioGUI/AssetStudioGUIForm.cs b/AssetStudioGUI/AssetStudioGUIForm.cs index 03f3e93..c113a69 100644 --- a/AssetStudioGUI/AssetStudioGUIForm.cs +++ b/AssetStudioGUI/AssetStudioGUIForm.cs @@ -158,7 +158,6 @@ namespace AssetStudioGUI 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; @@ -584,7 +583,7 @@ namespace AssetStudioGUI private void showExpOpt_Click(object sender, EventArgs e) { - var exportOpt = new ExportOptions(); + var exportOpt = new ExportOptionsForm(); exportOpt.ShowDialog(this); } @@ -2741,20 +2740,6 @@ namespace AssetStudioGUI Properties.Settings.Default.Save(); } - private static void FbxInitOrLoadOptions(string base64String) - { - if (string.IsNullOrEmpty(base64String)) - { - Studio.FbxSettings = new Fbx.Settings(); - Properties.Settings.Default.fbxSettings = Studio.FbxSettings.ToBase64(); - Properties.Settings.Default.Save(); - } - else - { - Studio.FbxSettings = Fbx.Settings.FromBase64(base64String); - } - } - private void moreGameOptionsToolStripMenuItem_Click(object sender, EventArgs e) { if (gameOptionsForm == null || gameOptionsForm.IsDisposed) diff --git a/AssetStudioGUI/ExportOptions.Designer.cs b/AssetStudioGUI/ExportOptionsForm.Designer.cs similarity index 99% rename from AssetStudioGUI/ExportOptions.Designer.cs rename to AssetStudioGUI/ExportOptionsForm.Designer.cs index 51f23bf..946b1d5 100644 --- a/AssetStudioGUI/ExportOptions.Designer.cs +++ b/AssetStudioGUI/ExportOptionsForm.Designer.cs @@ -1,6 +1,6 @@ namespace AssetStudioGUI { - partial class ExportOptions + partial class ExportOptionsForm { /// /// Required designer variable. @@ -907,7 +907,7 @@ this.Cancel.UseVisualStyleBackColor = false; this.Cancel.Click += new System.EventHandler(this.Cancel_Click); // - // ExportOptions + // ExportOptionsForm // this.AcceptButton = this.OKbutton; this.AutoScaleDimensions = new System.Drawing.SizeF(96F, 96F); @@ -924,7 +924,7 @@ this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle; this.MaximizeBox = false; this.MinimizeBox = false; - this.Name = "ExportOptions"; + this.Name = "ExportOptionsForm"; this.ShowIcon = false; this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; this.Text = "Export options"; diff --git a/AssetStudioGUI/ExportOptions.cs b/AssetStudioGUI/ExportOptionsForm.cs similarity index 86% rename from AssetStudioGUI/ExportOptions.cs rename to AssetStudioGUI/ExportOptionsForm.cs index efaf52b..4362858 100644 --- a/AssetStudioGUI/ExportOptions.cs +++ b/AssetStudioGUI/ExportOptionsForm.cs @@ -6,11 +6,11 @@ using System.Windows.Forms; namespace AssetStudioGUI { - public partial class ExportOptions : Form + public partial class ExportOptionsForm : Form { private static Dictionary uvBindings; - public ExportOptions() + public ExportOptionsForm() { InitializeComponent(); assetGroupOptions.SelectedIndex = Properties.Settings.Default.assetGroupOption; @@ -38,7 +38,7 @@ namespace AssetStudioGUI ((RadioButton)l2dMotionExportMethodPanel.Controls.Cast().First(x => x.AccessibleName == defaultMotionMode)).Checked = true; l2dForceBezierCheckBox.Checked = Properties.Settings.Default.l2dForceBezier; - SetFromFbxSettings(Studio.FbxSettings); + SetFromFbxSettings(Exporter.FbxSettings); } private void OKbutton_Click(object sender, EventArgs e) @@ -64,19 +64,19 @@ namespace AssetStudioGUI Properties.Settings.Default.l2dMotionMode = (CubismLive2DExtractor.Live2DMotionMode)Enum.Parse(typeof(CubismLive2DExtractor.Live2DMotionMode), checkedMotionMode.AccessibleName); Properties.Settings.Default.l2dForceBezier = l2dForceBezierCheckBox.Checked; - Studio.FbxSettings.EulerFilter = eulerFilter.Checked; - Studio.FbxSettings.FilterPrecision = (float)filterPrecision.Value; - Studio.FbxSettings.ExportAllNodes = exportAllNodes.Checked; - Studio.FbxSettings.ExportSkins = exportSkins.Checked; - Studio.FbxSettings.ExportAnimations = exportAnimations.Checked; - Studio.FbxSettings.ExportBlendShape = exportBlendShape.Checked; - Studio.FbxSettings.DumpMaterials = dumpMaterialsCheckBox.Checked; - Studio.FbxSettings.CastToBone = castToBone.Checked; - Studio.FbxSettings.ExportAllUvsAsDiffuseMaps = exportAllUvsAsDiffuseMaps.Checked; - Studio.FbxSettings.BoneSize = (int)boneSize.Value; - Studio.FbxSettings.ScaleFactor = (float)scaleFactor.Value; - Studio.FbxSettings.FbxVersionIndex = fbxVersion.SelectedIndex; - Studio.FbxSettings.FbxFormat = fbxFormat.SelectedIndex; + Exporter.FbxSettings.EulerFilter = eulerFilter.Checked; + Exporter.FbxSettings.FilterPrecision = (float)filterPrecision.Value; + Exporter.FbxSettings.ExportAllNodes = exportAllNodes.Checked; + Exporter.FbxSettings.ExportSkins = exportSkins.Checked; + Exporter.FbxSettings.ExportAnimations = exportAnimations.Checked; + Exporter.FbxSettings.ExportBlendShape = exportBlendShape.Checked; + Exporter.FbxSettings.DumpMaterials = dumpMaterialsCheckBox.Checked; + Exporter.FbxSettings.CastToBone = castToBone.Checked; + Exporter.FbxSettings.ExportAllUvsAsDiffuseMaps = exportAllUvsAsDiffuseMaps.Checked; + Exporter.FbxSettings.BoneSize = (int)boneSize.Value; + Exporter.FbxSettings.ScaleFactor = (float)scaleFactor.Value; + Exporter.FbxSettings.FbxVersionIndex = fbxVersion.SelectedIndex; + Exporter.FbxSettings.FbxFormat = fbxFormat.SelectedIndex; for (var i = 0; i < uvIndicesCheckedListBox.Items.Count; i++) { var isChecked = uvIndicesCheckedListBox.GetItemChecked(i); @@ -84,8 +84,8 @@ namespace AssetStudioGUI if ((isChecked && type < 0) || (!isChecked && type > 0)) uvBindings[i] *= -1; } - Studio.FbxSettings.UvBindings = uvBindings; - Properties.Settings.Default.fbxSettings = Studio.FbxSettings.ToBase64(); + Exporter.FbxSettings.UvBindings = uvBindings; + Properties.Settings.Default.fbxSettings = Exporter.FbxSettings.ToBase64(); Properties.Settings.Default.Save(); DialogResult = DialogResult.OK; diff --git a/AssetStudioGUI/ExportOptions.resx b/AssetStudioGUI/ExportOptionsForm.resx similarity index 100% rename from AssetStudioGUI/ExportOptions.resx rename to AssetStudioGUI/ExportOptionsForm.resx diff --git a/AssetStudioGUI/Exporter.cs b/AssetStudioGUI/Exporter.cs index 23371df..3bdd668 100644 --- a/AssetStudioGUI/Exporter.cs +++ b/AssetStudioGUI/Exporter.cs @@ -9,12 +9,24 @@ namespace AssetStudioGUI { internal static class Exporter { + internal static readonly Fbx.Settings FbxSettings; private static readonly HashSet ExportPathHashSet = new HashSet(System.StringComparer.OrdinalIgnoreCase); private static readonly HashSet InvalidChars = new HashSet(Path.GetInvalidFileNameChars()); static Exporter() { InvalidChars.UnionWith(new[] { '"', '<', '>', '|', ':', '*', '?', '\\', '/' }); + + if (string.IsNullOrEmpty(Properties.Settings.Default.fbxSettings)) + { + FbxSettings = new Fbx.Settings(); + Properties.Settings.Default.fbxSettings = FbxSettings.ToBase64(); + Properties.Settings.Default.Save(); + } + else + { + FbxSettings = Fbx.Settings.FromBase64(Properties.Settings.Default.fbxSettings); + } } private static bool TryExportFile(string dir, AssetItem item, string extension, out string fullPath, string mode = "Export") @@ -245,7 +257,7 @@ namespace AssetStudioGUI { exportFullPath = SafeFilePath(exportPath, item.Text + item.UniqueID, item.Text + ".fbx"); } - if (!Studio.FbxSettings.ExportAnimations) + if (!FbxSettings.ExportAnimations) animationList = new List(); var m_Animator = (Animator)item.Asset; var convert = animationList != null @@ -257,8 +269,8 @@ namespace AssetStudioGUI private static void ExportFbx(ModelConverter convert, string exportPath) { - ModelExporter.ExportFbx(exportPath, convert, Studio.FbxSettings); - if (!Studio.FbxSettings.DumpMaterials || convert.MaterialAssetSet.Count == 0 || !File.Exists(exportPath)) + ModelExporter.ExportFbx(exportPath, convert, FbxSettings); + if (!FbxSettings.DumpMaterials || convert.MaterialAssetSet.Count == 0 || !File.Exists(exportPath)) return; var exportDir = Path.Combine(Path.GetDirectoryName(exportPath), "Materials"); @@ -399,7 +411,7 @@ namespace AssetStudioGUI public static void ExportGameObject(GameObject gameObject, string exportPath, List animationList = null) { - if (!Studio.FbxSettings.ExportAnimations) + if (!FbxSettings.ExportAnimations) animationList = new List(); var convert = animationList != null ? new ModelConverter(gameObject, Properties.Settings.Default.convertType, animationList.Select(x => (AnimationClip)x.Asset).ToList()) @@ -411,7 +423,7 @@ namespace AssetStudioGUI public static void ExportGameObjectMerge(List gameObject, string exportPath, List animationList = null) { var rootName = Path.GetFileNameWithoutExtension(exportPath); - if (!Studio.FbxSettings.ExportAnimations) + if (!FbxSettings.ExportAnimations) animationList = new List(); var convert = animationList != null ? new ModelConverter(rootName, gameObject, Properties.Settings.Default.convertType, animationList.Select(x => (AnimationClip)x.Asset).ToList()) diff --git a/AssetStudioGUI/Studio.cs b/AssetStudioGUI/Studio.cs index f6baed4..825784e 100644 --- a/AssetStudioGUI/Studio.cs +++ b/AssetStudioGUI/Studio.cs @@ -88,7 +88,6 @@ namespace AssetStudioGUI public static List visibleAssets = new List(); public static L2DAssetsManager l2dAssetsManager = new L2DAssetsManager(); internal static Action StatusStripUpdate = x => { }; - internal static Fbx.Settings FbxSettings; public static int ExtractFolder(string path, string savePath) { @@ -1161,7 +1160,7 @@ namespace AssetStudioGUI { var baseDestPath = Path.Combine(exportPath, "Live2DOutput"); var modelGroupOption = Properties.Settings.Default.l2dModelGroupOption; - var l2dOptions = new Live2DOptions() + var extractorOptions = new Live2DExtractorOptions { SelectedClipMotions = selClipMotions, SelectedFadeMotions = selFadeMotions, @@ -1171,9 +1170,9 @@ namespace AssetStudioGUI SearchByFilename = Properties.Settings.Default.l2dAssetSearchByFilename, }; if (selClipMotions != null) - l2dOptions.MotionMode = Live2DMotionMode.AnimationClipV2; + extractorOptions.MotionMode = Live2DMotionMode.AnimationClipV2; else if (selFadeMotions != null || selFadeLst != null) - l2dOptions.MotionMode = Live2DMotionMode.MonoBehaviour; + extractorOptions.MotionMode = Live2DMotionMode.MonoBehaviour; ThreadPool.QueueUserWorkItem(state => { @@ -1197,7 +1196,7 @@ namespace AssetStudioGUI Logger.Info($"[{modelCounter + 1}/{totalModelCount}] Exporting Live2D from: \"{srcContainer}\"..."); try { - var cubismExtractor = new Live2DExtractor(assetGroupKvp.Value, cubismModel, l2dOptions); + var cubismExtractor = new Live2DExtractor(assetGroupKvp.Value, cubismModel, extractorOptions); var fileName = string.IsNullOrEmpty(mocMono.assetsFile.originalPath) ? Path.GetFileNameWithoutExtension(mocMono.assetsFile.fileName) : Path.GetFileNameWithoutExtension(mocMono.assetsFile.originalPath); @@ -1216,7 +1215,7 @@ namespace AssetStudioGUI modelPath = modelName; break; default: //ContainerPath - var container = l2dOptions.SearchByFilename && cubismModel != null + var container = extractorOptions.SearchByFilename && cubismModel != null ? cubismModel.Container : srcContainer; container = container == mocMono.assetsFile.fullName diff --git a/AssetStudioUtility/CubismLive2DExtractor/Live2DExtractor.cs b/AssetStudioUtility/CubismLive2DExtractor/Live2DExtractor.cs index dd09f43..a1dffb4 100644 --- a/AssetStudioUtility/CubismLive2DExtractor/Live2DExtractor.cs +++ b/AssetStudioUtility/CubismLive2DExtractor/Live2DExtractor.cs @@ -26,7 +26,7 @@ namespace CubismLive2DExtractor { public static AssemblyLoader Assembly { get; set; } private CubismModel Model { get; set; } - private Live2DOptions Options { get; } + private Live2DExtractorOptions Options { get; } private List FadeMotions { get; set; } private List AnimationClips { get; set; } private List Expressions { get; set; } @@ -42,7 +42,7 @@ namespace CubismLive2DExtractor private HashSet EyeBlinkParameters { get; set; } private HashSet LipSyncParameters { get; set; } - public Live2DExtractor(List modelAssetsList, CubismModel model, Live2DOptions l2dOptions) + public Live2DExtractor(List modelAssetsList, CubismModel model, Live2DExtractorOptions l2dOptions) { Options = l2dOptions; Expressions = new List(); diff --git a/AssetStudioUtility/CubismLive2DExtractor/Live2DOptions.cs b/AssetStudioUtility/CubismLive2DExtractor/Live2DExtractorOptions.cs similarity index 91% rename from AssetStudioUtility/CubismLive2DExtractor/Live2DOptions.cs rename to AssetStudioUtility/CubismLive2DExtractor/Live2DExtractorOptions.cs index c9c652b..4b9d7e3 100644 --- a/AssetStudioUtility/CubismLive2DExtractor/Live2DOptions.cs +++ b/AssetStudioUtility/CubismLive2DExtractor/Live2DExtractorOptions.cs @@ -3,7 +3,7 @@ using System.Collections.Generic; namespace CubismLive2DExtractor { - public sealed class Live2DOptions + public sealed class Live2DExtractorOptions { public List SelectedClipMotions { get; set; } public List SelectedFadeMotions { get; set; }