Skip to content

Commit

Permalink
Fixes for Broken NS Search.
Browse files Browse the repository at this point in the history
  • Loading branch information
BigSpice committed Jan 29, 2024
1 parent e24ed50 commit a16f52a
Show file tree
Hide file tree
Showing 16 changed files with 48 additions and 33 deletions.
Binary file modified VTOL_2.0.0/.vs/ProjectEvaluation/vtol.metadata.v7.bin
Binary file not shown.
Binary file modified VTOL_2.0.0/.vs/ProjectEvaluation/vtol.projects.v7.bin
Binary file not shown.
Binary file modified VTOL_2.0.0/.vs/VTOL/DesignTimeBuild/.dtbcache.v2
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified VTOL_2.0.0/.vs/VTOL/v17/.futdcache.v2
Binary file not shown.
Binary file modified VTOL_2.0.0/.vs/VTOL/v17/fileList.bin
Binary file not shown.
81 changes: 48 additions & 33 deletions VTOL_2.0.0/Pages/Page_Home.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -756,7 +756,7 @@ async void Auto_Install_(bool resart_ = false)
if (File.Exists(Current_Install_Folder + @"NorthstarLauncher.exe") && File.Exists(Current_Install_Folder + @"Titanfall2.exe"))
{
NSExe = Get_And_Set_Filepaths(Current_Install_Folder, "NorthstarLauncher.exe");
await Task.Delay(200);
await Task.Delay(400);

// Get the file version info for the notepad.
FileVersionInfo myFileVersionInfo = FileVersionInfo.GetVersionInfo(Current_Install_Folder + @"NorthstarLauncher.exe");
Expand Down Expand Up @@ -938,18 +938,7 @@ void INIT()
{
string FINAL = "";
Current_Install_Folder = InstalledApplications.GetApplictionInstallPath("Titanfall2");
if (Directory.Exists(Current_Install_Folder))
{
FINAL = Current_Install_Folder;
if (!Current_Install_Folder.EndsWith(@"\"))
{
string fix = Current_Install_Folder + @"\";
User_Settings_Vars.NorthstarInstallLocation = fix;
Current_Install_Folder = fix.Replace(@"\\", @"\").Replace("/", @"\");
}

}
else
if (!Directory.Exists(Current_Install_Folder))
{


Expand All @@ -963,7 +952,21 @@ void INIT()
return;







}
FINAL = Current_Install_Folder;
if (!Current_Install_Folder.EndsWith(@"\"))
{
string fix = Current_Install_Folder + @"\";
User_Settings_Vars.NorthstarInstallLocation = fix;
Current_Install_Folder = fix.Replace(@"\\", @"\").Replace("/", @"\");
}



}

Expand Down Expand Up @@ -2402,11 +2405,9 @@ public bool Check_Process_Running(string ProcessName)
Process[] pname = Process.GetProcessesByName(ProcessName);
if (pname.Length != 0)
{
GC.Collect();
return true;
}
pname = null;
GC.Collect();
return false;


Expand All @@ -2422,27 +2423,31 @@ private string Get_And_Set_Filepaths(string rootDir, string Filename)
try
{
DirectoryInfo directory = new DirectoryInfo(rootDir);
FileInfo[] files = directory.GetFiles("*" + Filename + "*.*");

foreach (FileInfo file in files)
{
if (file.Name.Equals(Filename))

IEnumerable<string> filesOrDirectories = FileDirectorySearch.Search(rootDir, Filename);

string _Location = filesOrDirectories.FirstOrDefault();


if (File.Exists(_Location))
{
return file.FullName;
}
}
return _Location;
}


return "\nCould not find " + Filename + "\n";
return null;
}

catch (Exception ex)
{
Log.Error(ex, $"A crash happened at {DateTime.Now.ToString("yyyy - MM - dd HH - mm - ss.ff", CultureInfo.InvariantCulture)}{Environment.NewLine}");
//Removed PaperTrailSystem Due to lack of reliability.
return null;


}


return "Exited with No Due to Missing Or Inaccurate Path";
return null;


}
Expand Down Expand Up @@ -2847,8 +2852,13 @@ private void Browse_Titanfall_Button_Click(object sender, RoutedEventArgs e)
{
Current_Install_Folder = path + @"\";
DirectoryInfo Dir = new DirectoryInfo(Current_Install_Folder);
string searchfile = "Titanfall2.exe";

if (Dir.Exists && File.Exists(Current_Install_Folder + "Titanfall2.exe"))
IEnumerable<string> filesOrDirectories = FileDirectorySearch.Search(Current_Install_Folder, searchfile);

string Titanfall2_Location = filesOrDirectories.FirstOrDefault();

if (Dir.Exists && File.Exists(Titanfall2_Location))
{
if (File.Exists(Current_Install_Folder + "NorthstarLauncher.exe"))
{
Expand Down Expand Up @@ -3765,20 +3775,25 @@ private void Unpack_To_Location(string Target_Zip, string Destination_Zip)
{
unpack_flg = false;
string searchPattern = @"Northstar.*";
string baseFolderPath = Path.Combine(Current_Install_Folder, User_Settings_Vars.Profile_Path);
string baseFolderPath = Path.Combine(Current_Install_Folder, User_Settings_Vars.Profile_Path) + @"\mods";

string[] matchingFolders = Directory.GetDirectories(baseFolderPath, searchPattern, SearchOption.AllDirectories);
if (Directory.Exists(baseFolderPath))
{
string[] matchingFolders = Directory.GetDirectories(baseFolderPath, searchPattern, SearchOption.AllDirectories);


foreach (string folderPath in matchingFolders)
{
if (Directory.Exists(folderPath))
foreach (string folderPath in matchingFolders)
{
if (Directory.Exists(folderPath))
{

TryDeleteDirectory(folderPath, true);
TryDeleteDirectory(folderPath, true);

}
}

}



string nrml = GetFile(Current_Install_Folder, @"ns_startup_args.txt");
Expand Down

0 comments on commit a16f52a

Please sign in to comment.