From 28626f2fa837216e50664f9c484b3ce049065acf Mon Sep 17 00:00:00 2001 From: MayNL Date: Mon, 29 Jun 2026 00:19:13 -0400 Subject: [PATCH] Added Set Pack ID tool -Removed 0 file from the editor --- PCK-Studio/Controls/Editor/PckEditor.cs | 38 +++++++++++ PCK-Studio/MainForm.Designer.cs | 26 +++++--- PCK-Studio/MainForm.cs | 16 +++++ PCK-Studio/MainForm.resx | 89 ++++++++++++++----------- 4 files changed, 120 insertions(+), 49 deletions(-) diff --git a/PCK-Studio/Controls/Editor/PckEditor.cs b/PCK-Studio/Controls/Editor/PckEditor.cs index 3addb7ce..9aaf214c 100644 --- a/PCK-Studio/Controls/Editor/PckEditor.cs +++ b/PCK-Studio/Controls/Editor/PckEditor.cs @@ -64,6 +64,8 @@ namespace PckStudio.Controls } } + public int _packID = -1; + private delegate void OnModifiedChangeDelegate(bool state); private OnModifiedChangeDelegate _onModifiedChangeDelegate; @@ -79,6 +81,25 @@ namespace PckStudio.Controls _originalEndianness = packInfo.Endianness; _currentEndianness = packInfo.Endianness; + if (EditorValue.File.TryGetAsset("0", PckAssetType.InfoFile, out PckAsset infoFile) && infoFile != null) + { + string packID; + + if (infoFile.TryGetParameter("PACKID", out packID)) + { + try + { + _packID = int.Parse(packID); + } + catch + { + _packID = -1; + } + } + + EditorValue.File.RemoveAsset(infoFile); + } + BigEndianCheckBox.Visible = packInfo.AllowEndianSwap; BigEndianCheckBox.Checked = packInfo.Endianness == OMI.ByteOrder.BigEndian; @@ -214,6 +235,16 @@ namespace PckStudio.Controls } } + // Add an info file back to the PCK + + if (_packID != -1) + { + PckAsset infoFile = new PckAsset("0", PckAssetType.InfoFile); + infoFile.AddParameter("PACKID", _packID.ToString()); + + EditorValue.File.InsertAsset(0, infoFile); + } + return true; } @@ -221,6 +252,13 @@ namespace PckStudio.Controls { _timesSaved++; _wasModified = false; + + PckAsset infoFile; + EditorValue.File.TryGetAsset("0", PckAssetType.InfoFile, out infoFile); + + if (infoFile != null) + EditorValue.File.RemoveAsset(infoFile); + MessageBox.Show($"{TitleName} saved.", "PCK successfully Saved"); Debug.WriteLine($"_timesSaved: {_timesSaved}"); } diff --git a/PCK-Studio/MainForm.Designer.cs b/PCK-Studio/MainForm.Designer.cs index 6003208f..f03e2bb0 100644 --- a/PCK-Studio/MainForm.Designer.cs +++ b/PCK-Studio/MainForm.Designer.cs @@ -47,12 +47,13 @@ this.closeAllToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.exitToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.pckToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.quickChangeToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.setPackIDToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.setXMLVersionStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.setXMLVersion0MenuItem = new PckStudio.ToolboxItems.ToolStripRadioButtonMenuItem(); this.setXMLVersion1MenuItem = new PckStudio.ToolboxItems.ToolStripRadioButtonMenuItem(); this.setXMLVersion2MenuItem = new PckStudio.ToolboxItems.ToolStripRadioButtonMenuItem(); this.setXMLVersion3MenuItem = new PckStudio.ToolboxItems.ToolStripRadioButtonMenuItem(); + this.quickChangeToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.miscToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.openPckManagerToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.convertMusicFilesToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); @@ -213,17 +214,18 @@ // pckToolStripMenuItem // this.pckToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { - this.quickChangeToolStripMenuItem, - this.setXMLVersionStripMenuItem}); + this.setPackIDToolStripMenuItem, + this.setXMLVersionStripMenuItem, + this.quickChangeToolStripMenuItem}); this.pckToolStripMenuItem.ForeColor = System.Drawing.Color.Silver; this.pckToolStripMenuItem.Name = "pckToolStripMenuItem"; resources.ApplyResources(this.pckToolStripMenuItem, "pckToolStripMenuItem"); // - // quickChangeToolStripMenuItem + // setPackIDToolStripMenuItem // - resources.ApplyResources(this.quickChangeToolStripMenuItem, "quickChangeToolStripMenuItem"); - this.quickChangeToolStripMenuItem.Name = "quickChangeToolStripMenuItem"; - this.quickChangeToolStripMenuItem.Click += new System.EventHandler(this.quickChangeToolStripMenuItem_Click); + this.setPackIDToolStripMenuItem.Name = "setPackIDToolStripMenuItem"; + resources.ApplyResources(this.setPackIDToolStripMenuItem, "setPackIDToolStripMenuItem"); + this.setPackIDToolStripMenuItem.Click += new System.EventHandler(this.setPackIDToolStripMenuItem_Click); // // setXMLVersionStripMenuItem // @@ -232,8 +234,8 @@ this.setXMLVersion1MenuItem, this.setXMLVersion2MenuItem, this.setXMLVersion3MenuItem}); - resources.ApplyResources(this.setXMLVersionStripMenuItem, "setXMLVersionStripMenuItem"); this.setXMLVersionStripMenuItem.Name = "setXMLVersionStripMenuItem"; + resources.ApplyResources(this.setXMLVersionStripMenuItem, "setXMLVersionStripMenuItem"); // // setXMLVersion0MenuItem // @@ -267,6 +269,12 @@ this.setXMLVersion3MenuItem.Tag = 3; this.setXMLVersion3MenuItem.Click += new System.EventHandler(this.setXMLVersionMenuItem_Click); // + // quickChangeToolStripMenuItem + // + resources.ApplyResources(this.quickChangeToolStripMenuItem, "quickChangeToolStripMenuItem"); + this.quickChangeToolStripMenuItem.Name = "quickChangeToolStripMenuItem"; + this.quickChangeToolStripMenuItem.Click += new System.EventHandler(this.quickChangeToolStripMenuItem_Click); + // // miscToolStripMenuItem // this.miscToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { @@ -548,7 +556,6 @@ this.StartPage.PerformLayout(); ((System.ComponentModel.ISupportInitialize)(this.pckOpen)).EndInit(); this.ResumeLayout(false); - this.PerformLayout(); } @@ -604,6 +611,7 @@ public ToolboxItems.ToolStripRadioButtonMenuItem setXMLVersion1MenuItem; public ToolboxItems.ToolStripRadioButtonMenuItem setXMLVersion2MenuItem; public ToolboxItems.ToolStripRadioButtonMenuItem setXMLVersion3MenuItem; + private System.Windows.Forms.ToolStripMenuItem setPackIDToolStripMenuItem; } } diff --git a/PCK-Studio/MainForm.cs b/PCK-Studio/MainForm.cs index 630b4536..d5e11516 100644 --- a/PCK-Studio/MainForm.cs +++ b/PCK-Studio/MainForm.cs @@ -625,5 +625,21 @@ namespace PckStudio } } } + + private void setPackIDToolStripMenuItem_Click(object sender, EventArgs e) + { + if (TryGetCurrentEditor(out IEditor editor)) + { + PckEditor pckEditor = editor as PckEditor; + + NumericPrompt packIDPrompt = new NumericPrompt(pckEditor._packID, -1, GameConstants.MAX_PACK_ID); + packIDPrompt.TextLabel.Text = "Pack ID"; + + if (packIDPrompt.ShowDialog() == DialogResult.OK) + { + pckEditor._packID = packIDPrompt.SelectedValueAsInt; + } + } + } } } \ No newline at end of file diff --git a/PCK-Studio/MainForm.resx b/PCK-Studio/MainForm.resx index a281ebaa..db50198b 100644 --- a/PCK-Studio/MainForm.resx +++ b/PCK-Studio/MainForm.resx @@ -146,6 +146,10 @@ Top, Left, Right + + + False + None @@ -240,7 +244,6 @@ Save - False @@ -317,8 +320,41 @@ File - - False + + 192, 22 + + + Set Pack ID + + + 121, 22 + + + Version 0 + + + 121, 22 + + + Version 1 + + + 121, 22 + + + Version 2 + + + 121, 22 + + + Version 3 + + + 192, 22 + + + Set Skin BOX Version @@ -481,39 +517,6 @@ False - - 121, 22 - - - Version 0 - - - 121, 22 - - - Version 1 - - - 121, 22 - - - Version 2 - - - 121, 22 - - - Version 3 - - - False - - - 192, 22 - - - Set Skin BOX Version - 41, 20 @@ -1961,7 +1964,7 @@ 0, 6, 60, 0 - 207, 24 + 208, 24 2 @@ -5851,10 +5854,10 @@ System.Windows.Forms.ToolStripMenuItem, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - quickChangeToolStripMenuItem + + setPackIDToolStripMenuItem - + System.Windows.Forms.ToolStripMenuItem, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 @@ -5887,6 +5890,12 @@ PckStudio.ToolboxItems.ToolStripRadioButtonMenuItem, PCK-Studio, Version=7.0.1.2, Culture=neutral, PublicKeyToken=null + + quickChangeToolStripMenuItem + + + System.Windows.Forms.ToolStripMenuItem, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + miscToolStripMenuItem