Skip to content

Commit

Permalink
Final Debugging Done
Browse files Browse the repository at this point in the history
Added Migration From Dcouments to Appdata
  • Loading branch information
BigSpice committed Dec 18, 2022
1 parent cb23e1e commit f819fdd
Show file tree
Hide file tree
Showing 6 changed files with 191 additions and 50 deletions.
71 changes: 67 additions & 4 deletions VTOL_2.0.0/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,15 @@ public partial class MainWindow : Window
bool Profile_card = false;
public User_Settings User_Settings_Vars = new User_Settings();
public string AppDataFolder = System.IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData));

public string DocumentsFolder = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);


public TlsPaperTrailLogger logger2 = new TlsPaperTrailLogger("logs5.papertrailapp.com", 38137);
public bool Is_Focused = true;
// public List<string> Current_Installed_Mods = new List<string>();
public HashSet<string> Current_Installed_Mods = new HashSet<string>();


bool failed_folder = false;

static void Main(string[] args)

Expand All @@ -63,7 +64,26 @@ public MainWindow()

//System.Threading.Thread.CurrentThread.CurrentUICulture = new CultureInfo("fr-FR");
//System.Threading.Thread.CurrentThread.CurrentCulture = new CultureInfo("fr-FR");Do
if (Directory.Exists(DocumentsFolder) && Directory.Exists(AppDataFolder))
{
if (!Directory.Exists(AppDataFolder + @"\VTOL_DATA\Settings"))

{
TryCreateDirectory(AppDataFolder + @"\VTOL_DATA\Settings");

}

if (File.Exists(DocumentsFolder + @"\VTOL_DATA\Settings\User_Settings.Json") && !File.Exists(AppDataFolder + @"\VTOL_DATA\Settings\User_Settings.Json"))
{
TryCopyFile(DocumentsFolder + @"\VTOL_DATA\Settings\User_Settings.Json", AppDataFolder + @"\VTOL_DATA\Settings\User_Settings.Json");

if (File.Exists(AppDataFolder + @"\VTOL_DATA\Settings\User_Settings.Json"))
{
TryDeleteDirectory(DocumentsFolder + @"\VTOL_DATA\",true);

}
}
}

if (Directory.Exists(AppDataFolder))
{
Expand Down Expand Up @@ -107,9 +127,45 @@ public MainWindow()
}
else
{
MessageBox.Show("VTOL SYSTEMS FAILED TO FIND YOUR DOCUMENTS FOLDER");
Application.Current.Shutdown();
failed_folder = true;
MessageBox.Show("VTOL SYSTEMS FAILED TO FIND YOUR APPDATA FOLDER, LOCATE A SAVE DATA FOLDER");

var folderDlg = new Ookii.Dialogs.Wpf.VistaFolderBrowserDialog();
folderDlg.ShowNewFolderButton = true;
// Show the FolderBrowserDialog.
var result = folderDlg.ShowDialog();
if (result == true)
{
string path = folderDlg.SelectedPath;
if (path == null || !Directory.Exists(path))
{
MessageBox.Show("INVALID FOLDER");




}
else
{

Properties.Settings.Default.BACKUP_SAVE_DEST = path + @"\";
Properties.Settings.Default.Save();
MessageBox.Show("RESTARTING TO SET HARD VALUES");

Restart();
}
}



//Application.Current.Shutdown();

}
if(failed_folder == true)
{
AppDataFolder = Properties.Settings.Default.BACKUP_SAVE_DEST;


}
if (User_Settings_Vars != null)
{
Expand Down Expand Up @@ -197,6 +253,13 @@ public MainWindow()



}
void Restart()
{
var currentExecutablePath = Process.GetCurrentProcess().MainModule.FileName;
Process.Start(currentExecutablePath);
Application.Current.Shutdown();

}
public static bool IsAdministrator()
{
Expand Down
21 changes: 20 additions & 1 deletion VTOL_2.0.0/Pages/Page_Home.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -821,6 +821,25 @@ public static string returnSafeString(string s)

return (s);
}
async void Restart_App()
{
await Task.Delay(500);

DispatchIfNecessary(() =>
{


SnackBar.Appearance = ControlAppearance.Info;
SnackBar.Title = "INFO";
SnackBar.Message = VTOL.Resources.Languages.Language.PleaseWaitAsVTOLRestarts;
SnackBar.Show();
});

await Task.Delay(1000);
var currentExecutablePath = Process.GetCurrentProcess().MainModule.FileName;
Process.Start(currentExecutablePath);
Application.Current.Shutdown();
}
void INIT()
{
try
Expand Down Expand Up @@ -2765,7 +2784,7 @@ private void Browse_Titanfall_Button_Click(object sender, RoutedEventArgs e)
SnackBar.Title = "SUCCESS";
SnackBar.Message = VTOL.Resources.Languages.Language.Page_Home_Browse_Titanfall_Button_Click_TheLocation+ Current_Install_Folder + VTOL.Resources.Languages.Language.Page_Home_Browse_Titanfall_Button_Click_IsValidAndHasBeenSet;
SnackBar.Show();

Restart_App();
}
else
{
Expand Down
1 change: 0 additions & 1 deletion VTOL_2.0.0/Pages/Page_Mods.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1802,7 +1802,6 @@ private void padd_Click(object sender, RoutedEventArgs e)

Mod_List_Box.ItemsSource = sorted;
Mod_List_Box.Refresh();
//Check_Updates_List();

}
catch (Exception ex)
Expand Down
Loading

0 comments on commit f819fdd

Please sign in to comment.