From 6c2047f6c0eb4a330c19911bef3cd7f026f10284 Mon Sep 17 00:00:00 2001 From: MattN-L Date: Sat, 30 Mar 2024 13:31:52 -0400 Subject: [PATCH 1/4] Fix exception when moving skin under or below a folder --- PCK-Studio/Classes/IO/TGA/TGAExtentionData.cs | 2 +- PCK-Studio/MainForm.cs | 29 ++++++++++++------- 2 files changed, 19 insertions(+), 12 deletions(-) diff --git a/PCK-Studio/Classes/IO/TGA/TGAExtentionData.cs b/PCK-Studio/Classes/IO/TGA/TGAExtentionData.cs index 55485144..3f5d6e45 100644 --- a/PCK-Studio/Classes/IO/TGA/TGAExtentionData.cs +++ b/PCK-Studio/Classes/IO/TGA/TGAExtentionData.cs @@ -49,7 +49,7 @@ namespace PckStudio.IO.TGA extensionData.JobTime = new TimeSpan(extensionData.TimeStamp.Hour, extensionData.TimeStamp.Minute, extensionData.TimeStamp.Second); extensionData.SoftwareID = Application.ProductName; Version.TryParse(Application.ProductVersion, out Version currentVersion); - extensionData.SoftwareVersion = [(byte)currentVersion.Major, (byte)currentVersion.Minor, (byte)currentVersion.Build]; + extensionData.SoftwareVersion = new byte[] { (byte)currentVersion.Major, (byte)currentVersion.Minor, (byte)currentVersion.Build }; extensionData.KeyColor = 0; extensionData.PixelAspectRatio = 0; extensionData.GammaValue = 0; diff --git a/PCK-Studio/MainForm.cs b/PCK-Studio/MainForm.cs index 0e3430ab..a5d18cf3 100644 --- a/PCK-Studio/MainForm.cs +++ b/PCK-Studio/MainForm.cs @@ -2276,21 +2276,28 @@ namespace PckStudio int index = pck.IndexOfFile(file); - if (index + amount < 0 || index + amount > pck.FileCount) return; - pck.RemoveFile(file); - pck.InsertFile(index + amount, file); + try + { + if (index + amount < 0 || index + amount > pck.FileCount) return; + pck.RemoveFile(file); + pck.InsertFile(index + amount, file); - if (IsSubPCK) - { - using (var stream = new MemoryStream()) + if (IsSubPCK) { - var writer = new PckFileWriter(pck, LittleEndianCheckBox.Checked ? OMI.Endianness.LittleEndian : OMI.Endianness.BigEndian); - writer.WriteToStream(stream); - (GetSubPCK(path).Tag as PckFileData).SetData(stream.ToArray()); + using (var stream = new MemoryStream()) + { + var writer = new PckFileWriter(pck, LittleEndianCheckBox.Checked ? OMI.Endianness.LittleEndian : OMI.Endianness.BigEndian); + writer.WriteToStream(stream); + (GetSubPCK(path).Tag as PckFileData).SetData(stream.ToArray()); + } } + BuildMainTreeView(); + wasModified = true; } - BuildMainTreeView(); - wasModified = true; + catch(Exception ex) + { + MessageBox.Show("Can't move file under or above a folder"); + } } [Obsolete] private void moveUpToolStripMenuItem_Click(object sender, EventArgs e) => moveFile(-1); From 613795d960027398476128260f52d03e75dd9365 Mon Sep 17 00:00:00 2001 From: MattN-L Date: Sat, 30 Mar 2024 13:53:28 -0400 Subject: [PATCH 2/4] Added compression support to BinkaToWav converter --- PCK-Studio/Classes/Utils/BinkaConverter.cs | 4 ++-- .../Additional-Popups/ItemSelectionPopUp.cs | 1 + PCK-Studio/MainForm.cs | 17 ++++++++++++++++- 3 files changed, 19 insertions(+), 3 deletions(-) diff --git a/PCK-Studio/Classes/Utils/BinkaConverter.cs b/PCK-Studio/Classes/Utils/BinkaConverter.cs index 5a13b544..cc97e913 100644 --- a/PCK-Studio/Classes/Utils/BinkaConverter.cs +++ b/PCK-Studio/Classes/Utils/BinkaConverter.cs @@ -30,7 +30,7 @@ namespace PckStudio.Classes.Utils MessageBox.Show($"Successfully converted {convertedCount}/{filenames.Length} file{(filenames.Length > 1 ? "s" : "")}", "Done!"); } - public static void ToBinka(string[] filenames, DirectoryInfo destination) + public static void ToBinka(string[] filenames, DirectoryInfo destination, int compressionLevel = 4) { int convertedCount = 0; Directory.CreateDirectory(ApplicationScope.DataCacher.CacheDirectory); @@ -56,7 +56,7 @@ namespace PckStudio.Classes.Utils } Cursor.Current = Cursors.WaitCursor; - int exitCode = Binka.ToBinka(cacheSongFilepath, Path.Combine(destination.FullName, Path.GetFileNameWithoutExtension(file) + ".binka"), 4); + int exitCode = Binka.ToBinka(cacheSongFilepath, Path.Combine(destination.FullName, Path.GetFileNameWithoutExtension(file) + ".binka"), compressionLevel); if (exitCode == 0) convertedCount++; } diff --git a/PCK-Studio/Forms/Additional-Popups/ItemSelectionPopUp.cs b/PCK-Studio/Forms/Additional-Popups/ItemSelectionPopUp.cs index c5017b39..f84b95a5 100644 --- a/PCK-Studio/Forms/Additional-Popups/ItemSelectionPopUp.cs +++ b/PCK-Studio/Forms/Additional-Popups/ItemSelectionPopUp.cs @@ -6,6 +6,7 @@ namespace PckStudio.Forms.Additional_Popups public partial class ItemSelectionPopUp : MetroFramework.Forms.MetroForm { public string SelectedItem => DialogResult == DialogResult.OK ? ComboBox.Text : string.Empty; + public int SelectedIndex => DialogResult == DialogResult.OK ? ComboBox.SelectedIndex : -1; public string LabelText { diff --git a/PCK-Studio/MainForm.cs b/PCK-Studio/MainForm.cs index a5d18cf3..bb7cb3bc 100644 --- a/PCK-Studio/MainForm.cs +++ b/PCK-Studio/MainForm.cs @@ -2180,7 +2180,22 @@ namespace PckStudio }; if (fileDialog.ShowDialog() == DialogResult.OK) { - BinkaConverter.ToBinka(fileDialog.FileNames, new DirectoryInfo(Path.GetDirectoryName(fileDialog.FileName))); + using ItemSelectionPopUp dialog = new ItemSelectionPopUp( + "Level 1 (Best Quality)", "Level 2", "Level 3", "Level 4", "Level 5", + "Level 6", "Level 7", "Level 8", "Level 9 (Worst Quality)") + { + LabelText = "Compression", + ButtonText = "OK" + }; + + if(dialog.ShowDialog() == DialogResult.OK) + { + BinkaConverter.ToBinka( + fileDialog.FileNames, + new DirectoryInfo(Path.GetDirectoryName(fileDialog.FileName)), + dialog.SelectedIndex + 1 // compression level + ); + } } } From b0ed143843b95c36728119dbf6dfe1aff27e1257 Mon Sep 17 00:00:00 2001 From: MattN-L Date: Sat, 30 Mar 2024 15:48:07 -0400 Subject: [PATCH 3/4] Fix for loss of data in rebuilt sub-pcks --- PCK-Studio/Internal/ApplicationBuildInfo.cs | 2 +- PCK-Studio/MainForm.cs | 30 +++++++++++++++++++-- 2 files changed, 29 insertions(+), 3 deletions(-) diff --git a/PCK-Studio/Internal/ApplicationBuildInfo.cs b/PCK-Studio/Internal/ApplicationBuildInfo.cs index f887b0e4..cadde39e 100644 --- a/PCK-Studio/Internal/ApplicationBuildInfo.cs +++ b/PCK-Studio/Internal/ApplicationBuildInfo.cs @@ -25,7 +25,7 @@ namespace PckStudio.Internal { // this is to specify which build release this is. This is manually updated for now // TODO: add different chars for different configurations - private const string BuildType = "b"; + private const string BuildType = "c"; private static System.Globalization.Calendar _buildCalendar; private static DateTime date = new FileInfo(Assembly.GetExecutingAssembly().Location).LastWriteTime; private static string _betaBuildVersion; diff --git a/PCK-Studio/MainForm.cs b/PCK-Studio/MainForm.cs index bb7cb3bc..51aec16e 100644 --- a/PCK-Studio/MainForm.cs +++ b/PCK-Studio/MainForm.cs @@ -929,7 +929,6 @@ namespace PckStudio using AddNewSkin add = new AddNewSkin(locFile); if (add.ShowDialog() == DialogResult.OK) { - if (currentPCK.HasFile("Skins.pck", PckFileType.SkinDataFile)) // Prioritize Skins.pck { TreeNode subPCK = treeViewMain.Nodes.Find("Skins.pck", false).FirstOrDefault(); @@ -1096,16 +1095,38 @@ namespace PckStudio if (parent == null) return; PckFileData parent_file = parent.Tag as PckFileData; + PckFile parent_file_pck = + new PckFileReader( + LittleEndianCheckBox.Checked ? + OMI.Endianness.LittleEndian : + OMI.Endianness.BigEndian + ).FromStream(new MemoryStream(parent_file.Data)); + if (parent_file.Filetype is PckFileType.TexturePackInfoFile || parent_file.Filetype is PckFileType.SkinDataFile) { Debug.WriteLine("Rebuilding " + parent_file.Filename); PckFile newPCKFile = new PckFile(3, parent_file.Filetype is PckFileType.SkinDataFile); + bool hasSkinsFolder = false; + + // add original pck files to prevent data loss + foreach (PckFileData _fd in parent_file_pck.GetFiles()) + { + PckFileData new_file = newPCKFile.CreateNewFile(_fd.Filename, _fd.Filetype); + // check for skins folder so files are placed consistently in final pck + if (_fd.Filename.StartsWith("Skins/") && parent_file.Filetype is PckFileType.SkinDataFile) hasSkinsFolder = true; + foreach (var prop in _fd.GetProperties()) + new_file.AddProperty(prop); + new_file.SetData(_fd.Data); + } + foreach (TreeNode node in GetAllChildNodes(parent.Nodes)) { if (node.Tag is PckFileData node_file) { - PckFileData new_file = newPCKFile.CreateNewFile(node_file.Filename.Replace(parent_file.Filename + "/", String.Empty), node_file.Filetype); + PckFileData new_file = newPCKFile.CreateNewFile( + (hasSkinsFolder ? "Skins/" : String.Empty) + + node_file.Filename.Replace(parent_file.Filename + "/", String.Empty), node_file.Filetype); foreach (var prop in node_file.GetProperties()) new_file.AddProperty(prop); new_file.SetData(node_file.Data); @@ -1115,7 +1136,12 @@ namespace PckStudio parent_file.SetData(new PckFileWriter(newPCKFile, LittleEndianCheckBox.Checked ? OMI.Endianness.LittleEndian : OMI.Endianness.BigEndian)); parent.Tag = parent_file; + // erase hidden sub-pck nodes to prevent duplication + parent.Nodes.Clear(); + BuildMainTreeView(); + + MessageBox.Show(this, $"Files added successfully to {parent_file.Filename}"); } } From 2f0abe33896d9a6efdb595e4d98ac73393b6e9ba Mon Sep 17 00:00:00 2001 From: MattN-L Date: Sun, 31 Mar 2024 11:25:15 -0400 Subject: [PATCH 4/4] Assigned an owner to every instance of show/showdialog --- PCK-Studio/Classes/Utils/BinkaConverter.cs | 8 +- PCK-Studio/Features/CemuPanel.cs | 14 +-- PCK-Studio/Features/PckManager.cs | 2 +- PCK-Studio/Features/WiiUPanel.cs | 18 +-- .../Additional-Popups/EntityForms/AddEntry.cs | 2 +- .../Additional-Popups/Grf/AddParameter.cs | 2 +- PCK-Studio/Forms/Editor/ANIMEditor.cs | 8 +- PCK-Studio/Forms/Editor/AnimationEditor.cs | 19 +-- PCK-Studio/Forms/Editor/AudioEditor.cs | 44 +++---- PCK-Studio/Forms/Editor/BehaviourEditor.cs | 4 +- PCK-Studio/Forms/Editor/COLEditor.cs | 2 +- PCK-Studio/Forms/Editor/GameRuleFileEditor.cs | 28 ++--- PCK-Studio/Forms/Editor/LOCEditor.cs | 8 +- PCK-Studio/Forms/Editor/MaterialsEditor.cs | 2 +- PCK-Studio/Forms/Editor/TextureAtlasEditor.cs | 8 +- .../Forms/Skins-And-Textures/AddNewSkin.cs | 22 ++-- .../Skins-And-Textures/AdvancedOptions.cs | 6 +- .../Forms/Skins-And-Textures/generateModel.cs | 16 +-- PCK-Studio/MainForm.cs | 112 +++++++++--------- PCK-Studio/Program.cs | 1 + 20 files changed, 165 insertions(+), 161 deletions(-) diff --git a/PCK-Studio/Classes/Utils/BinkaConverter.cs b/PCK-Studio/Classes/Utils/BinkaConverter.cs index cc97e913..f6f5e9e6 100644 --- a/PCK-Studio/Classes/Utils/BinkaConverter.cs +++ b/PCK-Studio/Classes/Utils/BinkaConverter.cs @@ -18,7 +18,7 @@ namespace PckStudio.Classes.Utils { int convertedCount = 0; InProgressPrompt waitDiag = new InProgressPrompt(); - waitDiag.Show(); + waitDiag.Show(Program.MainInstance); foreach (string file in filenames) { Binka.ToWav(file, Path.Combine(destination.FullName, Path.GetFileNameWithoutExtension(file) + ".binka")); @@ -27,7 +27,7 @@ namespace PckStudio.Classes.Utils waitDiag.Close(); waitDiag.Dispose(); - MessageBox.Show($"Successfully converted {convertedCount}/{filenames.Length} file{(filenames.Length > 1 ? "s" : "")}", "Done!"); + MessageBox.Show(Program.MainInstance, $"Successfully converted {convertedCount}/{filenames.Length} file{(filenames.Length > 1 ? "s" : "")}", "Done!"); } public static void ToBinka(string[] filenames, DirectoryInfo destination, int compressionLevel = 4) @@ -36,7 +36,7 @@ namespace PckStudio.Classes.Utils Directory.CreateDirectory(ApplicationScope.DataCacher.CacheDirectory); InProgressPrompt waitDiag = new InProgressPrompt(); - waitDiag.Show(); + waitDiag.Show(Program.MainInstance); foreach (string file in filenames) { @@ -63,7 +63,7 @@ namespace PckStudio.Classes.Utils waitDiag.Close(); waitDiag.Dispose(); - MessageBox.Show($"Successfully converted {convertedCount}/{filenames.Length} file{(filenames.Length > 1 ? "s" : "")}", "Done!"); + MessageBox.Show(Program.MainInstance, $"Successfully converted {convertedCount}/{filenames.Length} file{(filenames.Length > 1 ? "s" : "")}", "Done!"); } } } diff --git a/PCK-Studio/Features/CemuPanel.cs b/PCK-Studio/Features/CemuPanel.cs index 3dcf5117..a071beda 100644 --- a/PCK-Studio/Features/CemuPanel.cs +++ b/PCK-Studio/Features/CemuPanel.cs @@ -41,7 +41,7 @@ namespace PckStudio.Features { InitializeComponent(); if (!TryApplyPermanentCemuConfig() && - MessageBox.Show("Failed to get Cemu perma settings\nDo you want to open your local settings.xml file?", + MessageBox.Show(this, "Failed to get Cemu perma settings\nDo you want to open your local settings.xml file?", "Cemu mlc path not found", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes @@ -197,14 +197,14 @@ namespace PckStudio.Features DLCTreeView.Nodes.Clear(); if (!IsValidInstallDirectory()) { - MessageBox.Show("Please select a valid Game Directory!", "Invalid Directory Specified", + MessageBox.Show(this, "Please select a valid Game Directory!", "Invalid Directory Specified", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } if (!IsValidGameDirectory()) { - MessageBox.Show($"Could not find '{GetGameContentPath()}'!", "Not Found", + MessageBox.Show(this, $"Could not find '{GetGameContentPath()}'!", "Not Found", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } @@ -214,7 +214,7 @@ namespace PckStudio.Features if (!dlcDirectory.Exists) { - MessageBox.Show($"'{dirPath}' does not exist!", "Not Found", + MessageBox.Show(this, $"'{dirPath}' does not exist!", "Not Found", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } @@ -276,7 +276,7 @@ namespace PckStudio.Features if (prompt.NewText.ContainsAny(Path.GetInvalidPathChars())) { - MessageBox.Show("Invalid Folder name entered!", "Invalid Folder Name", MessageBoxButtons.OK, MessageBoxIcon.Error); + MessageBox.Show(this, "Invalid Folder name entered!", "Invalid Folder Name", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } @@ -284,7 +284,7 @@ namespace PckStudio.Features if (Directory.Exists(directoryPath)) { - MessageBox.Show("A Folder with the same name already exists!", "Folder Name taken", MessageBoxButtons.OK, MessageBoxIcon.Error); + MessageBox.Show(this, "A Folder with the same name already exists!", "Folder Name taken", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } Directory.CreateDirectory(directoryPath); @@ -302,7 +302,7 @@ namespace PckStudio.Features private void removePckToolStripMenuItem_Click(object sender, EventArgs e) { string pckName = DLCTreeView.SelectedNode.Text; - var result = MessageBox.Show($"Are you sure you want to permanently delete '{pckName}'?", "Hold up!", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question); + var result = MessageBox.Show(this, $"Are you sure you want to permanently delete '{pckName}'?", "Hold up!", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question); if (result == DialogResult.Yes) { string directoryPath = GetContentSubDirectory("WiiU", "DLC", pckName); diff --git a/PCK-Studio/Features/PckManager.cs b/PCK-Studio/Features/PckManager.cs index 6e6cacb8..9c34b76f 100644 --- a/PCK-Studio/Features/PckManager.cs +++ b/PCK-Studio/Features/PckManager.cs @@ -73,7 +73,7 @@ namespace PckStudio.Features } catch (NotImplementedException ex) { - MessageBox.Show(ex.Message, "Not Implemented"); + MessageBox.Show(this, ex.Message, "Not Implemented"); } } diff --git a/PCK-Studio/Features/WiiUPanel.cs b/PCK-Studio/Features/WiiUPanel.cs index adc3baac..8117e9f4 100644 --- a/PCK-Studio/Features/WiiUPanel.cs +++ b/PCK-Studio/Features/WiiUPanel.cs @@ -41,7 +41,7 @@ namespace PckStudio.Features [Obsolete("Prompt user to use Aroma instead!")] private void buttonSelect_Click(object sender, EventArgs e) { - MessageBox.Show("Please use Aroma's ftp Plugin!"); + MessageBox.Show(this, "Please use Aroma's ftp Plugin!"); return; } @@ -131,14 +131,14 @@ namespace PckStudio.Features } catch (Exception ex) { - MessageBox.Show(ex.ToString()); + MessageBox.Show(this, ex.ToString()); } return; } if (!Regex.IsMatch(IPv4TextBox.Text, @"^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$")) { - MessageBox.Show("Please enter a valid Wii U IP!"); + MessageBox.Show(this, "Please enter a valid Wii U IP!"); return; } @@ -169,7 +169,7 @@ namespace PckStudio.Features catch (Exception ex) { SetButtonState(ButtonState.Start); - MessageBox.Show(ex.ToString()); + MessageBox.Show(this, ex.ToString()); } } @@ -184,7 +184,7 @@ namespace PckStudio.Features ListViewHitTestInfo hitTestInfo = listViewPCKS.HitTest(e.Location); if (e.Button == MouseButtons.Right && hitTestInfo.Location != ListViewHitTestLocations.None) { - contextMenuStripCaffiine.Show(Cursor.Position); + contextMenuStripCaffiine.Show(this, Cursor.Position); } } @@ -194,7 +194,7 @@ namespace PckStudio.Features { SetButtonState(ButtonState.Wait); ReplacePck(mod); - MessageBox.Show("PCK Replaced!"); + MessageBox.Show(this, "PCK Replaced!"); } SetButtonState(ButtonState.Stop); UpdateDLCPath(); @@ -208,10 +208,10 @@ namespace PckStudio.Features OpenFileDialog openPCK = new OpenFileDialog(); openPCK.Filter = "PCK File|*.pck"; - if (openPCK.ShowDialog() == DialogResult.OK) + if (openPCK.ShowDialog(this) == DialogResult.OK) { ReplacePck(openPCK.FileName); - MessageBox.Show("PCK Replaced!"); + MessageBox.Show(this, "PCK Replaced!"); } } SetButtonState(ButtonState.Stop); @@ -283,7 +283,7 @@ namespace PckStudio.Features { OpenFileDialog ofd = new OpenFileDialog(); ofd.Filter = "Pack Image|*.png"; - if (ofd.ShowDialog() == DialogResult.OK) + if (ofd.ShowDialog(this) == DialogResult.OK) TextBoxPackImage.Text = ofd.FileName; } } diff --git a/PCK-Studio/Forms/Additional-Popups/EntityForms/AddEntry.cs b/PCK-Studio/Forms/Additional-Popups/EntityForms/AddEntry.cs index 85b9a19c..213adb23 100644 --- a/PCK-Studio/Forms/Additional-Popups/EntityForms/AddEntry.cs +++ b/PCK-Studio/Forms/Additional-Popups/EntityForms/AddEntry.cs @@ -52,7 +52,7 @@ namespace PckStudio.Forms.Additional_Popups.EntityForms } catch (Newtonsoft.Json.JsonException j_ex) { - MessageBox.Show(j_ex.Message, "Error"); + MessageBox.Show(this, j_ex.Message, "Error"); return; } diff --git a/PCK-Studio/Forms/Additional-Popups/Grf/AddParameter.cs b/PCK-Studio/Forms/Additional-Popups/Grf/AddParameter.cs index 36f3884b..ee5795d6 100644 --- a/PCK-Studio/Forms/Additional-Popups/Grf/AddParameter.cs +++ b/PCK-Studio/Forms/Additional-Popups/Grf/AddParameter.cs @@ -44,7 +44,7 @@ namespace PckStudio.Forms.Additional_Popups.Grf { if (string.IsNullOrWhiteSpace(ParameterName) || string.IsNullOrWhiteSpace(ParameterValue)) { - MessageBox.Show("Name and Value need valid values"); + MessageBox.Show(this, "Name and Value need valid values"); return; } DialogResult = DialogResult.OK; diff --git a/PCK-Studio/Forms/Editor/ANIMEditor.cs b/PCK-Studio/Forms/Editor/ANIMEditor.cs index 3184ae33..172af4a1 100644 --- a/PCK-Studio/Forms/Editor/ANIMEditor.cs +++ b/PCK-Studio/Forms/Editor/ANIMEditor.cs @@ -246,11 +246,11 @@ namespace PckStudio.Forms.Editor string value = string.Empty; while (!SkinANIM.IsValidANIM(value)) { - if (!string.IsNullOrWhiteSpace(value)) MessageBox.Show($"The following value \"{value}\" is not valid. Please try again."); + if (!string.IsNullOrWhiteSpace(value)) MessageBox.Show(this, $"The following value \"{value}\" is not valid. Please try again."); TextPrompt diag = new TextPrompt(value); diag.LabelText = "ANIM"; diag.OKButtonText = "Ok"; - if (diag.ShowDialog() == DialogResult.OK) + if (diag.ShowDialog(this) == DialogResult.OK) { value = diag.NewText; } @@ -276,7 +276,7 @@ namespace PckStudio.Forms.Editor FileName = animValue.Text + ".png", Filter = "Skin textures|*.png" }; - if (saveFileDialog.ShowDialog() != DialogResult.OK) + if (saveFileDialog.ShowDialog(this) != DialogResult.OK) return; bool isSlim = ruleset.Value.GetFlag(SkinAnimFlag.SLIM_MODEL); bool is64x64 = ruleset.Value.GetFlag(SkinAnimFlag.RESOLUTION_64x64); @@ -349,7 +349,7 @@ namespace PckStudio.Forms.Editor diag.ButtonText = "Presets"; diag.ButtonText = "Load"; - if (diag.ShowDialog() != DialogResult.OK) + if (diag.ShowDialog(this) != DialogResult.OK) return; var templateANIM = new SkinANIM(Templates[diag.SelectedItem]); diff --git a/PCK-Studio/Forms/Editor/AnimationEditor.cs b/PCK-Studio/Forms/Editor/AnimationEditor.cs index 456c5b32..249b3c70 100644 --- a/PCK-Studio/Forms/Editor/AnimationEditor.cs +++ b/PCK-Studio/Forms/Editor/AnimationEditor.cs @@ -308,6 +308,7 @@ namespace PckStudio.Forms.Editor private void importJavaAnimationToolStripMenuItem_Click(object sender, EventArgs e) { if (MessageBox.Show( + this, "This feature will replace the existing animation data. " + "It might fail if the selected animation script is invalid. " + "Are you sure that you want to continue?", @@ -329,7 +330,7 @@ namespace PckStudio.Forms.Editor string textureFile = fileDialog.FileName.Substring(0, fileDialog.FileName.Length - ".mcmeta".Length); if (!File.Exists(textureFile)) { - MessageBox.Show(textureFile + " was not found", "Texture not found"); + MessageBox.Show(this, textureFile + " was not found", "Texture not found"); return; } try @@ -343,7 +344,7 @@ namespace PckStudio.Forms.Editor } catch (JsonException j_ex) { - MessageBox.Show(j_ex.Message, "Invalid animation"); + MessageBox.Show(this, j_ex.Message, "Invalid animation"); return; } } @@ -392,29 +393,29 @@ namespace PckStudio.Forms.Editor // removes ".mcmeta" from filename string texturePath = Path.Combine(Path.GetDirectoryName(filename), Path.GetFileNameWithoutExtension(filename)); finalTexture.Save(texturePath); - MessageBox.Show("Animation was successfully exported as " + Path.GetFileName(filename), "Export successful!"); + MessageBox.Show(this, "Animation was successfully exported as " + Path.GetFileName(filename), "Export successful!"); } } private void howToInterpolation_Click(object sender, EventArgs e) { - MessageBox.Show("The Interpolation effect is when the animtion smoothly translates between the frames instead of simply displaying the next one. This can be seen with some vanilla Minecraft textures such as Magma and Prismarine.", "Interpolation"); + MessageBox.Show(this, "The Interpolation effect is when the animtion smoothly translates between the frames instead of simply displaying the next one. This can be seen with some vanilla Minecraft textures such as Magma and Prismarine.", "Interpolation"); } private void editorControlsToolStripMenuItem_Click(object sender, EventArgs e) { - MessageBox.Show("Simply drag and drop frames in the tree to rearrange your animation.\n\n" + + MessageBox.Show(this, "Simply drag and drop frames in the tree to rearrange your animation.\n\n" + "You can also preview your animation at any time by simply pressing the button under the animation display.", "Editor Controls"); } private void setBulkSpeedToolStripMenuItem_Click(object sender, EventArgs e) { - MessageBox.Show("You can edit the frame and its speed by double clicking a frame in the tree. If you'd like to change the entire animation's speed, you can do so with the \"Set Bulk Animation Speed\" button in the \"Tools\" tab", "How to use Bulk Animation tool"); + MessageBox.Show(this, "You can edit the frame and its speed by double clicking a frame in the tree. If you'd like to change the entire animation's speed, you can do so with the \"Set Bulk Animation Speed\" button in the \"Tools\" tab", "How to use Bulk Animation tool"); } private void javaAnimationSupportToolStripMenuItem_Click(object sender, EventArgs e) { - MessageBox.Show("You can import any valid Java Edition tile animations into your pck by opening an mcmeta.\n\n" + + MessageBox.Show(this, "You can import any valid Java Edition tile animations into your pck by opening an mcmeta.\n\n" + "You can also export your animation as an Java Edition tile animation. It will also export the actual texture in the same spot.", "Java Edition Support"); } @@ -448,7 +449,7 @@ namespace PckStudio.Forms.Editor var gif = Image.FromFile(fileDialog.FileName); if (!gif.RawFormat.Equals(ImageFormat.Gif)) { - MessageBox.Show("Selected file is not a gif", "Invalid file", MessageBoxButtons.OK, MessageBoxIcon.Error); + MessageBox.Show(this, "Selected file is not a gif", "Invalid file", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } @@ -481,7 +482,7 @@ namespace PckStudio.Forms.Editor Filter = "PNG Files | *.png", Title = "Select a PNG File", }; - if (ofd.ShowDialog() != DialogResult.OK) + if (ofd.ShowDialog(this) != DialogResult.OK) return; Image img = Image.FromFile(ofd.FileName); var textures = img.Split(ImageLayoutDirection.Vertical); diff --git a/PCK-Studio/Forms/Editor/AudioEditor.cs b/PCK-Studio/Forms/Editor/AudioEditor.cs index 3ac86ddc..7658640e 100644 --- a/PCK-Studio/Forms/Editor/AudioEditor.cs +++ b/PCK-Studio/Forms/Editor/AudioEditor.cs @@ -124,8 +124,8 @@ namespace PckStudio.Forms.Editor if (!parent.CreateDataFolder()) return; string FileName = Path.Combine(parent.GetDataPath(), entry.Text + ".binka"); - if (File.Exists(FileName)) MessageBox.Show("\"" + entry.Text + ".binka\" exists in the \"Data\" folder", "File found"); - else MessageBox.Show("\"" + entry.Text + ".binka\" does not exist in the \"Data\" folder. The game will crash when attempting to load this track.", "File missing"); + if (File.Exists(FileName)) MessageBox.Show(this, "\"" + entry.Text + ".binka\" exists in the \"Data\" folder", "File found"); + else MessageBox.Show(this, "\"" + entry.Text + ".binka\" does not exist in the \"Data\" folder. The game will crash when attempting to load this track.", "File missing"); } private void treeView1_AfterSelect(object sender, TreeViewEventArgs e) @@ -145,7 +145,7 @@ namespace PckStudio.Forms.Editor if (available.Length > 0) { using ItemSelectionPopUp add = new ItemSelectionPopUp(available); - if (add.ShowDialog() == DialogResult.OK) + if (add.ShowDialog(this) == DialogResult.OK) audioFile.AddCategory(GetCategoryId(add.SelectedItem)); else return; @@ -165,7 +165,7 @@ namespace PckStudio.Forms.Editor } else { - MessageBox.Show("There are no more categories that could be added", "All possible categories are used"); + MessageBox.Show(this, "There are no more categories that could be added", "All possible categories are used"); } } @@ -179,7 +179,7 @@ namespace PckStudio.Forms.Editor ofn.Multiselect = true; ofn.Filter = "Supported audio files (*.binka,*.wav)|*.binka;*.wav"; ofn.Title = "Please choose WAV or BINKA files to add to your pack"; - ofn.ShowDialog(); + ofn.ShowDialog(this); ofn.Dispose(); if (string.IsNullOrEmpty(ofn.FileName)) return; // Return if name is null or if the user cancels @@ -268,7 +268,7 @@ namespace PckStudio.Forms.Editor diag_text += " Pressing yes will replace the existing file. By pressing no, the song entry will be added without affecting the file." + "You can also cancel this operation and all files in queue."; - DialogResult user_prompt = MessageBox.Show(diag_text, "File already exists", MessageBoxButtons.YesNoCancel); + DialogResult user_prompt = MessageBox.Show(this, diag_text, "File already exists", MessageBoxButtons.YesNoCancel); while (user_prompt == DialogResult.None) ; // Stops the editor from adding or processing the file until the user has made their choice if (user_prompt == DialogResult.Cancel) { @@ -364,7 +364,7 @@ namespace PckStudio.Forms.Editor !audioFile.HasCategory(PckAudioFile.AudioCategory.EAudioType.Nether) || !audioFile.HasCategory(PckAudioFile.AudioCategory.EAudioType.End)) { - MessageBox.Show("Your changes were not saved. The game will crash when loading your pack if the Overworld, Nether and End categories don't all exist with at least one valid song.", "Mandatory Categories Missing"); + MessageBox.Show(this, "Your changes were not saved. The game will crash when loading your pack if the Overworld, Nether and End categories don't all exist with at least one valid song.", "Mandatory Categories Missing"); return; } @@ -375,7 +375,7 @@ namespace PckStudio.Forms.Editor { if (category.SongNames.Count < 1) { - MessageBox.Show("The game will crash upon loading your pack if any of the categories are empty. Please remove or occupy the category.", "Empty Category"); + MessageBox.Show(this, "The game will crash upon loading your pack if any of the categories are empty. Please remove or occupy the category.", "Empty Category"); return; } @@ -385,7 +385,7 @@ namespace PckStudio.Forms.Editor if (!File.Exists(FileName)) { songs_missing = true; - MessageBox.Show("\"" + song + ".binka\" does not exist in the \"Data\" folder. The game will crash when attempting to load this track.", "File missing"); + MessageBox.Show(this, "\"" + song + ".binka\" does not exist in the \"Data\" folder. The game will crash when attempting to load this track.", "File missing"); } } @@ -406,7 +406,7 @@ namespace PckStudio.Forms.Editor if (songs_missing) { - MessageBox.Show("Failed to save AudioData file because there are missing song entries", "Error"); + MessageBox.Show(this, "Failed to save AudioData file because there are missing song entries", "Error"); return; } @@ -421,7 +421,7 @@ namespace PckStudio.Forms.Editor private void helpToolStripMenuItem_Click(object sender, EventArgs e) { - MessageBox.Show("Simply drag and drop BINKA or WAV audio files into the right tree to add them to the category selected on the left tree.\n\n" + + MessageBox.Show(this, "Simply drag and drop BINKA or WAV audio files into the right tree to add them to the category selected on the left tree.\n\n" + "The \"Menu\" category will only play once when loading the pack, and never again.\n\n" + "The \"Creative\" category will only play songs listed in that category, and unlike other editions of Minecraft, will NOT play songs from the Overworld category. You can fix this by clicking the checkbox found at the top of the form.\n\n" + "The mini game categories will only play if you have your pack loaded in those mini games.\n\n" + @@ -430,7 +430,7 @@ namespace PckStudio.Forms.Editor private void deleteUnusedBINKAsToolStripMenuItem_Click(object sender, EventArgs e) { - DialogResult dr = MessageBox.Show("This will delete all unused BINKA songs in the Data directory. This cannot be undone. Are you sure you want to continue?", "Warning", MessageBoxButtons.YesNo); + DialogResult dr = MessageBox.Show(this, "This will delete all unused BINKA songs in the Data directory. This cannot be undone. Are you sure you want to continue?", "Warning", MessageBoxButtons.YesNo); if (dr != DialogResult.Yes) return; var totalSongList = new List(); foreach (string song in audioFile.Categories.SelectMany(cat => cat.SongNames)) @@ -458,17 +458,17 @@ namespace PckStudio.Forms.Editor totalDeleted++; } } - MessageBox.Show("Successfully deleted " + totalDeleted + " files", "Done"); + MessageBox.Show(this, "Successfully deleted " + totalDeleted + " files", "Done"); } private void howToAddSongsToolStripMenuItem_Click(object sender, EventArgs e) { - MessageBox.Show("Right click the right window and press \"Add Entry\" or drag and drop a valid WAV file into the editor's right window. You can also drop other BINKA files, either from the main game or using a tool like BinkMan. The editor will automatically put the song in the Data folder for you.", "How to add a song"); + MessageBox.Show(this, "Right click the right window and press \"Add Entry\" or drag and drop a valid WAV file into the editor's right window. You can also drop other BINKA files, either from the main game or using a tool like BinkMan. The editor will automatically put the song in the Data folder for you.", "How to add a song"); } private void whatAreTheCategoriesToolStripMenuItem_Click(object sender, EventArgs e) { - MessageBox.Show("Categories are pretty self explanatory. The game controls when each category should play.\n" + + MessageBox.Show(this, "Categories are pretty self explanatory. The game controls when each category should play.\n" + "\nGAMEPLAY - Plays in the specified dimensions and game modes.\n" + "-Overworld: Plays in survival mode and in Creative if no songs are set\n" + "-Nether: Plays in the Nether.\n" + @@ -484,17 +484,17 @@ namespace PckStudio.Forms.Editor private void howToEditCreditsToolStripMenuItem_Click(object sender, EventArgs e) { - MessageBox.Show("Click Tools -> Credits Editor. This will allow you to edit all the credits easily in the pack easily. Only supports English credits at the moment. ","How to edit credits?"); + MessageBox.Show(this, "Click Tools -> Credits Editor. This will allow you to edit all the credits easily in the pack easily. Only supports English credits at the moment. ","How to edit credits?"); } private void optimizeDataFolderToolStripMenuItem_Click(object sender, EventArgs e) { - MessageBox.Show("Click Tools -> Delete Unused BINKA files. This will clean your folder of any unused songs.", "How to optimize the Data folder"); + MessageBox.Show(this, "Click Tools -> Delete Unused BINKA files. This will clean your folder of any unused songs.", "How to optimize the Data folder"); } private void BINKACompressionToolStripMenuItem_Click(object sender, EventArgs e) { - MessageBox.Show("The numerical up/down control is responsible for the level of compression used when converting WAV files. The default is 4, which was commonly used by 4J for the game's files.","BINKA Compression Level"); + MessageBox.Show(this, "The numerical up/down control is responsible for the level of compression used when converting WAV files. The default is 4, which was commonly used by 4J for the game's files.","BINKA Compression Level"); } private void openDataFolderToolStripMenuItem_Click(object sender, EventArgs e) @@ -520,7 +520,7 @@ namespace PckStudio.Forms.Editor ofn.Multiselect = true; ofn.Filter = "Supported audio files (*.binka,*.wav)|*.binka;*.wav"; ofn.Title = "Please choose WAV or BINKA files to replace existing track files"; - ofn.ShowDialog(); + ofn.ShowDialog(this); ofn.Dispose(); if (string.IsNullOrEmpty(ofn.FileName)) return; // Return if name is null or if the user cancels @@ -578,7 +578,7 @@ namespace PckStudio.Forms.Editor { using ItemSelectionPopUp add = new ItemSelectionPopUp(available); add.ButtonText = "Save"; - if (add.ShowDialog() != DialogResult.OK) return; + if (add.ShowDialog(this) != DialogResult.OK) return; audioFile.RemoveCategory(category.audioType); @@ -592,13 +592,13 @@ namespace PckStudio.Forms.Editor } else { - MessageBox.Show("There are no categories that aren't already used", "All possible categories are used"); + MessageBox.Show(this, "There are no categories that aren't already used", "All possible categories are used"); } } private void organizeTracksToolStripMenuItem_Click(object sender, EventArgs e) { - if(MessageBox.Show("This function will move all binka files in the \"Data\" folder into a \"Music\" folder, to keep your data better organized. Would you like to continue?", "Move tracks?", MessageBoxButtons.YesNo) == DialogResult.Yes) + if(MessageBox.Show(this, "This function will move all binka files in the \"Data\" folder into a \"Music\" folder, to keep your data better organized. Would you like to continue?", "Move tracks?", MessageBoxButtons.YesNo) == DialogResult.Yes) { if (treeView1.Nodes.Count < 1 || !parent.CreateDataFolder()) return; string musicdir = Path.Combine(parent.GetDataPath(), "Music"); diff --git a/PCK-Studio/Forms/Editor/BehaviourEditor.cs b/PCK-Studio/Forms/Editor/BehaviourEditor.cs index 5e4dddde..26b32916 100644 --- a/PCK-Studio/Forms/Editor/BehaviourEditor.cs +++ b/PCK-Studio/Forms/Editor/BehaviourEditor.cs @@ -160,7 +160,7 @@ namespace PckStudio.Forms.Editor var diag = new AddEntry("behaviours", ApplicationScope.EntityImages); diag.acceptBtn.Text = "Save"; - if (diag.ShowDialog() == DialogResult.OK) + if (diag.ShowDialog(this) == DialogResult.OK) { if (String.IsNullOrEmpty(diag.SelectedEntity)) return; if (behaviourFile.entries.FindAll(behaviour => behaviour.name == diag.SelectedEntity).Count() > 0) @@ -213,7 +213,7 @@ namespace PckStudio.Forms.Editor { var diag = new AddEntry("behaviours", ApplicationScope.EntityImages); - if(diag.ShowDialog() == DialogResult.OK) + if(diag.ShowDialog(this) == DialogResult.OK) { if (string.IsNullOrEmpty(diag.SelectedEntity)) return; if (behaviourFile.entries.FindAll(behaviour => behaviour.name == diag.SelectedEntity).Count() > 0) diff --git a/PCK-Studio/Forms/Editor/COLEditor.cs b/PCK-Studio/Forms/Editor/COLEditor.cs index 611eaafb..6ae722aa 100644 --- a/PCK-Studio/Forms/Editor/COLEditor.cs +++ b/PCK-Studio/Forms/Editor/COLEditor.cs @@ -366,7 +366,7 @@ namespace PckStudio.Forms.Editor colorPick.AllowFullOpen = true; colorPick.AnyColor = true; colorPick.SolidColorOnly = tabControl.SelectedTab == colorsTab; - if (colorPick.ShowDialog() != DialogResult.OK) return; + if (colorPick.ShowDialog(this) != DialogResult.OK) return; pictureBox1.BackColor = colorPick.Color; if (tabControl.SelectedTab == waterTab && waterTreeView.SelectedNode != null && waterTreeView.SelectedNode.Tag != null && waterTreeView.SelectedNode.Tag is ColorContainer.WaterColor) diff --git a/PCK-Studio/Forms/Editor/GameRuleFileEditor.cs b/PCK-Studio/Forms/Editor/GameRuleFileEditor.cs index 1a820646..12d5eabb 100644 --- a/PCK-Studio/Forms/Editor/GameRuleFileEditor.cs +++ b/PCK-Studio/Forms/Editor/GameRuleFileEditor.cs @@ -47,16 +47,16 @@ namespace PckStudio.Forms.Editor public GameRuleFileEditor() { InitializeComponent(); - PromptForCompressionType(); + PromptForCompressionType(Program.MainInstance); saveToolStripMenuItem.Visible = !Settings.Default.AutoSaveChanges; } - private void PromptForCompressionType() + private void PromptForCompressionType(Form owner) { ItemSelectionPopUp dialog = new ItemSelectionPopUp(use_zlib, use_deflate, use_xmem); dialog.LabelText = "Type"; dialog.ButtonText = "Ok"; - if (dialog.ShowDialog() == DialogResult.OK) + if (dialog.ShowDialog(owner) == DialogResult.OK) { switch(dialog.SelectedItem) { @@ -97,7 +97,7 @@ namespace PckStudio.Forms.Editor catch (Exception ex) { Debug.WriteLine(ex.Message); - MessageBox.Show("Faild to open .grf/.grh file"); + MessageBox.Show(this, "Failed to open .grf/.grh file"); } return default!; } @@ -169,11 +169,11 @@ namespace PckStudio.Forms.Editor if (GrfTreeView.SelectedNode == null || !(GrfTreeView.SelectedNode.Tag is GameRuleFile.GameRule)) return; var grfTag = GrfTreeView.SelectedNode.Tag as GameRuleFile.GameRule; AddParameter prompt = new AddParameter(); - if (prompt.ShowDialog() == DialogResult.OK) + if (prompt.ShowDialog(this) == DialogResult.OK) { if (grfTag.Parameters.ContainsKey(prompt.ParameterName)) { - MessageBox.Show("Can't add detail that already exists.", "Error"); + MessageBox.Show(this, "Can't add detail that already exists.", "Error"); return; } grfTag.Parameters.Add(prompt.ParameterName, prompt.ParameterValue); @@ -190,7 +190,7 @@ namespace PckStudio.Forms.Editor ReloadParameterTreeView(); return; } - MessageBox.Show("No Rule selected"); + MessageBox.Show(this, "No Rule selected"); } private void GrfDetailsTreeView_KeyDown(object sender, KeyEventArgs e) @@ -205,7 +205,7 @@ namespace PckStudio.Forms.Editor GrfParametersTreeView.SelectedNode is TreeNode paramNode && paramNode.Tag is KeyValuePair param) { AddParameter prompt = new AddParameter(param.Key, param.Value, false); - if (prompt.ShowDialog() == DialogResult.OK) + if (prompt.ShowDialog(this) == DialogResult.OK) { rule.Parameters[prompt.ParameterName] = prompt.ParameterValue; ReloadParameterTreeView(); @@ -227,9 +227,9 @@ namespace PckStudio.Forms.Editor using (TextPrompt prompt = new TextPrompt()) { prompt.OKButtonText = "Add"; - if (MessageBox.Show($"Add Game Rule to {parentRule.Name}", "Attention", + if (MessageBox.Show(this, $"Add Game Rule to {parentRule.Name}", "Attention", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes && - prompt.ShowDialog() == DialogResult.OK && + prompt.ShowDialog(this) == DialogResult.OK && !string.IsNullOrWhiteSpace(prompt.NewText)) { var tag = parentRule.AddRule(prompt.NewText); @@ -264,7 +264,7 @@ namespace PckStudio.Forms.Editor { if (_file.Header.unknownData[3] != 0) { - MessageBox.Show("World grf saving is currently unsupported"); + MessageBox.Show(this, "World grf saving is currently unsupported"); return; } using (var stream = new MemoryStream()) @@ -273,12 +273,12 @@ namespace PckStudio.Forms.Editor { _pckfile?.SetData(new GameRuleFileWriter(_file)); DialogResult = DialogResult.OK; - MessageBox.Show("Saved!"); + MessageBox.Show(this, "Saved!"); } catch (Exception ex) { Console.WriteLine(ex.Message); - MessageBox.Show($"Failed to save grf file\n{ex.Message}", "Save Error", MessageBoxButtons.OK, MessageBoxIcon.Error); + MessageBox.Show(this, $"Failed to save grf file\n{ex.Message}", "Save Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } } @@ -287,7 +287,7 @@ namespace PckStudio.Forms.Editor { OpenFileDialog dialog = new OpenFileDialog(); dialog.Filter = "Game Rule File|*.grf"; - PromptForCompressionType(); + PromptForCompressionType(this); if (dialog.ShowDialog(this) == DialogResult.OK) { using (var fs = File.OpenRead(dialog.FileName)) diff --git a/PCK-Studio/Forms/Editor/LOCEditor.cs b/PCK-Studio/Forms/Editor/LOCEditor.cs index d19c067c..56d5a607 100644 --- a/PCK-Studio/Forms/Editor/LOCEditor.cs +++ b/PCK-Studio/Forms/Editor/LOCEditor.cs @@ -53,7 +53,7 @@ namespace PckStudio.Forms.Editor if (node == null || !currentLoc.LocKeys.ContainsKey(node.Text)) { - MessageBox.Show("Selected Node does not seem to be in the loc file"); + MessageBox.Show(this, "Selected Node does not seem to be in the loc file"); return; } ReloadTranslationTable(); @@ -65,7 +65,7 @@ namespace PckStudio.Forms.Editor using (TextPrompt prompt = new TextPrompt()) { prompt.OKButtonText = "Add"; - if (prompt.ShowDialog() == DialogResult.OK && + if (prompt.ShowDialog(this) == DialogResult.OK && !currentLoc.LocKeys.ContainsKey(prompt.NewText) && currentLoc.AddLocKey(prompt.NewText, "")) { @@ -87,7 +87,7 @@ namespace PckStudio.Forms.Editor if (e.ColumnIndex != 1 || treeViewLocKeys.SelectedNode == null) { - MessageBox.Show("something went wrong"); + MessageBox.Show(this, "something went wrong"); return; } currentLoc.SetLocEntry(treeViewLocKeys.SelectedNode.Text, tbl.Rows[e.RowIndex][0].ToString(), tbl.Rows[e.RowIndex][1].ToString()); @@ -136,7 +136,7 @@ namespace PckStudio.Forms.Editor { string[] avalibleLang = GetAvailableLanguages().ToArray(); using (var dialog = new AddLanguage(avalibleLang)) - if (dialog.ShowDialog() == DialogResult.OK) + if (dialog.ShowDialog(this) == DialogResult.OK) { currentLoc.AddLanguage(dialog.SelectedLanguage); ReloadTranslationTable(); diff --git a/PCK-Studio/Forms/Editor/MaterialsEditor.cs b/PCK-Studio/Forms/Editor/MaterialsEditor.cs index 614487e1..90af5a71 100644 --- a/PCK-Studio/Forms/Editor/MaterialsEditor.cs +++ b/PCK-Studio/Forms/Editor/MaterialsEditor.cs @@ -152,7 +152,7 @@ namespace PckStudio.Forms.Editor { var diag = new Additional_Popups.EntityForms.AddEntry("materials", ApplicationScope.EntityImages); - if (diag.ShowDialog() == DialogResult.OK) + if (diag.ShowDialog(this) == DialogResult.OK) { if (string.IsNullOrEmpty(diag.SelectedEntity)) return; if (materialFile.FindAll(mat => mat.Name == diag.SelectedEntity).Count() > 0) diff --git a/PCK-Studio/Forms/Editor/TextureAtlasEditor.cs b/PCK-Studio/Forms/Editor/TextureAtlasEditor.cs index 2f93d182..335aee53 100644 --- a/PCK-Studio/Forms/Editor/TextureAtlasEditor.cs +++ b/PCK-Studio/Forms/Editor/TextureAtlasEditor.cs @@ -513,7 +513,7 @@ namespace PckStudio.Forms.Editor Title = "Select Texture" }; - if (fileDialog.ShowDialog() == DialogResult.OK) + if (fileDialog.ShowDialog(this) == DialogResult.OK) { var img = Image.FromFile(fileDialog.FileName); SetTile(img); @@ -535,7 +535,7 @@ namespace PckStudio.Forms.Editor var animation = AnimationHelper.GetAnimationFromFile(file); var animationEditor = new AnimationEditor(animation, _selectedTile.Tile.InternalName, GetBlendColor()); - if (animationEditor.ShowDialog() != DialogResult.OK) + if (animationEditor.ShowDialog(this) != DialogResult.OK) { return; } @@ -552,7 +552,7 @@ namespace PckStudio.Forms.Editor Filter = "Tile Texture|*.png", FileName = _selectedTile.Tile.InternalName }; - if (saveFileDialog.ShowDialog() == DialogResult.OK) + if (saveFileDialog.ShowDialog(this) == DialogResult.OK) { dataTile.Texture.Save(saveFileDialog.FileName, ImageFormat.Png); } @@ -614,7 +614,7 @@ namespace PckStudio.Forms.Editor 0x211d1d // Black }; - if (colorPick.ShowDialog() != DialogResult.OK) return; + if (colorPick.ShowDialog(this) != DialogResult.OK) return; selectTilePictureBox.BlendColor = colorPick.Color; selectTilePictureBox.Image = dataTile.Texture; diff --git a/PCK-Studio/Forms/Skins-And-Textures/AddNewSkin.cs b/PCK-Studio/Forms/Skins-And-Textures/AddNewSkin.cs index bae14ad6..e0f20da2 100644 --- a/PCK-Studio/Forms/Skins-And-Textures/AddNewSkin.cs +++ b/PCK-Studio/Forms/Skins-And-Textures/AddNewSkin.cs @@ -51,19 +51,19 @@ namespace PckStudio.Popups { case 64: anim.SetFlag(SkinAnimFlag.RESOLUTION_64x64, true); - MessageBox.Show("64x64 Skin Detected"); + MessageBox.Show(this, "64x64 Skin Detected"); skinType = eSkinType._64x64; break; case 32: anim.SetFlag(SkinAnimFlag.RESOLUTION_64x64 | SkinAnimFlag.SLIM_MODEL, false); - MessageBox.Show("64x32 Skin Detected"); + MessageBox.Show(this, "64x32 Skin Detected"); skinType = eSkinType._64x32; break; default: if (img.Width == img.Height) { anim.SetFlag(SkinAnimFlag.RESOLUTION_64x64, true); - MessageBox.Show("64x64 HD Skin Detected"); + MessageBox.Show(this, "64x64 HD Skin Detected"); skinType = eSkinType._64x64HD; break; } @@ -71,12 +71,12 @@ namespace PckStudio.Popups if (img.Height == img.Width / 2) { anim.SetFlag(SkinAnimFlag.RESOLUTION_64x64 | SkinAnimFlag.SLIM_MODEL, false); - MessageBox.Show("64x32 HD Skin Detected"); + MessageBox.Show(this, "64x32 HD Skin Detected"); skinType = eSkinType._64x32HD; break; } - MessageBox.Show("Not a Valid Skin File"); + MessageBox.Show(this, "Not a Valid Skin File"); skinType = eSkinType.Invalid; return; } @@ -145,12 +145,12 @@ namespace PckStudio.Popups private void buttonSkin_Click(object sender, EventArgs e) { - contextMenuSkin.Show(Location.X + buttonSkin.Location.X + 2, Location.Y + buttonSkin.Location.Y + buttonSkin.Size.Height); + contextMenuSkin.Show(this, Location.X + buttonSkin.Location.X + 2, Location.Y + buttonSkin.Location.Y + buttonSkin.Size.Height); } private void buttonCape_Click(object sender, EventArgs e) { - contextMenuCape.Show(Location.X + buttonCape.Location.X + 2, Location.Y + buttonCape.Location.Y + buttonCape.Size.Height); + contextMenuCape.Show(this, Location.X + buttonCape.Location.X + 2, Location.Y + buttonCape.Location.Y + buttonCape.Size.Height); } private void replaceToolStripMenuItem_Click(object sender, EventArgs e) @@ -170,6 +170,7 @@ namespace PckStudio.Popups if (e.Button == MouseButtons.Right) { contextMenuSkin.Show( + this, x: Location.X + skinPictureBox.Location.X, y: Location.Y + skinPictureBox.Location.Y + skinPictureBox.Size.Height ); @@ -205,6 +206,7 @@ namespace PckStudio.Popups if (e.Button == MouseButtons.Right) { contextMenuCape.Show( + this, x: Location.X + capePictureBox.Location.X, y: Location.Y + capePictureBox.Location.Y + capePictureBox.Size.Height ); @@ -220,7 +222,7 @@ namespace PckStudio.Popups var img = Image.FromFile(ofd.FileName); if (img.RawFormat != ImageFormat.Png && img.Width != img.Height * 2) { - MessageBox.Show("Not a Valid Cape File"); + MessageBox.Show(this, "Not a Valid Cape File"); return; } capePictureBox.Image = Image.FromFile(ofd.FileName); @@ -237,7 +239,7 @@ namespace PckStudio.Popups { if (!int.TryParse(textSkinID.Text, out int _skinId)) { - MessageBox.Show("The Skin ID Must be a Unique 8 Digit Number Thats Not Already in Use", "Invalid Skin ID", MessageBoxButtons.OK, MessageBoxIcon.Error); + MessageBox.Show(this, "The Skin ID Must be a Unique 8 Digit Number Thats Not Already in Use", "Invalid Skin ID", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } string skinId = _skinId.ToString("d08"); @@ -283,7 +285,7 @@ namespace PckStudio.Popups private void CreateCustomModel_Click(object sender, EventArgs e) { //Prompt for skin model generator - if (MessageBox.Show("Create your own custom skin model?", "", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1) != DialogResult.Yes) + if (MessageBox.Show(this, "Create your own custom skin model?", "", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1) != DialogResult.Yes) return; skin.SetData(Resources.classic_template, ImageFormat.Png); diff --git a/PCK-Studio/Forms/Skins-And-Textures/AdvancedOptions.cs b/PCK-Studio/Forms/Skins-And-Textures/AdvancedOptions.cs index e536a96f..19d39a3f 100644 --- a/PCK-Studio/Forms/Skins-And-Textures/AdvancedOptions.cs +++ b/PCK-Studio/Forms/Skins-And-Textures/AdvancedOptions.cs @@ -41,7 +41,7 @@ namespace PckStudio.Popups DialogResult = DialogResult.OK; return; } - MessageBox.Show("Please select a filetype before applying"); + MessageBox.Show(this, "Please select a filetype before applying"); } private void applyBulkProperties(IReadOnlyCollection files, int index) @@ -73,10 +73,10 @@ namespace PckStudio.Popups if (Enum.IsDefined(typeof(PckFileType), index)) { - MessageBox.Show($"Data added to {(PckFileType)index} entries"); + MessageBox.Show(this, $"Data added to {(PckFileType)index} entries"); return; } - MessageBox.Show("Data added to all entries"); + MessageBox.Show(this, "Data added to all entries"); } private void treeMeta_AfterSelect(object sender, TreeViewEventArgs e) diff --git a/PCK-Studio/Forms/Skins-And-Textures/generateModel.cs b/PCK-Studio/Forms/Skins-And-Textures/generateModel.cs index 9171edf1..82df00a6 100644 --- a/PCK-Studio/Forms/Skins-And-Textures/generateModel.cs +++ b/PCK-Studio/Forms/Skins-And-Textures/generateModel.cs @@ -1052,7 +1052,7 @@ namespace PckStudio.Forms Bitmap bitmap = new Bitmap(uvPictureBox.Image, 64, 64); using SaveFileDialog saveFileDialog = new SaveFileDialog(); saveFileDialog.Filter = "PNG Image Files | *.png"; - if (saveFileDialog.ShowDialog() == DialogResult.OK) + if (saveFileDialog.ShowDialog(this) == DialogResult.OK) { bitmap.Save(saveFileDialog.FileName, ImageFormat.Png); } @@ -1066,7 +1066,7 @@ namespace PckStudio.Forms openFileDialog.Filter = "PNG Image Files | *.png"; openFileDialog.Title = "Select Skin Texture"; - if (openFileDialog.ShowDialog() == DialogResult.OK) // skins can only be a 1:1 ratio (base 64x64) or a 2:1 ratio (base 64x32) + if (openFileDialog.ShowDialog(this) == DialogResult.OK) // skins can only be a 1:1 ratio (base 64x64) or a 2:1 ratio (base 64x32) { using (var img = Image.FromFile(openFileDialog.FileName)) { @@ -1117,7 +1117,7 @@ namespace PckStudio.Forms private void listView1_DoubleClick(object sender, EventArgs e) { ColorDialog colorDialog = new ColorDialog(); - if (colorDialog.ShowDialog() == DialogResult.OK) + if (colorDialog.ShowDialog(this) == DialogResult.OK) listViewBoxes.SelectedItems[0].ForeColor = colorDialog.Color; Rerender(); } @@ -1175,7 +1175,7 @@ namespace PckStudio.Forms { SaveFileDialog saveFileDialog = new SaveFileDialog(); saveFileDialog.Filter = "Custom Skin Model File | *.CSM"; - if (saveFileDialog.ShowDialog() != DialogResult.OK) + if (saveFileDialog.ShowDialog(this) != DialogResult.OK) return; string contents = ""; foreach (ListViewItem listViewItem in listViewBoxes.Items) @@ -1199,7 +1199,7 @@ namespace PckStudio.Forms OpenFileDialog openFileDialog = new OpenFileDialog(); openFileDialog.Filter = "Custom Skin Model File | *.CSM"; openFileDialog.Title = "Select Custom Skin Model File"; - if (MessageBox.Show("Import custom model project file? Your current work will be lost!", "", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1) == DialogResult.Yes && openFileDialog.ShowDialog() == DialogResult.OK) + if (MessageBox.Show(this, "Import custom model project file? Your current work will be lost!", "", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1) == DialogResult.Yes && openFileDialog.ShowDialog(this) == DialogResult.OK) { listViewBoxes.Items.Clear(); modelBoxes.Clear(); @@ -1246,7 +1246,7 @@ namespace PckStudio.Forms catch (Exception ex) { Console.WriteLine(ex.Message); - MessageBox.Show("Please Select a Part"); + MessageBox.Show(this, "Please Select a Part"); } } @@ -1261,7 +1261,7 @@ namespace PckStudio.Forms private void changeColorToolStripMenuItem_Click(object sender, EventArgs e) { ColorDialog colorDialog = new ColorDialog(); - if (colorDialog.ShowDialog() == DialogResult.OK) + if (colorDialog.ShowDialog(this) == DialogResult.OK) listViewBoxes.SelectedItems[0].ForeColor = colorDialog.Color; Rerender(); } @@ -1368,7 +1368,7 @@ namespace PckStudio.Forms OpenFileDialog openFileDialog = new OpenFileDialog(); openFileDialog.Filter = "JSON Model File | *.JSON"; openFileDialog.Title = "Select JSON Model File"; - if (MessageBox.Show("Import custom model project file? Your current work will be lost!", "", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1) == DialogResult.Yes && openFileDialog.ShowDialog() == DialogResult.OK) + if (MessageBox.Show(this, "Import custom model project file? Your current work will be lost!", "", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1) == DialogResult.Yes && openFileDialog.ShowDialog(this) == DialogResult.OK) { listViewBoxes.Items.Clear(); string str1 = JSONToCSM(openFileDialog.FileName); diff --git a/PCK-Studio/MainForm.cs b/PCK-Studio/MainForm.cs index 51aec16e..602c1b01 100644 --- a/PCK-Studio/MainForm.cs +++ b/PCK-Studio/MainForm.cs @@ -126,7 +126,7 @@ namespace PckStudio } catch (OverflowException ex) { - MessageBox.Show("Failed to open pck\n" + + MessageBox.Show(this, "Failed to open pck\n" + "Try checking the 'Open/Save as Switch/Vita/PS4 pck' checkbox in the upper right corner.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); Debug.WriteLine(ex.Message); @@ -150,7 +150,7 @@ namespace PckStudio currentPCK = openPck(filepath); if (currentPCK == null) { - MessageBox.Show(string.Format("Failed to load {0}", Path.GetFileName(filepath)), "Error"); + MessageBox.Show(this, string.Format("Failed to load {0}", Path.GetFileName(filepath)), "Error"); return; } @@ -254,7 +254,7 @@ namespace PckStudio { ofd.CheckFileExists = true; ofd.Filter = "PCK (Minecraft Console Package)|*.pck"; - if (ofd.ShowDialog() == DialogResult.OK) + if (ofd.ShowDialog(this) == DialogResult.OK) { LoadPckFromFile(ofd.FileName); } @@ -274,14 +274,14 @@ namespace PckStudio } catch (OverflowException ex) { - MessageBox.Show("Failed to open pck\n" + + MessageBox.Show(this, "Failed to open pck\n" + $"Try {(LittleEndianCheckBox.Checked ? "unchecking" : "checking")} the 'Open/Save as Switch/Vita/PS4 pck' check box in the upper right corner.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); Debug.WriteLine(ex.Message); } catch { - MessageBox.Show("Failed to open pck. There's two common reasons for this:\n" + + MessageBox.Show(this, "Failed to open pck. There's two common reasons for this:\n" + "1. The file is audio/music cues PCK file. Please use the specialized editor while inside of a pck file.\n" + "2. We're aware of an issue where a pck file might fail to load because it contains multiple entries with the same path.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); @@ -481,7 +481,7 @@ namespace PckStudio } var viewer = new TextureAtlasEditor(currentPCK, file.Filename, img, tile_size); - if (viewer.ShowDialog() == DialogResult.OK) + if (viewer.ShowDialog(this) == DialogResult.OK) { Image texture = viewer.FinalTexture; if(isBanners) @@ -557,7 +557,7 @@ namespace PckStudio if (file.HasProperty("BOX")) { using generateModel generate = new generateModel(file); - if (generate.ShowDialog() == DialogResult.OK) + if (generate.ShowDialog(this) == DialogResult.OK) { entryDataTextBox.Text = entryTypeTextBox.Text = string.Empty; wasModified = true; @@ -573,7 +573,7 @@ namespace PckStudio public void HandleModelsFile(PckFileData file) { - MessageBox.Show("Models.bin support has not been implemented. You can use the Spark Editor for the time being to edit these files.", "Not implemented yet."); + MessageBox.Show(this, "Models.bin support has not been implemented. You can use the Spark Editor for the time being to edit these files.", "Not implemented yet."); } public void HandleBehavioursFile(PckFileData file) @@ -752,7 +752,7 @@ namespace PckStudio using SaveFileDialog exFile = new SaveFileDialog(); exFile.FileName = Path.GetFileName(file.Filename); exFile.Filter = Path.GetExtension(file.Filename).Replace(".", string.Empty) + " File|*" + Path.GetExtension(file.Filename); - if (exFile.ShowDialog() != DialogResult.OK || + if (exFile.ShowDialog(this) != DialogResult.OK || // Makes sure chosen directory isn't null or whitespace AKA makes sure its usable string.IsNullOrWhiteSpace(Path.GetDirectoryName(exFile.FileName))) { @@ -765,7 +765,7 @@ namespace PckStudio } // Verification that file extraction path was successful - MessageBox.Show($"\"{node.Text}\" successfully extracted"); + MessageBox.Show(this, $"\"{node.Text}\" successfully extracted"); } private void SaveTemplate() @@ -773,7 +773,7 @@ namespace PckStudio using SaveFileDialog saveFileDialog = new SaveFileDialog(); saveFileDialog.Filter = "PCK (Minecraft Console Package)|*.pck"; saveFileDialog.DefaultExt = ".pck"; - if (saveFileDialog.ShowDialog() == DialogResult.OK) + if (saveFileDialog.ShowDialog(this) == DialogResult.OK) { Save(saveFileDialog.FileName); saveLocation = saveFileDialog.FileName; @@ -788,7 +788,7 @@ namespace PckStudio var writer = new PckFileWriter(currentPCK, LittleEndianCheckBox.Checked ? OMI.Endianness.LittleEndian : OMI.Endianness.BigEndian); writer.WriteToFile(filePath); wasModified = false; - MessageBox.Show("Saved Pck file", "File Saved"); + MessageBox.Show(this, "Saved Pck file", "File Saved"); } private void replaceToolStripMenuItem_Click(object sender, EventArgs e) @@ -811,7 +811,7 @@ namespace PckStudio string fileExt = Path.GetExtension(file.Filename); ofd.Filter = $"{file.Filetype} (*{fileExt}{extra_extensions})|*{fileExt}{extra_extensions}"; - if (ofd.ShowDialog() == DialogResult.OK) + if (ofd.ShowDialog(this) == DialogResult.OK) { string newFileExt = Path.GetExtension(ofd.FileName); file.SetData(File.ReadAllBytes(ofd.FileName)); @@ -822,7 +822,7 @@ namespace PckStudio } return; } - MessageBox.Show("Can't replace a folder."); + MessageBox.Show(this, "Can't replace a folder."); } /// @@ -838,7 +838,7 @@ namespace PckStudio if (file.Filetype == PckFileType.TextureFile && (file.Filename == itemPath + "compass.png" || file.Filename == itemPath + "clock.png")) { - if (MessageBox.Show("Are you sure want to delete this file? If \"compass.png\" or \"clock.png\" are missing, your game will crash upon loading this pack.", "Warning", + if (MessageBox.Show(this, "Are you sure want to delete this file? If \"compass.png\" or \"clock.png\" are missing, your game will crash upon loading this pack.", "Warning", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.No) return true; } @@ -874,7 +874,7 @@ namespace PckStudio wasModified = true; } } - else if (MessageBox.Show("Are you sure want to delete this folder? All contents will be deleted", "Warning", + else if (MessageBox.Show(this, "Are you sure want to delete this folder? All contents will be deleted", "Warning", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes) { string pckFolderDir = node.FullPath; @@ -899,7 +899,7 @@ namespace PckStudio { if (currentPCK.TryGetFile(diag.NewText, file.Filetype, out _)) { - MessageBox.Show($"{diag.NewText} already exists", "File already exists"); + MessageBox.Show(this, $"{diag.NewText} already exists", "File already exists"); return; } file.Filename = diag.NewText; @@ -927,7 +927,7 @@ namespace PckStudio LOCFile locFile = null; TryGetLocFile(out locFile); using AddNewSkin add = new AddNewSkin(locFile); - if (add.ShowDialog() == DialogResult.OK) + if (add.ShowDialog(this) == DialogResult.OK) { if (currentPCK.HasFile("Skins.pck", PckFileType.SkinDataFile)) // Prioritize Skins.pck { @@ -987,12 +987,12 @@ namespace PckStudio if (currentPCK.Contains(PckFileType.AudioFile)) { // the chance of this happening is really really slim but just in case - MessageBox.Show("There is already an audio file in this PCK!", "Can't create audio.pck"); + MessageBox.Show(this, "There is already an audio file in this PCK!", "Can't create audio.pck"); return; } if (string.IsNullOrEmpty(saveLocation)) { - MessageBox.Show("You must save your pck before creating or opening a music cues PCK file", "Can't create audio.pck"); + MessageBox.Show(this, "You must save your pck before creating or opening a music cues PCK file", "Can't create audio.pck"); return; } @@ -1014,7 +1014,7 @@ namespace PckStudio if (currentPCK.Contains($"res/textures/{Animation.GetCategoryName(diag.Category)}/{diag.SelectedTile}.png", PckFileType.TextureFile)) { - MessageBox.Show($"{diag.SelectedTile} is already present.", "File already present"); + MessageBox.Show(this, $"{diag.SelectedTile} is already present.", "File already present"); return; } @@ -1025,7 +1025,7 @@ namespace PckStudio Animation animation = AnimationHelper.GetAnimationFromFile(file); using AnimationEditor animationEditor = new AnimationEditor(animation, diag.SelectedTile); - if (animationEditor.ShowDialog() == DialogResult.OK) + if (animationEditor.ShowDialog(this) == DialogResult.OK) { wasModified = true; AnimationHelper.SaveAnimationToFile(file, animation); @@ -1193,7 +1193,7 @@ namespace PckStudio { Debug.WriteLine(ex.Message); Trace.WriteLine("Invalid ANIM value: " + property.Value); - MessageBox.Show("Failed to parse ANIM value, aborting to normal functionality. Please make sure the value only includes hexadecimal characters (0-9,A-F) and has no more than 8 characters."); + MessageBox.Show(this, "Failed to parse ANIM value, aborting to normal functionality. Please make sure the value only includes hexadecimal characters (0-9,A-F) and has no more than 8 characters."); } break; @@ -1214,7 +1214,7 @@ namespace PckStudio { Debug.WriteLine(ex.Message); Trace.WriteLine("Invalid BOX value: " + property.Value); - MessageBox.Show("Failed to parse BOX value, aborting to normal functionality."); + MessageBox.Show(this, "Failed to parse BOX value, aborting to normal functionality."); } break; @@ -1225,7 +1225,7 @@ namespace PckStudio using (AddPropertyPrompt addProperty = new AddPropertyPrompt(property)) { - if (addProperty.ShowDialog() == DialogResult.OK) + if (addProperty.ShowDialog(this) == DialogResult.OK) { file.SetProperty(file.GetPropertyIndex(property), addProperty.Property); RebuildSubPCK(treeViewMain.SelectedNode.FullPath); @@ -1317,7 +1317,7 @@ namespace PckStudio t.Tag is PckFileData file) { using AddPropertyPrompt addProperty = new AddPropertyPrompt(); - if (addProperty.ShowDialog() == DialogResult.OK) + if (addProperty.ShowDialog(this) == DialogResult.OK) { file.AddProperty(addProperty.Property); RebuildSubPCK(treeViewMain.SelectedNode.FullPath); @@ -1429,7 +1429,7 @@ namespace PckStudio checkSaveState(); TextPrompt namePrompt = new TextPrompt(); namePrompt.OKButtonText = "Ok"; - if (namePrompt.ShowDialog() == DialogResult.OK) + if (namePrompt.ShowDialog(this) == DialogResult.OK) { currentPCK = InitializePack(new Random().Next(8000, int.MaxValue), 0, namePrompt.NewText, true); isTemplateFile = true; @@ -1442,7 +1442,7 @@ namespace PckStudio { checkSaveState(); CreateTexturePackPrompt packPrompt = new CreateTexturePackPrompt(); - if (packPrompt.ShowDialog() == DialogResult.OK) + if (packPrompt.ShowDialog(this) == DialogResult.OK) { currentPCK = InitializeTexturePack(new Random().Next(8000, int.MaxValue), 0, packPrompt.PackName, packPrompt.PackRes, packPrompt.CreateSkinsPck); isTemplateFile = true; @@ -1455,7 +1455,7 @@ namespace PckStudio { checkSaveState(); CreateTexturePackPrompt packPrompt = new CreateTexturePackPrompt(); - if (packPrompt.ShowDialog() == DialogResult.OK) + if (packPrompt.ShowDialog(this) == DialogResult.OK) { currentPCK = InitializeMashUpPack(new Random().Next(8000, int.MaxValue), 0, packPrompt.PackName, packPrompt.PackRes); isTemplateFile = true; @@ -1468,7 +1468,7 @@ namespace PckStudio { using AdvancedOptions advanced = new AdvancedOptions(currentPCK); advanced.IsLittleEndian = LittleEndianCheckBox.Checked; - if (advanced.ShowDialog() == DialogResult.OK) + if (advanced.ShowDialog(this) == DialogResult.OK) { wasModified = true; BuildMainTreeView(); @@ -1484,7 +1484,7 @@ namespace PckStudio private void aboutToolStripMenuItem_Click(object sender, EventArgs e) { using CreditsForm info = new CreditsForm(); - info.ShowDialog(); + info.ShowDialog(this); } private void treeViewMain_KeyDown(object sender, KeyEventArgs e) @@ -1522,7 +1522,7 @@ namespace PckStudio { if (!HasDataFolder()) { - DialogResult result = MessageBox.Show("There is not a \"Data\" folder present in the pack folder. Would you like to create one?", "Folder missing", MessageBoxButtons.YesNo); + DialogResult result = MessageBox.Show(this, "There is not a \"Data\" folder present in the pack folder. Would you like to create one?", "Folder missing", MessageBoxButtons.YesNo); if (result == DialogResult.No) return false; else Directory.CreateDirectory(GetDataPath()); } @@ -1538,7 +1538,7 @@ namespace PckStudio private void importExtractedSkinsFolder(object sender, EventArgs e) { using FolderBrowserDialog contents = new FolderBrowserDialog(); - if (contents.ShowDialog() == DialogResult.OK && Directory.Exists(contents.SelectedPath)) + if (contents.ShowDialog(this) == DialogResult.OK && Directory.Exists(contents.SelectedPath)) { string filepath = treeViewMain.SelectedNode?.FullPath ?? ""; if (treeViewMain.SelectedNode is not null && treeViewMain.SelectedNode.IsTagOfType()) @@ -1635,7 +1635,7 @@ namespace PckStudio contents.Title = "Select Extracted Skin File"; contents.Filter = "Skin File (*.png)|*.png"; - if (contents.ShowDialog() == DialogResult.OK) + if (contents.ShowDialog(this) == DialogResult.OK) { string skinNameImport = Path.GetFileName(contents.FileName); byte[] data = File.ReadAllBytes(contents.FileName); @@ -1676,7 +1676,7 @@ namespace PckStudio } catch (Exception ex) { - MessageBox.Show(ex.Message); + MessageBox.Show(this, ex.Message); } } } @@ -1688,7 +1688,7 @@ namespace PckStudio TextPrompt folderNamePrompt = new TextPrompt(); if (treeViewMain.SelectedNode is not null) folderNamePrompt.contextLabel.Text = $"New folder at the location of \"{treeViewMain.SelectedNode.FullPath}\""; folderNamePrompt.OKButtonText = "Add"; - if (folderNamePrompt.ShowDialog() == DialogResult.OK) + if (folderNamePrompt.ShowDialog(this) == DialogResult.OK) { TreeNode folerNode = CreateNode(folderNamePrompt.NewText); folerNode.ImageIndex = 0; @@ -1781,7 +1781,7 @@ namespace PckStudio { if (currentPCK is not null && wasModified && - MessageBox.Show("Save PCK?", "Unsaved PCK", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes) + MessageBox.Show(this, "Save PCK?", "Unsaved PCK", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes) { if (isTemplateFile || string.IsNullOrEmpty(saveLocation)) { @@ -1809,7 +1809,7 @@ namespace PckStudio { string[] Filepaths = (string[])e.Data.GetData(DataFormats.FileDrop, false); if (Filepaths.Length > 1) - MessageBox.Show("Only one pck file at a time is currently supported"); + MessageBox.Show(this, "Only one pck file at a time is currently supported"); LoadPckFromFile(Filepaths[0]); } @@ -1920,15 +1920,15 @@ namespace PckStudio { using OpenFileDialog fileDialog = new OpenFileDialog(); fileDialog.Filter = "Texture File(*.png,*.tga)|*.png;*.tga"; - if (fileDialog.ShowDialog() == DialogResult.OK) + if (fileDialog.ShowDialog(this) == DialogResult.OK) { using TextPrompt renamePrompt = new TextPrompt(Path.GetFileName(fileDialog.FileName)); renamePrompt.LabelText = "Path"; - if (renamePrompt.ShowDialog() == DialogResult.OK && !string.IsNullOrEmpty(renamePrompt.NewText)) + if (renamePrompt.ShowDialog(this) == DialogResult.OK && !string.IsNullOrEmpty(renamePrompt.NewText)) { if (currentPCK.Contains(renamePrompt.NewText, PckFileType.TextureFile)) { - MessageBox.Show($"'{renamePrompt.NewText}' already exists.", "Import failed", MessageBoxButtons.OK, MessageBoxIcon.Warning); + MessageBox.Show(this, $"'{renamePrompt.NewText}' already exists.", "Import failed", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } PckFileData file = currentPCK.CreateNewFile(renamePrompt.NewText, PckFileType.TextureFile, () => File.ReadAllBytes(fileDialog.FileName)); @@ -1942,7 +1942,7 @@ namespace PckStudio { if (treeViewMain.SelectedNode.Tag is PckFileData file) { - MessageBox.Show( + MessageBox.Show(this, "File path: " + file.Filename + "\nAssigned File type: " + (int)file.Filetype + " (" + file.Filetype + ")" + "\nFile size: " + file.Size + @@ -2008,7 +2008,7 @@ namespace PckStudio { if (currentPCK.TryGetFile("colours.col", PckFileType.ColourTableFile, out _)) { - MessageBox.Show("A color table file already exists in this PCK and a new one cannot be created.", "Operation aborted"); + MessageBox.Show(this, "A color table file already exists in this PCK and a new one cannot be created.", "Operation aborted"); return; } PckFileData newColorFile = currentPCK.CreateNewFile("colours.col", PckFileType.ColourTableFile); @@ -2029,11 +2029,11 @@ namespace PckStudio SaveFileDialog saveFileDialog = new SaveFileDialog(); saveFileDialog.Filter = "3DS Texture|*.3dst"; saveFileDialog.DefaultExt = ".3dst"; - if (saveFileDialog.ShowDialog() == DialogResult.OK) + if (saveFileDialog.ShowDialog(this) == DialogResult.OK) { Image img = file.GetTexture(); var writer = new _3DSTextureWriter(img); - writer.WriteToFile(saveFileDialog.FileName); + writer.WriteToFile(saveFileDialog.FileName); } } } @@ -2081,7 +2081,7 @@ namespace PckStudio { if (currentPCK.TryGetFile("Skins.pck", PckFileType.SkinDataFile, out _)) { - MessageBox.Show("A Skins.pck file already exists in this PCK and a new one cannot be created.", "Operation aborted"); + MessageBox.Show(this, "A Skins.pck file already exists in this PCK and a new one cannot be created.", "Operation aborted"); return; } @@ -2130,14 +2130,14 @@ namespace PckStudio ofd.Filter = "All files (*.*)|*.*"; ofd.Multiselect = false; - if (ofd.ShowDialog() == DialogResult.OK) + if (ofd.ShowDialog(this) == DialogResult.OK) { using AddFilePrompt diag = new AddFilePrompt("res/" + Path.GetFileName(ofd.FileName)); if (diag.ShowDialog(this) == DialogResult.OK) { if (currentPCK.Contains(diag.Filepath, diag.Filetype)) { - MessageBox.Show($"'{diag.Filepath}' of type {diag.Filetype} already exists.", "Import failed", MessageBoxButtons.OK, MessageBoxIcon.Warning); + MessageBox.Show(this, $"'{diag.Filepath}' of type {diag.Filetype} already exists.", "Import failed", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } PckFileData file = currentPCK.CreateNewFile(diag.Filepath, diag.Filetype, () => File.ReadAllBytes(ofd.FileName)); @@ -2155,7 +2155,7 @@ namespace PckStudio { if (currentPCK.TryGetFile("behaviours.bin", PckFileType.BehavioursFile, out _)) { - MessageBox.Show("A behaviours file already exists in this PCK and a new one cannot be created.", "Operation aborted"); + MessageBox.Show(this, "A behaviours file already exists in this PCK and a new one cannot be created.", "Operation aborted"); return; } @@ -2167,7 +2167,7 @@ namespace PckStudio { if (currentPCK.TryGetFile("entityMaterials.bin", PckFileType.MaterialFile, out _)) { - MessageBox.Show("A behaviours file already exists in this PCK and a new one cannot be created.", "Operation aborted"); + MessageBox.Show(this, "A behaviours file already exists in this PCK and a new one cannot be created.", "Operation aborted"); return; } currentPCK.CreateNewFile("entityMaterials.bin", PckFileType.MaterialFile, MaterialResources.MaterialsFileInitializer); @@ -2189,7 +2189,7 @@ namespace PckStudio }; if (!PckManager.Visible) { - PckManager.Show(); + PckManager.Show(this); PckManager.BringToFront(); } if (PckManager.Focus()) @@ -2204,7 +2204,7 @@ namespace PckStudio Filter = "WAV files (*.wav)|*.wav", Title = "Please choose WAV files to convert to BINKA" }; - if (fileDialog.ShowDialog() == DialogResult.OK) + if (fileDialog.ShowDialog(this) == DialogResult.OK) { using ItemSelectionPopUp dialog = new ItemSelectionPopUp( "Level 1 (Best Quality)", "Level 2", "Level 3", "Level 4", "Level 5", @@ -2214,7 +2214,7 @@ namespace PckStudio ButtonText = "OK" }; - if(dialog.ShowDialog() == DialogResult.OK) + if(dialog.ShowDialog(this) == DialogResult.OK) { BinkaConverter.ToBinka( fileDialog.FileNames, @@ -2233,7 +2233,7 @@ namespace PckStudio Filter = "BINKA files (*.binka)|*.binka", Title = "Please choose BINKA files to convert to WAV" }; - if (fileDialog.ShowDialog() == DialogResult.OK) + if (fileDialog.ShowDialog(this) == DialogResult.OK) { BinkaConverter.ToWav(fileDialog.FileNames, new DirectoryInfo(Path.GetDirectoryName(fileDialog.FileName))); } @@ -2289,7 +2289,7 @@ namespace PckStudio Program.UpdateToLatest("Would you like to download it?", MessageBoxButtons.YesNo, MessageBoxIcon.Question, DialogResult.Yes); return; } - MessageBox.Show("Already up to date.", "No update available"); + MessageBox.Show(this, "Already up to date.", "No update available"); } [Obsolete] // the move functions are to eventually be removed in favor of drag and drop @@ -2337,7 +2337,7 @@ namespace PckStudio } catch(Exception ex) { - MessageBox.Show("Can't move file under or above a folder"); + MessageBox.Show(this, "Can't move file under or above a folder"); } } [Obsolete] diff --git a/PCK-Studio/Program.cs b/PCK-Studio/Program.cs index 9b5ee113..af587263 100644 --- a/PCK-Studio/Program.cs +++ b/PCK-Studio/Program.cs @@ -58,6 +58,7 @@ namespace PckStudio { bool updateAvailable = Updater.IsUpdateAvailable(Application.ProductVersion); if (updateAvailable && MessageBox.Show( + MainInstance ?? null, "New update available.\n" + message, "Update Available",