mirror of
https://github.com/aelurum/AssetStudio.git
synced 2026-11-14 11:18:47 -05:00
Some refactor
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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)
|
||||
|
||||
+3
-3
@@ -1,6 +1,6 @@
|
||||
namespace AssetStudioGUI
|
||||
{
|
||||
partial class ExportOptions
|
||||
partial class ExportOptionsForm
|
||||
{
|
||||
/// <summary>
|
||||
/// 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";
|
||||
@@ -6,11 +6,11 @@ using System.Windows.Forms;
|
||||
|
||||
namespace AssetStudioGUI
|
||||
{
|
||||
public partial class ExportOptions : Form
|
||||
public partial class ExportOptionsForm : Form
|
||||
{
|
||||
private static Dictionary<int, int> uvBindings;
|
||||
|
||||
public ExportOptions()
|
||||
public ExportOptionsForm()
|
||||
{
|
||||
InitializeComponent();
|
||||
assetGroupOptions.SelectedIndex = Properties.Settings.Default.assetGroupOption;
|
||||
@@ -38,7 +38,7 @@ namespace AssetStudioGUI
|
||||
((RadioButton)l2dMotionExportMethodPanel.Controls.Cast<Control>().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;
|
||||
@@ -9,12 +9,24 @@ namespace AssetStudioGUI
|
||||
{
|
||||
internal static class Exporter
|
||||
{
|
||||
internal static readonly Fbx.Settings FbxSettings;
|
||||
private static readonly HashSet<string> ExportPathHashSet = new HashSet<string>(System.StringComparer.OrdinalIgnoreCase);
|
||||
private static readonly HashSet<char> InvalidChars = new HashSet<char>(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<AssetItem>();
|
||||
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<AssetItem> animationList = null)
|
||||
{
|
||||
if (!Studio.FbxSettings.ExportAnimations)
|
||||
if (!FbxSettings.ExportAnimations)
|
||||
animationList = new List<AssetItem>();
|
||||
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> gameObject, string exportPath, List<AssetItem> animationList = null)
|
||||
{
|
||||
var rootName = Path.GetFileNameWithoutExtension(exportPath);
|
||||
if (!Studio.FbxSettings.ExportAnimations)
|
||||
if (!FbxSettings.ExportAnimations)
|
||||
animationList = new List<AssetItem>();
|
||||
var convert = animationList != null
|
||||
? new ModelConverter(rootName, gameObject, Properties.Settings.Default.convertType, animationList.Select(x => (AnimationClip)x.Asset).ToList())
|
||||
|
||||
@@ -88,7 +88,6 @@ namespace AssetStudioGUI
|
||||
public static List<AssetItem> visibleAssets = new List<AssetItem>();
|
||||
public static L2DAssetsManager l2dAssetsManager = new L2DAssetsManager();
|
||||
internal static Action<string> 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
|
||||
|
||||
@@ -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<MonoBehaviour> FadeMotions { get; set; }
|
||||
private List<AnimationClip> AnimationClips { get; set; }
|
||||
private List<MonoBehaviour> Expressions { get; set; }
|
||||
@@ -42,7 +42,7 @@ namespace CubismLive2DExtractor
|
||||
private HashSet<string> EyeBlinkParameters { get; set; }
|
||||
private HashSet<string> LipSyncParameters { get; set; }
|
||||
|
||||
public Live2DExtractor(List<Object> modelAssetsList, CubismModel model, Live2DOptions l2dOptions)
|
||||
public Live2DExtractor(List<Object> modelAssetsList, CubismModel model, Live2DExtractorOptions l2dOptions)
|
||||
{
|
||||
Options = l2dOptions;
|
||||
Expressions = new List<MonoBehaviour>();
|
||||
|
||||
+1
-1
@@ -3,7 +3,7 @@ using System.Collections.Generic;
|
||||
|
||||
namespace CubismLive2DExtractor
|
||||
{
|
||||
public sealed class Live2DOptions
|
||||
public sealed class Live2DExtractorOptions
|
||||
{
|
||||
public List<AnimationClip> SelectedClipMotions { get; set; }
|
||||
public List<MonoBehaviour> SelectedFadeMotions { get; set; }
|
||||
Reference in New Issue
Block a user