mirror of
https://github.com/aelurum/AssetStudio.git
synced 2025-05-25 05:40:21 -04:00
[GUI] Add ability to filter live2d model assets
This commit is contained in:
parent
2c860f004b
commit
1623981c0e
@ -288,15 +288,20 @@ namespace AssetStudioGUI
|
|||||||
typeMap.Clear();
|
typeMap.Clear();
|
||||||
classesListView.EndUpdate();
|
classesListView.EndUpdate();
|
||||||
|
|
||||||
var types = exportableAssets.Select(x => x.Type).Distinct().OrderBy(x => x.ToString()).ToArray();
|
var types = new SortedSet<string>();
|
||||||
foreach (var type in types)
|
types.UnionWith(exportableAssets.Select(x => x.TypeString));
|
||||||
|
if (Studio.cubismMocList.Count > 0)
|
||||||
|
{
|
||||||
|
types.Add("MonoBehaviour (Live2D Model)");
|
||||||
|
}
|
||||||
|
foreach (var typeString in types)
|
||||||
{
|
{
|
||||||
var typeItem = new ToolStripMenuItem
|
var typeItem = new ToolStripMenuItem
|
||||||
{
|
{
|
||||||
CheckOnClick = true,
|
CheckOnClick = true,
|
||||||
Name = type.ToString(),
|
Name = typeString,
|
||||||
Size = new Size(180, 22),
|
Size = new Size(180, 22),
|
||||||
Text = type.ToString()
|
Text = typeString
|
||||||
};
|
};
|
||||||
typeItem.Click += typeToolStripMenuItem_Click;
|
typeItem.Click += typeToolStripMenuItem_Click;
|
||||||
filterTypeToolStripMenuItem.DropDownItems.Add(typeItem);
|
filterTypeToolStripMenuItem.DropDownItems.Add(typeItem);
|
||||||
@ -321,6 +326,22 @@ namespace AssetStudioGUI
|
|||||||
if (typeItem != allToolStripMenuItem)
|
if (typeItem != allToolStripMenuItem)
|
||||||
{
|
{
|
||||||
allToolStripMenuItem.Checked = false;
|
allToolStripMenuItem.Checked = false;
|
||||||
|
|
||||||
|
var monoBehaviourItemArray = filterTypeToolStripMenuItem.DropDownItems.Find("MonoBehaviour", false);
|
||||||
|
var monoBehaviourMocItemArray = filterTypeToolStripMenuItem.DropDownItems.Find("MonoBehaviour (Live2D Model)", false);
|
||||||
|
if (monoBehaviourItemArray.Length > 0 && monoBehaviourMocItemArray.Length > 0)
|
||||||
|
{
|
||||||
|
var monoBehaviourItem = (ToolStripMenuItem)monoBehaviourItemArray[0];
|
||||||
|
var monoBehaviourMocItem = (ToolStripMenuItem)monoBehaviourMocItemArray[0];
|
||||||
|
if (typeItem == monoBehaviourItem && monoBehaviourItem.Checked)
|
||||||
|
{
|
||||||
|
monoBehaviourMocItem.Checked = false;
|
||||||
|
}
|
||||||
|
else if (typeItem == monoBehaviourMocItem && monoBehaviourMocItem.Checked)
|
||||||
|
{
|
||||||
|
monoBehaviourItem.Checked = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if (allToolStripMenuItem.Checked)
|
else if (allToolStripMenuItem.Checked)
|
||||||
{
|
{
|
||||||
@ -1837,6 +1858,7 @@ namespace AssetStudioGUI
|
|||||||
assetListView.BeginUpdate();
|
assetListView.BeginUpdate();
|
||||||
assetListView.SelectedIndices.Clear();
|
assetListView.SelectedIndices.Clear();
|
||||||
var show = new List<ClassIDType>();
|
var show = new List<ClassIDType>();
|
||||||
|
var filterMoc = false;
|
||||||
if (!allToolStripMenuItem.Checked)
|
if (!allToolStripMenuItem.Checked)
|
||||||
{
|
{
|
||||||
for (var i = 1; i < filterTypeToolStripMenuItem.DropDownItems.Count; i++)
|
for (var i = 1; i < filterTypeToolStripMenuItem.DropDownItems.Count; i++)
|
||||||
@ -1844,10 +1866,15 @@ namespace AssetStudioGUI
|
|||||||
var item = (ToolStripMenuItem)filterTypeToolStripMenuItem.DropDownItems[i];
|
var item = (ToolStripMenuItem)filterTypeToolStripMenuItem.DropDownItems[i];
|
||||||
if (item.Checked)
|
if (item.Checked)
|
||||||
{
|
{
|
||||||
show.Add((ClassIDType)Enum.Parse(typeof(ClassIDType), item.Text));
|
if (item.Name == "MonoBehaviour (Live2D Model)")
|
||||||
|
filterMoc = true;
|
||||||
|
else
|
||||||
|
show.Add((ClassIDType)Enum.Parse(typeof(ClassIDType), item.Text));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
visibleAssets = exportableAssets.FindAll(x => show.Contains(x.Type));
|
visibleAssets = filterMoc
|
||||||
|
? exportableAssets.FindAll(x => cubismMocList.Contains(x.Asset) || show.Contains(x.Type))
|
||||||
|
: exportableAssets.FindAll(x => show.Contains(x.Type));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -1859,16 +1886,16 @@ namespace AssetStudioGUI
|
|||||||
switch (mode)
|
switch (mode)
|
||||||
{
|
{
|
||||||
case ListSearchFilterMode.Include:
|
case ListSearchFilterMode.Include:
|
||||||
visibleAssets = visibleAssets.FindAll(
|
visibleAssets = visibleAssets.FindAll(x =>
|
||||||
x => x.Text.IndexOf(listSearch.Text, StringComparison.OrdinalIgnoreCase) >= 0 ||
|
x.Text.IndexOf(listSearch.Text, StringComparison.OrdinalIgnoreCase) >= 0
|
||||||
x.SubItems[1].Text.IndexOf(listSearch.Text, StringComparison.OrdinalIgnoreCase) >= 0 ||
|
|| x.SubItems[1].Text.IndexOf(listSearch.Text, StringComparison.OrdinalIgnoreCase) >= 0
|
||||||
x.SubItems[3].Text.IndexOf(listSearch.Text, StringComparison.OrdinalIgnoreCase) >= 0);
|
|| x.SubItems[3].Text.IndexOf(listSearch.Text, StringComparison.OrdinalIgnoreCase) >= 0);
|
||||||
break;
|
break;
|
||||||
case ListSearchFilterMode.Exclude:
|
case ListSearchFilterMode.Exclude:
|
||||||
visibleAssets = visibleAssets.FindAll(
|
visibleAssets = visibleAssets.FindAll(x =>
|
||||||
x => x.Text.IndexOf(listSearch.Text, StringComparison.OrdinalIgnoreCase) <= 0 &&
|
x.Text.IndexOf(listSearch.Text, StringComparison.OrdinalIgnoreCase) <= 0
|
||||||
x.SubItems[1].Text.IndexOf(listSearch.Text, StringComparison.OrdinalIgnoreCase) <= 0 &&
|
&& x.SubItems[1].Text.IndexOf(listSearch.Text, StringComparison.OrdinalIgnoreCase) <= 0
|
||||||
x.SubItems[3].Text.IndexOf(listSearch.Text, StringComparison.OrdinalIgnoreCase) <= 0);
|
&& x.SubItems[3].Text.IndexOf(listSearch.Text, StringComparison.OrdinalIgnoreCase) <= 0);
|
||||||
break;
|
break;
|
||||||
case ListSearchFilterMode.RegexName:
|
case ListSearchFilterMode.RegexName:
|
||||||
case ListSearchFilterMode.RegexContainer:
|
case ListSearchFilterMode.RegexContainer:
|
||||||
@ -1939,7 +1966,6 @@ namespace AssetStudioGUI
|
|||||||
.ToList();
|
.ToList();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Studio.ExportAssets(saveFolderDialog.Folder, toExportAssets, exportType);
|
Studio.ExportAssets(saveFolderDialog.Folder, toExportAssets, exportType);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user