Add option to filter Live2D textures

This commit is contained in:
VaDiM
2026-09-10 02:16:04 +03:00
parent dd83e43673
commit 9744c47fd3
9 changed files with 87 additions and 19 deletions
+37 -15
View File
@@ -115,8 +115,9 @@ namespace AssetStudioCLI.Options
//live2d //live2d
public static Option<CubismLive2DExtractor.Live2DModelGroupOption> o_l2dGroupOption; public static Option<CubismLive2DExtractor.Live2DModelGroupOption> o_l2dGroupOption;
public static Option<CubismLive2DExtractor.Live2DMotionMode> o_l2dMotionMode; public static Option<CubismLive2DExtractor.Live2DMotionMode> o_l2dMotionMode;
public static Option<bool> f_l2dAssetSearchByFilename;
public static Option<bool> f_l2dForceBezier; public static Option<bool> f_l2dForceBezier;
public static Option<bool> f_l2dAssetSearchByFilename;
public static Option<bool> f_l2dFilterTextures;
//fbx //fbx
public static Option<float> o_fbxScaleFactor; public static Option<float> o_fbxScaleFactor;
public static Option<int> o_fbxBoneSize; public static Option<int> o_fbxBoneSize;
@@ -365,18 +366,6 @@ namespace AssetStudioCLI.Options
optionExample: "Example: \"--l2d-motion-mode animationClip\"\n", optionExample: "Example: \"--l2d-motion-mode animationClip\"\n",
optionHelpGroup: HelpGroups.Live2D optionHelpGroup: HelpGroups.Live2D
); );
f_l2dAssetSearchByFilename = new GroupedOption<bool>
(
optionDefaultValue: false,
optionName: "--l2d-search-by-filename",
optionDescription: "(Flag) If specified, Studio will search for model-related Live2D assets by file name\n" +
"rather than by container\n" +
"(Preferred option if all l2d assets of a single model are stored in a single file\n" +
"or containers are obfuscated)\n",
optionExample: "",
optionHelpGroup: HelpGroups.Live2D,
isFlag: true
);
f_l2dForceBezier = new GroupedOption<bool> f_l2dForceBezier = new GroupedOption<bool>
( (
optionDefaultValue: false, optionDefaultValue: false,
@@ -387,6 +376,28 @@ namespace AssetStudioCLI.Options
optionHelpGroup: HelpGroups.Live2D, optionHelpGroup: HelpGroups.Live2D,
isFlag: true isFlag: true
); );
f_l2dAssetSearchByFilename = new GroupedOption<bool>
(
optionDefaultValue: false,
optionName: "--l2d-search-by-filename",
optionDescription: "(Flag) If specified, Studio will search for model-related Live2D assets by file name\n" +
"rather than by container\n" +
"(Preferred option if all l2d assets of a single model are stored in a single file\n" +
"or containers are obfuscated)\n",
optionExample: "",
optionHelpGroup: HelpGroups.Live2D,
isFlag: true
);
f_l2dFilterTextures = new GroupedOption<bool>
(
optionDefaultValue: false,
optionName: "--l2d-filter-textures",
optionDescription: "(Flag) If specified, Studio will only export model textures with \"texture\"\nin their names\n" +
"(Only when \"--l2d-search-by-filename\" flag is used)",
optionExample: "",
optionHelpGroup: HelpGroups.Live2D,
isFlag: true
);
#endregion #endregion
#region Init FBX Options #region Init FBX Options
@@ -785,6 +796,16 @@ namespace AssetStudioCLI.Options
f_overwriteExisting.Value = true; f_overwriteExisting.Value = true;
flagIndexes.Add(i); flagIndexes.Add(i);
break; break;
case "--l2d-smooth-motions":
if (o_workMode.Value != WorkMode.Live2D)
{
Console.WriteLine($"{"Error".Color(brightRed)} during parsing [{flag.Color(brightYellow)}] flag. This flag is not suitable for the current working mode [{o_workMode.Value}].\n");
ShowOptionDescription(o_workMode);
return;
}
f_l2dForceBezier.Value = true;
flagIndexes.Add(i);
break;
case "--l2d-search-by-filename": case "--l2d-search-by-filename":
if (o_workMode.Value != WorkMode.Live2D) if (o_workMode.Value != WorkMode.Live2D)
{ {
@@ -795,14 +816,14 @@ namespace AssetStudioCLI.Options
f_l2dAssetSearchByFilename.Value = true; f_l2dAssetSearchByFilename.Value = true;
flagIndexes.Add(i); flagIndexes.Add(i);
break; break;
case "--l2d-smooth-motions": case "--l2d-filter-textures":
if (o_workMode.Value != WorkMode.Live2D) if (o_workMode.Value != WorkMode.Live2D)
{ {
Console.WriteLine($"{"Error".Color(brightRed)} during parsing [{flag.Color(brightYellow)}] flag. This flag is not suitable for the current working mode [{o_workMode.Value}].\n"); Console.WriteLine($"{"Error".Color(brightRed)} during parsing [{flag.Color(brightYellow)}] flag. This flag is not suitable for the current working mode [{o_workMode.Value}].\n");
ShowOptionDescription(o_workMode); ShowOptionDescription(o_workMode);
return; return;
} }
f_l2dForceBezier.Value = true; f_l2dFilterTextures.Value = true;
flagIndexes.Add(i); flagIndexes.Add(i);
break; break;
case "--fbx-dump-mats": case "--fbx-dump-mats":
@@ -1621,6 +1642,7 @@ namespace AssetStudioCLI.Options
sb.AppendLine($"# Filter Exclusion Mode: {f_filterExcludeMode}"); sb.AppendLine($"# Filter Exclusion Mode: {f_filterExcludeMode}");
sb.AppendLine($"# Model Group Option: {o_l2dGroupOption}"); sb.AppendLine($"# Model Group Option: {o_l2dGroupOption}");
sb.AppendFormat("# Search Model-related Assets by: {0}\n", f_l2dAssetSearchByFilename.Value ? "FileName" : "Container"); sb.AppendFormat("# Search Model-related Assets by: {0}\n", f_l2dAssetSearchByFilename.Value ? "FileName" : "Container");
sb.AppendLine($"# Filter Textures: {f_l2dFilterTextures}");
sb.AppendLine($"# Motion Export Method: {o_l2dMotionMode}"); sb.AppendLine($"# Motion Export Method: {o_l2dMotionMode}");
sb.AppendLine($"# Smooth Motions: {f_l2dForceBezier}"); sb.AppendLine($"# Smooth Motions: {f_l2dForceBezier}");
sb.AppendLine($"# Assembly Path: \"{o_assemblyPath}\""); sb.AppendLine($"# Assembly Path: \"{o_assemblyPath}\"");
+1
View File
@@ -1193,6 +1193,7 @@ namespace AssetStudioCLI
MotionMode = CLIOptions.o_l2dMotionMode.Value, MotionMode = CLIOptions.o_l2dMotionMode.Value,
ForceBezier = CLIOptions.f_l2dForceBezier.Value, ForceBezier = CLIOptions.f_l2dForceBezier.Value,
SearchByFilename = CLIOptions.f_l2dAssetSearchByFilename.Value, SearchByFilename = CLIOptions.f_l2dAssetSearchByFilename.Value,
FilterTextures = CLIOptions.f_l2dFilterTextures.Value,
}; };
if (l2dAssetsManager.ModelDict.Keys.First().serializedType?.m_Type == null && CLIOptions.o_assemblyPath.Value == "") if (l2dAssetsManager.ModelDict.Keys.First().serializedType?.m_Type == null && CLIOptions.o_assemblyPath.Value == "")
{ {
+20
View File
@@ -80,6 +80,7 @@
this.exportAllNodes = new System.Windows.Forms.CheckBox(); this.exportAllNodes = new System.Windows.Forms.CheckBox();
this.eulerFilter = new System.Windows.Forms.CheckBox(); this.eulerFilter = new System.Windows.Forms.CheckBox();
this.optionTooltip = new System.Windows.Forms.ToolTip(this.components); this.optionTooltip = new System.Windows.Forms.ToolTip(this.components);
this.l2dFilterTexturesCheckBox = new System.Windows.Forms.CheckBox();
this.optionsTabControl = new System.Windows.Forms.TabControl(); this.optionsTabControl = new System.Windows.Forms.TabControl();
this.generalTabPage = new System.Windows.Forms.TabPage(); this.generalTabPage = new System.Windows.Forms.TabPage();
this.panel2 = new System.Windows.Forms.Panel(); this.panel2 = new System.Windows.Forms.Panel();
@@ -399,6 +400,7 @@
this.optionTooltip.SetToolTip(this.l2dAssetSearchByFilenameCheckBox, "Preferred option if all l2d assets of a single model are stored in a single file " + this.optionTooltip.SetToolTip(this.l2dAssetSearchByFilenameCheckBox, "Preferred option if all l2d assets of a single model are stored in a single file " +
"or containers are obfuscated"); "or containers are obfuscated");
this.l2dAssetSearchByFilenameCheckBox.UseVisualStyleBackColor = true; this.l2dAssetSearchByFilenameCheckBox.UseVisualStyleBackColor = true;
this.l2dAssetSearchByFilenameCheckBox.CheckedChanged += new System.EventHandler(this.l2dAssetSearchByFilenameCheckBox_CheckedChanged);
// //
// l2dModelGroupComboBox // l2dModelGroupComboBox
// //
@@ -765,6 +767,22 @@
this.eulerFilter.Text = "EulerFilter"; this.eulerFilter.Text = "EulerFilter";
this.eulerFilter.UseVisualStyleBackColor = true; this.eulerFilter.UseVisualStyleBackColor = true;
// //
// l2dFilterTexturesCheckBox
//
this.l2dFilterTexturesCheckBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.l2dFilterTexturesCheckBox.AutoSize = true;
this.l2dFilterTexturesCheckBox.Checked = true;
this.l2dFilterTexturesCheckBox.CheckState = System.Windows.Forms.CheckState.Checked;
this.l2dFilterTexturesCheckBox.Location = new System.Drawing.Point(7, 166);
this.l2dFilterTexturesCheckBox.Name = "l2dFilterTexturesCheckBox";
this.l2dFilterTexturesCheckBox.Size = new System.Drawing.Size(146, 19);
this.l2dFilterTexturesCheckBox.TabIndex = 6;
this.l2dFilterTexturesCheckBox.Text = "Filter textures by name";
this.optionTooltip.SetToolTip(this.l2dFilterTexturesCheckBox, "If specified, Studio will only export model textures with \"texture\" in their name" +
"s");
this.l2dFilterTexturesCheckBox.UseVisualStyleBackColor = true;
//
// optionsTabControl // optionsTabControl
// //
this.optionsTabControl.Controls.Add(this.generalTabPage); this.optionsTabControl.Controls.Add(this.generalTabPage);
@@ -881,6 +899,7 @@
// live2DTabPage // live2DTabPage
// //
this.live2DTabPage.BackColor = System.Drawing.SystemColors.Menu; this.live2DTabPage.BackColor = System.Drawing.SystemColors.Menu;
this.live2DTabPage.Controls.Add(this.l2dFilterTexturesCheckBox);
this.live2DTabPage.Controls.Add(this.l2dAssetSearchByFilenameCheckBox); this.live2DTabPage.Controls.Add(this.l2dAssetSearchByFilenameCheckBox);
this.live2DTabPage.Controls.Add(this.l2dModelGroupLabel); this.live2DTabPage.Controls.Add(this.l2dModelGroupLabel);
this.live2DTabPage.Controls.Add(this.l2dModelGroupComboBox); this.live2DTabPage.Controls.Add(this.l2dModelGroupComboBox);
@@ -1013,5 +1032,6 @@
private System.Windows.Forms.Panel panel2; private System.Windows.Forms.Panel panel2;
private System.Windows.Forms.CheckBox keepSpriteSizeCheckBox; private System.Windows.Forms.CheckBox keepSpriteSizeCheckBox;
private System.Windows.Forms.CheckBox dumpMaterialsCheckBox; private System.Windows.Forms.CheckBox dumpMaterialsCheckBox;
private System.Windows.Forms.CheckBox l2dFilterTexturesCheckBox;
} }
} }
+10 -2
View File
@@ -33,10 +33,12 @@ namespace AssetStudioGUI
rawByteArrayFromMono.Checked = Properties.Settings.Default.rawByteArrayFromMono; rawByteArrayFromMono.Checked = Properties.Settings.Default.rawByteArrayFromMono;
l2dModelGroupComboBox.SelectedIndex = (int)Properties.Settings.Default.l2dModelGroupOption; l2dModelGroupComboBox.SelectedIndex = (int)Properties.Settings.Default.l2dModelGroupOption;
l2dAssetSearchByFilenameCheckBox.Checked = Properties.Settings.Default.l2dAssetSearchByFilename;
var defaultMotionMode = Properties.Settings.Default.l2dMotionMode.ToString(); var defaultMotionMode = Properties.Settings.Default.l2dMotionMode.ToString();
((RadioButton)l2dMotionExportMethodPanel.Controls.Cast<Control>().First(x => x.AccessibleName == defaultMotionMode)).Checked = true; ((RadioButton)l2dMotionExportMethodPanel.Controls.Cast<Control>().First(x => x.AccessibleName == defaultMotionMode)).Checked = true;
l2dForceBezierCheckBox.Checked = Properties.Settings.Default.l2dForceBezier; l2dForceBezierCheckBox.Checked = Properties.Settings.Default.l2dForceBezier;
l2dAssetSearchByFilenameCheckBox.Checked = Properties.Settings.Default.l2dAssetSearchByFilename;
l2dFilterTexturesCheckBox.Checked = Properties.Settings.Default.l2dFilterTextures;
l2dFilterTexturesCheckBox.Enabled = l2dAssetSearchByFilenameCheckBox.Checked;
SetFromFbxSettings(Exporter.FbxSettings); SetFromFbxSettings(Exporter.FbxSettings);
} }
@@ -59,10 +61,11 @@ namespace AssetStudioGUI
Properties.Settings.Default.rawByteArrayFromMono = rawByteArrayFromMono.Checked; Properties.Settings.Default.rawByteArrayFromMono = rawByteArrayFromMono.Checked;
Properties.Settings.Default.l2dModelGroupOption = (CubismLive2DExtractor.Live2DModelGroupOption)l2dModelGroupComboBox.SelectedIndex; Properties.Settings.Default.l2dModelGroupOption = (CubismLive2DExtractor.Live2DModelGroupOption)l2dModelGroupComboBox.SelectedIndex;
Properties.Settings.Default.l2dAssetSearchByFilename = l2dAssetSearchByFilenameCheckBox.Checked;
var checkedMotionMode = (RadioButton)l2dMotionExportMethodPanel.Controls.Cast<Control>().First(x => ((RadioButton)x).Checked); var checkedMotionMode = (RadioButton)l2dMotionExportMethodPanel.Controls.Cast<Control>().First(x => ((RadioButton)x).Checked);
Properties.Settings.Default.l2dMotionMode = (CubismLive2DExtractor.Live2DMotionMode)Enum.Parse(typeof(CubismLive2DExtractor.Live2DMotionMode), checkedMotionMode.AccessibleName); Properties.Settings.Default.l2dMotionMode = (CubismLive2DExtractor.Live2DMotionMode)Enum.Parse(typeof(CubismLive2DExtractor.Live2DMotionMode), checkedMotionMode.AccessibleName);
Properties.Settings.Default.l2dForceBezier = l2dForceBezierCheckBox.Checked; Properties.Settings.Default.l2dForceBezier = l2dForceBezierCheckBox.Checked;
Properties.Settings.Default.l2dAssetSearchByFilename = l2dAssetSearchByFilenameCheckBox.Checked;
Properties.Settings.Default.l2dFilterTextures = l2dFilterTexturesCheckBox.Checked;
Exporter.FbxSettings.EulerFilter = eulerFilter.Checked; Exporter.FbxSettings.EulerFilter = eulerFilter.Checked;
Exporter.FbxSettings.FilterPrecision = (float)filterPrecision.Value; Exporter.FbxSettings.FilterPrecision = (float)filterPrecision.Value;
@@ -157,6 +160,11 @@ namespace AssetStudioGUI
uvIndicesCheckedListBox_SelectedIndexChanged(sender, e); uvIndicesCheckedListBox_SelectedIndexChanged(sender, e);
} }
private void l2dAssetSearchByFilenameCheckBox_CheckedChanged(object sender, EventArgs e)
{
l2dFilterTexturesCheckBox.Enabled = l2dAssetSearchByFilenameCheckBox.Checked;
}
//highDpi workaround (net472/.net-win7) //highDpi workaround (net472/.net-win7)
private void ExportOptions_Load(object sender, EventArgs e) private void ExportOptions_Load(object sender, EventArgs e)
{ {
+13 -1
View File
@@ -12,7 +12,7 @@ namespace AssetStudioGUI.Properties {
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "18.5.0.0")] [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "18.7.0.0")]
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
@@ -394,5 +394,17 @@ namespace AssetStudioGUI.Properties {
this["keepSpriteSize"] = value; this["keepSpriteSize"] = value;
} }
} }
[global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("True")]
public bool l2dFilterTextures {
get {
return ((bool)(this["l2dFilterTextures"]));
}
set {
this["l2dFilterTextures"] = value;
}
}
} }
} }
@@ -95,5 +95,8 @@
<Setting Name="keepSpriteSize" Type="System.Boolean" Scope="User"> <Setting Name="keepSpriteSize" Type="System.Boolean" Scope="User">
<Value Profile="(Default)">True</Value> <Value Profile="(Default)">True</Value>
</Setting> </Setting>
<Setting Name="l2dFilterTextures" Type="System.Boolean" Scope="User">
<Value Profile="(Default)">True</Value>
</Setting>
</Settings> </Settings>
</SettingsFile> </SettingsFile>
+1
View File
@@ -1168,6 +1168,7 @@ namespace AssetStudioGUI
MotionMode = Properties.Settings.Default.l2dMotionMode, MotionMode = Properties.Settings.Default.l2dMotionMode,
ForceBezier = Properties.Settings.Default.l2dForceBezier, ForceBezier = Properties.Settings.Default.l2dForceBezier,
SearchByFilename = Properties.Settings.Default.l2dAssetSearchByFilename, SearchByFilename = Properties.Settings.Default.l2dAssetSearchByFilename,
FilterTextures = Properties.Settings.Default.l2dFilterTextures,
}; };
if (selClipMotions != null) if (selClipMotions != null)
extractorOptions.MotionMode = Live2DMotionMode.AnimationClipV2; extractorOptions.MotionMode = Live2DMotionMode.AnimationClipV2;
@@ -256,7 +256,7 @@ namespace CubismLive2DExtractor
{ {
Texture2Ds = renderTextureSet.ToList(); Texture2Ds = renderTextureSet.ToList();
} }
else if (Options.SearchByFilename) else if (Options.SearchByFilename && Options.FilterTextures)
{ {
Texture2Ds = Texture2Ds.Where(x => x.m_Name.ToLower().Contains("texture")).ToList(); Texture2Ds = Texture2Ds.Where(x => x.m_Name.ToLower().Contains("texture")).ToList();
} }
@@ -11,5 +11,6 @@ namespace CubismLive2DExtractor
public Live2DMotionMode MotionMode { get; set; } = Live2DMotionMode.MonoBehaviour; public Live2DMotionMode MotionMode { get; set; } = Live2DMotionMode.MonoBehaviour;
public bool ForceBezier { get; set; } public bool ForceBezier { get; set; }
public bool SearchByFilename { get; set; } public bool SearchByFilename { get; set; }
public bool FilterTextures { get; set; }
} }
} }