From 0846ccdc15a9f21236c12379d16fd75bf00ec319 Mon Sep 17 00:00:00 2001 From: Adriwin <76881633+Adriwin06@users.noreply.github.com> Date: Mon, 4 Aug 2025 23:08:23 +0200 Subject: [PATCH 1/2] Add basic AttribSys JSON export --- VaultFormat/AttribSysVaultForm.Designer.cs | 161 +++++++++++---------- VaultFormat/AttribSysVaultForm.cs | 29 ++++ VaultFormat/AttribSysVaultForm.resx | 54 +++---- VaultFormat/VaultFormat.csproj | 3 + 4 files changed, 141 insertions(+), 106 deletions(-) diff --git a/VaultFormat/AttribSysVaultForm.Designer.cs b/VaultFormat/AttribSysVaultForm.Designer.cs index 73f50d6..c69e618 100644 --- a/VaultFormat/AttribSysVaultForm.Designer.cs +++ b/VaultFormat/AttribSysVaultForm.Designer.cs @@ -29,115 +29,117 @@ protected override void Dispose(bool disposing) /// private void InitializeComponent() { - this.components = new System.ComponentModel.Container(); - this.menu = new System.Windows.Forms.MenuStrip(); - this.toolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem(); - this.lstDataChunks = new System.Windows.Forms.ListView(); - this.colClassName = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); - this.colClassHash = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); - this.colCollectionHash = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); - this.contextMenu = new System.Windows.Forms.ContextMenuStrip(this.components); - this.changeCollectionHashToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.propertyGrid2 = new System.Windows.Forms.PropertyGrid(); - this.menu.SuspendLayout(); - this.contextMenu.SuspendLayout(); - this.SuspendLayout(); + components = new System.ComponentModel.Container(); + menu = new System.Windows.Forms.MenuStrip(); + toolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem(); + lstDataChunks = new System.Windows.Forms.ListView(); + colClassName = new System.Windows.Forms.ColumnHeader(); + colClassHash = new System.Windows.Forms.ColumnHeader(); + colCollectionHash = new System.Windows.Forms.ColumnHeader(); + contextMenu = new System.Windows.Forms.ContextMenuStrip(components); + changeCollectionHashToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + propertyGrid2 = new System.Windows.Forms.PropertyGrid(); + exportVaultToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + menu.SuspendLayout(); + contextMenu.SuspendLayout(); + SuspendLayout(); // // menu // - this.menu.GripMargin = new System.Windows.Forms.Padding(2, 2, 0, 2); - this.menu.ImageScalingSize = new System.Drawing.Size(24, 24); - this.menu.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { - this.toolStripMenuItem1}); - this.menu.Location = new System.Drawing.Point(0, 0); - this.menu.Name = "menu"; - this.menu.Padding = new System.Windows.Forms.Padding(4, 2, 0, 2); - this.menu.Size = new System.Drawing.Size(1312, 33); - this.menu.TabIndex = 1; - this.menu.Text = "menuStrip1"; + menu.ImageScalingSize = new System.Drawing.Size(24, 24); + menu.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { toolStripMenuItem1 }); + menu.Location = new System.Drawing.Point(0, 0); + menu.Name = "menu"; + menu.Padding = new System.Windows.Forms.Padding(3, 2, 0, 2); + menu.Size = new System.Drawing.Size(1020, 24); + menu.TabIndex = 1; + menu.Text = "menuStrip1"; // // toolStripMenuItem1 // - this.toolStripMenuItem1.Name = "toolStripMenuItem1"; - this.toolStripMenuItem1.Size = new System.Drawing.Size(54, 29); - this.toolStripMenuItem1.Text = "File"; + toolStripMenuItem1.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { exportVaultToolStripMenuItem }); + toolStripMenuItem1.Name = "toolStripMenuItem1"; + toolStripMenuItem1.Size = new System.Drawing.Size(38, 20); + toolStripMenuItem1.Text = "File"; // // lstDataChunks // - this.lstDataChunks.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] { - this.colClassName, - this.colClassHash, - this.colCollectionHash}); - this.lstDataChunks.ContextMenuStrip = this.contextMenu; - this.lstDataChunks.Dock = System.Windows.Forms.DockStyle.Top; - this.lstDataChunks.FullRowSelect = true; - this.lstDataChunks.GridLines = true; - this.lstDataChunks.HideSelection = false; - this.lstDataChunks.Location = new System.Drawing.Point(0, 33); - this.lstDataChunks.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); - this.lstDataChunks.Name = "lstDataChunks"; - this.lstDataChunks.Size = new System.Drawing.Size(1312, 301); - this.lstDataChunks.TabIndex = 4; - this.lstDataChunks.UseCompatibleStateImageBehavior = false; - this.lstDataChunks.View = System.Windows.Forms.View.Details; - this.lstDataChunks.DoubleClick += new System.EventHandler(this.lstDataChunks_DoubleClick); + lstDataChunks.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] { colClassName, colClassHash, colCollectionHash }); + lstDataChunks.ContextMenuStrip = contextMenu; + lstDataChunks.Dock = System.Windows.Forms.DockStyle.Top; + lstDataChunks.FullRowSelect = true; + lstDataChunks.GridLines = true; + lstDataChunks.Location = new System.Drawing.Point(0, 24); + lstDataChunks.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4); + lstDataChunks.Name = "lstDataChunks"; + lstDataChunks.Size = new System.Drawing.Size(1020, 242); + lstDataChunks.TabIndex = 4; + lstDataChunks.UseCompatibleStateImageBehavior = false; + lstDataChunks.View = System.Windows.Forms.View.Details; + lstDataChunks.DoubleClick += lstDataChunks_DoubleClick; // // colClassName // - this.colClassName.Text = "ClassName"; - this.colClassName.Width = 250; + colClassName.Text = "ClassName"; + colClassName.Width = 250; // // colClassHash // - this.colClassHash.Text = "ClassHash"; - this.colClassHash.Width = 250; + colClassHash.Text = "ClassHash"; + colClassHash.Width = 250; // // colCollectionHash // - this.colCollectionHash.Text = "CollectionHash"; - this.colCollectionHash.Width = 250; + colCollectionHash.Text = "CollectionHash"; + colCollectionHash.Width = 250; // // contextMenu // - this.contextMenu.ImageScalingSize = new System.Drawing.Size(24, 24); - this.contextMenu.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { - this.changeCollectionHashToolStripMenuItem}); - this.contextMenu.Name = "contextMenu"; - this.contextMenu.Size = new System.Drawing.Size(268, 36); + contextMenu.ImageScalingSize = new System.Drawing.Size(24, 24); + contextMenu.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { changeCollectionHashToolStripMenuItem }); + contextMenu.Name = "contextMenu"; + contextMenu.Size = new System.Drawing.Size(202, 26); // // changeCollectionHashToolStripMenuItem // - this.changeCollectionHashToolStripMenuItem.Name = "changeCollectionHashToolStripMenuItem"; - this.changeCollectionHashToolStripMenuItem.Size = new System.Drawing.Size(267, 32); - this.changeCollectionHashToolStripMenuItem.Text = "Change CollectionHash"; - this.changeCollectionHashToolStripMenuItem.Click += new System.EventHandler(this.changeCollectionHashToolStripMenuItem_Click); + changeCollectionHashToolStripMenuItem.Name = "changeCollectionHashToolStripMenuItem"; + changeCollectionHashToolStripMenuItem.Size = new System.Drawing.Size(201, 22); + changeCollectionHashToolStripMenuItem.Text = "Change CollectionHash"; + changeCollectionHashToolStripMenuItem.Click += changeCollectionHashToolStripMenuItem_Click; // // propertyGrid2 // - this.propertyGrid2.Location = new System.Drawing.Point(0, 346); - this.propertyGrid2.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); - this.propertyGrid2.Name = "propertyGrid2"; - this.propertyGrid2.Size = new System.Drawing.Size(1312, 752); - this.propertyGrid2.TabIndex = 6; + propertyGrid2.Location = new System.Drawing.Point(0, 277); + propertyGrid2.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4); + propertyGrid2.Name = "propertyGrid2"; + propertyGrid2.Size = new System.Drawing.Size(1020, 602); + propertyGrid2.TabIndex = 6; + // + // exportVaultToolStripMenuItem + // + exportVaultToolStripMenuItem.Name = "exportVaultToolStripMenuItem"; + exportVaultToolStripMenuItem.Size = new System.Drawing.Size(180, 22); + exportVaultToolStripMenuItem.Text = "Export to JSON"; + exportVaultToolStripMenuItem.Click += exportVaultToolStripMenuItem_Click; // // AttribSysVaultForm // - this.AutoScaleDimensions = new System.Drawing.SizeF(9F, 20F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(1312, 1097); - this.Controls.Add(this.propertyGrid2); - this.Controls.Add(this.lstDataChunks); - this.Controls.Add(this.menu); - this.MainMenuStrip = this.menu; - this.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); - this.Name = "AttribSysVaultForm"; - this.Text = "AttribSysVault Editor"; - this.FormClosed += new System.Windows.Forms.FormClosedEventHandler(this.AttribSysVaultForm_FormClosed); - this.menu.ResumeLayout(false); - this.menu.PerformLayout(); - this.contextMenu.ResumeLayout(false); - this.ResumeLayout(false); - this.PerformLayout(); + AutoScaleDimensions = new System.Drawing.SizeF(7F, 16F); + AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + ClientSize = new System.Drawing.Size(1020, 878); + Controls.Add(propertyGrid2); + Controls.Add(lstDataChunks); + Controls.Add(menu); + MainMenuStrip = menu; + Margin = new System.Windows.Forms.Padding(2, 2, 2, 2); + Name = "AttribSysVaultForm"; + Text = "AttribSysVault Editor"; + FormClosed += AttribSysVaultForm_FormClosed; + menu.ResumeLayout(false); + menu.PerformLayout(); + contextMenu.ResumeLayout(false); + ResumeLayout(false); + PerformLayout(); } @@ -151,6 +153,7 @@ private void InitializeComponent() private System.Windows.Forms.ContextMenuStrip contextMenu; private System.Windows.Forms.ToolStripMenuItem changeCollectionHashToolStripMenuItem; private System.Windows.Forms.PropertyGrid propertyGrid2; + private System.Windows.Forms.ToolStripMenuItem exportVaultToolStripMenuItem; } } diff --git a/VaultFormat/AttribSysVaultForm.cs b/VaultFormat/AttribSysVaultForm.cs index 95af9bb..81c8599 100644 --- a/VaultFormat/AttribSysVaultForm.cs +++ b/VaultFormat/AttribSysVaultForm.cs @@ -2,6 +2,8 @@ using System.Collections; using System.Globalization; using System.Windows.Forms; +using System.IO; +using Newtonsoft.Json; using PluginAPI; using BundleUtilities; using LangEditor; @@ -129,5 +131,32 @@ private void AttribSysVaultForm_FormClosed(object s, FormClosedEventArgs e) EditEvent?.Invoke(); UpdateDisplay(); } + + private void exportVaultToolStripMenuItem_Click(object sender, EventArgs e) + { + // Dialog Creation + SaveFileDialog saveDialog = new SaveFileDialog(); + saveDialog.Filter = "JSON File (*.json)|*.json"; + saveDialog.Title = "Save AttribSys as JSON"; + saveDialog.FileName = "AttribSys.json"; + + // Dialog Logic + if (saveDialog.ShowDialog() == DialogResult.OK) + { + try + { + // Convertion of the AttribSys. Might need smarter structure to only keep the essential data concerning the configuration of the vehicle + string jsonContent = JsonConvert.SerializeObject(AttribSys, Formatting.Indented); + + File.WriteAllText(saveDialog.FileName, jsonContent); + + MessageBox.Show("Successfully exported to " + saveDialog.FileName, "Export Complete", MessageBoxButtons.OK, MessageBoxIcon.Information); + } + catch (Exception ex) + { + MessageBox.Show("Failed to export file. Error: " + ex.Message, "Export Failed", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + } } } diff --git a/VaultFormat/AttribSysVaultForm.resx b/VaultFormat/AttribSysVaultForm.resx index 49f5b2b..2abdbf0 100644 --- a/VaultFormat/AttribSysVaultForm.resx +++ b/VaultFormat/AttribSysVaultForm.resx @@ -1,17 +1,17 @@  - diff --git a/VaultFormat/VaultFormat.csproj b/VaultFormat/VaultFormat.csproj index 0fad378..780a5e9 100644 --- a/VaultFormat/VaultFormat.csproj +++ b/VaultFormat/VaultFormat.csproj @@ -16,6 +16,9 @@ + + + From f192f5ad31f69932a5507a8a83cc1a6e360e728f Mon Sep 17 00:00:00 2001 From: Adriwin <76881633+Adriwin06@users.noreply.github.com> Date: Tue, 7 Oct 2025 20:43:52 +0200 Subject: [PATCH 2/2] Small oversight --- BundleManager/BundleManager.csproj | 1 + 1 file changed, 1 insertion(+) diff --git a/BundleManager/BundleManager.csproj b/BundleManager/BundleManager.csproj index ea8907b..16fffe3 100644 --- a/BundleManager/BundleManager.csproj +++ b/BundleManager/BundleManager.csproj @@ -68,6 +68,7 @@ +