Skip to content

Commit

Permalink
add auto detect and fill path at select Dir stage
Browse files Browse the repository at this point in the history
  • Loading branch information
marona42 committed Sep 30, 2021
1 parent 81ebff8 commit 4ed912f
Showing 1 changed file with 23 additions and 2 deletions.
25 changes: 23 additions & 2 deletions SCTools/SCTool_Redesigned/Pages/selectDir.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,35 @@ public partial class selectDir : Page
public selectDir()
{
InitializeComponent();
verify_Path(Defaultdir);
try
{
verify_Path(getDir());
}
catch (Exception e)
{
verify_Path(Defaultdir);
}

if (App.Settings.GameFolder != null)
{
PhasePath.Content = App.Settings.GameFolder;
}
}

private string getDir()
{
string infodir = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) + "\\Star Citizen\\build.info";
if(!File.Exists(infodir))
{
App.Logger.Warn("StarCitizeen build info File does not exist. Maybe not installed?");
throw new FileNotFoundException("build.info");
}
string[] _buildinfo = File.ReadAllLines(infodir);
App.Logger.Debug("guessedDir:"+_buildinfo[0].Substring(12, _buildinfo[0].Length - 27));
if (_buildinfo[0].Contains("\\LIVE\\Bin64\\StarCitizen.exe"))
return _buildinfo[0].Substring(12,_buildinfo[0].Length-27);
App.Logger.Warn("Cannot get path from build info");
throw new FileFormatException("build.info");
}
private bool verify_Path(string directoryPath)
{
App.Logger.Info("Check game folder path");
Expand Down

0 comments on commit 4ed912f

Please sign in to comment.