From ccd7d90189c8d16c8ef58dfc19e11202806000de Mon Sep 17 00:00:00 2001 From: cooolbros Date: Fri, 19 Apr 2024 23:25:58 +1000 Subject: [PATCH] Check for tf_win64.exe Fixes #6 --- src/HUDMerger/Commands/MergeCommand.cs | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/src/HUDMerger/Commands/MergeCommand.cs b/src/HUDMerger/Commands/MergeCommand.cs index e3d6e1a..3a88718 100644 --- a/src/HUDMerger/Commands/MergeCommand.cs +++ b/src/HUDMerger/Commands/MergeCommand.cs @@ -44,9 +44,26 @@ static bool PathContainsPath(string parentDir, string subDir) return !relativeDirectory.StartsWith("..") && !Path.IsPathRooted(relativeDirectory); } - if (PathContainsPath(Path.Join(((App)Application.Current).Settings.Value.TeamFortress2Folder, "tf\\custom"), _mainWindowViewModel.TargetHUD!.FolderPath) && Process.GetProcessesByName("hl2").Length != 0) + bool teamFortress2FolderContainsTarget = PathContainsPath(Path.Join(((App)Application.Current).Settings.Value.TeamFortress2Folder, "tf\\custom"), _mainWindowViewModel.TargetHUD!.FolderPath); + + Process[] processes; + + if (teamFortress2FolderContainsTarget) + { + processes = [ + ..Process.GetProcessesByName("hl2"), + ..Process.GetProcessesByName("tf"), + ..Process.GetProcessesByName("tf_win64"), + ]; + } + else + { + processes = []; + } + + if (teamFortress2FolderContainsTarget && processes.Length != 0) { - MessageBox.Show("HL2 process open, cannot merge!", "HL2 Open Error", MessageBoxButton.OK, MessageBoxImage.Error); + MessageBox.Show("TF2 process open, cannot merge!", "TF2 Open Error", MessageBoxButton.OK, MessageBoxImage.Error); return; } #endif