diff --git a/AssetStudioGUI/AssetStudioGUIForm.cs b/AssetStudioGUI/AssetStudioGUIForm.cs index 3d75be3..5ad70de 100644 --- a/AssetStudioGUI/AssetStudioGUIForm.cs +++ b/AssetStudioGUI/AssetStudioGUIForm.cs @@ -142,7 +142,7 @@ namespace AssetStudioGUI private async void loadFile_Click(object sender, EventArgs e) { openFileDialog1.InitialDirectory = openDirectoryBackup; - if (openFileDialog1.ShowDialog() == DialogResult.OK) + if (openFileDialog1.ShowDialog(this) == DialogResult.OK) { ResetForm(); openDirectoryBackup = Path.GetDirectoryName(openFileDialog1.FileNames[0]); @@ -168,7 +168,7 @@ namespace AssetStudioGUI private async void extractFileToolStripMenuItem_Click(object sender, EventArgs e) { - if (openFileDialog1.ShowDialog() == DialogResult.OK) + if (openFileDialog1.ShowDialog(this) == DialogResult.OK) { var saveFolderDialog = new OpenFolderDialog(); saveFolderDialog.Title = "Select the save folder"; @@ -223,10 +223,6 @@ namespace AssetStudioGUI sceneTreeView.BeginUpdate(); sceneTreeView.Nodes.AddRange(treeNodeCollection.ToArray()); - foreach (var node in treeNodeCollection) - { - node.HideCheckBox(); - } sceneTreeView.EndUpdate(); treeNodeCollection.Clear(); @@ -462,7 +458,7 @@ namespace AssetStudioGUI private void showExpOpt_Click(object sender, EventArgs e) { var exportOpt = new ExportOptions(); - exportOpt.ShowDialog(); + exportOpt.ShowDialog(this); } private void assetListView_RetrieveVirtualItem(object sender, RetrieveVirtualItemEventArgs e) @@ -1404,25 +1400,32 @@ namespace AssetStudioGUI { var gameObjects = new List(); GetSelectedParentNode(sceneTreeView.Nodes, gameObjects); - var saveFileDialog = new SaveFileDialog(); - saveFileDialog.FileName = gameObjects[0].m_Name + " (merge).fbx"; - saveFileDialog.AddExtension = false; - saveFileDialog.Filter = "Fbx file (*.fbx)|*.fbx"; - saveFileDialog.InitialDirectory = saveDirectoryBackup; - if (saveFileDialog.ShowDialog() == DialogResult.OK) + if (gameObjects.Count > 0) { - saveDirectoryBackup = Path.GetDirectoryName(saveFileDialog.FileName); - var exportPath = saveFileDialog.FileName; - List animationList = null; - if (animation) + var saveFileDialog = new SaveFileDialog(); + saveFileDialog.FileName = gameObjects[0].m_Name + " (merge).fbx"; + saveFileDialog.AddExtension = false; + saveFileDialog.Filter = "Fbx file (*.fbx)|*.fbx"; + saveFileDialog.InitialDirectory = saveDirectoryBackup; + if (saveFileDialog.ShowDialog(this) == DialogResult.OK) { - animationList = GetSelectedAssets().Where(x => x.Type == ClassIDType.AnimationClip).ToList(); - if (animationList.Count == 0) + saveDirectoryBackup = Path.GetDirectoryName(saveFileDialog.FileName); + var exportPath = saveFileDialog.FileName; + List animationList = null; + if (animation) { - animationList = null; + animationList = GetSelectedAssets().Where(x => x.Type == ClassIDType.AnimationClip).ToList(); + if (animationList.Count == 0) + { + animationList = null; + } } + ExportObjectsMergeWithAnimationClip(exportPath, gameObjects, animationList); } - ExportObjectsMergeWithAnimationClip(exportPath, gameObjects, animationList); + } + else + { + StatusStripUpdate("No Object selected for export."); } } } diff --git a/AssetStudioGUI/Components/GameObjectTreeNode.cs b/AssetStudioGUI/Components/GameObjectTreeNode.cs index f4c6e4e..f8f6fcd 100644 --- a/AssetStudioGUI/Components/GameObjectTreeNode.cs +++ b/AssetStudioGUI/Components/GameObjectTreeNode.cs @@ -7,11 +7,6 @@ namespace AssetStudioGUI { public GameObject gameObject; - public GameObjectTreeNode(string name) - { - Text = name; - } - public GameObjectTreeNode(GameObject gameObject) { this.gameObject = gameObject; diff --git a/AssetStudioGUI/Components/OpenFolderDialog.cs b/AssetStudioGUI/Components/OpenFolderDialog.cs index cd8dcea..f0b9d65 100644 --- a/AssetStudioGUI/Components/OpenFolderDialog.cs +++ b/AssetStudioGUI/Components/OpenFolderDialog.cs @@ -14,12 +14,12 @@ namespace AssetStudioGUI internal DialogResult ShowDialog(IWin32Window owner = null) { -#if NETFRAMEWORK +//#if NETFRAMEWORK if (Environment.OSVersion.Version.Major >= 6) { return ShowVistaDialog(owner); } -#endif +//#endif return ShowFolderBrowserDialog(owner); } diff --git a/AssetStudioGUI/Components/TreeViewExtensions.cs b/AssetStudioGUI/Components/TreeViewExtensions.cs deleted file mode 100644 index e166280..0000000 --- a/AssetStudioGUI/Components/TreeViewExtensions.cs +++ /dev/null @@ -1,48 +0,0 @@ -using System; -using System.Runtime.InteropServices; -using System.Windows.Forms; - -namespace AssetStudioGUI -{ - internal static class TreeViewExtensions - { - private const int TVIF_STATE = 0x8; - private const int TVIS_STATEIMAGEMASK = 0xF000; - private const int TV_FIRST = 0x1100; - private const int TVM_SETITEM = TV_FIRST + 63; - - [StructLayout(LayoutKind.Sequential, Pack = 8, CharSet = CharSet.Auto)] - private struct TVITEM - { - public int mask; - public IntPtr hItem; - public int state; - public int stateMask; - [MarshalAs(UnmanagedType.LPTStr)] - public string lpszText; - public int cchTextMax; - public int iImage; - public int iSelectedImage; - public int cChildren; - public IntPtr lParam; - } - - [DllImport("user32.dll", CharSet = CharSet.Auto)] - private static extern IntPtr SendMessage(IntPtr hWnd, int Msg, IntPtr wParam, ref TVITEM lParam); - - /// - /// Hides the checkbox for the specified node on a TreeView control. - /// - public static void HideCheckBox(this TreeNode node) - { - var tvi = new TVITEM - { - hItem = node.Handle, - mask = TVIF_STATE, - stateMask = TVIS_STATEIMAGEMASK, - state = TVIS_STATEIMAGEMASK - }; - SendMessage(node.TreeView.Handle, TVM_SETITEM, IntPtr.Zero, ref tvi); - } - } -} diff --git a/AssetStudioGUI/Studio.cs b/AssetStudioGUI/Studio.cs index ab7caae..c645509 100644 --- a/AssetStudioGUI/Studio.cs +++ b/AssetStudioGUI/Studio.cs @@ -265,7 +265,7 @@ namespace AssetStudioGUI Progress.Reset(); foreach (var assetsFile in assetsManager.assetsFileList) { - var fileNode = new GameObjectTreeNode(assetsFile.fileName); //RootNode + var fileNode = new TreeNode(assetsFile.fileName); //RootNode foreach (var obj in assetsFile.Objects) { @@ -307,11 +307,12 @@ namespace AssetStudioGUI { if (m_Father.m_GameObject.TryGet(out var parentGameObject)) { - if (!treeNodeDictionary.TryGetValue(parentGameObject, out parentNode)) + if (!treeNodeDictionary.TryGetValue(parentGameObject, out var parentGameObjectNode)) { - parentNode = new GameObjectTreeNode(parentGameObject); - treeNodeDictionary.Add(parentGameObject, parentNode); + parentGameObjectNode = new GameObjectTreeNode(parentGameObject); + treeNodeDictionary.Add(parentGameObject, parentGameObjectNode); } + parentNode = parentGameObjectNode; } } } @@ -514,7 +515,7 @@ namespace AssetStudioGUI var count = nodes.Cast().Sum(x => x.Nodes.Count); int k = 0; Progress.Reset(); - foreach (GameObjectTreeNode node in nodes) + foreach (TreeNode node in nodes) { //遍历一级子节点 foreach (GameObjectTreeNode j in node.Nodes) @@ -635,7 +636,7 @@ namespace AssetStudioGUI } else { - StatusStripUpdate("No Object can be exported."); + StatusStripUpdate("No Object selected for export."); } }); } @@ -667,11 +668,11 @@ namespace AssetStudioGUI public static void GetSelectedParentNode(TreeNodeCollection nodes, List gameObjects) { - foreach (GameObjectTreeNode i in nodes) + foreach (TreeNode i in nodes) { - if (i.Checked) + if (i is GameObjectTreeNode gameObjectTreeNode && i.Checked) { - gameObjects.Add(i.gameObject); + gameObjects.Add(gameObjectTreeNode.gameObject); } else { diff --git a/AssetStudioUtility/SpriteHelper.cs b/AssetStudioUtility/SpriteHelper.cs index 62e1eba..7803827 100644 --- a/AssetStudioUtility/SpriteHelper.cs +++ b/AssetStudioUtility/SpriteHelper.cs @@ -82,7 +82,7 @@ namespace AssetStudio var polygons = triangles.Select(x => new Polygon(new LinearLineSegment(x.Select(y => new PointF(y.X, y.Y)).ToArray()))).ToArray(); IPathCollection path = new PathCollection(polygons); var matrix = Matrix3x2.CreateScale(m_Sprite.m_PixelsToUnits); - 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); + matrix *= Matrix3x2.CreateTranslation(textureRect.width * m_Sprite.m_Pivot.X - textureRectOffset.X, textureRect.height * m_Sprite.m_Pivot.Y - textureRectOffset.Y); path = path.Transform(matrix); var graphicsOptions = new GraphicsOptions {