From d800339e215f1bb71d649ee429874860291cd7ca Mon Sep 17 00:00:00 2001 From: miku-666 <74728189+NessieHax@users.noreply.github.com> Date: Tue, 1 Aug 2023 17:24:03 +0200 Subject: [PATCH 1/8] MainForm.cs - File Type Handlers now no longer have to check if data is available --- PCK-Studio/MainForm.cs | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/PCK-Studio/MainForm.cs b/PCK-Studio/MainForm.cs index bab6b3c1..335c9194 100644 --- a/PCK-Studio/MainForm.cs +++ b/PCK-Studio/MainForm.cs @@ -407,20 +407,12 @@ namespace PckStudio private void HandleColourFile(PckFile.FileData file) { - if (file.Size == 0) - { - MessageBox.Show("No Color data found.", "Error", MessageBoxButtons.OK, - MessageBoxIcon.Error); - return; - } using COLEditor diag = new COLEditor(file); wasModified = diag.ShowDialog(this) == DialogResult.OK; } public void HandleSkinFile(PckFile.FileData file) { - if (file.Size <= 0) - return; using (var ms = new MemoryStream(file.Data)) { var texture = Image.FromStream(ms); @@ -965,6 +957,11 @@ namespace PckStudio { if (treeViewMain.SelectedNode is TreeNode t && t.Tag is PckFile.FileData file) { + if (file.Size <= 0) + { + Debug.WriteLine($"'{file.Filename}' has no data attached.", category: nameof(HandleTextureFile)); + return; + } pckFileTypeHandler[file.Filetype]?.Invoke(file); } } From dbdb43e32e59105c3356990647606afb6f7b6102 Mon Sep 17 00:00:00 2001 From: miku-666 <74728189+NessieHax@users.noreply.github.com> Date: Wed, 2 Aug 2023 13:12:13 +0200 Subject: [PATCH 2/8] Updated AdvancedOptions.cs --- .../AdvancedOptions.Designer.cs | 217 +++++++++--------- .../Skins-And-Textures/AdvancedOptions.cs | 130 ++++------- .../Skins-And-Textures/AdvancedOptions.resx | 107 +++++---- PCK-Studio/MainForm.cs | 2 +- 4 files changed, 215 insertions(+), 241 deletions(-) diff --git a/PCK-Studio/Forms/Skins-And-Textures/AdvancedOptions.Designer.cs b/PCK-Studio/Forms/Skins-And-Textures/AdvancedOptions.Designer.cs index 6d02ad80..0a943689 100644 --- a/PCK-Studio/Forms/Skins-And-Textures/AdvancedOptions.Designer.cs +++ b/PCK-Studio/Forms/Skins-And-Textures/AdvancedOptions.Designer.cs @@ -29,51 +29,57 @@ private void InitializeComponent() { System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(AdvancedOptions)); - this.treeMeta = new System.Windows.Forms.TreeView(); - this.comboBox1 = new MetroFramework.Controls.MetroComboBox(); - this.label1 = new System.Windows.Forms.Label(); + System.Windows.Forms.Label label1; + System.Windows.Forms.Label label2; + System.Windows.Forms.Label label3; + this.propertyTreeview = new System.Windows.Forms.TreeView(); + this.fileTypeComboBox = new MetroFramework.Controls.MetroComboBox(); this.applyButton = new MetroFramework.Controls.MetroButton(); - this.label2 = new System.Windows.Forms.Label(); - this.label3 = new System.Windows.Forms.Label(); - this.entryDataTextBox = new MetroFramework.Controls.MetroTextBox(); - this.entryTypeTextBox = new MetroFramework.Controls.MetroTextBox(); + this.propertyValueTextBox = new MetroFramework.Controls.MetroTextBox(); + this.propertyKeyTextBox = new MetroFramework.Controls.MetroTextBox(); + label1 = new System.Windows.Forms.Label(); + label2 = new System.Windows.Forms.Label(); + label3 = new System.Windows.Forms.Label(); this.SuspendLayout(); // - // treeMeta + // propertyTreeview // - resources.ApplyResources(this.treeMeta, "treeMeta"); - this.treeMeta.Name = "treeMeta"; - this.treeMeta.AfterSelect += new System.Windows.Forms.TreeViewEventHandler(this.treeMeta_AfterSelect); + this.propertyTreeview.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(20)))), ((int)(((byte)(20)))), ((int)(((byte)(20))))); + this.propertyTreeview.BorderStyle = System.Windows.Forms.BorderStyle.None; + this.propertyTreeview.ForeColor = System.Drawing.SystemColors.Window; + resources.ApplyResources(this.propertyTreeview, "propertyTreeview"); + this.propertyTreeview.Name = "propertyTreeview"; + this.propertyTreeview.AfterSelect += new System.Windows.Forms.TreeViewEventHandler(this.treeMeta_AfterSelect); // - // comboBox1 + // fileTypeComboBox // - this.comboBox1.FormattingEnabled = true; - resources.ApplyResources(this.comboBox1, "comboBox1"); - this.comboBox1.Items.AddRange(new object[] { - resources.GetString("comboBox1.Items"), - resources.GetString("comboBox1.Items1"), - resources.GetString("comboBox1.Items2"), - resources.GetString("comboBox1.Items3"), - resources.GetString("comboBox1.Items4"), - resources.GetString("comboBox1.Items5"), - resources.GetString("comboBox1.Items6"), - resources.GetString("comboBox1.Items7"), - resources.GetString("comboBox1.Items8"), - resources.GetString("comboBox1.Items9"), - resources.GetString("comboBox1.Items10"), - resources.GetString("comboBox1.Items11"), - resources.GetString("comboBox1.Items12"), - resources.GetString("comboBox1.Items13")}); - this.comboBox1.Name = "comboBox1"; - this.comboBox1.Style = MetroFramework.MetroColorStyle.Silver; - this.comboBox1.Theme = MetroFramework.MetroThemeStyle.Dark; - this.comboBox1.UseSelectable = true; + this.fileTypeComboBox.FormattingEnabled = true; + resources.ApplyResources(this.fileTypeComboBox, "fileTypeComboBox"); + this.fileTypeComboBox.Items.AddRange(new object[] { + resources.GetString("fileTypeComboBox.Items"), + resources.GetString("fileTypeComboBox.Items1"), + resources.GetString("fileTypeComboBox.Items2"), + resources.GetString("fileTypeComboBox.Items3"), + resources.GetString("fileTypeComboBox.Items4"), + resources.GetString("fileTypeComboBox.Items5"), + resources.GetString("fileTypeComboBox.Items6"), + resources.GetString("fileTypeComboBox.Items7"), + resources.GetString("fileTypeComboBox.Items8"), + resources.GetString("fileTypeComboBox.Items9"), + resources.GetString("fileTypeComboBox.Items10"), + resources.GetString("fileTypeComboBox.Items11"), + resources.GetString("fileTypeComboBox.Items12"), + resources.GetString("fileTypeComboBox.Items13")}); + this.fileTypeComboBox.Name = "fileTypeComboBox"; + this.fileTypeComboBox.Style = MetroFramework.MetroColorStyle.Silver; + this.fileTypeComboBox.Theme = MetroFramework.MetroThemeStyle.Dark; + this.fileTypeComboBox.UseSelectable = true; // // label1 // - resources.ApplyResources(this.label1, "label1"); - this.label1.ForeColor = System.Drawing.Color.White; - this.label1.Name = "label1"; + resources.ApplyResources(label1, "label1"); + label1.ForeColor = System.Drawing.Color.White; + label1.Name = "label1"; // // applyButton // @@ -87,89 +93,89 @@ // // label2 // - resources.ApplyResources(this.label2, "label2"); - this.label2.ForeColor = System.Drawing.Color.White; - this.label2.Name = "label2"; + resources.ApplyResources(label2, "label2"); + label2.ForeColor = System.Drawing.Color.White; + label2.Name = "label2"; // // label3 // - resources.ApplyResources(this.label3, "label3"); - this.label3.ForeColor = System.Drawing.Color.White; - this.label3.Name = "label3"; + resources.ApplyResources(label3, "label3"); + label3.ForeColor = System.Drawing.Color.White; + label3.Name = "label3"; // - // entryDataTextBox + // propertyValueTextBox // // // // - this.entryDataTextBox.CustomButton.Image = ((System.Drawing.Image)(resources.GetObject("resource.Image"))); - this.entryDataTextBox.CustomButton.Location = ((System.Drawing.Point)(resources.GetObject("resource.Location"))); - this.entryDataTextBox.CustomButton.Name = ""; - this.entryDataTextBox.CustomButton.Size = ((System.Drawing.Size)(resources.GetObject("resource.Size"))); - this.entryDataTextBox.CustomButton.Style = MetroFramework.MetroColorStyle.Blue; - this.entryDataTextBox.CustomButton.TabIndex = ((int)(resources.GetObject("resource.TabIndex"))); - this.entryDataTextBox.CustomButton.Theme = MetroFramework.MetroThemeStyle.Light; - this.entryDataTextBox.CustomButton.UseSelectable = true; - this.entryDataTextBox.CustomButton.Visible = ((bool)(resources.GetObject("resource.Visible"))); - this.entryDataTextBox.Lines = new string[0]; - resources.ApplyResources(this.entryDataTextBox, "entryDataTextBox"); - this.entryDataTextBox.MaxLength = 32767; - this.entryDataTextBox.Name = "entryDataTextBox"; - this.entryDataTextBox.PasswordChar = '\0'; - this.entryDataTextBox.ScrollBars = System.Windows.Forms.ScrollBars.None; - this.entryDataTextBox.SelectedText = ""; - this.entryDataTextBox.SelectionLength = 0; - this.entryDataTextBox.SelectionStart = 0; - this.entryDataTextBox.ShortcutsEnabled = true; - this.entryDataTextBox.Style = MetroFramework.MetroColorStyle.Silver; - this.entryDataTextBox.Theme = MetroFramework.MetroThemeStyle.Dark; - this.entryDataTextBox.UseSelectable = true; - this.entryDataTextBox.WaterMarkColor = System.Drawing.Color.FromArgb(((int)(((byte)(109)))), ((int)(((byte)(109)))), ((int)(((byte)(109))))); - this.entryDataTextBox.WaterMarkFont = new System.Drawing.Font("Segoe UI", 12F, System.Drawing.FontStyle.Italic, System.Drawing.GraphicsUnit.Pixel); + this.propertyValueTextBox.CustomButton.Image = ((System.Drawing.Image)(resources.GetObject("resource.Image"))); + this.propertyValueTextBox.CustomButton.Location = ((System.Drawing.Point)(resources.GetObject("resource.Location"))); + this.propertyValueTextBox.CustomButton.Name = ""; + this.propertyValueTextBox.CustomButton.Size = ((System.Drawing.Size)(resources.GetObject("resource.Size"))); + this.propertyValueTextBox.CustomButton.Style = MetroFramework.MetroColorStyle.Blue; + this.propertyValueTextBox.CustomButton.TabIndex = ((int)(resources.GetObject("resource.TabIndex"))); + this.propertyValueTextBox.CustomButton.Theme = MetroFramework.MetroThemeStyle.Light; + this.propertyValueTextBox.CustomButton.UseSelectable = true; + this.propertyValueTextBox.CustomButton.Visible = ((bool)(resources.GetObject("resource.Visible"))); + this.propertyValueTextBox.Lines = new string[0]; + resources.ApplyResources(this.propertyValueTextBox, "propertyValueTextBox"); + this.propertyValueTextBox.MaxLength = 32767; + this.propertyValueTextBox.Name = "propertyValueTextBox"; + this.propertyValueTextBox.PasswordChar = '\0'; + this.propertyValueTextBox.ScrollBars = System.Windows.Forms.ScrollBars.None; + this.propertyValueTextBox.SelectedText = ""; + this.propertyValueTextBox.SelectionLength = 0; + this.propertyValueTextBox.SelectionStart = 0; + this.propertyValueTextBox.ShortcutsEnabled = true; + this.propertyValueTextBox.Style = MetroFramework.MetroColorStyle.Silver; + this.propertyValueTextBox.Theme = MetroFramework.MetroThemeStyle.Dark; + this.propertyValueTextBox.UseSelectable = true; + this.propertyValueTextBox.WaterMarkColor = System.Drawing.Color.FromArgb(((int)(((byte)(109)))), ((int)(((byte)(109)))), ((int)(((byte)(109))))); + this.propertyValueTextBox.WaterMarkFont = new System.Drawing.Font("Segoe UI", 12F, System.Drawing.FontStyle.Italic, System.Drawing.GraphicsUnit.Pixel); // - // entryTypeTextBox + // propertyKeyTextBox // // // // - this.entryTypeTextBox.CustomButton.Image = ((System.Drawing.Image)(resources.GetObject("resource.Image1"))); - this.entryTypeTextBox.CustomButton.ImeMode = ((System.Windows.Forms.ImeMode)(resources.GetObject("resource.ImeMode"))); - this.entryTypeTextBox.CustomButton.Location = ((System.Drawing.Point)(resources.GetObject("resource.Location1"))); - this.entryTypeTextBox.CustomButton.Name = ""; - this.entryTypeTextBox.CustomButton.Size = ((System.Drawing.Size)(resources.GetObject("resource.Size1"))); - this.entryTypeTextBox.CustomButton.Style = MetroFramework.MetroColorStyle.Blue; - this.entryTypeTextBox.CustomButton.TabIndex = ((int)(resources.GetObject("resource.TabIndex1"))); - this.entryTypeTextBox.CustomButton.Theme = MetroFramework.MetroThemeStyle.Light; - this.entryTypeTextBox.CustomButton.UseSelectable = true; - this.entryTypeTextBox.CustomButton.Visible = ((bool)(resources.GetObject("resource.Visible1"))); - this.entryTypeTextBox.Lines = new string[0]; - resources.ApplyResources(this.entryTypeTextBox, "entryTypeTextBox"); - this.entryTypeTextBox.MaxLength = 32767; - this.entryTypeTextBox.Name = "entryTypeTextBox"; - this.entryTypeTextBox.PasswordChar = '\0'; - this.entryTypeTextBox.ScrollBars = System.Windows.Forms.ScrollBars.None; - this.entryTypeTextBox.SelectedText = ""; - this.entryTypeTextBox.SelectionLength = 0; - this.entryTypeTextBox.SelectionStart = 0; - this.entryTypeTextBox.ShortcutsEnabled = true; - this.entryTypeTextBox.Style = MetroFramework.MetroColorStyle.Silver; - this.entryTypeTextBox.Theme = MetroFramework.MetroThemeStyle.Dark; - this.entryTypeTextBox.UseSelectable = true; - this.entryTypeTextBox.WaterMarkColor = System.Drawing.Color.FromArgb(((int)(((byte)(109)))), ((int)(((byte)(109)))), ((int)(((byte)(109))))); - this.entryTypeTextBox.WaterMarkFont = new System.Drawing.Font("Segoe UI", 12F, System.Drawing.FontStyle.Italic, System.Drawing.GraphicsUnit.Pixel); + this.propertyKeyTextBox.CustomButton.Image = ((System.Drawing.Image)(resources.GetObject("resource.Image1"))); + this.propertyKeyTextBox.CustomButton.ImeMode = ((System.Windows.Forms.ImeMode)(resources.GetObject("resource.ImeMode"))); + this.propertyKeyTextBox.CustomButton.Location = ((System.Drawing.Point)(resources.GetObject("resource.Location1"))); + this.propertyKeyTextBox.CustomButton.Name = ""; + this.propertyKeyTextBox.CustomButton.Size = ((System.Drawing.Size)(resources.GetObject("resource.Size1"))); + this.propertyKeyTextBox.CustomButton.Style = MetroFramework.MetroColorStyle.Blue; + this.propertyKeyTextBox.CustomButton.TabIndex = ((int)(resources.GetObject("resource.TabIndex1"))); + this.propertyKeyTextBox.CustomButton.Theme = MetroFramework.MetroThemeStyle.Light; + this.propertyKeyTextBox.CustomButton.UseSelectable = true; + this.propertyKeyTextBox.CustomButton.Visible = ((bool)(resources.GetObject("resource.Visible1"))); + this.propertyKeyTextBox.Lines = new string[0]; + resources.ApplyResources(this.propertyKeyTextBox, "propertyKeyTextBox"); + this.propertyKeyTextBox.MaxLength = 32767; + this.propertyKeyTextBox.Name = "propertyKeyTextBox"; + this.propertyKeyTextBox.PasswordChar = '\0'; + this.propertyKeyTextBox.ScrollBars = System.Windows.Forms.ScrollBars.None; + this.propertyKeyTextBox.SelectedText = ""; + this.propertyKeyTextBox.SelectionLength = 0; + this.propertyKeyTextBox.SelectionStart = 0; + this.propertyKeyTextBox.ShortcutsEnabled = true; + this.propertyKeyTextBox.Style = MetroFramework.MetroColorStyle.Silver; + this.propertyKeyTextBox.Theme = MetroFramework.MetroThemeStyle.Dark; + this.propertyKeyTextBox.UseSelectable = true; + this.propertyKeyTextBox.WaterMarkColor = System.Drawing.Color.FromArgb(((int)(((byte)(109)))), ((int)(((byte)(109)))), ((int)(((byte)(109))))); + this.propertyKeyTextBox.WaterMarkFont = new System.Drawing.Font("Segoe UI", 12F, System.Drawing.FontStyle.Italic, System.Drawing.GraphicsUnit.Pixel); // // AdvancedOptions // resources.ApplyResources(this, "$this"); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.Controls.Add(this.entryTypeTextBox); - this.Controls.Add(this.label2); - this.Controls.Add(this.label3); - this.Controls.Add(this.entryDataTextBox); + this.Controls.Add(this.propertyKeyTextBox); + this.Controls.Add(label2); + this.Controls.Add(label3); + this.Controls.Add(this.propertyValueTextBox); this.Controls.Add(this.applyButton); - this.Controls.Add(this.label1); - this.Controls.Add(this.comboBox1); - this.Controls.Add(this.treeMeta); + this.Controls.Add(label1); + this.Controls.Add(this.fileTypeComboBox); + this.Controls.Add(this.propertyTreeview); this.MaximizeBox = false; this.MinimizeBox = false; this.Name = "AdvancedOptions"; @@ -185,13 +191,10 @@ #endregion - private System.Windows.Forms.TreeView treeMeta; - private MetroFramework.Controls.MetroComboBox comboBox1; + private System.Windows.Forms.TreeView propertyTreeview; + private MetroFramework.Controls.MetroComboBox fileTypeComboBox; private MetroFramework.Controls.MetroButton applyButton; - private System.Windows.Forms.Label label1; - private System.Windows.Forms.Label label2; - private System.Windows.Forms.Label label3; - private MetroFramework.Controls.MetroTextBox entryDataTextBox; - private MetroFramework.Controls.MetroTextBox entryTypeTextBox; + private MetroFramework.Controls.MetroTextBox propertyValueTextBox; + private MetroFramework.Controls.MetroTextBox propertyKeyTextBox; } } \ No newline at end of file diff --git a/PCK-Studio/Forms/Skins-And-Textures/AdvancedOptions.cs b/PCK-Studio/Forms/Skins-And-Textures/AdvancedOptions.cs index b57b4386..0b4be354 100644 --- a/PCK-Studio/Forms/Skins-And-Textures/AdvancedOptions.cs +++ b/PCK-Studio/Forms/Skins-And-Textures/AdvancedOptions.cs @@ -1,7 +1,11 @@ -using OMI.Formats.Pck; +using OMI; +using OMI.Formats.Pck; using OMI.Workers.Pck; +using PckStudio.Classes.FileTypes; using System; +using System.Collections.Generic; using System.Data; +using System.Diagnostics; using System.Drawing; using System.IO; using System.Linq; @@ -11,120 +15,78 @@ namespace PckStudio { public partial class AdvancedOptions : MetroFramework.Forms.MetroForm { - PckFile currentPCK; - public bool littleEndian; + public bool IsLittleEndian + { + set + { + _endianness = value ? Endianness.LittleEndian : Endianness.BigEndian; + } + } + private PckFile _pckFile; + private Endianness _endianness; - public AdvancedOptions(PckFile currentPCKIn) + public AdvancedOptions(PckFile pckFile) { InitializeComponent(); - currentPCK = currentPCKIn; - treeMeta.Nodes.Clear(); - treeMeta.Nodes.AddRange(currentPCK.GetPropertyList().Select((s) => new TreeNode(s)).ToArray()); + _pckFile = pckFile; + propertyTreeview.Nodes.Clear(); + propertyTreeview.Nodes.AddRange(_pckFile.GetPropertyList().Select(s => new TreeNode(s)).ToArray()); } private void applyButton_Click(object sender, EventArgs e) { - switch (comboBox1.SelectedIndex) + if (fileTypeComboBox.SelectedIndex >= 0 && fileTypeComboBox.SelectedIndex <= 13) { - case 0: - { - applyBulkProperties(); - DialogResult = DialogResult.OK; - } - break; - case > 0 and <= 13: - { - applyBulkProperties((PckFile.FileData.FileType)(comboBox1.SelectedIndex - 1)); - DialogResult = DialogResult.OK; - } - break; - default: - MessageBox.Show("Please select a filetype before applying"); - break; + applyBulkProperties(_pckFile.Files, fileTypeComboBox.SelectedIndex - 1); + DialogResult = DialogResult.OK; + return; } + MessageBox.Show("Please select a filetype before applying"); } - private void applyBulkProperties() + private void applyBulkProperties(FileCollection files, int index) { - foreach (PckFile.FileData file in currentPCK.Files) + foreach (PckFile.FileData file in files) { if (file.Filetype == PckFile.FileData.FileType.TexturePackInfoFile || - file.Filetype == PckFile.FileData.FileType.SkinDataFile) + file.Filetype == PckFile.FileData.FileType.SkinDataFile) { try { - var reader = new PckFileReader(littleEndian - ? OMI.Endianness.LittleEndian - : OMI.Endianness.BigEndian); - PckFile SubPCK = reader.FromStream(new MemoryStream(file.Data)); - foreach (PckFile.FileData SubFile in SubPCK.Files) + var reader = new PckFileReader(_endianness); + using var ms = new MemoryStream(file.Data); + PckFile subPCK = reader.FromStream(ms); + applyBulkProperties(subPCK.Files, index); + var writer = new PckFileWriter(subPCK, _endianness); + using (var stream = new MemoryStream()) { - SubFile.Properties.Add(entryTypeTextBox.Text, entryDataTextBox.Text); + writer.WriteToStream(stream); + file.SetData(stream.ToArray()); } - var writer = new PckFileWriter(SubPCK, littleEndian - ? OMI.Endianness.LittleEndian - : OMI.Endianness.BigEndian); - var stream = new MemoryStream(); - writer.WriteToStream(stream); - file.SetData(stream.ToArray()); - stream.Dispose(); } catch (OverflowException ex) { - System.Diagnostics.Debug.WriteLine(ex.Message); + Debug.WriteLine(ex.Message); } } - file.Properties.Add(entryTypeTextBox.Text, entryDataTextBox.Text); + if (index == -1 || (Enum.IsDefined(typeof(PckFile.FileData.FileType), index) && (int)file.Filetype == index)) + { + file.Properties.Add(propertyKeyTextBox.Text, propertyValueTextBox.Text); + } + } + + if (Enum.IsDefined(typeof(PckFile.FileData.FileType), index)) + { + MessageBox.Show($"Data added to {(PckFile.FileData.FileType)index} entries"); + return; } MessageBox.Show("Data added to all entries"); } - private void applyBulkProperties(PckFile.FileData.FileType filetype) - { - foreach (PckFile.FileData file in currentPCK.Files) - { - if (file.Filetype == PckFile.FileData.FileType.TexturePackInfoFile || - file.Filetype == PckFile.FileData.FileType.SkinDataFile) - { - try - { - var reader = new PckFileReader(littleEndian - ? OMI.Endianness.LittleEndian - : OMI.Endianness.BigEndian); - PckFile SubPCK = reader.FromStream(new MemoryStream(file.Data)); - foreach (PckFile.FileData SubFile in SubPCK.Files) - { - if (SubFile.Filetype == filetype) - { - SubFile.Properties.Add(entryTypeTextBox.Text, entryDataTextBox.Text); - } - } - var writer = new PckFileWriter(SubPCK, littleEndian - ? OMI.Endianness.LittleEndian - : OMI.Endianness.BigEndian); - var stream = new MemoryStream(); - writer.WriteToStream(stream); - file.SetData(stream.ToArray()); - stream.Dispose(); - } - catch (OverflowException ex) - { - System.Diagnostics.Debug.WriteLine(ex.Message); - } - } - - if (file.Filetype == filetype) - { - file.Properties.Add(entryTypeTextBox.Text, entryDataTextBox.Text); - } - } - MessageBox.Show($"Data Added to {filetype} File Entries"); - } - private void treeMeta_AfterSelect(object sender, TreeViewEventArgs e) { - entryTypeTextBox.Text = treeMeta.SelectedNode.Text; + propertyKeyTextBox.Text = propertyTreeview.SelectedNode.Text; } } } diff --git a/PCK-Studio/Forms/Skins-And-Textures/AdvancedOptions.resx b/PCK-Studio/Forms/Skins-And-Textures/AdvancedOptions.resx index c203b86e..05461101 100644 --- a/PCK-Studio/Forms/Skins-And-Textures/AdvancedOptions.resx +++ b/PCK-Studio/Forms/Skins-And-Textures/AdvancedOptions.resx @@ -118,99 +118,102 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - + 23, 63 - + 272, 142 - + 13 - - treeMeta + + propertyTreeview - + System.Windows.Forms.TreeView, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - + $this - + 7 - + 23 - + All Files - + Skin Files (.png;.tga) - + Cape Files (.png;.tga) - + Texture Files (.png;.tga) - + UI Data Files (?) - + Info Files (0) - + Texture Pack Info Files (.pck) - + Localization Files (.loc) - + Game Rules Files (.grf) - + Audio Files (.pck) - + Colour Table Files (.col) - + Game Rules Header Files (.grh) - + Skin Data Files (.pck) - + Material Files (.bin) - + 65, 254 - + 157, 29 - + 1 - - comboBox1 + + fileTypeComboBox - + MetroFramework.Controls.MetroComboBox, MetroFramework, Version=1.4.0.0, Culture=neutral, PublicKeyToken=5f91a84759bf584a - + $this - + 6 + + False + True - 20, 260 + 20, 261 45, 13 @@ -234,7 +237,7 @@ 5 - 228, 260 + 228, 257 75, 23 @@ -257,6 +260,9 @@ 4 + + False + True @@ -284,6 +290,9 @@ 1 + + False + True @@ -327,25 +336,25 @@ False - + 164, 224 - + 139, 20 - + 9 - - entryDataTextBox + + propertyValueTextBox - + MetroFramework.Controls.MetroTextBox, MetroFramework, Version=1.4.0.0, Culture=neutral, PublicKeyToken=5f91a84759bf584a - + $this - + 3 @@ -366,25 +375,25 @@ False - + 19, 224 - + 139, 20 - + 14 - - entryTypeTextBox + + propertyKeyTextBox - + MetroFramework.Controls.MetroTextBox, MetroFramework, Version=1.4.0.0, Culture=neutral, PublicKeyToken=5f91a84759bf584a - + $this - + 0 diff --git a/PCK-Studio/MainForm.cs b/PCK-Studio/MainForm.cs index 335c9194..d4feded7 100644 --- a/PCK-Studio/MainForm.cs +++ b/PCK-Studio/MainForm.cs @@ -1324,7 +1324,7 @@ namespace PckStudio private void quickChangeToolStripMenuItem_Click(object sender, EventArgs e) { using AdvancedOptions advanced = new AdvancedOptions(currentPCK); - advanced.littleEndian = LittleEndianCheckBox.Checked; + advanced.IsLittleEndian = LittleEndianCheckBox.Checked; if (advanced.ShowDialog() == DialogResult.OK) { wasModified = true; From 896e2f667175596abc2f172272ee01b33fe4961b Mon Sep 17 00:00:00 2001 From: miku-666 <74728189+NessieHax@users.noreply.github.com> Date: Wed, 2 Aug 2023 13:29:08 +0200 Subject: [PATCH 3/8] Moved Animation.cs to 'Internal' folder and changed namespace --- .../Forms/Additional-Popups/Animation/ChangeTile.cs | 8 ++++---- PCK-Studio/Forms/Editor/AnimationEditor.cs | 1 + PCK-Studio/Forms/Editor/AnimationPictureBox.cs | 1 + PCK-Studio/{Forms/Editor => Internal}/Animation.cs | 6 ++---- PCK-Studio/PckStudio.csproj | 2 +- 5 files changed, 9 insertions(+), 9 deletions(-) rename PCK-Studio/{Forms/Editor => Internal}/Animation.cs (98%) diff --git a/PCK-Studio/Forms/Additional-Popups/Animation/ChangeTile.cs b/PCK-Studio/Forms/Additional-Popups/Animation/ChangeTile.cs index d0a6c36c..3cd495cf 100644 --- a/PCK-Studio/Forms/Additional-Popups/Animation/ChangeTile.cs +++ b/PCK-Studio/Forms/Additional-Popups/Animation/ChangeTile.cs @@ -12,10 +12,10 @@ namespace PckStudio.Forms.Additional_Popups.Animation internal partial class ChangeTile : MetroForm { string selectedTile = ""; - Editor.Animation.AnimationCategory category = Editor.Animation.AnimationCategory.Blocks; + Internal.Animation.AnimationCategory category = Internal.Animation.AnimationCategory.Blocks; public string SelectedTile => selectedTile; - public Editor.Animation.AnimationCategory Category => category; + public Internal.Animation.AnimationCategory Category => category; List treeViewBlockCache = new List(); List treeViewItemCache = new List(); @@ -43,8 +43,8 @@ namespace PckStudio.Forms.Additional_Popups.Animation selectedTile = tileData; Debug.WriteLine(selectedTile); category = e.Node.TreeView == treeViewItems - ? Editor.Animation.AnimationCategory.Items - : Editor.Animation.AnimationCategory.Blocks; + ? Internal.Animation.AnimationCategory.Items + : Internal.Animation.AnimationCategory.Blocks; } } diff --git a/PCK-Studio/Forms/Editor/AnimationEditor.cs b/PCK-Studio/Forms/Editor/AnimationEditor.cs index c9739128..4a064d6f 100644 --- a/PCK-Studio/Forms/Editor/AnimationEditor.cs +++ b/PCK-Studio/Forms/Editor/AnimationEditor.cs @@ -16,6 +16,7 @@ using PckStudio.Forms.Utilities; using PckStudio.Extensions; using PckStudio.Properties; using System.Diagnostics; +using PckStudio.Internal; namespace PckStudio.Forms.Editor { diff --git a/PCK-Studio/Forms/Editor/AnimationPictureBox.cs b/PCK-Studio/Forms/Editor/AnimationPictureBox.cs index d5fa6cfd..3d0116a9 100644 --- a/PCK-Studio/Forms/Editor/AnimationPictureBox.cs +++ b/PCK-Studio/Forms/Editor/AnimationPictureBox.cs @@ -24,6 +24,7 @@ using System.Drawing.Drawing2D; using System.Runtime.CompilerServices; using PckStudio.Extensions; +using PckStudio.Internal; namespace PckStudio.Forms.Editor { diff --git a/PCK-Studio/Forms/Editor/Animation.cs b/PCK-Studio/Internal/Animation.cs similarity index 98% rename from PCK-Studio/Forms/Editor/Animation.cs rename to PCK-Studio/Internal/Animation.cs index 27fd2f73..76ec2b04 100644 --- a/PCK-Studio/Forms/Editor/Animation.cs +++ b/PCK-Studio/Internal/Animation.cs @@ -21,11 +21,9 @@ using System.Drawing; using PckStudio.Extensions; using System.Text; - -// TODO: change namespace -namespace PckStudio.Forms.Editor +namespace PckStudio.Internal { - sealed class Animation + internal sealed class Animation { public const int MinimumFrameTime = 1; diff --git a/PCK-Studio/PckStudio.csproj b/PCK-Studio/PckStudio.csproj index 50456f78..dc588039 100644 --- a/PCK-Studio/PckStudio.csproj +++ b/PCK-Studio/PckStudio.csproj @@ -299,7 +299,7 @@ MultiTextPrompt.cs - + Component From 7f1c459c1ddef1224648290df37408a2a9b1378a Mon Sep 17 00:00:00 2001 From: miku-666 <74728189+NessieHax@users.noreply.github.com> Date: Wed, 2 Aug 2023 13:31:09 +0200 Subject: [PATCH 4/8] Added AnimationExtensions.cs and moved java animation conversion to AnimationExtensions --- PCK-Studio/Extensions/AnimationExtensions.cs | 35 +++++++++++++++++++ PCK-Studio/Forms/Editor/AnimationEditor.cs | 2 +- .../Forms/Utilities/AnimationResources.cs | 19 ---------- PCK-Studio/PckStudio.csproj | 1 + 4 files changed, 37 insertions(+), 20 deletions(-) create mode 100644 PCK-Studio/Extensions/AnimationExtensions.cs diff --git a/PCK-Studio/Extensions/AnimationExtensions.cs b/PCK-Studio/Extensions/AnimationExtensions.cs new file mode 100644 index 00000000..4c7aeb3f --- /dev/null +++ b/PCK-Studio/Extensions/AnimationExtensions.cs @@ -0,0 +1,35 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; +using Newtonsoft.Json.Linq; +using PckStudio.Internal; + +namespace PckStudio.Extensions +{ + internal static class AnimationExtensions + { + + internal static JObject ConvertToJavaAnimation(this Animation animation) + { + JObject janimation = new JObject(); + JObject mcmeta = new JObject(); + mcmeta["comment"] = $"Animation converted with {Application.ProductName}"; + mcmeta["animation"] = janimation; + JArray jframes = new JArray(); + foreach (var frame in animation.GetFrames()) + { + JObject jframe = new JObject(); + jframe["index"] = animation.GetTextureIndex(frame.Texture); + jframe["time"] = frame.Ticks; + jframes.Add(jframe); + }; + janimation["interpolation"] = animation.Interpolate; + janimation["frames"] = jframes; + return mcmeta; + } + + } +} diff --git a/PCK-Studio/Forms/Editor/AnimationEditor.cs b/PCK-Studio/Forms/Editor/AnimationEditor.cs index 4a064d6f..fbecaecb 100644 --- a/PCK-Studio/Forms/Editor/AnimationEditor.cs +++ b/PCK-Studio/Forms/Editor/AnimationEditor.cs @@ -404,7 +404,7 @@ namespace PckStudio.Forms.Editor fileDialog.Filter = "Animation Scripts (*.mcmeta)|*.png.mcmeta"; if (fileDialog.ShowDialog(this) == DialogResult.OK) { - JObject mcmeta = AnimationResources.ConvertAnimationToJson(currentAnimation); + JObject mcmeta = currentAnimation.ConvertToJavaAnimation(); string jsondata = JsonConvert.SerializeObject(mcmeta, Formatting.Indented); string filename = fileDialog.FileName; File.WriteAllText(filename, jsondata); diff --git a/PCK-Studio/Forms/Utilities/AnimationResources.cs b/PCK-Studio/Forms/Utilities/AnimationResources.cs index df887429..c803c434 100644 --- a/PCK-Studio/Forms/Utilities/AnimationResources.cs +++ b/PCK-Studio/Forms/Utilities/AnimationResources.cs @@ -80,24 +80,5 @@ namespace PckStudio.Forms.Utilities return _blockImageList; } } - - internal static JObject ConvertAnimationToJson(Animation animation) - { - JObject janimation = new JObject(); - JObject mcmeta = new JObject(); - mcmeta["comment"] = $"Animation converted by {Application.ProductName}"; - mcmeta["animation"] = janimation; - JArray jframes = new JArray(); - foreach (var frame in animation.GetFrames()) - { - JObject jframe = new JObject(); - jframe["index"] = animation.GetTextureIndex(frame.Texture); - jframe["time"] = frame.Ticks; - jframes.Add(jframe); - }; - janimation["interpolation"] = animation.Interpolate; - janimation["frames"] = jframes; - return mcmeta; - } } } diff --git a/PCK-Studio/PckStudio.csproj b/PCK-Studio/PckStudio.csproj index dc588039..4c746964 100644 --- a/PCK-Studio/PckStudio.csproj +++ b/PCK-Studio/PckStudio.csproj @@ -178,6 +178,7 @@ Component + From 4a9ed403fdb598a66b271370d5dd60aa680eccc7 Mon Sep 17 00:00:00 2001 From: miku-666 <74728189+NessieHax@users.noreply.github.com> Date: Wed, 2 Aug 2023 13:33:22 +0200 Subject: [PATCH 5/8] Renamed CreateTexturePack.cs to CreateTexturePackPrompt.cs --- ...cs => CreateTexturePackPrompt.Designer.cs} | 45 +++++++++---------- ...turePack.cs => CreateTexturePackPrompt.cs} | 8 ++-- ...Pack.resx => CreateTexturePackPrompt.resx} | 36 +++++++-------- PCK-Studio/MainForm.cs | 4 +- PCK-Studio/PckStudio.csproj | 10 ++--- 5 files changed, 51 insertions(+), 52 deletions(-) rename PCK-Studio/Forms/Additional-Popups/{CreateTexturePack.Designer.cs => CreateTexturePackPrompt.Designer.cs} (79%) rename PCK-Studio/Forms/Additional-Popups/{CreateTexturePack.cs => CreateTexturePackPrompt.cs} (68%) rename PCK-Studio/Forms/Additional-Popups/{CreateTexturePack.resx => CreateTexturePackPrompt.resx} (99%) diff --git a/PCK-Studio/Forms/Additional-Popups/CreateTexturePack.Designer.cs b/PCK-Studio/Forms/Additional-Popups/CreateTexturePackPrompt.Designer.cs similarity index 79% rename from PCK-Studio/Forms/Additional-Popups/CreateTexturePack.Designer.cs rename to PCK-Studio/Forms/Additional-Popups/CreateTexturePackPrompt.Designer.cs index 242f1dcd..415a5649 100644 --- a/PCK-Studio/Forms/Additional-Popups/CreateTexturePack.Designer.cs +++ b/PCK-Studio/Forms/Additional-Popups/CreateTexturePackPrompt.Designer.cs @@ -1,6 +1,6 @@ namespace PckStudio { - partial class CreateTexturePack + partial class CreateTexturePackPrompt { /// /// Required designer variable. @@ -28,11 +28,11 @@ /// private void InitializeComponent() { - System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(CreateTexturePack)); + System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(CreateTexturePackPrompt)); this.TextLabel = new System.Windows.Forms.Label(); this.OKButton = new System.Windows.Forms.Button(); this.InputTextBox = new MetroFramework.Controls.MetroTextBox(); - this.metroComboBox1 = new MetroFramework.Controls.MetroComboBox(); + this.resolutionComboBox = new MetroFramework.Controls.MetroComboBox(); this.label1 = new System.Windows.Forms.Label(); this.SuspendLayout(); // @@ -80,24 +80,24 @@ this.InputTextBox.WaterMarkColor = System.Drawing.Color.FromArgb(((int)(((byte)(109)))), ((int)(((byte)(109)))), ((int)(((byte)(109))))); this.InputTextBox.WaterMarkFont = new System.Drawing.Font("Segoe UI", 12F, System.Drawing.FontStyle.Italic, System.Drawing.GraphicsUnit.Pixel); // - // metroComboBox1 + // resolutionComboBox // - this.metroComboBox1.FormattingEnabled = true; - resources.ApplyResources(this.metroComboBox1, "metroComboBox1"); - this.metroComboBox1.Items.AddRange(new object[] { - resources.GetString("metroComboBox1.Items"), - resources.GetString("metroComboBox1.Items1"), - resources.GetString("metroComboBox1.Items2"), - resources.GetString("metroComboBox1.Items3"), - resources.GetString("metroComboBox1.Items4"), - resources.GetString("metroComboBox1.Items5"), - resources.GetString("metroComboBox1.Items6"), - resources.GetString("metroComboBox1.Items7"), - resources.GetString("metroComboBox1.Items8")}); - this.metroComboBox1.Name = "metroComboBox1"; - this.metroComboBox1.Style = MetroFramework.MetroColorStyle.Silver; - this.metroComboBox1.Theme = MetroFramework.MetroThemeStyle.Dark; - this.metroComboBox1.UseSelectable = true; + this.resolutionComboBox.FormattingEnabled = true; + resources.ApplyResources(this.resolutionComboBox, "resolutionComboBox"); + this.resolutionComboBox.Items.AddRange(new object[] { + resources.GetString("resolutionComboBox.Items"), + resources.GetString("resolutionComboBox.Items1"), + resources.GetString("resolutionComboBox.Items2"), + resources.GetString("resolutionComboBox.Items3"), + resources.GetString("resolutionComboBox.Items4"), + resources.GetString("resolutionComboBox.Items5"), + resources.GetString("resolutionComboBox.Items6"), + resources.GetString("resolutionComboBox.Items7"), + resources.GetString("resolutionComboBox.Items8")}); + this.resolutionComboBox.Name = "resolutionComboBox"; + this.resolutionComboBox.Style = MetroFramework.MetroColorStyle.Silver; + this.resolutionComboBox.Theme = MetroFramework.MetroThemeStyle.Dark; + this.resolutionComboBox.UseSelectable = true; // // label1 // @@ -112,11 +112,10 @@ resources.ApplyResources(this, "$this"); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.Controls.Add(this.label1); - this.Controls.Add(this.metroComboBox1); + this.Controls.Add(this.resolutionComboBox); this.Controls.Add(this.InputTextBox); this.Controls.Add(this.OKButton); this.Controls.Add(this.TextLabel); - this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None; this.MaximizeBox = false; this.MinimizeBox = false; this.Name = "CreateTexturePack"; @@ -133,7 +132,7 @@ public System.Windows.Forms.Button OKButton; public System.Windows.Forms.Label TextLabel; private MetroFramework.Controls.MetroTextBox InputTextBox; - private MetroFramework.Controls.MetroComboBox metroComboBox1; + private MetroFramework.Controls.MetroComboBox resolutionComboBox; public System.Windows.Forms.Label label1; } } \ No newline at end of file diff --git a/PCK-Studio/Forms/Additional-Popups/CreateTexturePack.cs b/PCK-Studio/Forms/Additional-Popups/CreateTexturePackPrompt.cs similarity index 68% rename from PCK-Studio/Forms/Additional-Popups/CreateTexturePack.cs rename to PCK-Studio/Forms/Additional-Popups/CreateTexturePackPrompt.cs index 5a2946d4..b94620b8 100644 --- a/PCK-Studio/Forms/Additional-Popups/CreateTexturePack.cs +++ b/PCK-Studio/Forms/Additional-Popups/CreateTexturePackPrompt.cs @@ -4,22 +4,22 @@ using MetroFramework.Forms; namespace PckStudio { - public partial class CreateTexturePack : MetroForm + public partial class CreateTexturePackPrompt : MetroForm { /// /// Text entered only access when DialogResult == DialogResult.OK /// public string PackName => InputTextBox.Text; - public string PackRes => metroComboBox1.Text; + public string PackRes => resolutionComboBox.Text; - public CreateTexturePack() + public CreateTexturePackPrompt() { InitializeComponent(); } private void OKBtn_Click(object sender, EventArgs e) { - if (metroComboBox1.SelectedIndex < 0) + if (resolutionComboBox.SelectedIndex < 0) return; DialogResult = DialogResult.OK; } diff --git a/PCK-Studio/Forms/Additional-Popups/CreateTexturePack.resx b/PCK-Studio/Forms/Additional-Popups/CreateTexturePackPrompt.resx similarity index 99% rename from PCK-Studio/Forms/Additional-Popups/CreateTexturePack.resx rename to PCK-Studio/Forms/Additional-Popups/CreateTexturePackPrompt.resx index 8c770886..d66ae6ea 100644 --- a/PCK-Studio/Forms/Additional-Popups/CreateTexturePack.resx +++ b/PCK-Studio/Forms/Additional-Popups/CreateTexturePackPrompt.resx @@ -213,55 +213,55 @@ 2 - + 23 - + x8 - + x16 - + x32 - + x48 - + x64 - + x80 - + x96 - + x112 - + x128 - + 60, 39 - + 165, 29 - + 6 - - metroComboBox1 + + resolutionComboBox - + MetroFramework.Controls.MetroComboBox, MetroFramework, Version=1.4.0.0, Culture=neutral, PublicKeyToken=5f91a84759bf584a - + $this - + 1 diff --git a/PCK-Studio/MainForm.cs b/PCK-Studio/MainForm.cs index d4feded7..e0d1412b 100644 --- a/PCK-Studio/MainForm.cs +++ b/PCK-Studio/MainForm.cs @@ -1298,7 +1298,7 @@ namespace PckStudio private void texturePackToolStripMenuItem_Click(object sender, EventArgs e) { checkSaveState(); - CreateTexturePack packPrompt = new CreateTexturePack(); + CreateTexturePackPrompt packPrompt = new CreateTexturePackPrompt(); if (packPrompt.ShowDialog() == DialogResult.OK) { currentPCK = InitializeTexturePack(new Random().Next(8000, int.MaxValue), 0, packPrompt.PackName, packPrompt.PackRes); @@ -1311,7 +1311,7 @@ namespace PckStudio private void mashUpPackToolStripMenuItem_Click(object sender, EventArgs e) { checkSaveState(); - CreateTexturePack packPrompt = new CreateTexturePack(); + CreateTexturePackPrompt packPrompt = new CreateTexturePackPrompt(); if (packPrompt.ShowDialog() == DialogResult.OK) { currentPCK = InitializeMashUpPack(new Random().Next(8000, int.MaxValue), 0, packPrompt.PackName, packPrompt.PackRes); diff --git a/PCK-Studio/PckStudio.csproj b/PCK-Studio/PckStudio.csproj index 4c746964..1a92d8cb 100644 --- a/PCK-Studio/PckStudio.csproj +++ b/PCK-Studio/PckStudio.csproj @@ -276,11 +276,11 @@ AddLanguage.cs - + Form - - CreateTexturePack.cs + + CreateTexturePackPrompt.cs Form @@ -503,8 +503,8 @@ AddLanguage.cs - - CreateTexturePack.cs + + CreateTexturePackPrompt.cs Designer From 9e3c3002268a73db39ac697a64d261b7373a7343 Mon Sep 17 00:00:00 2001 From: miku-666 <74728189+NessieHax@users.noreply.github.com> Date: Wed, 2 Aug 2023 14:03:05 +0200 Subject: [PATCH 6/8] Moved CSMBFile and PckAudioFile from 'Classes/FileTypes' to 'FileFormats' folder --- PCK-Studio/Classes/IO/CSMB/CSMBFileReader.cs | 2 +- PCK-Studio/Classes/IO/CSMB/CSMBFileWriter.cs | 2 +- PCK-Studio/Classes/IO/PckAudio/PckAudioFileReader.cs | 2 +- PCK-Studio/Classes/IO/PckAudio/PckAudioFileWriter.cs | 2 +- PCK-Studio/{Classes/FileTypes => FileFormats}/CSMBFile.cs | 5 ++--- .../{Classes/FileTypes => FileFormats}/PckAudioFile.cs | 2 +- PCK-Studio/Forms/Editor/AudioEditor.cs | 2 +- PCK-Studio/Forms/Skins-And-Textures/AdvancedOptions.cs | 1 - PCK-Studio/Forms/Utilities/pckCenterOpen.cs | 1 - PCK-Studio/MainForm.cs | 2 +- PCK-Studio/PckStudio.csproj | 4 ++-- 11 files changed, 11 insertions(+), 14 deletions(-) rename PCK-Studio/{Classes/FileTypes => FileFormats}/CSMBFile.cs (95%) rename PCK-Studio/{Classes/FileTypes => FileFormats}/PckAudioFile.cs (99%) diff --git a/PCK-Studio/Classes/IO/CSMB/CSMBFileReader.cs b/PCK-Studio/Classes/IO/CSMB/CSMBFileReader.cs index 6144150a..76fc8f56 100644 --- a/PCK-Studio/Classes/IO/CSMB/CSMBFileReader.cs +++ b/PCK-Studio/Classes/IO/CSMB/CSMBFileReader.cs @@ -2,7 +2,7 @@ using System.Text; using OMI; using OMI.Workers; -using PckStudio.Classes.FileTypes; +using PckStudio.FileFormats; namespace PckStudio.Classes.IO.CSMB { diff --git a/PCK-Studio/Classes/IO/CSMB/CSMBFileWriter.cs b/PCK-Studio/Classes/IO/CSMB/CSMBFileWriter.cs index 0481f3db..e2c95f31 100644 --- a/PCK-Studio/Classes/IO/CSMB/CSMBFileWriter.cs +++ b/PCK-Studio/Classes/IO/CSMB/CSMBFileWriter.cs @@ -1,6 +1,6 @@ using System.IO; using System.Text; -using PckStudio.Classes.FileTypes; +using PckStudio.FileFormats; using OMI.Workers; using OMI; diff --git a/PCK-Studio/Classes/IO/PckAudio/PckAudioFileReader.cs b/PCK-Studio/Classes/IO/PckAudio/PckAudioFileReader.cs index 66893c5f..be0941ee 100644 --- a/PCK-Studio/Classes/IO/PckAudio/PckAudioFileReader.cs +++ b/PCK-Studio/Classes/IO/PckAudio/PckAudioFileReader.cs @@ -1,6 +1,6 @@ using OMI; using OMI.Workers; -using PckStudio.Classes.FileTypes; +using PckStudio.FileFormats; using System; using System.Collections.Generic; using System.Diagnostics; diff --git a/PCK-Studio/Classes/IO/PckAudio/PckAudioFileWriter.cs b/PCK-Studio/Classes/IO/PckAudio/PckAudioFileWriter.cs index afed490a..0ceee001 100644 --- a/PCK-Studio/Classes/IO/PckAudio/PckAudioFileWriter.cs +++ b/PCK-Studio/Classes/IO/PckAudio/PckAudioFileWriter.cs @@ -1,6 +1,6 @@ using OMI; using OMI.Workers; -using PckStudio.Classes.FileTypes; +using PckStudio.FileFormats; using System.Collections.Generic; using System.IO; using System.Text; diff --git a/PCK-Studio/Classes/FileTypes/CSMBFile.cs b/PCK-Studio/FileFormats/CSMBFile.cs similarity index 95% rename from PCK-Studio/Classes/FileTypes/CSMBFile.cs rename to PCK-Studio/FileFormats/CSMBFile.cs index a9d00858..9bc1db11 100644 --- a/PCK-Studio/Classes/FileTypes/CSMBFile.cs +++ b/PCK-Studio/FileFormats/CSMBFile.cs @@ -5,11 +5,10 @@ using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; -using PckStudio.Models; -namespace PckStudio.Classes.FileTypes +namespace PckStudio.FileFormats { - #region File Template + #region File Structure /* Version - 4 bytes[int32] NumberOfParts - 4 bytes[int32] diff --git a/PCK-Studio/Classes/FileTypes/PckAudioFile.cs b/PCK-Studio/FileFormats/PckAudioFile.cs similarity index 99% rename from PCK-Studio/Classes/FileTypes/PckAudioFile.cs rename to PCK-Studio/FileFormats/PckAudioFile.cs index d9524b10..0ceb6608 100644 --- a/PCK-Studio/Classes/FileTypes/PckAudioFile.cs +++ b/PCK-Studio/FileFormats/PckAudioFile.cs @@ -5,7 +5,7 @@ using System.Text; using System.Threading.Tasks; using OMI.Formats.Languages; -namespace PckStudio.Classes.FileTypes +namespace PckStudio.FileFormats { public class PckAudioFile { diff --git a/PCK-Studio/Forms/Editor/AudioEditor.cs b/PCK-Studio/Forms/Editor/AudioEditor.cs index 4ca6a27a..76df1760 100644 --- a/PCK-Studio/Forms/Editor/AudioEditor.cs +++ b/PCK-Studio/Forms/Editor/AudioEditor.cs @@ -13,7 +13,7 @@ using NAudio.Wave; using OMI.Formats.Pck; -using PckStudio.Classes.FileTypes; +using PckStudio.FileFormats; using PckStudio.Classes.IO.PCK; using PckStudio.Forms.Additional_Popups.Audio; using PckStudio.Forms.Additional_Popups; diff --git a/PCK-Studio/Forms/Skins-And-Textures/AdvancedOptions.cs b/PCK-Studio/Forms/Skins-And-Textures/AdvancedOptions.cs index 0b4be354..81f307f4 100644 --- a/PCK-Studio/Forms/Skins-And-Textures/AdvancedOptions.cs +++ b/PCK-Studio/Forms/Skins-And-Textures/AdvancedOptions.cs @@ -1,7 +1,6 @@ using OMI; using OMI.Formats.Pck; using OMI.Workers.Pck; -using PckStudio.Classes.FileTypes; using System; using System.Collections.Generic; using System.Data; diff --git a/PCK-Studio/Forms/Utilities/pckCenterOpen.cs b/PCK-Studio/Forms/Utilities/pckCenterOpen.cs index 11ccb4b3..5325c0f7 100644 --- a/PCK-Studio/Forms/Utilities/pckCenterOpen.cs +++ b/PCK-Studio/Forms/Utilities/pckCenterOpen.cs @@ -15,7 +15,6 @@ using System.Windows.Media.Imaging; using System.IO.Packaging; using PckStudio; using System.IO.Compression; -using PckStudio.Classes.FileTypes; using PckStudio.Classes.IO.PCK; using OMI.Formats.Pck; using OMI.Workers.Pck; diff --git a/PCK-Studio/MainForm.cs b/PCK-Studio/MainForm.cs index e0d1412b..7afe447c 100644 --- a/PCK-Studio/MainForm.cs +++ b/PCK-Studio/MainForm.cs @@ -18,7 +18,7 @@ using OMI.Workers.GameRule; using OMI.Workers.Language; using PckStudio.Properties; -using PckStudio.Classes.FileTypes; +using PckStudio.FileFormats; using PckStudio.Forms; using PckStudio.Forms.Utilities; using PckStudio.Forms.Editor; diff --git a/PCK-Studio/PckStudio.csproj b/PCK-Studio/PckStudio.csproj index 1a92d8cb..7e8ff7f0 100644 --- a/PCK-Studio/PckStudio.csproj +++ b/PCK-Studio/PckStudio.csproj @@ -205,8 +205,8 @@ - - + + From 2d3ff781cbf3a6e142f06ce5de04ee44bbda957f Mon Sep 17 00:00:00 2001 From: miku-666 <74728189+NessieHax@users.noreply.github.com> Date: Wed, 2 Aug 2023 14:46:31 +0200 Subject: [PATCH 7/8] MainForm.cs - Updated PckManager It now only hides itself when closing --- PCK-Studio/MainForm.cs | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/PCK-Studio/MainForm.cs b/PCK-Studio/MainForm.cs index 7afe447c..d8720d99 100644 --- a/PCK-Studio/MainForm.cs +++ b/PCK-Studio/MainForm.cs @@ -157,6 +157,7 @@ namespace PckStudio private void MainForm_FormClosing(object sender, FormClosingEventArgs e) { + PckManager?.Close(); checkSaveState(); } @@ -962,7 +963,7 @@ namespace PckStudio Debug.WriteLine($"'{file.Filename}' has no data attached.", category: nameof(HandleTextureFile)); return; } - pckFileTypeHandler[file.Filetype]?.Invoke(file); + pckFileTypeHandler[file.Filetype]?.Invoke(file); } } @@ -2257,13 +2258,15 @@ namespace PckStudio private void openPckManagerToolStripMenuItem_Click(object sender, EventArgs e) { PckManager ??= new PckManager(); - PckManager.BringToFront(); - PckManager.Focus(); - if (!PckManager.Visible) + PckManager.FormClosing += (s, e) => { - PckManager.FormClosed += delegate { PckManager = null; }; - PckManager.Show(this); - } + PckManager.Hide(); + e.Cancel = true; + }; + if (!PckManager.Visible) + PckManager.Show(); + if (PckManager.Focus()) + PckManager.BringToFront(); } private async void wavBinkaToolStripMenuItem_Click(object sender, EventArgs e) @@ -2313,7 +2316,7 @@ namespace PckStudio if (exitCode == 0) convertedCount++; - } + } int fileCount = fileDialog.FileNames.Length; From 920f78a8e1441d18433c496a646c4e499190b141 Mon Sep 17 00:00:00 2001 From: miku-666 <74728189+NessieHax@users.noreply.github.com> Date: Wed, 2 Aug 2023 15:35:46 +0200 Subject: [PATCH 8/8] GRFEditor - Improved resizing --- .../Editor/GameRuleFileEditor.Designer.cs | 61 +++++++++---------- PCK-Studio/Forms/Editor/GameRuleFileEditor.cs | 9 --- 2 files changed, 29 insertions(+), 41 deletions(-) diff --git a/PCK-Studio/Forms/Editor/GameRuleFileEditor.Designer.cs b/PCK-Studio/Forms/Editor/GameRuleFileEditor.Designer.cs index 489bc757..5320010b 100644 --- a/PCK-Studio/Forms/Editor/GameRuleFileEditor.Designer.cs +++ b/PCK-Studio/Forms/Editor/GameRuleFileEditor.Designer.cs @@ -54,11 +54,11 @@ this.wiiUPSVitaToolStripMenuItem = new PckStudio.ToolStripRadioButtonMenuItem(); this.pS3ToolStripMenuItem = new PckStudio.ToolStripRadioButtonMenuItem(); this.xbox360ToolStripMenuItem = new PckStudio.ToolStripRadioButtonMenuItem(); - this.metroPanel1 = new MetroFramework.Controls.MetroPanel(); + this.tableLayoutPanel1 = new System.Windows.Forms.TableLayoutPanel(); this.MessageContextMenu.SuspendLayout(); this.DetailContextMenu.SuspendLayout(); this.menuStrip1.SuspendLayout(); - this.metroPanel1.SuspendLayout(); + this.tableLayoutPanel1.SuspendLayout(); this.SuspendLayout(); // // GrfTreeView @@ -66,11 +66,11 @@ this.GrfTreeView.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(64)))), ((int)(((byte)(64)))), ((int)(((byte)(64))))); this.GrfTreeView.BorderStyle = System.Windows.Forms.BorderStyle.None; this.GrfTreeView.ContextMenuStrip = this.MessageContextMenu; - this.GrfTreeView.Dock = System.Windows.Forms.DockStyle.Left; + this.GrfTreeView.Dock = System.Windows.Forms.DockStyle.Fill; this.GrfTreeView.ForeColor = System.Drawing.SystemColors.MenuBar; - this.GrfTreeView.Location = new System.Drawing.Point(0, 0); + this.GrfTreeView.Location = new System.Drawing.Point(3, 23); this.GrfTreeView.Name = "GrfTreeView"; - this.GrfTreeView.Size = new System.Drawing.Size(223, 312); + this.GrfTreeView.Size = new System.Drawing.Size(219, 312); this.GrfTreeView.TabIndex = 0; this.GrfTreeView.AfterSelect += new System.Windows.Forms.TreeViewEventHandler(this.GrfTreeView_AfterSelect); this.GrfTreeView.KeyDown += new System.Windows.Forms.KeyEventHandler(this.GrfTreeView_KeyDown); @@ -102,11 +102,11 @@ this.GrfParametersTreeView.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(64)))), ((int)(((byte)(64)))), ((int)(((byte)(64))))); this.GrfParametersTreeView.BorderStyle = System.Windows.Forms.BorderStyle.None; this.GrfParametersTreeView.ContextMenuStrip = this.DetailContextMenu; - this.GrfParametersTreeView.Dock = System.Windows.Forms.DockStyle.Right; + this.GrfParametersTreeView.Dock = System.Windows.Forms.DockStyle.Fill; this.GrfParametersTreeView.ForeColor = System.Drawing.SystemColors.MenuBar; - this.GrfParametersTreeView.Location = new System.Drawing.Point(227, 0); + this.GrfParametersTreeView.Location = new System.Drawing.Point(228, 23); this.GrfParametersTreeView.Name = "GrfParametersTreeView"; - this.GrfParametersTreeView.Size = new System.Drawing.Size(223, 312); + this.GrfParametersTreeView.Size = new System.Drawing.Size(219, 312); this.GrfParametersTreeView.TabIndex = 1; this.GrfParametersTreeView.NodeMouseDoubleClick += new System.Windows.Forms.TreeNodeMouseClickEventHandler(this.GrfDetailsTreeView_NodeMouseDoubleClick); this.GrfParametersTreeView.KeyDown += new System.Windows.Forms.KeyEventHandler(this.GrfDetailsTreeView_KeyDown); @@ -136,7 +136,7 @@ // metroLabel1 // this.metroLabel1.AutoSize = true; - this.metroLabel1.Location = new System.Drawing.Point(25, 88); + this.metroLabel1.Location = new System.Drawing.Point(3, 0); this.metroLabel1.Name = "metroLabel1"; this.metroLabel1.Size = new System.Drawing.Size(73, 19); this.metroLabel1.TabIndex = 2; @@ -146,9 +146,8 @@ // // metroLabel2 // - this.metroLabel2.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); this.metroLabel2.AutoSize = true; - this.metroLabel2.Location = new System.Drawing.Point(252, 88); + this.metroLabel2.Location = new System.Drawing.Point(228, 0); this.metroLabel2.Name = "metroLabel2"; this.metroLabel2.Size = new System.Drawing.Size(75, 19); this.metroLabel2.TabIndex = 0; @@ -292,35 +291,32 @@ this.xbox360ToolStripMenuItem.Text = "Xbox 360"; this.xbox360ToolStripMenuItem.CheckedChanged += new System.EventHandler(this.xbox360ToolStripMenuItem_CheckedChanged); // - // metroPanel1 + // tableLayoutPanel1 // - this.metroPanel1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + this.tableLayoutPanel1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); - this.metroPanel1.Controls.Add(this.GrfParametersTreeView); - this.metroPanel1.Controls.Add(this.GrfTreeView); - this.metroPanel1.HorizontalScrollbarBarColor = true; - this.metroPanel1.HorizontalScrollbarHighlightOnWheel = false; - this.metroPanel1.HorizontalScrollbarSize = 10; - this.metroPanel1.Location = new System.Drawing.Point(25, 110); - this.metroPanel1.Name = "metroPanel1"; - this.metroPanel1.Size = new System.Drawing.Size(450, 312); - this.metroPanel1.TabIndex = 4; - this.metroPanel1.Theme = MetroFramework.MetroThemeStyle.Dark; - this.metroPanel1.VerticalScrollbarBarColor = true; - this.metroPanel1.VerticalScrollbarHighlightOnWheel = false; - this.metroPanel1.VerticalScrollbarSize = 10; - this.metroPanel1.Resize += new System.EventHandler(this.metroPanel1_Resize); + this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 50F)); + this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 50F)); + this.tableLayoutPanel1.Controls.Add(this.metroLabel1, 0, 0); + this.tableLayoutPanel1.Controls.Add(this.GrfParametersTreeView, 1, 1); + this.tableLayoutPanel1.Controls.Add(this.GrfTreeView, 0, 1); + this.tableLayoutPanel1.Controls.Add(this.metroLabel2, 1, 0); + this.tableLayoutPanel1.Location = new System.Drawing.Point(25, 110); + this.tableLayoutPanel1.Name = "tableLayoutPanel1"; + this.tableLayoutPanel1.RowCount = 2; + this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F)); + this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle()); + this.tableLayoutPanel1.Size = new System.Drawing.Size(450, 312); + this.tableLayoutPanel1.TabIndex = 4; // // GameRuleFileEditor // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.ClientSize = new System.Drawing.Size(500, 450); - this.Controls.Add(this.metroPanel1); + this.Controls.Add(this.tableLayoutPanel1); this.Controls.Add(this.menuStrip1); - this.Controls.Add(this.metroLabel2); - this.Controls.Add(this.metroLabel1); this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); this.MainMenuStrip = this.menuStrip1; this.MaximizeBox = false; @@ -337,7 +333,8 @@ this.DetailContextMenu.ResumeLayout(false); this.menuStrip1.ResumeLayout(false); this.menuStrip1.PerformLayout(); - this.metroPanel1.ResumeLayout(false); + this.tableLayoutPanel1.ResumeLayout(false); + this.tableLayoutPanel1.PerformLayout(); this.ResumeLayout(false); this.PerformLayout(); @@ -359,7 +356,7 @@ private System.Windows.Forms.ToolStripMenuItem fileToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem saveToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem openToolStripMenuItem; - private MetroFramework.Controls.MetroPanel metroPanel1; + private System.Windows.Forms.TableLayoutPanel tableLayoutPanel1; private System.Windows.Forms.ToolStripMenuItem compressionLvlToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem levelToolStripMenuItem; diff --git a/PCK-Studio/Forms/Editor/GameRuleFileEditor.cs b/PCK-Studio/Forms/Editor/GameRuleFileEditor.cs index 5e1e7872..9f2e20e1 100644 --- a/PCK-Studio/Forms/Editor/GameRuleFileEditor.cs +++ b/PCK-Studio/Forms/Editor/GameRuleFileEditor.cs @@ -282,15 +282,6 @@ namespace PckStudio.Forms.Editor } } - private void metroPanel1_Resize(object sender, EventArgs e) - { - int padding = 2; - GrfTreeView.Size = new Size(metroPanel1.Size.Width / 2 - padding, metroPanel1.Size.Height); - GrfParametersTreeView.Size = new Size(metroPanel1.Size.Width / 2 - padding, metroPanel1.Size.Height); - // good enough - metroLabel2.Location = new Point(metroPanel1.Size.Width / 2 + 25, metroLabel2.Location.Y); - } - private void openToolStripMenuItem_Click(object sender, EventArgs e) { OpenFileDialog dialog = new OpenFileDialog();