diff --git a/CHANGELOG.md b/CHANGELOG.md index 479a737d..bff7e3c3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,5 @@ -7.0 (IN DEVELOPMENT) +7.0.0.0 ==================== -Some features may be completely missing or incomplete at this point in time! -Added .3dst (3DS Texture) support -Semi-added Sub-Pck editing diff --git a/PCK-Studio/Extensions/PictureBoxExtensions.cs b/PCK-Studio/Extensions/PictureBoxExtensions.cs new file mode 100644 index 00000000..e26446da --- /dev/null +++ b/PCK-Studio/Extensions/PictureBoxExtensions.cs @@ -0,0 +1,27 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Reflection; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace PckStudio.Extensions +{ + internal static class PictureBoxExtensions + { + public static bool IsAnimating(this PictureBox pictureBox) + { + var fi = typeof(PictureBox).GetField("currentlyAnimating", BindingFlags.NonPublic | BindingFlags.Instance); + return (bool)fi.GetValue(pictureBox); + } + + public static void Animate(this PictureBox pictureBox, bool animate) + { + var animateMethod = typeof(PictureBox).GetMethod("Animate", BindingFlags.NonPublic | BindingFlags.Instance, + null, new Type[] { typeof(bool) }, null); + animateMethod.Invoke(pictureBox, new object[] { animate }); + } + + } +} diff --git a/PCK-Studio/Extensions/TreeViewExtensions.cs b/PCK-Studio/Extensions/TreeViewExtensions.cs new file mode 100644 index 00000000..61583041 --- /dev/null +++ b/PCK-Studio/Extensions/TreeViewExtensions.cs @@ -0,0 +1,26 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; +using PckStudio.Internal.App; + +namespace PckStudio.Extensions +{ + internal static class TreeViewExtensions + { + public static TreeNode[] FindPath(this TreeView treeView, string path) + { + if (string.IsNullOrWhiteSpace(path)) + return Array.Empty(); + string segment = path.Substring(0, path.IndexOf(treeView.PathSeparator)); + if (treeView.Nodes.ContainsKey(segment)) + { + var res = treeView.Nodes[segment].GetChildNodes().Where(node => node.FullPath == path).ToArray(); + return res; + } + return Array.Empty(); + } + } +} diff --git a/PCK-Studio/Forms/Skins-And-Textures/AddNewSkin.cs b/PCK-Studio/Forms/Skins-And-Textures/AddNewSkin.cs index 7f4b8f6c..2e99e2a8 100644 --- a/PCK-Studio/Forms/Skins-And-Textures/AddNewSkin.cs +++ b/PCK-Studio/Forms/Skins-And-Textures/AddNewSkin.cs @@ -108,12 +108,12 @@ namespace PckStudio.Popups private void buttonSkin_Click(object sender, EventArgs e) { - contextMenuSkin.Show(this, Location.X + buttonSkin.Location.X + 2, Location.Y + buttonSkin.Location.Y + buttonSkin.Size.Height); + contextMenuSkin.Show(this, buttonSkin.Location.X + 2, buttonSkin.Location.Y + buttonSkin.Size.Height); } private void buttonCape_Click(object sender, EventArgs e) { - contextMenuCape.Show(this, Location.X + buttonCape.Location.X + 2, Location.Y + buttonCape.Location.Y + buttonCape.Size.Height); + contextMenuCape.Show(this, buttonCape.Location.X + 2, buttonCape.Location.Y + buttonCape.Size.Height); } private void replaceToolStripMenuItem_Click(object sender, EventArgs e) @@ -134,8 +134,8 @@ namespace PckStudio.Popups { contextMenuSkin.Show( this, - x: Location.X + skinPictureBox.Location.X, - y: Location.Y + skinPictureBox.Location.Y + skinPictureBox.Size.Height + x: skinPictureBox.Location.X, + y: skinPictureBox.Location.Y + skinPictureBox.Size.Height ); return; } @@ -172,8 +172,8 @@ namespace PckStudio.Popups { contextMenuCape.Show( this, - x: Location.X + capePictureBox.Location.X, - y: Location.Y + capePictureBox.Location.Y + capePictureBox.Size.Height + x: capePictureBox.Location.X, + y: capePictureBox.Location.Y + capePictureBox.Size.Height ); return; } diff --git a/PCK-Studio/MainForm.Designer.cs b/PCK-Studio/MainForm.Designer.cs index eb75cbbe..8c9e1cd4 100644 --- a/PCK-Studio/MainForm.Designer.cs +++ b/PCK-Studio/MainForm.Designer.cs @@ -1122,6 +1122,7 @@ this.treeViewMain.DragOver += new System.Windows.Forms.DragEventHandler(this.treeViewMain_DragOver); this.treeViewMain.DoubleClick += new System.EventHandler(this.treeViewMain_DoubleClick); this.treeViewMain.KeyDown += new System.Windows.Forms.KeyEventHandler(this.treeViewMain_KeyDown); + this.treeViewMain.NodeMouseClick += new System.Windows.Forms.TreeNodeMouseClickEventHandler(this.treeViewMain_NodeMouseClick); // // imageList // diff --git a/PCK-Studio/MainForm.cs b/PCK-Studio/MainForm.cs index ccb74324..b350b5f9 100644 --- a/PCK-Studio/MainForm.cs +++ b/PCK-Studio/MainForm.cs @@ -424,7 +424,7 @@ namespace PckStudio private void BuildMainTreeView() { // In case the Rename function was just used and the selected node name no longer matches the file name - string selectedNodeText = treeViewMain.SelectedNode is TreeNode node ? node.Text : string.Empty; + string selectedNodeText = treeViewMain.SelectedNode is TreeNode node ? node.FullPath : string.Empty; previewPictureBox.Image = Resources.NoImageFound; treeMeta.Nodes.Clear(); treeViewMain.Nodes.Clear(); @@ -441,9 +441,8 @@ namespace PckStudio } treeViewMain.Sort(); - TreeNode[] selectedNodes; - if (!string.IsNullOrEmpty(selectedNodeText) && - (selectedNodes = treeViewMain.Nodes.Find(selectedNodeText, true)).Length > 0) + TreeNode[] selectedNodes = treeViewMain.FindPath(selectedNodeText); + if (selectedNodes.Length > 0) { treeViewMain.SelectedNode = selectedNodes[0]; } @@ -2505,6 +2504,7 @@ namespace PckStudio private void exitToolStripMenuItem_Click(object sender, EventArgs e) { + PckManager?.Close(); Application.Exit(); } @@ -2644,5 +2644,11 @@ namespace PckStudio setFileTypeToolStripMenuItem.Visible = false; } } + + private void treeViewMain_NodeMouseClick(object sender, TreeNodeMouseClickEventArgs e) + { + if (e.Node is not null) + treeViewMain.SelectedNode = e.Node; + } } } \ No newline at end of file diff --git a/PCK-Studio/PckStudio.csproj b/PCK-Studio/PckStudio.csproj index 6f435b56..01c1b746 100644 --- a/PCK-Studio/PckStudio.csproj +++ b/PCK-Studio/PckStudio.csproj @@ -135,6 +135,8 @@ + + Form @@ -777,14 +779,14 @@ --> - + - $(GitHash) + $(GitHash) $(GitBranch) @@ -799,7 +801,7 @@ - + <_Parameter1>GitHash <_Parameter2>$(BuildHash) diff --git a/PCK-Studio/ToolboxItems/AnimationPictureBox.cs b/PCK-Studio/ToolboxItems/AnimationPictureBox.cs index 580cd49f..196b19e1 100644 --- a/PCK-Studio/ToolboxItems/AnimationPictureBox.cs +++ b/PCK-Studio/ToolboxItems/AnimationPictureBox.cs @@ -34,37 +34,38 @@ namespace PckStudio.ToolboxItems private bool _isPlaying; - private void PictureBox_Internal_Animate(PictureBox pictureBox, bool animate) - { - var animateMethod = typeof(PictureBox).GetMethod("Animate", - System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance, - null, new Type[] { typeof(bool) }, null); - animateMethod.Invoke(pictureBox, new object[] { animate }); - } - public new Image Image { get => base.Image; set { base.Image = value; - PictureBox_Internal_Animate(this, false); + this.Animate(false); if (value is null) return; value.SelectActiveFrame(new FrameDimension(value.FrameDimensionsList[0]), 0); } } + protected override void OnPaint(PaintEventArgs paintEventArgs) + { + base.OnPaint(paintEventArgs); + if (!_isPlaying && this.IsAnimating()) + { + Stop(); + } + } + public void Start() { _isPlaying = true; - PictureBox_Internal_Animate(this, _isPlaying); + this.Animate(_isPlaying); } public void Stop() { _isPlaying = false; - PictureBox_Internal_Animate(this, _isPlaying); + this.Animate(_isPlaying); } protected override void Dispose(bool disposing)