From f38695bd600a2b419092576ba535fd1244416341 Mon Sep 17 00:00:00 2001 From: Checkm8Croft Date: Fri, 3 Apr 2026 12:44:01 +0200 Subject: [PATCH] Adeed support for .prj and .wad files in FileAssociation --- FileAssociation/FormMain.Designer.cs | 74 +++++++++++++++++++--------- FileAssociation/FormMain.cs | 24 +++++++-- FileAssociation/Program.cs | 40 +++++++++++++-- 3 files changed, 107 insertions(+), 31 deletions(-) diff --git a/FileAssociation/FormMain.Designer.cs b/FileAssociation/FormMain.Designer.cs index fafc3c299..0721426f7 100644 --- a/FileAssociation/FormMain.Designer.cs +++ b/FileAssociation/FormMain.Designer.cs @@ -19,9 +19,11 @@ private void InitializeComponent() { this.button_Apply = new DarkUI.Controls.DarkButton(); this.button_Close = new DarkUI.Controls.DarkButton(); + this.checkBox_prj = new DarkUI.Controls.DarkCheckBox(); this.checkBox_prj2 = new DarkUI.Controls.DarkCheckBox(); - this.checkBox_trproj = new DarkUI.Controls.DarkCheckBox(); + this.checkBox_wad = new DarkUI.Controls.DarkCheckBox(); this.checkBox_wad2 = new DarkUI.Controls.DarkCheckBox(); + this.checkBox_trproj = new DarkUI.Controls.DarkCheckBox(); this.label = new DarkUI.Controls.DarkLabel(); this.panel = new System.Windows.Forms.Panel(); this.panel.SuspendLayout(); @@ -31,7 +33,7 @@ private void InitializeComponent() // this.button_Apply.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); this.button_Apply.Checked = false; - this.button_Apply.Location = new System.Drawing.Point(124, 113); + this.button_Apply.Location = new System.Drawing.Point(124, 165); this.button_Apply.Name = "button_Apply"; this.button_Apply.Size = new System.Drawing.Size(75, 23); this.button_Apply.TabIndex = 4; @@ -43,43 +45,63 @@ private void InitializeComponent() this.button_Close.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); this.button_Close.Checked = false; this.button_Close.DialogResult = System.Windows.Forms.DialogResult.Cancel; - this.button_Close.Location = new System.Drawing.Point(205, 113); + this.button_Close.Location = new System.Drawing.Point(205, 165); this.button_Close.Name = "button_Close"; this.button_Close.Size = new System.Drawing.Size(75, 23); this.button_Close.TabIndex = 5; this.button_Close.Text = "Close"; this.button_Close.Click += new System.EventHandler(this.button_Close_Click); // + // checkBox_prj + // + this.checkBox_prj.AutoSize = true; + this.checkBox_prj.Location = new System.Drawing.Point(14, 35); + this.checkBox_prj.Name = "checkBox_prj"; + this.checkBox_prj.Size = new System.Drawing.Size(156, 17); + this.checkBox_prj.TabIndex = 1; + this.checkBox_prj.Text = ".prj files with TombEditor"; + this.checkBox_prj.CheckedChanged += new System.EventHandler(this.checkBox_CheckedChanged); + // // checkBox_prj2 // this.checkBox_prj2.AutoSize = true; - this.checkBox_prj2.Location = new System.Drawing.Point(14, 35); + this.checkBox_prj2.Location = new System.Drawing.Point(14, 58); this.checkBox_prj2.Name = "checkBox_prj2"; this.checkBox_prj2.Size = new System.Drawing.Size(161, 17); - this.checkBox_prj2.TabIndex = 1; + this.checkBox_prj2.TabIndex = 2; this.checkBox_prj2.Text = ".prj2 files with TombEditor"; this.checkBox_prj2.CheckedChanged += new System.EventHandler(this.checkBox_CheckedChanged); // - // checkBox_trproj + // checkBox_wad // - this.checkBox_trproj.AutoSize = true; - this.checkBox_trproj.Location = new System.Drawing.Point(14, 81); - this.checkBox_trproj.Name = "checkBox_trproj"; - this.checkBox_trproj.Size = new System.Drawing.Size(156, 17); - this.checkBox_trproj.TabIndex = 3; - this.checkBox_trproj.Text = ".trproj files with TombIDE"; - this.checkBox_trproj.CheckedChanged += new System.EventHandler(this.checkBox_CheckedChanged); + this.checkBox_wad.AutoSize = true; + this.checkBox_wad.Location = new System.Drawing.Point(14, 81); + this.checkBox_wad.Name = "checkBox_wad"; + this.checkBox_wad.Size = new System.Drawing.Size(156, 17); + this.checkBox_wad.TabIndex = 3; + this.checkBox_wad.Text = ".wad files with WadTool"; + this.checkBox_wad.CheckedChanged += new System.EventHandler(this.checkBox_CheckedChanged); // // checkBox_wad2 // this.checkBox_wad2.AutoSize = true; - this.checkBox_wad2.Location = new System.Drawing.Point(14, 58); + this.checkBox_wad2.Location = new System.Drawing.Point(14, 104); this.checkBox_wad2.Name = "checkBox_wad2"; this.checkBox_wad2.Size = new System.Drawing.Size(156, 17); - this.checkBox_wad2.TabIndex = 2; + this.checkBox_wad2.TabIndex = 4; this.checkBox_wad2.Text = ".wad2 files with WadTool"; this.checkBox_wad2.CheckedChanged += new System.EventHandler(this.checkBox_CheckedChanged); // + // checkBox_trproj + // + this.checkBox_trproj.AutoSize = true; + this.checkBox_trproj.Location = new System.Drawing.Point(14, 127); + this.checkBox_trproj.Name = "checkBox_trproj"; + this.checkBox_trproj.Size = new System.Drawing.Size(156, 17); + this.checkBox_trproj.TabIndex = 5; + this.checkBox_trproj.Text = ".trproj files with TombIDE"; + this.checkBox_trproj.CheckedChanged += new System.EventHandler(this.checkBox_CheckedChanged); + // // label // this.label.AutoSize = true; @@ -98,12 +120,14 @@ private void InitializeComponent() this.panel.Controls.Add(this.button_Apply); this.panel.Controls.Add(this.checkBox_trproj); this.panel.Controls.Add(this.checkBox_wad2); + this.panel.Controls.Add(this.checkBox_wad); this.panel.Controls.Add(this.checkBox_prj2); + this.panel.Controls.Add(this.checkBox_prj); this.panel.Controls.Add(this.label); this.panel.Dock = System.Windows.Forms.DockStyle.Fill; this.panel.Location = new System.Drawing.Point(0, 0); this.panel.Name = "panel"; - this.panel.Size = new System.Drawing.Size(293, 149); + this.panel.Size = new System.Drawing.Size(293, 200); this.panel.TabIndex = 0; // // FormMain @@ -112,7 +136,7 @@ private void InitializeComponent() this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.CancelButton = this.button_Close; - this.ClientSize = new System.Drawing.Size(293, 149); + this.ClientSize = new System.Drawing.Size(293, 200); this.Controls.Add(this.panel); this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle; this.MaximizeBox = false; @@ -129,13 +153,15 @@ private void InitializeComponent() #endregion - private DarkUI.Controls.DarkButton button_Apply; - private DarkUI.Controls.DarkButton button_Close; - private DarkUI.Controls.DarkCheckBox checkBox_prj2; - private DarkUI.Controls.DarkCheckBox checkBox_trproj; - private DarkUI.Controls.DarkCheckBox checkBox_wad2; - private DarkUI.Controls.DarkLabel label; - private System.Windows.Forms.Panel panel; + private DarkUI.Controls.DarkButton button_Apply; + private DarkUI.Controls.DarkButton button_Close; + private DarkUI.Controls.DarkCheckBox checkBox_prj; + private DarkUI.Controls.DarkCheckBox checkBox_prj2; + private DarkUI.Controls.DarkCheckBox checkBox_wad; + private DarkUI.Controls.DarkCheckBox checkBox_wad2; + private DarkUI.Controls.DarkCheckBox checkBox_trproj; + private DarkUI.Controls.DarkLabel label; + private System.Windows.Forms.Panel panel; } } diff --git a/FileAssociation/FormMain.cs b/FileAssociation/FormMain.cs index 3b77fb8e2..56abab2fd 100644 --- a/FileAssociation/FormMain.cs +++ b/FileAssociation/FormMain.cs @@ -9,6 +9,8 @@ public partial class FormMain : DarkForm private bool _wasPRJ2Checked = false; private bool _wasWAD2Checked = false; private bool _wasTRPROJChecked = false; + private bool _wasPRJChecked = false; + private bool _wasWADChecked = false; public FormMain() { @@ -17,7 +19,9 @@ public FormMain() protected override void OnLoad(EventArgs e) { + _wasPRJChecked = checkBox_prj.Checked = Association.IsAssociatedWith(".prj", DefaultPaths.TombEditorExecutable); _wasPRJ2Checked = checkBox_prj2.Checked = Association.IsAssociatedWith(".prj2", DefaultPaths.TombEditorExecutable); + _wasWADChecked = checkBox_wad.Checked = Association.IsAssociatedWith(".wad", DefaultPaths.WadToolExecutable); _wasWAD2Checked = checkBox_wad2.Checked = Association.IsAssociatedWith(".wad2", DefaultPaths.WadToolExecutable); _wasTRPROJChecked = checkBox_trproj.Checked = Association.IsAssociatedWith(".trproj", DefaultPaths.TombIDEExecutable); @@ -33,11 +37,21 @@ private void button_Apply_Click(object sender, EventArgs e) else Association.ClearAssociations(".prj2"); + if (checkBox_prj.Checked) + Program.AssociatePRJ(); + else + Association.ClearAssociations(".prj"); + if (checkBox_wad2.Checked) Program.AssociateWAD2(); else Association.ClearAssociations(".wad2"); + if (checkBox_wad.Checked) + Program.AssociateWAD(); + else + Association.ClearAssociations(".wad"); + if (checkBox_trproj.Checked) Program.AssociateTRPROJ(); else @@ -46,6 +60,8 @@ private void button_Apply_Click(object sender, EventArgs e) _wasPRJ2Checked = checkBox_prj2.Checked; _wasWAD2Checked = checkBox_wad2.Checked; _wasTRPROJChecked = checkBox_trproj.Checked; + _wasPRJChecked = checkBox_prj.Checked; + _wasWADChecked = checkBox_wad.Checked; button_Apply.Enabled = false; } @@ -54,8 +70,10 @@ private void button_Close_Click(object sender, EventArgs e) => Close(); private void checkBox_CheckedChanged(object sender, EventArgs e) - => button_Apply.Enabled = checkBox_prj2.Checked != _wasPRJ2Checked - || checkBox_wad2.Checked != _wasWAD2Checked - || checkBox_trproj.Checked != _wasTRPROJChecked; + => button_Apply.Enabled = checkBox_prj.Checked != _wasPRJChecked + || checkBox_prj2.Checked != _wasPRJ2Checked + || checkBox_wad.Checked != _wasWADChecked + || checkBox_wad2.Checked != _wasWAD2Checked + || checkBox_trproj.Checked != _wasTRPROJChecked; } } diff --git a/FileAssociation/Program.cs b/FileAssociation/Program.cs index cac7fb7a8..dd6694023 100644 --- a/FileAssociation/Program.cs +++ b/FileAssociation/Program.cs @@ -38,20 +38,30 @@ private static void OpenGUI() private static void RunAssociation() { + AssociatePRJ(); AssociatePRJ2(); + AssociateWAD(); AssociateWAD2(); AssociateTRPROJ(); } - private static void RunAssociationWithBinaryArgs(string args) + private static void RunAssociationWithBinaryArgs(string args) { - bool associatePRJ2 = int.Parse(args[1].ToString()) != 0; - bool associateWAD2 = int.Parse(args[2].ToString()) != 0; - bool associateTRPROJ = int.Parse(args[3].ToString()) != 0; + bool associatePRJ = int.Parse(args[1].ToString()) != 0; + bool associatePRJ2 = int.Parse(args[2].ToString()) != 0; + bool associateWAD = int.Parse(args[3].ToString()) != 0; + bool associateWAD2 = int.Parse(args[4].ToString()) != 0; + bool associateTRPROJ = int.Parse(args[5].ToString()) != 0; + + if (associatePRJ) + AssociatePRJ(); if (associatePRJ2) AssociatePRJ2(); + if (associateWAD) + AssociateWAD(); + if (associateWAD2) AssociateWAD2(); @@ -61,7 +71,9 @@ private static void RunAssociationWithBinaryArgs(string args) private static void RunDeassociation() // Is this even a real word? { + Association.ClearAssociations(".prj"); Association.ClearAssociations(".prj2"); + Association.ClearAssociations(".wad"); Association.ClearAssociations(".wad2"); Association.ClearAssociations(".trproj"); } @@ -76,6 +88,16 @@ public static void AssociatePRJ2() Association.SetAssociation(extension, openWith, description, iconPath); } + public static void AssociatePRJ() + { + string extension = ".prj"; + string openWith = DefaultPaths.TombEditorExecutable; + string description = "TombEditor Project File"; + string iconPath = Path.Combine(DefaultPaths.ResourcesDirectory, "te_file.ico"); + + Association.SetAssociation(extension, openWith, description, iconPath); + } + public static void AssociateWAD2() { string extension = ".wad2"; @@ -86,6 +108,16 @@ public static void AssociateWAD2() Association.SetAssociation(extension, openWith, description, iconPath); } + public static void AssociateWAD() + { + string extension = ".wad"; + string openWith = DefaultPaths.WadToolExecutable; + string description = "Wad Object File"; + string iconPath = Path.Combine(DefaultPaths.ResourcesDirectory, "wt_file.ico"); + + Association.SetAssociation(extension, openWith, description, iconPath); + } + public static void AssociateTRPROJ() { string extension = ".trproj";