Ability to preview/export non-exportable assets when possible.
This commit is contained in:
@@ -77,26 +77,6 @@ namespace AssetStudioCLI
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static bool ExportAssetBundle(AssetItem item, string exportPath)
|
|
||||||
{
|
|
||||||
if (!TryExportFile(exportPath, item, ".json", out var exportFullPath))
|
|
||||||
return false;
|
|
||||||
var m_AssetBundle = (AssetBundle)item.Asset;
|
|
||||||
var str = JsonConvert.SerializeObject(m_AssetBundle, Formatting.Indented);
|
|
||||||
File.WriteAllText(exportFullPath, str);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static bool ExportIndexObject(AssetItem item, string exportPath)
|
|
||||||
{
|
|
||||||
if (!TryExportFile(exportPath, item, ".json", out var exportFullPath))
|
|
||||||
return false;
|
|
||||||
var m_IndexObject = (IndexObject)item.Asset;
|
|
||||||
var str = JsonConvert.SerializeObject(m_IndexObject, Formatting.Indented);
|
|
||||||
File.WriteAllText(exportFullPath, str);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static bool ExportMiHoYoBinData(AssetItem item, string exportPath)
|
public static bool ExportMiHoYoBinData(AssetItem item, string exportPath)
|
||||||
{
|
{
|
||||||
string exportFullPath;
|
string exportFullPath;
|
||||||
@@ -271,15 +251,21 @@ namespace AssetStudioCLI
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static bool ExportMaterial(AssetItem item, string exportPath)
|
public static bool ExportJsonFile(AssetItem item, string exportPath)
|
||||||
{
|
{
|
||||||
if (!TryExportFile(exportPath, item, ".json", out var exportFullPath))
|
if (!TryExportFile(exportPath, item, ".json", out var exportFullPath))
|
||||||
return false;
|
return false;
|
||||||
var m_Material = (Material)item.Asset;
|
var str = JsonConvert.SerializeObject(item.Asset, Formatting.Indented);
|
||||||
var str = JsonConvert.SerializeObject(m_Material, Formatting.Indented);
|
if (!string.IsNullOrEmpty(str) && str != "{}")
|
||||||
|
{
|
||||||
File.WriteAllText(exportFullPath, str);
|
File.WriteAllText(exportFullPath, str);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return ExportRawFile(item, exportPath);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static bool ExportRawFile(AssetItem item, string exportPath)
|
public static bool ExportRawFile(AssetItem item, string exportPath)
|
||||||
{
|
{
|
||||||
@@ -354,20 +340,14 @@ namespace AssetStudioCLI
|
|||||||
return ExportMovieTexture(item, exportPath);
|
return ExportMovieTexture(item, exportPath);
|
||||||
case ClassIDType.Sprite:
|
case ClassIDType.Sprite:
|
||||||
return ExportSprite(item, exportPath);
|
return ExportSprite(item, exportPath);
|
||||||
case ClassIDType.Material:
|
|
||||||
return ExportMaterial(item, exportPath);
|
|
||||||
case ClassIDType.Animator:
|
case ClassIDType.Animator:
|
||||||
return false;
|
return false;
|
||||||
case ClassIDType.AnimationClip:
|
case ClassIDType.AnimationClip:
|
||||||
return ExportAnimationClip(item, exportPath);
|
return ExportAnimationClip(item, exportPath);
|
||||||
case ClassIDType.AssetBundle:
|
|
||||||
return ExportAssetBundle(item, exportPath);
|
|
||||||
case ClassIDType.IndexObject:
|
|
||||||
return ExportIndexObject(item, exportPath);
|
|
||||||
case ClassIDType.MiHoYoBinData:
|
case ClassIDType.MiHoYoBinData:
|
||||||
return ExportMiHoYoBinData(item, exportPath);
|
return ExportMiHoYoBinData(item, exportPath);
|
||||||
default:
|
default:
|
||||||
return ExportRawFile(item, exportPath);
|
return ExportJsonFile(item, exportPath);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
2
AssetStudioGUI/AssetStudioGUIForm.Designer.cs
generated
2
AssetStudioGUI/AssetStudioGUIForm.Designer.cs
generated
@@ -312,7 +312,7 @@
|
|||||||
this.toolStripMenuItem16.Name = "toolStripMenuItem16";
|
this.toolStripMenuItem16.Name = "toolStripMenuItem16";
|
||||||
this.toolStripMenuItem16.Size = new System.Drawing.Size(225, 22);
|
this.toolStripMenuItem16.Size = new System.Drawing.Size(225, 22);
|
||||||
this.toolStripMenuItem16.Text = "Specify AI version";
|
this.toolStripMenuItem16.Text = "Specify AI version";
|
||||||
this.toolStripMenuItem16.MouseHover += new System.EventHandler(this.toolStripMenuItem16_MouseHover);
|
this.toolStripMenuItem16.DropDownOpening += new System.EventHandler(this.toolStripMenuItem16_DropDownOpening);
|
||||||
//
|
//
|
||||||
// specifyAIVersion
|
// specifyAIVersion
|
||||||
//
|
//
|
||||||
|
|||||||
@@ -139,7 +139,6 @@ namespace AssetStudioGUI
|
|||||||
specifyGame.SelectedIndexChanged += new EventHandler(toolStripComboBox2_SelectedIndexChanged);
|
specifyGame.SelectedIndexChanged += new EventHandler(toolStripComboBox2_SelectedIndexChanged);
|
||||||
Logger.Info($"Target Game is {Studio.Game.DisplayName}");
|
Logger.Info($"Target Game is {Studio.Game.DisplayName}");
|
||||||
CABManager.LoadMap(Studio.Game);
|
CABManager.LoadMap(Studio.Game);
|
||||||
Task.Run(() => AIVersionManager.FetchVersions());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void AssetStudioGUIForm_DragEnter(object sender, DragEventArgs e)
|
private void AssetStudioGUIForm_DragEnter(object sender, DragEventArgs e)
|
||||||
@@ -788,30 +787,22 @@ namespace AssetStudioGUI
|
|||||||
case Sprite m_Sprite:
|
case Sprite m_Sprite:
|
||||||
PreviewSprite(assetItem, m_Sprite);
|
PreviewSprite(assetItem, m_Sprite);
|
||||||
break;
|
break;
|
||||||
case Material m_Material:
|
|
||||||
PreviewMaterial(m_Material);
|
|
||||||
StatusStripUpdate("Can be exported to JSON file.");
|
|
||||||
break;
|
|
||||||
case Animator _:
|
case Animator _:
|
||||||
StatusStripUpdate("Can be exported to FBX file.");
|
StatusStripUpdate("Can be exported to FBX file.");
|
||||||
break;
|
goto default;
|
||||||
case AnimationClip _:
|
case AnimationClip _:
|
||||||
StatusStripUpdate("Can be exported with Animator or Objects or .anim file.");
|
StatusStripUpdate("Can be exported with Animator or Objects or .anim file.");
|
||||||
break;
|
break;
|
||||||
case AssetBundle m_AssetBundle:
|
|
||||||
PreviewAssetBundle(m_AssetBundle);
|
|
||||||
StatusStripUpdate("Can be exported to JSON file.");
|
|
||||||
break;
|
|
||||||
case IndexObject m_IndexObject:
|
|
||||||
PreviewIndexObject(m_IndexObject);
|
|
||||||
StatusStripUpdate("Can be exported to JSON file.");
|
|
||||||
break;
|
|
||||||
case MiHoYoBinData m_MiHoYoBinData:
|
case MiHoYoBinData m_MiHoYoBinData:
|
||||||
PreviewMiHoYoBinData(m_MiHoYoBinData);
|
PreviewText(m_MiHoYoBinData.Str);
|
||||||
StatusStripUpdate("Can be exported/previewed as JSON if data is a valid JSON (check XOR).");
|
StatusStripUpdate("Can be exported/previewed as JSON if data is a valid JSON (check XOR).");
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
var str = assetItem.Asset.Dump();
|
var str = assetItem.Asset.Dump();
|
||||||
|
if (string.IsNullOrEmpty(str))
|
||||||
|
{
|
||||||
|
str = JsonConvert.SerializeObject(assetItem.Asset, Formatting.Indented);
|
||||||
|
}
|
||||||
if (str != null)
|
if (str != null)
|
||||||
{
|
{
|
||||||
textPreviewBox.Text = str;
|
textPreviewBox.Text = str;
|
||||||
@@ -1041,23 +1032,6 @@ namespace AssetStudioGUI
|
|||||||
PreviewText(str);
|
PreviewText(str);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void PreviewAssetBundle(AssetBundle m_AssetBundle)
|
|
||||||
{
|
|
||||||
var str = JsonConvert.SerializeObject(m_AssetBundle, Formatting.Indented);
|
|
||||||
PreviewText(str);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void PreviewIndexObject(IndexObject m_IndexObject)
|
|
||||||
{
|
|
||||||
var str = JsonConvert.SerializeObject(m_IndexObject, Formatting.Indented);
|
|
||||||
PreviewText(str);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void PreviewMiHoYoBinData(MiHoYoBinData m_MiHoYoBinData)
|
|
||||||
{
|
|
||||||
PreviewText(m_MiHoYoBinData.Str);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void PreviewFont(Font m_Font)
|
private void PreviewFont(Font m_Font)
|
||||||
{
|
{
|
||||||
if (m_Font.m_FontData != null)
|
if (m_Font.m_FontData != null)
|
||||||
@@ -1273,12 +1247,6 @@ namespace AssetStudioGUI
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void PreviewMaterial(Material m_Material)
|
|
||||||
{
|
|
||||||
var str = JsonConvert.SerializeObject(m_Material, Formatting.Indented);
|
|
||||||
PreviewText(str);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void PreviewTexture(DirectBitmap bitmap)
|
private void PreviewTexture(DirectBitmap bitmap)
|
||||||
{
|
{
|
||||||
imageTexture?.Dispose();
|
imageTexture?.Dispose();
|
||||||
@@ -2190,42 +2158,53 @@ namespace AssetStudioGUI
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void toolStripMenuItem16_MouseHover(object sender, EventArgs e)
|
private async void toolStripMenuItem16_DropDownOpening(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
if (specifyAIVersion.Items.Count == 1 && AIVersionManager.Loaded)
|
if (specifyAIVersion.Enabled && await AIVersionManager.FetchVersions())
|
||||||
{
|
{
|
||||||
specifyAIVersion.Items.AddRange(AIVersionManager.GetVersions());
|
UpdateVersionList();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private async void toolStripComboBox1_SelectedIndexChanged(object sender, EventArgs e)
|
private async void toolStripComboBox1_SelectedIndexChanged(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
if (specifyAIVersion.SelectedIndex == 0) return;
|
if (specifyAIVersion.SelectedIndex == 0)
|
||||||
optionsToolStripMenuItem.DropDown.Visible = false;
|
|
||||||
string version = specifyAIVersion.SelectedItem.ToString();
|
|
||||||
|
|
||||||
Logger.Info($"Loading AI v{version}");
|
|
||||||
specifyAIVersion.Enabled = false;
|
|
||||||
var path = AIVersionManager.GetAIPath(version);
|
|
||||||
if (string.IsNullOrEmpty(path))
|
|
||||||
{
|
{
|
||||||
Logger.Warning("Invalid version, Aborting...");
|
|
||||||
specifyAIVersion.SelectedIndex = 0;
|
|
||||||
SpecifyAIVersionUpdate(true);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var needDownload = await AIVersionManager.NeedDownload(version);
|
optionsToolStripMenuItem.DropDown.Visible = false;
|
||||||
if (needDownload)
|
var version = specifyAIVersion.SelectedItem.ToString();
|
||||||
{
|
|
||||||
Logger.Info($"AI v{version} not found !");
|
|
||||||
var json = await AIVersionManager.DownloadAI(version);
|
|
||||||
|
|
||||||
File.WriteAllText(path, json);
|
if (version.Contains(" "))
|
||||||
|
{
|
||||||
|
version = version.Split(' ')[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Logger.Info($"Loading AI v{version}");
|
||||||
|
SpecifyAIVersionUpdate(false);
|
||||||
|
var path = await AIVersionManager.FetchAI(version);
|
||||||
await Task.Run(() => ResourceIndex.FromFile(path));
|
await Task.Run(() => ResourceIndex.FromFile(path));
|
||||||
|
UpdateVersionList();
|
||||||
SpecifyAIVersionUpdate(true);
|
SpecifyAIVersionUpdate(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void UpdateVersionList()
|
||||||
|
{
|
||||||
|
var selectedIndex = specifyAIVersion.SelectedIndex;
|
||||||
|
specifyAIVersion.Items.Clear();
|
||||||
|
specifyAIVersion.Items.Add("None");
|
||||||
|
|
||||||
|
var versions = AIVersionManager.GetVersions();
|
||||||
|
foreach (var version in versions)
|
||||||
|
{
|
||||||
|
specifyAIVersion.Items.Add(version.Item1 + (version.Item2 ? " (cached)" : ""));
|
||||||
|
}
|
||||||
|
|
||||||
|
specifyAIVersion.SelectedIndexChanged -= new EventHandler(toolStripComboBox1_SelectedIndexChanged);
|
||||||
|
specifyAIVersion.SelectedIndex = selectedIndex;
|
||||||
|
specifyAIVersion.SelectedIndexChanged += new EventHandler(toolStripComboBox1_SelectedIndexChanged);
|
||||||
|
}
|
||||||
|
|
||||||
private void toolStripComboBox2_SelectedIndexChanged(object sender, EventArgs e)
|
private void toolStripComboBox2_SelectedIndexChanged(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
optionsToolStripMenuItem.DropDown.Visible = false;
|
optionsToolStripMenuItem.DropDown.Visible = false;
|
||||||
|
|||||||
@@ -107,26 +107,6 @@ namespace AssetStudioGUI
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static bool ExportAssetBundle(AssetItem item, string exportPath)
|
|
||||||
{
|
|
||||||
if (!TryExportFile(exportPath, item, ".json", out var exportFullPath))
|
|
||||||
return false;
|
|
||||||
var m_AssetBundle = (AssetBundle)item.Asset;
|
|
||||||
var str = JsonConvert.SerializeObject(m_AssetBundle, Formatting.Indented);
|
|
||||||
File.WriteAllText(exportFullPath, str);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static bool ExportIndexObject(AssetItem item, string exportPath)
|
|
||||||
{
|
|
||||||
if (!TryExportFile(exportPath, item, ".json", out var exportFullPath))
|
|
||||||
return false;
|
|
||||||
var m_IndexObject = (IndexObject)item.Asset;
|
|
||||||
var str = JsonConvert.SerializeObject(m_IndexObject, Formatting.Indented);
|
|
||||||
File.WriteAllText(exportFullPath, str);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static bool ExportMiHoYoBinData(AssetItem item, string exportPath)
|
public static bool ExportMiHoYoBinData(AssetItem item, string exportPath)
|
||||||
{
|
{
|
||||||
string exportFullPath;
|
string exportFullPath;
|
||||||
@@ -301,15 +281,21 @@ namespace AssetStudioGUI
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static bool ExportMaterial(AssetItem item, string exportPath)
|
public static bool ExportJsonFile(AssetItem item, string exportPath)
|
||||||
{
|
{
|
||||||
if (!TryExportFile(exportPath, item, ".json", out var exportFullPath))
|
if (!TryExportFile(exportPath, item, ".json", out var exportFullPath))
|
||||||
return false;
|
return false;
|
||||||
var m_Material = (Material)item.Asset;
|
var str = JsonConvert.SerializeObject(item.Asset, Formatting.Indented);
|
||||||
var str = JsonConvert.SerializeObject(m_Material, Formatting.Indented);
|
if (!string.IsNullOrEmpty(str) && str != "{}")
|
||||||
|
{
|
||||||
File.WriteAllText(exportFullPath, str);
|
File.WriteAllText(exportFullPath, str);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return ExportRawFile(item, exportPath);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static bool ExportRawFile(AssetItem item, string exportPath)
|
public static bool ExportRawFile(AssetItem item, string exportPath)
|
||||||
{
|
{
|
||||||
@@ -440,20 +426,14 @@ namespace AssetStudioGUI
|
|||||||
return ExportMovieTexture(item, exportPath);
|
return ExportMovieTexture(item, exportPath);
|
||||||
case ClassIDType.Sprite:
|
case ClassIDType.Sprite:
|
||||||
return ExportSprite(item, exportPath);
|
return ExportSprite(item, exportPath);
|
||||||
case ClassIDType.Material:
|
|
||||||
return ExportMaterial(item, exportPath);
|
|
||||||
case ClassIDType.Animator:
|
case ClassIDType.Animator:
|
||||||
return ExportAnimator(item, exportPath);
|
return ExportAnimator(item, exportPath);
|
||||||
case ClassIDType.AnimationClip:
|
case ClassIDType.AnimationClip:
|
||||||
return ExportAnimationClip(item, exportPath);
|
return ExportAnimationClip(item, exportPath);
|
||||||
case ClassIDType.AssetBundle:
|
|
||||||
return ExportAssetBundle(item, exportPath);
|
|
||||||
case ClassIDType.IndexObject:
|
|
||||||
return ExportIndexObject(item, exportPath);
|
|
||||||
case ClassIDType.MiHoYoBinData:
|
case ClassIDType.MiHoYoBinData:
|
||||||
return ExportMiHoYoBinData(item, exportPath);
|
return ExportMiHoYoBinData(item, exportPath);
|
||||||
default:
|
default:
|
||||||
return ExportRawFile(item, exportPath);
|
return ExportJsonFile(item, exportPath);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -459,12 +459,19 @@ namespace AssetStudioGUI
|
|||||||
Progress.Report(++i, objectCount);
|
Progress.Report(++i, objectCount);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
StatusStripUpdate("Building container list...");
|
||||||
|
|
||||||
|
i = 0;
|
||||||
|
Progress.Reset();
|
||||||
|
var containersCount = containers.Count;
|
||||||
foreach ((var pptr, var container) in containers)
|
foreach ((var pptr, var container) in containers)
|
||||||
{
|
{
|
||||||
if (pptr.TryGet(out var obj))
|
if (pptr.TryGet(out var obj))
|
||||||
{
|
{
|
||||||
objectAssetItemDic[obj].Container = container;
|
objectAssetItemDic[obj].Container = container;
|
||||||
}
|
}
|
||||||
|
Progress.Report(++i, containersCount);
|
||||||
}
|
}
|
||||||
foreach (var tmp in exportableAssets)
|
foreach (var tmp in exportableAssets)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user