Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
74 changes: 50 additions & 24 deletions FileAssociation/FormMain.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 21 additions & 3 deletions FileAssociation/FormMain.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
{
Expand All @@ -17,7 +19,9 @@ public FormMain()

protected override void OnLoad(EventArgs e)
{
_wasPRJChecked = checkBox_prj.Checked = Association.IsAssociatedWith(".prj", DefaultPaths.TombEditorExecutable);
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indentation inconsistency, we use tabs rather than spaces in this part of the code.

_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);

Expand All @@ -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
Expand All @@ -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;
}
Expand All @@ -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
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Another indentation inconsistency. Use tabs instead of spaces. Additionally, the OR chain below should have 4 tabs instead of 5

|| checkBox_prj2.Checked != _wasPRJ2Checked
|| checkBox_wad.Checked != _wasWADChecked
|| checkBox_wad2.Checked != _wasWAD2Checked
|| checkBox_trproj.Checked != _wasTRPROJChecked;
}
}
40 changes: 36 additions & 4 deletions FileAssociation/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,20 +38,30 @@ private static void OpenGUI()

private static void RunAssociation()
{
AssociatePRJ();
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Again, use tabs instead of spaces please.

AssociatePRJ2();
AssociateWAD();
AssociateWAD2();
AssociateTRPROJ();
}

private static void RunAssociationWithBinaryArgs(string args)
private static void RunAssociationWithBinaryArgs(string args)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above.

{
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;
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The order of args has changed here, we can't do this due to compatibility reasons with the old installer. Please restore the previous PRJ2, WAD2 and TRPROJ order and add the new PRJ and WAD entries at the end.

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();

Expand All @@ -61,7 +71,9 @@ private static void RunAssociationWithBinaryArgs(string args)

private static void RunDeassociation() // Is this even a real word?
{
Association.ClearAssociations(".prj");
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indentation inconsistency.

Association.ClearAssociations(".prj2");
Association.ClearAssociations(".wad");
Association.ClearAssociations(".wad2");
Association.ClearAssociations(".trproj");
}
Expand All @@ -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";
Expand All @@ -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";
Expand Down