Skip to content

Commit e1cfff6

Browse files
committed
minor fixes and improvements
1 parent 44514a4 commit e1cfff6

6 files changed

Lines changed: 38 additions & 87 deletions

File tree

AssetStudioGUI/AssetStudioGUIForm.cs

Lines changed: 25 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ private async void AssetStudioGUIForm_DragDrop(object sender, DragEventArgs e)
141141
private async void loadFile_Click(object sender, EventArgs e)
142142
{
143143
openFileDialog1.InitialDirectory = openDirectoryBackup;
144-
if (openFileDialog1.ShowDialog() == DialogResult.OK)
144+
if (openFileDialog1.ShowDialog(this) == DialogResult.OK)
145145
{
146146
ResetForm();
147147
openDirectoryBackup = Path.GetDirectoryName(openFileDialog1.FileNames[0]);
@@ -167,7 +167,7 @@ private async void loadFolder_Click(object sender, EventArgs e)
167167

168168
private async void extractFileToolStripMenuItem_Click(object sender, EventArgs e)
169169
{
170-
if (openFileDialog1.ShowDialog() == DialogResult.OK)
170+
if (openFileDialog1.ShowDialog(this) == DialogResult.OK)
171171
{
172172
var saveFolderDialog = new OpenFolderDialog();
173173
saveFolderDialog.Title = "Select the save folder";
@@ -222,10 +222,6 @@ private async void BuildAssetStructures()
222222

223223
sceneTreeView.BeginUpdate();
224224
sceneTreeView.Nodes.AddRange(treeNodeCollection.ToArray());
225-
foreach (var node in treeNodeCollection)
226-
{
227-
node.HideCheckBox();
228-
}
229225
sceneTreeView.EndUpdate();
230226
treeNodeCollection.Clear();
231227

@@ -461,7 +457,7 @@ private void displayAssetInfo_Check(object sender, EventArgs e)
461457
private void showExpOpt_Click(object sender, EventArgs e)
462458
{
463459
var exportOpt = new ExportOptions();
464-
exportOpt.ShowDialog();
460+
exportOpt.ShowDialog(this);
465461
}
466462

467463
private void assetListView_RetrieveVirtualItem(object sender, RetrieveVirtualItemEventArgs e)
@@ -1384,25 +1380,32 @@ private void ExportMergeObjects(bool animation)
13841380
{
13851381
var gameObjects = new List<GameObject>();
13861382
GetSelectedParentNode(sceneTreeView.Nodes, gameObjects);
1387-
var saveFileDialog = new SaveFileDialog();
1388-
saveFileDialog.FileName = gameObjects[0].m_Name + " (merge).fbx";
1389-
saveFileDialog.AddExtension = false;
1390-
saveFileDialog.Filter = "Fbx file (*.fbx)|*.fbx";
1391-
saveFileDialog.InitialDirectory = saveDirectoryBackup;
1392-
if (saveFileDialog.ShowDialog() == DialogResult.OK)
1393-
{
1394-
saveDirectoryBackup = Path.GetDirectoryName(saveFileDialog.FileName);
1395-
var exportPath = saveFileDialog.FileName;
1396-
List<AssetItem> animationList = null;
1397-
if (animation)
1383+
if (gameObjects.Count > 0)
1384+
{
1385+
var saveFileDialog = new SaveFileDialog();
1386+
saveFileDialog.FileName = gameObjects[0].m_Name + " (merge).fbx";
1387+
saveFileDialog.AddExtension = false;
1388+
saveFileDialog.Filter = "Fbx file (*.fbx)|*.fbx";
1389+
saveFileDialog.InitialDirectory = saveDirectoryBackup;
1390+
if (saveFileDialog.ShowDialog(this) == DialogResult.OK)
13981391
{
1399-
animationList = GetSelectedAssets().Where(x => x.Type == ClassIDType.AnimationClip).ToList();
1400-
if (animationList.Count == 0)
1392+
saveDirectoryBackup = Path.GetDirectoryName(saveFileDialog.FileName);
1393+
var exportPath = saveFileDialog.FileName;
1394+
List<AssetItem> animationList = null;
1395+
if (animation)
14011396
{
1402-
animationList = null;
1397+
animationList = GetSelectedAssets().Where(x => x.Type == ClassIDType.AnimationClip).ToList();
1398+
if (animationList.Count == 0)
1399+
{
1400+
animationList = null;
1401+
}
14031402
}
1403+
ExportObjectsMergeWithAnimationClip(exportPath, gameObjects, animationList);
14041404
}
1405-
ExportObjectsMergeWithAnimationClip(exportPath, gameObjects, animationList);
1405+
}
1406+
else
1407+
{
1408+
StatusStripUpdate("No Object selected for export.");
14061409
}
14071410
}
14081411
}

AssetStudioGUI/Components/GameObjectTreeNode.cs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,6 @@ internal class GameObjectTreeNode : TreeNode
77
{
88
public GameObject gameObject;
99

10-
public GameObjectTreeNode(string name)
11-
{
12-
Text = name;
13-
}
14-
1510
public GameObjectTreeNode(GameObject gameObject)
1611
{
1712
this.gameObject = gameObject;

AssetStudioGUI/Components/OpenFolderDialog.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,12 @@ internal class OpenFolderDialog
1414

1515
internal DialogResult ShowDialog(IWin32Window owner = null)
1616
{
17-
#if NETFRAMEWORK
17+
//#if NETFRAMEWORK
1818
if (Environment.OSVersion.Version.Major >= 6)
1919
{
2020
return ShowVistaDialog(owner);
2121
}
22-
#endif
22+
//#endif
2323
return ShowFolderBrowserDialog(owner);
2424
}
2525

AssetStudioGUI/Components/TreeViewExtensions.cs

Lines changed: 0 additions & 48 deletions
This file was deleted.

AssetStudioGUI/Studio.cs

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,7 @@ public static (string, List<TreeNode>) BuildAssetData()
265265
Progress.Reset();
266266
foreach (var assetsFile in assetsManager.assetsFileList)
267267
{
268-
var fileNode = new GameObjectTreeNode(assetsFile.fileName); //RootNode
268+
var fileNode = new TreeNode(assetsFile.fileName); //RootNode
269269

270270
foreach (var obj in assetsFile.Objects)
271271
{
@@ -307,11 +307,12 @@ public static (string, List<TreeNode>) BuildAssetData()
307307
{
308308
if (m_Father.m_GameObject.TryGet(out var parentGameObject))
309309
{
310-
if (!treeNodeDictionary.TryGetValue(parentGameObject, out parentNode))
310+
if (!treeNodeDictionary.TryGetValue(parentGameObject, out var parentGameObjectNode))
311311
{
312-
parentNode = new GameObjectTreeNode(parentGameObject);
313-
treeNodeDictionary.Add(parentGameObject, parentNode);
312+
parentGameObjectNode = new GameObjectTreeNode(parentGameObject);
313+
treeNodeDictionary.Add(parentGameObject, parentGameObjectNode);
314314
}
315+
parentNode = parentGameObjectNode;
315316
}
316317
}
317318
}
@@ -514,7 +515,7 @@ public static void ExportSplitObjects(string savePath, TreeNodeCollection nodes)
514515
var count = nodes.Cast<TreeNode>().Sum(x => x.Nodes.Count);
515516
int k = 0;
516517
Progress.Reset();
517-
foreach (GameObjectTreeNode node in nodes)
518+
foreach (TreeNode node in nodes)
518519
{
519520
//遍历一级子节点
520521
foreach (GameObjectTreeNode j in node.Nodes)
@@ -635,7 +636,7 @@ public static void ExportObjectsWithAnimationClip(string exportPath, TreeNodeCol
635636
}
636637
else
637638
{
638-
StatusStripUpdate("No Object can be exported.");
639+
StatusStripUpdate("No Object selected for export.");
639640
}
640641
});
641642
}
@@ -667,11 +668,11 @@ public static void ExportObjectsMergeWithAnimationClip(string exportPath, List<G
667668

668669
public static void GetSelectedParentNode(TreeNodeCollection nodes, List<GameObject> gameObjects)
669670
{
670-
foreach (GameObjectTreeNode i in nodes)
671+
foreach (TreeNode i in nodes)
671672
{
672-
if (i.Checked)
673+
if (i is GameObjectTreeNode gameObjectTreeNode && i.Checked)
673674
{
674-
gameObjects.Add(i.gameObject);
675+
gameObjects.Add(gameObjectTreeNode.gameObject);
675676
}
676677
else
677678
{

AssetStudioUtility/SpriteHelper.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ private static Image<Bgra32> CutImage(Sprite m_Sprite, Texture2D m_Texture2D, Re
8282
var polygons = triangles.Select(x => new Polygon(new LinearLineSegment(x.Select(y => new PointF(y.X, y.Y)).ToArray()))).ToArray();
8383
IPathCollection path = new PathCollection(polygons);
8484
var matrix = Matrix3x2.CreateScale(m_Sprite.m_PixelsToUnits);
85-
matrix *= Matrix3x2.CreateTranslation(m_Sprite.m_Rect.width * m_Sprite.m_Pivot.X - textureRectOffset.X, m_Sprite.m_Rect.height * m_Sprite.m_Pivot.Y - textureRectOffset.Y);
85+
matrix *= Matrix3x2.CreateTranslation(textureRect.width * m_Sprite.m_Pivot.X - textureRectOffset.X, textureRect.height * m_Sprite.m_Pivot.Y - textureRectOffset.Y);
8686
path = path.Transform(matrix);
8787
var graphicsOptions = new GraphicsOptions
8888
{

0 commit comments

Comments
 (0)